Commit Graph

214 Commits

Author SHA1 Message Date
D. Scott Boggs c93e5a5020 Add static assertions 2023-01-09 09:03:21 -05:00
D. Scott Boggs fcc2035b46 Add constructors for ID types 2023-01-09 09:03:21 -05:00
D. Scott Boggs 876ac3b985 Add Mention ID type 2023-01-09 09:03:21 -05:00
D. Scott Boggs 6d8a9d6194 Add List ID type 2023-01-09 09:03:21 -05:00
D. Scott Boggs 6e044c3f35 Use `impl AsRef<str>` instead of `&str` to work with new ID types 2023-01-09 09:03:21 -05:00
D. Scott Boggs 06caec85b3 Add ID type for reports 2023-01-09 09:03:21 -05:00
D. Scott Boggs d4e7c4b59b Add ID type for relationships 2023-01-09 09:03:21 -05:00
D. Scott Boggs f4ef3c27ab Add ID type for pushes 2023-01-09 09:03:21 -05:00
D. Scott Boggs f188c20250 Add ID type for notifications 2023-01-09 09:03:21 -05:00
D. Scott Boggs c5f199b460 Add ID type for filters 2023-01-09 09:03:21 -05:00
D. Scott Boggs 9f4327f546 Add ID type for attachments 2023-01-09 09:03:21 -05:00
D. Scott Boggs 547d994d13 Add ID type for account 2023-01-09 09:03:21 -05:00
Matthias Beyer 97ae0973c3 Wrap status id in helper type
This wrapper type ensures that the status id cannot accidentially be
compared to some other string that represents something entirely else.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-09 09:03:21 -05:00
D. Scott Boggs 10ec4dc81f Fix: backwards compatibility 2023-01-09 07:27:53 -05:00
D. Scott Boggs 14dc17e582 Split status_builder module into a few files 2023-01-09 07:27:53 -05:00
D. Scott Boggs cc6bd77cab Publish NewStatus fields 2023-01-09 07:27:53 -05:00
D. Scott Boggs abafaf224c Add support for Filter v2 2023-01-09 07:27:53 -05:00
D. Scott Boggs 6ee2f277d8 Move legacy Filter type to mod v1; publish fields 2023-01-09 07:27:53 -05:00
D. Scott Boggs acef484b73 Finish TODO Parse DateTime before publishing this field 2023-01-09 07:27:53 -05:00
D. Scott Boggs 94624ac1db Make additional fields public 2023-01-09 07:27:53 -05:00
jhwgh1968 83e02464af Add notification type "follow request" 2023-01-09 04:51:26 -05:00
jhwgh1968 9fd1b29521 Add "poll" notification support 2023-01-09 04:51:26 -05:00
Matthias Beyer 6dcffc0802 Fix: Use Visibility pub here, to be backwards compatible
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-04 08:29:52 -05:00
Matthias Beyer e0f38240b7 Make package fields workspace-wide
This patch makes the "version", "license", "authors" and "edition"
fields in the manifest workspace-wide.

This way we ensure that mastodon-async-entities stays in sync with
mastodon-async.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-04 08:29:52 -05:00
Matthias Beyer af3facfbf0 Add mastodon_async_entities
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>
2023-01-04 08:29:52 -05:00
Matthias Beyer 02de9f5d32 Fix: Remove unused import
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-03 10:59:42 -05:00
Matthias Beyer 53447d1f48 Fix: Pass arguments in right order
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-03 10:59:42 -05:00
Matthias Beyer 5d445d2708 Fix clippy: Remove unnecessary Ok + ? operator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-03 10:59:42 -05:00
Matthias Beyer 88ba4c0894 Fix clippy: Remove unnecessary Ok + ? operator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-03 10:59:42 -05:00
Matthias Beyer b47e435b49 Fix: Let clippy lint all features
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-03 10:59:42 -05:00
Matthias Beyer 00c390f56b fixup! Add error variant for when not all bytes are written 2023-01-03 07:13:25 -05:00
D. Scott Boggs 1e4b2e0adb use serde_json's to_writer 2023-01-03 07:13:25 -05:00
Matthias Beyer dbbdb8e5c0 Add error variant for when not all bytes are written
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>
2023-01-03 07:13:25 -05:00
Scott Boggs 21dd421656 Move prelude use statements to separate fn 2023-01-03 07:02:36 -05:00
Matthias Beyer faf0cda10c Add test for API exports
This patch adds a test file that only tries to import everything that's
exposed from the crate API, so we do not accidentially vanish something
from the API.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-03 07:02:36 -05:00
dependabot[bot] c497e11b4d Update url requirement from 1 to 2
Updates the requirements on [url](https://github.com/servo/rust-url) to permit the latest version.
- [Release notes](https://github.com/servo/rust-url/releases)
- [Commits](https://github.com/servo/rust-url/compare/v1.0.0...v2.3.1)

---
updated-dependencies:
- dependency-name: url
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-02 07:17:24 -05:00
Matthias Beyer e328924193 Add rust-cache in CI workflow
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2023-01-01 11:25:02 -05:00
D. Scott Boggs f830671ee9 Make tokio's rt-multi-thread enabled again in examples 2023-01-01 11:22:43 -05:00
D. Scott Boggs 6ba0cd03f8 Drop unnecessary tokio feature dependency 2022-12-30 07:16:29 -05:00
Matthias Beyer c32f628c49 Make Registered::complete() accept an AsRef<str>
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>
2022-12-29 14:07:09 -05:00
D. Scott Boggs f037379d0f drop dependency on hyper-old-types in favor of parse_link_header 2022-12-29 14:06:07 -05:00
Matthias Beyer 5832111f46 Replace dependency "chrono" with "time"
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-29 13:43:26 -05:00
D. Scott Boggs 96fbef900e Change error implementation to use thiserror 2022-12-29 13:27:41 -05:00
D. Scott Boggs d2cdd8e514 Add debugging note to the README 2022-12-29 12:19:23 -05:00
Matthias Beyer 346ac52f30 Add workflow job to check formatting
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-29 07:14:00 -05:00
Matthias Beyer c689b8390c Run cargo-fmt on whole codebase
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-29 07:14:00 -05:00
Matthias Beyer d61c2e5c91 Empty rustfmt configuration for default settings
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-29 07:14:00 -05:00
Matthias Beyer 89f9efe639 Add workflow job to build examples
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-12-29 06:42:50 -05:00
D. Scott Boggs 351bb0741b spelling and clippy fixes 2022-12-29 06:41:57 -05:00
Matthias Beyer 963a3323ea Optimize: Remove clone() call
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>
2022-12-29 05:58:30 -05:00