pub struct MnsServer<T> { /* private fields */ }Expand description
MNS OBEX server. Receives a connection from the remote device on the MNS RFCOMM channel,
performs the OBEX handshake, and yields MAP event reports via next_event.
Obtain via MnsServer::accept.
Implementations§
Source§impl<T: AsyncRead + AsyncWrite + Unpin> MnsServer<T>
impl<T: AsyncRead + AsyncWrite + Unpin> MnsServer<T>
Sourcepub async fn accept(stream: T) -> Result<Self, MnsError>
pub async fn accept(stream: T) -> Result<Self, MnsError>
Wraps stream in OBEX framing, performs the OBEX CONNECT handshake as the MNS server,
and validates the Target UUID against the MNS service UUID.
§Errors
Returns MnsError::InvalidTarget if the CONNECT request Target header is absent or
does not match bb582b41-420c-11db-b0de-0800200c9a66. Returns MnsError::Obex on
packet decode failure or MnsError::Transport on I/O failure.
Sourcepub async fn next_event_raw(&mut self) -> Result<Option<Bytes>, MnsError>
pub async fn next_event_raw(&mut self) -> Result<Option<Bytes>, MnsError>
Returns the raw event-report XML body bytes from the next OBEX PUT, or None on
OBEX DISCONNECT. Handles the full OBEX exchange. Does not parse the body — callers
needing a typed MnsEvent should call next_event instead.
§Errors
Returns MnsError::UnexpectedOpcode if the device sends an opcode other than PUT,
PUT_FINAL, or DISCONNECT. Returns MnsError::UnexpectedEof if the stream closes
mid-packet. Returns MnsError::Transport on I/O failure.
Sourcepub async fn next_event(&mut self) -> Result<Option<MnsEvent>, MnsError>
pub async fn next_event(&mut self) -> Result<Option<MnsEvent>, MnsError>
Returns Ok(None) when the device sends a clean OBEX DISCONNECT.
§Errors
Returns MnsError::UnexpectedOpcode if the device sends an opcode other than PUT,
PUT_FINAL, or DISCONNECT. Returns MnsError::UnexpectedEof if the stream closes
mid-packet. XML parse errors from parse_event_report are propagated unchanged.