Skip to main content

Payload

Struct Payload 

Source
pub struct Payload<F, T, S, B> {
    pub from: F,
    pub lead: bool,
    pub thread: Option<T>,
    pub to: S,
    pub body: B,
    pub kind: Kind,
    pub at_ms: u64,
}
Expand description

The fields of a signed payload (R196). One struct is the layout of both sides (01M49W17GGV1K5FZEKJRPV0GNA): the sender writes a Content that borrows the fields of its post, and a reader reads a Signed that owns them. A reader skips each field that it does not know.

Fields§

§from: F

The user and the session ID of the sender.

§lead: bool

True when the sender posts as the lead (R198). The place and the claims of the sender are not signed.

§thread: Option<T>

The thread of the post. None for a direct message.

§to: S§body: B§kind: Kind§at_ms: u64

The time of the message, in milliseconds since the Unix epoch.

Implementations§

Source§

impl Payload<&Who, &ThreadName, &[Selector], &str>

Source

pub fn payload(&self) -> String

The payload of the signature: the base64url of the JSON of the content. The sender makes it one time. Each other side keeps its bytes.

Source

pub fn sign(&self, key: &Key) -> String

The signature of the content by the device key key.

Source

pub fn verify(&self, sig: &str) -> Result<String, SignError>

Checks that sig signs this content. Gives the thumbprint of the key that signed it. The caller checks that the key belongs to the sender.

Source§

impl Payload<Who, ThreadName, Vec<Selector>, String>

Source

pub fn covers(&self, content: &Content<'_>) -> bool

True when the payload holds the fields of content.

Trait Implementations§

Source§

impl<F: Clone, T: Clone, S: Clone, B: Clone> Clone for Payload<F, T, S, B>

Source§

fn clone(&self) -> Payload<F, T, S, B>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: Debug, T: Debug, S: Debug, B: Debug> Debug for Payload<F, T, S, B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, F, T, S, B> Deserialize<'de> for Payload<F, T, S, B>
where F: Deserialize<'de>, T: Deserialize<'de>, S: Deserialize<'de> + Default, B: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<F: PartialEq, T: PartialEq, S: PartialEq, B: PartialEq> PartialEq for Payload<F, T, S, B>

Source§

fn eq(&self, other: &Payload<F, T, S, B>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<F, T, S, B> Serialize for Payload<F, T, S, B>
where F: Serialize, T: Serialize, S: Serialize, B: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<F: Copy, T: Copy, S: Copy, B: Copy> Copy for Payload<F, T, S, B>

Source§

impl<F: Eq, T: Eq, S: Eq, B: Eq> Eq for Payload<F, T, S, B>

Source§

impl<F, T, S, B> StructuralPartialEq for Payload<F, T, S, B>

Auto Trait Implementations§

§

impl<F, T, S, B> Freeze for Payload<F, T, S, B>
where F: Freeze, S: Freeze, B: Freeze, T: Freeze,

§

impl<F, T, S, B> RefUnwindSafe for Payload<F, T, S, B>

§

impl<F, T, S, B> Send for Payload<F, T, S, B>
where F: Send, S: Send, B: Send, T: Send,

§

impl<F, T, S, B> Sync for Payload<F, T, S, B>
where F: Sync, S: Sync, B: Sync, T: Sync,

§

impl<F, T, S, B> Unpin for Payload<F, T, S, B>
where F: Unpin, S: Unpin, B: Unpin, T: Unpin,

§

impl<F, T, S, B> UnsafeUnpin for Payload<F, T, S, B>

§

impl<F, T, S, B> UnwindSafe for Payload<F, T, S, B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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