diff --git a/Cargo.toml b/Cargo.toml index 8b47a34..e095e3b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "clippet" description = "Provides a teeny way to have some nice byte structures that's easy to use." -version = "0.1.2" +version = "0.1.3" edition = "2021" authors = ["Celeste "] license = "LGPL-3.0-or-later" diff --git a/src/lib.rs b/src/lib.rs index cafebda..241e2fd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -107,4 +107,17 @@ impl Clippet { return clip } + /// Takes a sequence of bytes and wraps it around a Clippet structure. + /// + /// ```no_run + /// let data = Clippet::from_bytes(foo); + /// ``` + pub fn from_bytes(bytes: BytesMut) -> Clippet { + let clip = Clippet { label: "".to_string(), size: 1, data: vec![bytes] }; + return clip + } + /// Alias of `get_size(&self)` + pub fn len(&self) -> i32 { + return get_size(&self) + } }