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.
Auto Trait Implementations§
impl<T> Freeze for MnsServer<T>where
T: Freeze,
impl<T> RefUnwindSafe for MnsServer<T>where
T: RefUnwindSafe,
impl<T> Send for MnsServer<T>where
T: Send,
impl<T> Sync for MnsServer<T>where
T: Sync,
impl<T> Unpin for MnsServer<T>where
T: Unpin,
impl<T> UnsafeUnpin for MnsServer<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for MnsServer<T>where
T: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more