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.