This patch move the entities module to a helper-crate.
With this, we give the user the opportunity to use only the entities
types in their codebase, if need be.
One scenario where this is required came up in
https://github.com/dscottboggs/mastodon-async/issues/38
TL;DR is: A user needed to be able to pass types like `Status` from a
backend part of an application to a frontend which was compiled to WASM.
Because mastodon_async depends on tokio, which does not compile to WASM
(at least not with the features required by mastodon_async).
One option would have been to provide types in the application code
which can be constructed from mastodon_asyncs entity types. This would
lead to _a lot_ of code duplication (over several projects still,... but
that's rather undesireable anyways).
The solution mastodon_async offers with this patch is a helper-crate
which only contains the entity types: mastodon_async_entities.
mastodon_async publicly exports the whole mastodon_async_entities crate,
so users do not have to depend on the latter directly.
In addition to the `entities` module from mastodon_async, also the
`Visibility` type had to be moved.
`mastodon_async_entities` also got an own `Error` type, which
`mastodon_async::Error` can of course wrap.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Suggested-by: D. Scott Boggs <scott@tams.tech>
cargo-clippy tells us that the `crate::helpers::json::to_writer` and
`crate::helpers::toml::to_writer` functions were implemented without
checking the return value of the `write()` function called inside.
That might lead to serious issues on the user site, if indeed not all
bytes were written.
This patch fixes the issue of the user not knowning about the issue by
introducing a new error variant and returning it in case of unfinished
writes.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This patch changes the signature of `Registered::complete` to accept an
`AsRef<str>`. This _should_ be backwards compatible to the old version.
This change was implemented as it has the neat benefit that a user can
implement a type that does not implement `Debug` or `Display`, but only
`AsRef<str>`.
This can be done to ensure that the access code is not accidentially
shown in log output, which might be pasted to some code forge for bug
reporting.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This patch makes the `Headers` helper type that is only used to be able
to implement Serialize on it only contain a reference to the actual
headers. This way we don't need to clone() the object returned by
`reqwest::Repsonse::headers()`.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
There were too many false positive responses from libmagic to have this
just happen in the background. In a future release I may add a specific
error which is returned when the given file has no extension, and
downstream application developers can use that as an indicator that they
should ask the user if they want to detect the filetype, making use of
libmagic directly in the downstream application as appropriate.