Skip to main content

Participant

Struct Participant 

Source
pub struct Participant<'domain> { /* private fields */ }
Expand description

A domain participant.

A participant is the entry point for all DDS communication within a Domain. All other entities, including topics, readers, writers, publishers, and subscribers, are created under a participant and are scoped to its lifetime.

Use Participant::new for simple construction or Participant::builder for QoS and listener configuration.

Implementations§

Source§

impl<'d> Participant<'d>

Source

pub fn new(domain: &'d Domain) -> Result<Self>

Creates a new participant in the given Domain with default QoS and no listener.

§Errors

Returns an Error if the participant fails to create.

§Examples
use cyclonedds::{Domain, Participant};

let domain = Domain::default();
let participant = Participant::new(&domain)?;
Source

pub const fn builder<'q>(domain: &'d Domain) -> ParticipantBuilder<'d, 'q>

Returns a ParticipantBuilder for constructing a participant with custom QoS or a listener.

§Examples
use cyclonedds::{Domain, Participant};

let domain = Domain::default();
let participant = Participant::builder(&domain).build()?;
Source

pub fn set_listener<L>(&mut self, listener: L) -> Result<()>
where L: AsRef<Listener>,

Sets the Listener on this participant, replacing any previously set listener.

§Errors

Returns an Error if the listener fails to set.

§Examples
use cyclonedds::{Domain, Listener, Participant, listener::SubscriberListener};

let domain = Domain::default();
let mut participant = Participant::new(&domain)?;
let listener =
    Listener::new().with_subscriber(|s| s.with_data_on_readers(|_| println!("data available")));
participant.set_listener(listener)?;
Source

pub fn unset_listener(&mut self) -> Result<()>

Removes the listener from this participant.

§Errors

Returns an Error if the listener fails to unset.

§Examples
use cyclonedds::{Domain, Participant};

let domain = Domain::default();
let mut participant = Participant::new(&domain)?;
participant.unset_listener()?;
Source

pub fn with_listener<L>(self, listener: L) -> Result<Self>
where L: AsRef<Listener>,

Sets the Listener on this participant, consuming and returning self.

Useful for chaining participant construction with listener configuration.

§Errors

Returns an Error if the listener fails to set.

§Examples
use cyclonedds::{Domain, Listener, Participant};

let domain = Domain::default();
let participant = Participant::new(&domain)?.with_listener(Listener::new())?;

Trait Implementations§

Source§

impl<'domain> Debug for Participant<'domain>

Source§

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

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

impl Drop for Participant<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Entity for Participant<'_>

Source§

fn id(&self) -> EntityId

Returns the EntityId of this entity. Read more
Source§

fn instance_handle(&self) -> Result<InstanceHandle>

Returns the InstanceHandle of this entity. Read more
Source§

fn status_changes(&self) -> Result<Status>

Returns the set of status flags that have changed since they were last read or taken. Read more
Source§

fn take_status(&self, mask: Option<Status>) -> Result<Status>

Takes and clears the status flags matching mask, or all flags if mask is None. Read more
Source§

fn read_status(&self, mask: Option<Status>) -> Result<Status>

Reads the status flags matching mask without clearing them, or all flags if mask is None. Read more
Source§

fn status_mask(&self) -> Result<Status>

Returns the status mask enabled on the entity. Read more
Source§

fn set_status_mask(&self, mask: Status) -> Result<()>

Sets and enables a status mask on the entity. Read more

Auto Trait Implementations§

§

impl<'domain> Freeze for Participant<'domain>

§

impl<'domain> RefUnwindSafe for Participant<'domain>

§

impl<'domain> Send for Participant<'domain>

§

impl<'domain> Sync for Participant<'domain>

§

impl<'domain> Unpin for Participant<'domain>

§

impl<'domain> UnsafeUnpin for Participant<'domain>

§

impl<'domain> UnwindSafe for Participant<'domain>

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> Same for T

Source§

type Output = T

Should always be Self
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.