summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md6
-rw-r--r--bzipper/Cargo.toml4
-rw-r--r--bzipper/src/buffer/mod.rs33
-rw-r--r--bzipper_macros/Cargo.toml6
4 files changed, 42 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ff3b789..94831b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,12 @@
This is the changelog of bzipper.
See `"README.md"` for more information.
+## 0.6.1
+
+* Bump dependency version
+* Update docs
+* Add more examples
+
## 0.6.0
* Update readme
diff --git a/bzipper/Cargo.toml b/bzipper/Cargo.toml
index 7e1babb..2a4bfe1 100644
--- a/bzipper/Cargo.toml
+++ b/bzipper/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bzipper"
-version = "0.6.0"
+version = "0.6.1"
edition = "2021"
rust-version = "1.81"
documentation = "https://docs.rs/bzipper/"
@@ -20,7 +20,7 @@ alloc = []
std = []
[dependencies]
-bzipper_macros = { path = "../bzipper_macros", version = "0.6.0"}
+bzipper_macros = { path = "../bzipper_macros", version = "0.6.1"}
[lints]
workspace = true
diff --git a/bzipper/src/buffer/mod.rs b/bzipper/src/buffer/mod.rs
index ad2e743..f39b108 100644
--- a/bzipper/src/buffer/mod.rs
+++ b/bzipper/src/buffer/mod.rs
@@ -30,12 +30,41 @@ use core::fmt::{Debug, Formatter};
use core::marker::PhantomData;
use core::ops::{Deref, DerefMut};
+// We cannot use arrays for the `Buffer` type as
+// that would require `generic_const_exprs`.
+
/// Typed (de)serialisation buffer.
///
/// This structure is intended as a lightweight wrapper around byte buffers for specific (de)serialisations of specific types.
///
/// The methods [`write`](Self::write) and [`read`](Self::read) can be used to <interpreting> the internal buffer.
/// Other methods exist for accessing the internal buffer directly.
+///
+/// # Examples
+///
+/// Create a buffer for holding a `Request` enumeration:
+///
+/// ```
+/// use bzipper::{Buffer, FixedString, Serialise};
+///
+/// #[derive(Serialise)]
+/// enum Request {
+/// Join { username: FixedString<0x10> },
+///
+/// Quit { username: FixedString<0x10> },
+///
+/// SendMessage { message: FixedString<0x20> },
+/// }
+///
+/// use Request::*;
+///
+/// let join_request = Join { username: FixedString::try_from("epsiloneridani").unwrap() };
+///
+/// let mut buf = Buffer::<Request>::new();
+/// buf.write(&join_request);
+///
+/// // Do something with the buffer...
+/// ```
#[cfg_attr(doc, doc(cfg(feature = "alloc")))]
#[derive(Clone, Eq, PartialEq)]
pub struct Buffer<T: Serialise> {
@@ -63,12 +92,12 @@ impl<T: Serialise> Buffer<T> {
#[must_use]
pub fn as_mut_ptr(&mut self) -> *mut u8 { self.buf.as_mut_ptr() }
- /// Gets a slice of the intenral buffer.
+ /// Gets a slice of the internal buffer.
#[inline(always)]
#[must_use]
pub const fn as_slice(&self) -> &[u8] { unsafe { core::slice::from_raw_parts(self.as_ptr(), self.len()) } }
- /// Gets a mutable slice of the intenral buffer.
+ /// Gets a mutable slice of the internal buffer.
#[inline(always)]
#[must_use]
pub fn as_mut_slice(&mut self) -> &mut [u8] { &mut self.buf }
diff --git a/bzipper_macros/Cargo.toml b/bzipper_macros/Cargo.toml
index 695aefe..30a6eab 100644
--- a/bzipper_macros/Cargo.toml
+++ b/bzipper_macros/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "bzipper_macros"
-version = "0.6.0"
+version = "0.6.1"
edition = "2021"
documentation = "https://docs.rs/bzipper_macros/"
@@ -16,8 +16,8 @@ proc-macro = true
[dependencies]
proc-macro2 = "1.0.86"
-quote = "1.0.36"
-syn = "2.0.72"
+quote = "1.0.37"
+syn = "2.0.75"
[lints]
workspace = true