TypedSpscSender

Struct TypedSpscSender 

Source
pub struct TypedSpscSender<C> { /* private fields */ }
Expand description

Typed SPSC sender that publishes v1-framed messages using codec C.

§Contract

  • Publishes a v1 header prefix (indexbus_msg) plus codec-defined payload bytes.
  • If encoding fails, no message is published.

Implementations§

Source§

impl<C> TypedSpscSender<C>

Source

pub fn new(inner: SpscSender, codec: C) -> Self

Wrap an indexbus-core SPSC sender with a codec.

Source§

impl<C> TypedSpscSender<C>

Source

pub fn publish<T>(&self, meta: MsgMeta, value: &T) -> Result<(), Error>
where C: CodecId + EncodeInto<T>,

Publish value with the provided message identity.

This encodes a v1 header into the slot prefix, encodes value into the payload region, and publishes the resulting slot bytes.

§Errors
Source

pub fn publish_msg<T>(&self, value: &T) -> Result<(), Error>
where T: IndexbusMsgSpec, C: CodecId + EncodeInto<T>,

Publish a typed message using compile-time identity (T::META).

This is sugar over Self::publish. Use publish(meta, value) if you need dynamic identity or non-default flags.

Auto Trait Implementations§

§

impl<C> Freeze for TypedSpscSender<C>
where C: Freeze,

§

impl<C> !RefUnwindSafe for TypedSpscSender<C>

§

impl<C> Send for TypedSpscSender<C>
where C: Send,

§

impl<C> !Sync for TypedSpscSender<C>

§

impl<C> Unpin for TypedSpscSender<C>
where C: Unpin,

§

impl<C> !UnwindSafe for TypedSpscSender<C>

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.