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
impl Subscribe
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Subscribe instance.
No socket is opened until connect() is called.
Sourcepub fn connect(
&mut self,
url: &str,
connection_options: ConnectionOptions,
) -> Result<()>
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.
Sourcepub fn disconnect(&mut self) -> Result<()>
pub fn disconnect(&mut self) -> Result<()>
Disconnects the current connection and frees the associated resources.
§Errors:
Returns MotorcortexError::Connection if the disconnection fails.
Sourcepub fn subscribe<I>(
&mut self,
request: &Request,
paths: I,
group_name: &str,
frequency_divider: u32,
) -> Result<ReadOnlySubscription>where
I: Parameters,
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
impl Connection for Subscribe
Implement the common trait for Subscribe