diff options
-rw-r--r-- | CHANGELOG.md | 5 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | bzipper-monochrome.svg | 3 | ||||
-rw-r--r-- | src/serialise/mod.rs | 31 |
4 files changed, 37 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 781fc7b..c16e1dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ This is the changelog of `bzipper`. See `"README.md"` for more information. +## 0.4.6 + +* Fix docs logo (again) +* Update docs (add examples) + ## 0.4.5 * Fix package metadata :( @@ -1,6 +1,6 @@ [package] name = "bzipper" -version = "0.4.5" +version = "0.4.6" authors = ["Gabriel Bjørnager Jensen"] edition = "2021" description = "Binary (de)serialiser." diff --git a/bzipper-monochrome.svg b/bzipper-monochrome.svg index 904b7bd..5a6e1f8 100644 --- a/bzipper-monochrome.svg +++ b/bzipper-monochrome.svg @@ -6,6 +6,5 @@ <polyline fill="none" points="76,68 76,76 20,76 59.029437252,20" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="8" /> </mask> - <rect fill="#FFFFFF" height="100%" width="100%" x="0" y="0" /> - <rect fill="#B4202D" height="100%" mask="url(#z)" width="100%" x="0" y="0" /> + <rect fill="#FFFFFF" height="100%" mask="url(#z)" width="100%" x="0" y="0" /> </svg> diff --git a/src/serialise/mod.rs b/src/serialise/mod.rs index 0685323..16c8313 100644 --- a/src/serialise/mod.rs +++ b/src/serialise/mod.rs @@ -34,10 +34,39 @@ use core::num::NonZero; pub trait Serialise: Sized { /// The error of serialisation. /// - /// Use [`Infallible`] if **all** deserialisations are infallible, as is the case of zero-length types. + /// Use [`Infallible`] if **all** deserialisations are infallible, as is the case of zero-length types (such as [the unit type](unit)). type Error; /// The maximum amount of bytes that can result from serialisation. + /// + /// Until derive macros are implemented, this value should be set to the sum of the members' own size limits (if chaining is used, that is): + /// + /// ``` + /// use bzipper::{Serialise, Sstream}; + /// + /// struct Foo { + /// bar: u16, + /// baz: f32, + /// } + /// + /// impl Serialise for Foo { + /// type Error = bzipper::Error; + /// + /// const SERIALISE_LIMIT: usize = u16::SERIALISE_LIMIT + f32::SERIALISE_LIMIT; + /// + /// fn serialise(&self, stream: &mut Sstream) -> Result<usize, Self::Error> { + /// let mut count = 0x0; + /// + /// // Serialise fields using chaining. + /// count += self.bar.serialise(stream)?; + /// count += self.baz.serialise(stream)?; + /// + /// Ok(count) + /// } + /// } + /// ``` + /// + /// In the future, dervice macros will make manual chaining redundant. const SERIALISE_LIMIT: usize; /// Serialises `self` into a byte stream. |