[][src]Struct sync15::Payload

pub struct Payload {
    pub id: Guid,
    pub deleted: bool,
    pub data: Map<String, Value>,
}

Represents the decrypted payload in a Bso. Provides a minimal layer of type safety to avoid double-encrypting.

Fields

id: Guiddeleted: booldata: 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]

"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]

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]

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]

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]

impl PartialEq<Payload> for Payload[src]

impl Serialize for Payload[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,