Skip to main content

MapClient

Struct MapClient 

Source
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>

Source

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.

Source

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.

Source

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.

Source

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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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>

Source

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 telecommsg → 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>

Source

pub async fn connect(stream: T) -> Result<Self, MapError>

Sends the MAP UUID as the OBEX Target header and validates the server’s response.

§Errors

Returns MapError if the transport fails, packet encoding fails, the server rejects the connection, or the response omits the ConnectionId header.

Source§

impl<T: AsyncRead + AsyncWrite + Unpin> MapClient<T>

Source

pub async fn list_message_folders(&mut self) -> Result<FolderListing, MapError>

Backs up to root if already inside a subfolder, then navigates telecommsg 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.