pub struct MapClient<T> { /* private fields */ }Expand description
MAP session over an OBEX transport. Owns the OBEX state machine and the framed I/O.
Obtain via MapClient::connect.
Implementations§
Source§impl<T: AsyncRead + AsyncWrite + Unpin> MapClient<T>
impl<T: AsyncRead + AsyncWrite + Unpin> MapClient<T>
Sourcepub async fn get_folder_listing(&mut self) -> Result<FolderListing, MapError>
pub async fn get_folder_listing(&mut self) -> Result<FolderListing, MapError>
Returns the MAP folder listing for the current object store level via GetFolderListing
GET with Type x-obex/folder-listing. Folders are in device-reported document order.
§Errors
Returns MapError::ServerError if the remote returns a non-OK response.
Returns MapError::FolderListing if the response body is malformed XML.
Returns MapError::Obex or MapError::Transport on lower-layer failure.
Sourcepub async fn set_notification_registration(
&mut self,
enable: bool,
) -> Result<(), MapError>
pub async fn set_notification_registration( &mut self, enable: bool, ) -> Result<(), MapError>
When enable is true, the phone will connect to the MNS channel and push event reports.
When false, it stops. The caller must keep the MAP session alive while notifications are active.
§Errors
Returns MapError::ServerError if the remote returns a non-OK response.
Returns MapError::Obex or MapError::Transport on lower-layer failure.
Sourcepub async fn hold(&mut self) -> Result<(), MapError>
pub async fn hold(&mut self) -> Result<(), MapError>
Reads from the transport until the remote closes the stream, discarding all received
packets. Returns Ok(()) on clean close. Does not send OBEX DISCONNECT and does not
parse received packet opcodes.
§Errors
Returns MapError::Transport on a framing error from the underlying codec.
Sourcepub async fn disconnect(self) -> Result<(), MapError>
pub async fn disconnect(self) -> Result<(), MapError>
Sends OBEX DISCONNECT and awaits the server acknowledgement.
Consumes self — the session is unusable after this call regardless of the outcome.
Does not close the underlying stream; the stream is dropped when self is consumed.
§Errors
Returns MapError if the request cannot be encoded, the transport fails, or the
server returns a non-OK response.
Source§impl<T: AsyncRead + AsyncWrite + Unpin> MapClient<T>
impl<T: AsyncRead + AsyncWrite + Unpin> MapClient<T>
Sourcepub async fn list_messages(
&mut self,
filter: &ListMessagesFilter,
) -> Result<Vec<MessageEntry>, MapError>
pub async fn list_messages( &mut self, filter: &ListMessagesFilter, ) -> Result<Vec<MessageEntry>, MapError>
Caller must navigate to the target folder via Self::set_folder before calling this.
Sends a GetMessagesListing GET with no Name header — the device lists the current OBEX
working directory. Accumulates body chunks across CONTINUE responses before parsing.
§Errors
Returns MapError if the transport fails, the server rejects the request, or the
response XML is malformed.
Sourcepub async fn get_message(&mut self, handle: &str) -> Result<BMessage, MapError>
pub async fn get_message(&mut self, handle: &str) -> Result<BMessage, MapError>
Sends a GetMessage GET with Type: x-bt/message and Charset=UTF-8. Accumulates body
chunks across CONTINUE responses before parsing.
§Errors
Returns MapError::InvalidInput if handle is empty or contains CR or LF — it lands
verbatim in the OBEX Name header. Returns MapError if the transport fails, the server
rejects the request, the response body exceeds 4 MiB, is not valid UTF-8, or the bMessage
is malformed.
Sourcepub async fn push_message(
&mut self,
phone: &str,
text: &str,
) -> Result<String, MapError>
pub async fn push_message( &mut self, phone: &str, text: &str, ) -> Result<String, MapError>
Sends text as an outbound SMS to phone via MAP PushMessage. Returns the opaque
handle assigned by the remote, suitable for passing to set_message_status. Caller must
have navigated to outbox via set_folder(Folder::Outbox) first.
§Errors
Returns MapError if encoding fails, the transport closes, the server rejects the
request, or the OK response contains no Name header.
Sourcepub async fn set_message_status_read(
&mut self,
handle: &str,
status: MessageStatus,
) -> Result<(), MapError>
pub async fn set_message_status_read( &mut self, handle: &str, status: MessageStatus, ) -> Result<(), MapError>
Marks the message identified by handle as status (read or unread) via MAP
SetMessageStatus. Caller must navigate to the containing folder via set_folder first.
§Errors
Returns MapError::InvalidInput if handle is empty or contains CR or LF.
Returns MapError::ServerError if the remote returns a non-OK response.
Returns MapError::Obex or MapError::Transport on lower-layer failure.
Sourcepub async fn set_message_status_deleted(
&mut self,
handle: &str,
deleted: bool,
) -> Result<(), MapError>
pub async fn set_message_status_deleted( &mut self, handle: &str, deleted: bool, ) -> Result<(), MapError>
Marks the message identified by handle as deleted (true) or undeleted (false) via
MAP SetMessageStatus. Caller must navigate to the containing folder via set_folder first.
§Errors
Returns MapError::InvalidInput if handle is empty or contains CR or LF.
Returns MapError::ServerError if the remote returns a non-OK response.
Returns MapError::Obex or MapError::Transport on lower-layer failure.
Source§impl<T: AsyncRead + AsyncWrite + Unpin> MapClient<T>
impl<T: AsyncRead + AsyncWrite + Unpin> MapClient<T>
Sourcepub async fn set_folder(&mut self, folder: Folder) -> Result<(), MapError>
pub async fn set_folder(&mut self, folder: Folder) -> Result<(), MapError>
If already inside a subfolder (e.g. after a prior set_folder call), backs up to root
first, then navigates telecom → msg → folder. iOS requires one SETPATH per level;
a single slash-joined path is rejected.
§Errors
Returns MapError if any SETPATH fails to encode, the transport closes, or the
server returns a non-OK response for any step.
Source§impl<T: AsyncRead + AsyncWrite + Unpin> MapClient<T>
impl<T: AsyncRead + AsyncWrite + Unpin> MapClient<T>
Sourcepub async fn list_message_folders(&mut self) -> Result<FolderListing, MapError>
pub async fn list_message_folders(&mut self) -> Result<FolderListing, MapError>
Backs up to root if already inside a subfolder, then navigates telecom → msg and
lists that level. Use this instead of a bare MapClient::get_folder_listing, which
lists only the current OBEX directory — on iOS that is the root unless the
telecom/msg SETPATHs are issued first.
§Errors
Returns MapError if a backup or forward SETPATH fails, the server returns a
non-OK response, or the listing XML is malformed.
Auto Trait Implementations§
impl<T> Freeze for MapClient<T>where
T: Freeze,
impl<T> RefUnwindSafe for MapClient<T>where
T: RefUnwindSafe,
impl<T> Send for MapClient<T>where
T: Send,
impl<T> Sync for MapClient<T>where
T: Sync,
impl<T> Unpin for MapClient<T>where
T: Unpin,
impl<T> UnsafeUnpin for MapClient<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for MapClient<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