p2panda_sync

Enum FromSync

Source
pub enum FromSync<T>
where T: TopicQuery,
{ HandshakeSuccess(T), Data { header: Vec<u8>, payload: Option<Vec<u8>>, }, }
Expand description

Messages which can be sent to the higher application layers (for further validation or persistance) and the underlying transport layer (for managing the sync session).

Variants§

§

HandshakeSuccess(T)

During the “Handshake” phase both peers usually manage access control and negotiate the “topic query” they want to exchange over. This message indicates that this phase has ended.

Implementations for p2panda-net are required to send this message to the underlying transport layer to inform the “backend” that we’ve successfully requested access, exchanged the topic query with the remote peer and are about to begin sync.

With this information backends can optionally apply optimisations, which might for example be required to keep application messages in-order (as there might exist other channels the backend exchanges similar data over at the same time).

§

Data

Application data we’ve received during the sync session from the remote peer and want to forward to higher application layers.

These “frontends” might further process, decrypt payloads, sort messages or apply more validation before they get finally persisted or rendered to the user. At this point the sync protocol is merely “forwarding” it without any knowledge of how the data is used.

Fields

§header: Vec<u8>

Exchanged data from sync session.

Some data-types might be designed with “off-chain” use in mind, where a “header” is crucial for integrity and authenticity but the actual “payload” is optional or requested lazily in a later process.

§payload: Option<Vec<u8>>

Optional “body” which can represent “off-chain” application data.

This is useful for realising “off-chain” compatible data types. Implementations without this distinction will always leave this field as None and only encode their data types in the header field.

Trait Implementations§

Source§

impl<T> Debug for FromSync<T>
where T: TopicQuery + Debug,

Source§

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

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

impl<T> PartialEq for FromSync<T>
where T: TopicQuery + PartialEq,

Source§

fn eq(&self, other: &FromSync<T>) -> 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<T> StructuralPartialEq for FromSync<T>
where T: TopicQuery,

Auto Trait Implementations§

§

impl<T> Freeze for FromSync<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for FromSync<T>
where T: RefUnwindSafe,

§

impl<T> Send for FromSync<T>

§

impl<T> Sync for FromSync<T>

§

impl<T> Unpin for FromSync<T>
where T: Unpin,

§

impl<T> UnwindSafe for FromSync<T>
where T: UnwindSafe,

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> 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, 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.