[−][src]Struct sync15::bso_record::Payload
Represents the decrypted payload in a Bso. Provides a minimal layer of type safety to avoid double-encrypting.
Fields
id: Guid
deleted: bool
data: Map<String, Value>
Implementations
impl Payload
[src]
pub fn new_tombstone(id: impl Into<Guid>) -> Payload
[src]
pub fn new_tombstone_with_ttl(id: impl Into<Guid>, ttl: u32) -> Payload
[src]
pub fn with_sortindex(self, index: i32) -> Payload
[src]
pub fn with_auto_field<T>(self, name: &str, v: Option<T>) -> Payload where
T: Into<Value>,
[src]
T: Into<Value>,
"Auto" fields are fields like 'sortindex' and 'ttl', which are:
- Added to the payload automatically when deserializing if present on the incoming BSO or envelope.
- Removed from the payload automatically and attached to the BSO or envelope if present on the outgoing payload.
pub fn take_auto_field<V>(&mut self, name: &str) -> Option<V> where
V: for<'a> Deserialize<'a>,
[src]
V: for<'a> Deserialize<'a>,
pub fn id(&self) -> &str
[src]
pub fn is_tombstone(&self) -> bool
[src]
pub fn from_json(value: Value) -> Result<Payload, Error>
[src]
pub fn into_record<T>(self) -> Result<T, Error> where
T: for<'a> Deserialize<'a>,
[src]
T: for<'a> Deserialize<'a>,
Deserializes the BSO payload into a specific record type T
.
BSO payloads are unstructured JSON objects, with string keys and
dynamically-typed values. into_record
makes it more convenient to
work with payloads by converting them into data type-specific structs.
Your record type only needs to derive or implement serde::Deserialize
;
Serde will take care of the rest.
Errors
into_record
returns errors for type mismatches. As an example, trying
to deserialize a string value from the payload into an integer field in
T
will fail.
If there's a chance that a field contains invalid or mistyped data,
you'll want to extract it from payload.data
manually, instead of using
into_record
. This has been seen in the wild: for example, dateAdded
for bookmarks can be either an integer or a string.
pub fn from_record<T>(v: T) -> Result<Payload, Error> where
T: Serialize,
[src]
T: Serialize,
pub fn into_json_string(self) -> String
[src]
Trait Implementations
impl Clone for Payload
[src]
impl Debug for Payload
[src]
impl<'de> Deserialize<'de> for Payload
[src]
fn deserialize<__D>(
__deserializer: __D
) -> Result<Payload, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]
__deserializer: __D
) -> Result<Payload, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
impl PartialEq<Payload> for Payload
[src]
impl Serialize for Payload
[src]
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
impl StructuralPartialEq for Payload
[src]
Auto Trait Implementations
impl RefUnwindSafe for Payload
impl Send for Payload
impl Sync for Payload
impl Unpin for Payload
impl UnwindSafe for Payload
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,