Struct redis_work_queue::Item
source · 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 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