pub struct Connection<L> { /* private fields */ }Expand description
A MAVLink endpoint over a ByteLink: sends and receives whole messages, and signs
and verifies them when configured to.
A connection owns its sending identity and sequence counter, a streaming Parser for
the bytes it reads, and optional signing. Attach a Signer to sign every outgoing
frame and a Verifier to check every signed incoming one.
Implementations§
Source§impl<L: ByteLink> Connection<L>
impl<L: ByteLink> Connection<L>
Sourcepub fn with_signer(self, signer: Signer) -> Self
pub fn with_signer(self, signer: Signer) -> Self
Sourcepub fn with_verifier(self, verifier: Verifier) -> Self
pub fn with_verifier(self, verifier: Verifier) -> Self
Sourcepub async fn send<M: Message>(&mut self, message: &M) -> Result<()>
pub async fn send<M: Message>(&mut self, message: &M) -> Result<()>
Sends a typed message, signing it if a signer is attached.
§Arguments
message- the message to send.
§Returns
Ok(()) once the frame has been written to the link.
§Errors
Returns MavlinkError::PayloadTooLong if the message does not fit a frame, or a
link error from the underlying ByteLink.
Sourcepub async fn recv(&mut self) -> Result<Frame>
pub async fn recv(&mut self) -> Result<Frame>
Receives the next whole frame from the link, verifying its signature if required.
§Returns
The next valid frame.
§Errors
Returns MavlinkError::Closed if the link ends before a frame arrives,
MavlinkError::Unsigned if a signature is required but the frame is unsigned,
MavlinkError::BadSignature or MavlinkError::ReplayedTimestamp if a signed
frame does not verify, or a link error from the underlying ByteLink.