Add some useful #![deny(...)] lints:
- missing_docs to disallow undocumented public items;
- missing_debug_implementations for public types;
- no unsafe code or unstable features.
This has some implications for Error:
- because attohttpc doesn't distinguish between errors
when serializing or deserializing request/response
data, Error::RequestJson and Error::ResponseJson have
been merged into Error::Json. In practice this shouldn't
matter much because request data is (usually) well-formed.
- attohttpc also doesn't return errors for HTTP responses
with statuses in the [400-599] range, so manual conversion
to an error is needed (this now happens in ResponseType::from_response).
This commit adds support for alternative Listenbrainz hosts.
L10 defines the most used official host for Listenbrainz.
I have refactored the Client struct to have the `api_root_url` field.
This is automatically set to the value L10 defines, when a Client is
instantiated with `new()`. On the invocation of `client_with_url(url:
&str)`, the `api_root_url` field is set to the Listenbrainz instance
API root URL passed to the function.
The 1:1 functions <-> API methods have been modified to use
`self.api_root_url` as the base of the `format!()` macro invoked, rather
than the global constant of `API_ROOT_URL`.
This commit has been tested with the examples, and appears to be
functional.
Fixes#2.
Signed-off-by: Dom Rodriguez <shymega@shymega.org.uk>
This uses GitHub Actions, it builds listenbrainz-rs and runs unit tests
if applicable.
It is triggered by the following GitHub events:
- A push to the repo
- A PR made to the repo
Of course, it's not strictly necssary to use GitHub Actions; there are
other services.
Signed-off-by: Dom Rodriguez <shymega@shymega.org.uk>
Add the `rate_limit` field to all response types,
which contains rate limiting information such as
maximum and remaining requests in the current
time frame, as well as when the next time frame
starts.
All response types now also implement the `ResponseType`
trait (internal for now). Currently this trait allows
converting from `ureq::Response` to the response type,
by extracting rate limiting information from the response
headers and deserializing the response body into the
response type.
The ListenBrainz struct is a more ergonomic client
than raw::Client. It supports authentication using
a ListenBrainz token. Currently, it allows submitting
"listened" and "now playing" requests to the API
in a more convenient way than manually creating all
request data.