pub struct Json<T>(pub T);Expand description
Newtype wrapping a T so it can be sent and received as JSON through the existing
RsmqConnection API.
#[derive(Serialize, Deserialize)]
struct Job { name: String }
let mut rsmq = Rsmq::new(Default::default()).await?;
rsmq.send_message("jobs", Json(Job { name: "hi".into() }), None).await?;
if let Some(msg) = rsmq.receive_message::<Json<Job>>("jobs", None).await? {
println!("{}", msg.message.0.name);
rsmq.delete_message("jobs", &msg.id).await?;
}§Panics
From<Json<T>> for RedisBytes panics if serde_json::to_vec fails — only possible for
values that aren’t representable as JSON (maps with non-string keys, NaN floats, custom
Serialize impls that error). For fallible serialization use RsmqJsonExt::send_json
instead, which surfaces the error as Err.
Tuple Fields§
§0: TTrait Implementations§
Source§impl<T: Serialize> From<Json<T>> for RedisBytes
impl<T: Serialize> From<Json<T>> for RedisBytes
Source§fn from(json: Json<T>) -> RedisBytes
fn from(json: Json<T>) -> RedisBytes
Converts to this type from the input type.
Source§impl<T: DeserializeOwned> TryFrom<RedisBytes> for Json<T>
impl<T: DeserializeOwned> TryFrom<RedisBytes> for Json<T>
impl<T: Eq> Eq for Json<T>
impl<T> StructuralPartialEq for Json<T>
Auto Trait Implementations§
impl<T> Freeze for Json<T>where
T: Freeze,
impl<T> RefUnwindSafe for Json<T>where
T: RefUnwindSafe,
impl<T> Send for Json<T>where
T: Send,
impl<T> Sync for Json<T>where
T: Sync,
impl<T> Unpin for Json<T>where
T: Unpin,
impl<T> UnsafeUnpin for Json<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Json<T>where
T: UnwindSafe,
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