Skip to main content

Op

Enum Op 

pub enum Op<'a> {
    Store(Store<'a>),
    Modify(Modify<'a>),
}
Expand description

A mutation to session state, in a form that can be serialized and replayed.

Passed to State::apply to replay a mutation. A persistence backend can also match on it to map each operation onto its own representation (e.g. SQL statements), the same way Property is matched.

Variants§

§

Store(Store<'a>)

Stores new data. Can fail if the session has no room for it.

§

Modify(Modify<'a>)

Changes or removes stored data. Never needs new storage.

Implementations§

§

impl<'a> Op<'a>

pub const fn store_outbox(packet_id: PacketId, entry: &OutboxEntry<'a>) -> Self

Creates an operation to store an outgoing publish from an OutboxEntry, preserving its QoS.

pub const fn remove_outbox(packet_id: PacketId) -> Self

Creates an operation to remove an outgoing publish from the outbox.

pub const fn store_qos2_pubcomp(packet_id: PacketId) -> Self

Creates an operation to store a QoS 2 entry directly in the awaiting-PUBCOMP state.

pub const fn remove_pubrel(packet_id: PacketId) -> Self

Creates an operation to remove a QoS 2 entry from the awaiting-PUBCOMP phase (pubrel-pending set).

pub const fn store_incoming_qos2(packet_id: PacketId) -> Self

Creates an operation to store an incoming QoS 2 publish in the awaiting-PUBREL phase.

pub const fn remove_incoming_qos2(packet_id: PacketId) -> Self

Creates an operation to remove an incoming QoS 2 publish.

pub const fn clear() -> Self

Creates an operation to clear all in-flight session state.

pub const fn store_filter(filter: &'a TopicFilter, state: FilterState) -> Self

Creates an operation to store (or replace) a filter entry verbatim.

pub const fn remove_filter(filter: &'a TopicFilter) -> Self

Creates an operation to remove a filter entry.

pub const fn mark_sent(packet_id: PacketId) -> Self

Creates an operation that marks a pending QoS 1 or QoS 2 publish as having been written to the wire at least once.

const fn op_code(&self) -> u8

Returns the op code byte for this operation.

pub fn decode(r: &mut Reader<'a>) -> Result<Self, OpDecodeError>

Decodes an operation from the provided reader.

§Errors

Returns OpDecodeError if the reader contains invalid data.

pub(crate) fn decode_as( r: &mut Reader<'a>, layout: Layout, ) -> Result<Self, OpDecodeError>

Decodes an operation encoded in layout.

Trait Implementations§

§

impl<'a> Clone for Op<'a>

§

fn clone(&self) -> Op<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
§

impl<'a> Copy for Op<'a>

§

impl<'a> Debug for Op<'a>

§

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

Formats the value using the given formatter. Read more
§

impl Encode for Op<'_>

§

fn encode<S: Sink>(&self, w: &mut Writer<S>) -> Result<(), S::Error>

Writes the encoded value. Read more
Source§

fn encoded_len(&self) -> usize

Returns the number of bytes encode writes.
§

impl<'a> From<Modify<'a>> for Op<'a>

§

fn from(op: Modify<'a>) -> Self

Converts to this type from the input type.
§

impl<'a> From<Store<'a>> for Op<'a>

§

fn from(op: Store<'a>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for Op<'a>

§

impl<'a> RefUnwindSafe for Op<'a>

§

impl<'a> Send for Op<'a>

§

impl<'a> Sync for Op<'a>

§

impl<'a> Unpin for Op<'a>

§

impl<'a> UnsafeUnpin for Op<'a>

§

impl<'a> UnwindSafe for Op<'a>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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 more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more