pub struct Context { /* private fields */ }Expand description
Small owner for a set of multicast publication sockets.
Implementations§
Source§impl Context
impl Context
Sourcepub fn publication_count(&self) -> usize
pub fn publication_count(&self) -> usize
Returns the number of tracked publications.
Sourcepub fn contains_publication(&self, id: PublicationId) -> bool
pub fn contains_publication(&self, id: PublicationId) -> bool
Returns whether a publication ID exists in the context.
Sourcepub fn get_publication(&self, id: PublicationId) -> Option<&Publication>
pub fn get_publication(&self, id: PublicationId) -> Option<&Publication>
Returns an immutable reference to one publication.
Sourcepub fn get_publication_mut(
&mut self,
id: PublicationId,
) -> Option<&mut Publication>
pub fn get_publication_mut( &mut self, id: PublicationId, ) -> Option<&mut Publication>
Returns a mutable reference to one publication.
Sourcepub fn add_publication(
&mut self,
config: PublicationConfig,
) -> Result<PublicationId, MctxError>
pub fn add_publication( &mut self, config: PublicationConfig, ) -> Result<PublicationId, MctxError>
Creates a new publication socket from configuration and stores it.
Sourcepub fn add_publication_with_socket(
&mut self,
config: PublicationConfig,
socket: Socket,
) -> Result<PublicationId, MctxError>
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.
Sourcepub fn add_publication_with_udp_socket(
&mut self,
config: PublicationConfig,
socket: UdpSocket,
) -> Result<PublicationId, MctxError>
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.
Sourcepub fn remove_publication(&mut self, id: PublicationId) -> bool
pub fn remove_publication(&mut self, id: PublicationId) -> bool
Removes one publication and drops its socket.
Sourcepub fn take_publication(&mut self, id: PublicationId) -> Option<Publication>
pub fn take_publication(&mut self, id: PublicationId) -> Option<Publication>
Extracts one publication from the context.
Sourcepub fn publications(&self) -> &[Publication]
pub fn publications(&self) -> &[Publication]
Returns all tracked publications.
Sourcepub fn publications_mut(&mut self) -> &mut [Publication]
pub fn publications_mut(&mut self) -> &mut [Publication]
Returns all tracked publications mutably.
Sourcepub fn send(
&self,
id: PublicationId,
payload: &[u8],
) -> Result<SendReport, MctxError>
pub fn send( &self, id: PublicationId, payload: &[u8], ) -> Result<SendReport, MctxError>
Sends one payload through the selected publication.
Sourcepub fn send_all(
&self,
payload: &[u8],
out: &mut Vec<SendReport>,
) -> Result<usize, MctxError>
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.
Sourcepub fn metrics_snapshot(&self) -> ContextMetricsSnapshot
pub fn metrics_snapshot(&self) -> ContextMetricsSnapshot
Returns a snapshot of the context’s current metrics.
Counter fields such as total_packets_sent are cumulative for the
lifetime of the context for send activity issued through Context
methods. They are not recomputed from the currently active publications,
and they do not decrease when a publication is removed.