Skip to main content

Context

Struct Context 

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

Small owner for a set of multicast publication sockets.

Implementations§

Source§

impl Context

Source

pub fn new() -> Self

Creates an empty multicast sender context.

Source

pub fn publication_count(&self) -> usize

Returns the number of tracked publications.

Source

pub fn contains_publication(&self, id: PublicationId) -> bool

Returns whether a publication ID exists in the context.

Source

pub fn get_publication(&self, id: PublicationId) -> Option<&Publication>

Returns an immutable reference to one publication.

Source

pub fn get_publication_mut( &mut self, id: PublicationId, ) -> Option<&mut Publication>

Returns a mutable reference to one publication.

Source

pub fn add_publication( &mut self, config: PublicationConfig, ) -> Result<PublicationId, MctxError>

Creates a new publication socket from configuration and stores it.

Source

pub fn add_publication_with_socket( &mut self, config: PublicationConfig, socket: Socket, ) -> Result<PublicationId, MctxError>

Stores an existing socket as a publication after configuring it.

Source

pub fn add_publication_with_udp_socket( &mut self, config: PublicationConfig, socket: UdpSocket, ) -> Result<PublicationId, MctxError>

Stores an existing standard-library UDP socket as a publication after configuring it.

Source

pub fn remove_publication(&mut self, id: PublicationId) -> bool

Removes one publication and drops its socket.

Source

pub fn take_publication(&mut self, id: PublicationId) -> Option<Publication>

Extracts one publication from the context.

Source

pub fn publications(&self) -> &[Publication]

Returns all tracked publications.

Source

pub fn publications_mut(&mut self) -> &mut [Publication]

Returns all tracked publications mutably.

Source

pub fn send( &self, id: PublicationId, payload: &[u8], ) -> Result<SendReport, MctxError>

Sends one payload through the selected publication.

Source

pub fn send_all( &self, payload: &[u8], out: &mut Vec<SendReport>, ) -> Result<usize, MctxError>

Sends the same payload through every publication and pushes reports into out.

If one publication fails, reports already written into out are preserved.

Trait Implementations§

Source§

impl Debug for Context

Source§

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

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

impl Default for Context

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.