-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement optimized
Serialize
and Deserialize
for Schedule
(
#129) * Add Serde compatiblity for type Schedule * fix: impl Deserialize behind feature gate * feat: implement optimized `Serialize` and `Deserialize` for `Schedule` Serialization: Serialization uses a direct reference into the `Schedule::source`. Previously, the blanket implementation of `ToString::to_string` had been used, which unnecessarily allocated a string and leveraged `format!` machinery. Deserialization: Deserialization suggests the `Deserializer` to provide an owned `String` to the visitor, as the `Schedule` will take ownership of the `String` after successful decoding. `Deserializer`s not incapable of providing owned `String`s may pass a `&str`, which is decoded, then cloned into an owned `String` for storage in `Schedule::source`. Public API changes: Beside implementing `Serialize` and `Deserialize` behind the `"serde"` feature flag, this changeset also adds a new public method `Schedule::source(&self) -> &str`. This new public method is generally useful and therefore not guarded by the `"serde"` feature flag. * feat(ci): run tests for default features and all features separately * style: normalize serde tests - normalize test names, indicating token verification - [lowercase][C-GOOD-ERR] failure messages [C-GOOD-ERR]: https://rust-lang.github.io/api-guidelines/interoperability.html?highlight=lowercase#error-types-are-meaningful-and-well-behaved-c-good-err * test: e2e test deserialized schedules with binary format This changeset implements serde serialization and deserialization tests beyond the token representation tests provided by `serde_test`. Schedules are serialized to a binary format ([`postcard`][postcard]), then deserialized and used to yield events following a given date and time. These events are compared to a limited set of restricted upcoming events. The tests cover shorthand as well as ranged period cron schedule notation. [postcard]: https://docs.rs/postcard/ --------- Co-authored-by: Max Huster <maxekinge@googlemail.com>
- Loading branch information
1 parent
bc07787
commit c5d5589
Showing
3 changed files
with
159 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters