pub struct JsonSerdeCodec;Expand description
A codec for encoding JSON messages that relies on serde_json.
Only available with the json_serde feature enabled.
§Example
ⓘ
// Primitive types:
let (get, set, remove) = use_local_storage::<i32, JsonSerdeCodec>("my-key");
// Structs:
#[derive(Serialize, Deserialize, Clone, Default, PartialEq)]
pub struct MyState {
pub hello: String,
}
let (get, set, remove) = use_local_storage::<MyState, JsonSerdeCodec>("my-struct-key");Trait Implementations§
Source§impl<T> Decoder<T> for JsonSerdeCodecwhere
T: for<'de> Deserialize<'de>,
impl<T> Decoder<T> for JsonSerdeCodecwhere
T: for<'de> Deserialize<'de>,
Auto Trait Implementations§
impl Freeze for JsonSerdeCodec
impl RefUnwindSafe for JsonSerdeCodec
impl Send for JsonSerdeCodec
impl Sync for JsonSerdeCodec
impl Unpin for JsonSerdeCodec
impl UnwindSafe for JsonSerdeCodec
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
Source§impl<T, D> HybridDecoder<T, str> for D
impl<T, D> HybridDecoder<T, str> for D
type Error = <D as Decoder<T>>::Error
fn is_binary_decoder() -> bool
fn decode_str( val: &str, ) -> Result<T, HybridCoderError<<D as HybridDecoder<T, str>>::Error>>
fn decode_bin(_val: &[u8]) -> Result<T, HybridCoderError<Self::Error>>
Source§impl<T, E> HybridEncoder<T, String> for E
impl<T, E> HybridEncoder<T, String> for E
type Error = <E as Encoder<T>>::Error
fn is_binary_encoder() -> bool
fn encode_str( val: &T, ) -> Result<String, HybridCoderError<<E as HybridEncoder<T, String>>::Error>>
fn encode_bin(_val: &T) -> Result<Vec<u8>, HybridCoderError<Self::Error>>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.