Skip to main content

Subscribe

Struct Subscribe 

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

Real-time streaming client that receives parameter updates from the server.

§Thread Safety

Subscribe is Send but not Sync. You can move it to another thread, but you cannot share it between threads by reference. The internal receive thread is managed automatically — no external synchronization is needed for subscription reads via ReadOnlySubscription, which is independently thread-safe.

Implementations§

Source§

impl Subscribe

Source

pub fn new() -> Self

Creates a new Subscribe instance.

No socket is opened until connect() is called.

Source

pub fn connect( &mut self, url: &str, connection_options: ConnectionOptions, ) -> Result<()>

Establishes a connection to a specified server URL using the given configuration options.

Opens a SUB socket, connects to the server, and spawns a background receive thread for processing incoming subscription updates.

§Arguments:
  • url - The server’s address (e.g., “wss://127.0.0.1:5569”).
  • connection_options - The connection settings, including TLS certificate and timeouts.
§Errors:

Returns MotorcortexError::Connection if the socket cannot be opened or the connection fails.

Source

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

Disconnects the current connection and frees the associated resources.

§Errors:

Returns MotorcortexError::Connection if the disconnection fails.

Source

pub fn unsubscribe(&mut self, request: &Request, id: u32) -> Result<()>

Removes a subscription and its associated server-side group.

§Arguments:
  • request - The Request client used to remove the group on the server.
  • id - The subscription ID to remove.
§Errors:

Returns MotorcortexError::Subscription if the NNG unsubscribe fails.

Source

pub fn subscribe<I>( &mut self, request: &Request, paths: I, group_name: &str, frequency_divider: u32, ) -> Result<ReadOnlySubscription>
where I: Parameters,

Creates a new subscription for the specified parameters.

§Arguments:
  • request - The Request client used to create the group on the server.
  • paths - The parameter paths to subscribe to.
  • group_name - An alias for the subscription group.
  • frequency_divider - Update rate divider relative to the server’s base frequency.
§Errors:

Returns MotorcortexError::Subscription if the group creation or NNG subscribe fails.

Trait Implementations§

Source§

impl Connection for Subscribe

Implement the common trait for Subscribe

Source§

fn connect(&mut self, url: &str, options: ConnectionOptions) -> Result<()>

Connect to a server
Source§

fn disconnect(&mut self) -> Result<()>

Disconnect from the server
Source§

impl Drop for Subscribe

Source§

fn drop(&mut self)

Executes the destructor for this 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.