pub struct AlpineClient { /* private fields */ }Expand description
High-level controller client that orchestrates discovery, handshake, streaming, control, and keepalive flows.
§Guarantees
- Handshake runs over
TimeoutTransport<CborUdpTransport>and fails fast. - Streaming uses a compiled
StreamProfileand cannot change behavior once active. - Keepalive tasks start after handshake and abort on
close().
Implementations§
Source§impl AlpineClient
impl AlpineClient
Sourcepub async fn connect(
local_addr: SocketAddr,
remote_addr: SocketAddr,
identity: DeviceIdentity,
capabilities: CapabilitySet,
credentials: NodeCredentials,
) -> Result<Self, ClientError>
pub async fn connect( local_addr: SocketAddr, remote_addr: SocketAddr, identity: DeviceIdentity, capabilities: CapabilitySet, credentials: NodeCredentials, ) -> Result<Self, ClientError>
Connects to a remote ALPINE device using the provided credentials.
§Behavior
- Executes discovery/handshake via
CborUdpTransportandTimeoutTransport. - Spins up a keepalive future that ticks every 5 seconds.
- Builds
ControlClientonce keys are derived socontrol_envelopeworks.
§Errors
Returns ClientError::Io for socket failures or missing session material,
ClientError::Handshake for protocol errors, and ClientError::Stream for
transport issues.
Sourcepub async fn start_stream(
&mut self,
profile: StreamProfile,
) -> Result<String, ClientError>
pub async fn start_stream( &mut self, profile: StreamProfile, ) -> Result<String, ClientError>
Starts streaming with the selected profile; Auto is the default.
§Guarantees
- Profiles are validated/normalized; invalid combinations return explicit errors.
config_idis bound to the session and can’t change once streaming begins.- Streaming transport is built after the profile is locked.
§Errors
Returns ClientError::Io for socket issues or session material that is missing.
Returns ClientError::Handshake if the profile cannot be bound or the session rejects it.
Sourcepub fn send_frame(
&self,
channel_format: ChannelFormat,
channels: Vec<u16>,
priority: u8,
groups: Option<HashMap<String, Vec<u16>>>,
metadata: Option<HashMap<String, Value>>,
) -> Result<(), ClientError>
pub fn send_frame( &self, channel_format: ChannelFormat, channels: Vec<u16>, priority: u8, groups: Option<HashMap<String, Vec<u16>>>, metadata: Option<HashMap<String, Value>>, ) -> Result<(), ClientError>
Sends a streaming frame via the high-level helper.
§Guarantees
- Validation reuses
AlnpStream, so it refuses to send when the session is not ready. - Applies jitter strategy before encoding.
- Requires
start_streamto have bound a profile before calling.
§Errors
Returns StreamError wrapped in ClientError::Stream.
Sourcepub async fn close(self)
pub async fn close(self)
Gracefully closes the client, stopping keepalive tasks.
§Behavior
- Transitions the session state to closed.
- Aborts the keepalive background job immediately.
Sourcepub fn control_envelope(
&self,
seq: u64,
op: ControlOp,
payload: Value,
) -> Result<ControlEnvelope, HandshakeError>
pub fn control_envelope( &self, seq: u64, op: ControlOp, payload: Value, ) -> Result<ControlEnvelope, HandshakeError>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AlpineClient
impl !RefUnwindSafe for AlpineClient
impl Send for AlpineClient
impl Sync for AlpineClient
impl Unpin for AlpineClient
impl !UnwindSafe for AlpineClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more