Struct Writer

Source
pub struct Writer { /* private fields */ }
Expand description

Wraps RingBuffer and allows to publish messages. Only single writer should be present at any time.

Implementations§

Source§

impl Writer

Source

pub fn claim(&self, len: usize, fin: bool) -> Claim<'_>

Claim part of the underlying RingBuffer for publication. The fin flag is used to indicate final message fragment.

§Panics

When aligned message length is greater than the MTU.

Source

pub fn claim_with_user_defined( &self, len: usize, fin: bool, user_defined: u32, ) -> Claim<'_>

Claim part of the underlying RingBuffer for publication. The fin flag is used to indicate final message fragment. This method also accepts user_defined value that will be attached to the message frame header.

§Panics

When aligned message length is greater than the MTU.

Source

pub fn continuation(&self, len: usize, fin: bool) -> Claim<'_>

Claim part of the underlying RingBuffer for continuation frame publication also passing fin value to indicate final message fragment.

§Panics

When aligned message length is greater than the MTU.

Source

pub fn heartbeat(&self) -> Claim<'_>

Claim part of the underlying RingBuffer for heartbeat frame publication (zero payload, no user defined field and no fragmentation). This operation will always succeed.

Source

pub fn heartbeat_with_user_defined(&self, user_defined: u32) -> Claim<'_>

Claim part of the underlying RingBuffer for heartbeat frame publication with user defined field (zero payload and no fragmentation). This operation will always succeed.

Source

pub const fn mtu(&self) -> usize

Get maximum permissible unaligned payload length that can be accepted by the buffer. It is calculated as min(capacity / 2 - size_of::<FrameHeader>(), MAX_PAYLOAD_LEN) where MAX_PAYLOAD_LEN is (1 << 31) - 1.

Trait Implementations§

Source§

impl Debug for Writer

Source§

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

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

impl From<RingBuffer> for Writer

Source§

fn from(ring: RingBuffer) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !Freeze for Writer

§

impl !RefUnwindSafe for Writer

§

impl !Send for Writer

§

impl !Sync for Writer

§

impl Unpin for Writer

§

impl UnwindSafe for Writer

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.