pub struct Item {
pub id: String,
pub data: Box<[u8]>,
}
Expand description
An item for a work queue. Each item has an ID and associated data.
Fields§
§id: String
§data: Box<[u8]>
Implementations§
Source§impl Item
impl Item
Sourcepub fn new(data: Box<[u8]>) -> Item
pub fn new(data: Box<[u8]>) -> Item
Create a new item, with the provided data
and a random id (a uuid).
Sourcepub fn from_string_data(data: String) -> Item
pub fn from_string_data(data: String) -> Item
Create a new item, with the provided data
and a random id (a uuid).
The item’s data is the output of data.into_bytes().into_boxed_slice()
.
Sourcepub fn from_json_data<T: Serialize>(data: &T) -> Result<Item>
pub fn from_json_data<T: Serialize>(data: &T) -> Result<Item>
Create a new item with a random id (a uuid). The data is the result of
serde_json::to_vec(data)
.
Sourcepub fn data_json<'a, T: Deserialize<'a>>(&'a self) -> Result<T>
pub fn data_json<'a, T: Deserialize<'a>>(&'a self) -> Result<T>
Returns the data, parsed as JSON.
Sourcepub fn data_json_static<T: for<'de> Deserialize<'de>>(&self) -> Result<T>
pub fn data_json_static<T: for<'de> Deserialize<'de>>(&self) -> Result<T>
Returns the data, parsed as JSON, with a static lifetime.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Item
impl RefUnwindSafe for Item
impl Send for Item
impl Sync for Item
impl Unpin for Item
impl UnwindSafe for Item
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more