add len() and from_bytes()
This commit is contained in:
parent
ed0da9da59
commit
2267e441f7
2 changed files with 14 additions and 1 deletions
|
@ -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 <colean@colean.cc>"]
|
||||
license = "LGPL-3.0-or-later"
|
||||
|
|
13
src/lib.rs
13
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)
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue