pub struct MailClient { /* private fields */ }Expand description
Async HTTP client bound to one mailbox base URL and one bearer credential.
Clone is cheap (shared reqwest::Client). The bearer is stored so every
/mail/* and /admin/* call presents the same account; session identity
is still resolved server-side from the TCP peer.
Implementations§
Source§impl MailClient
impl MailClient
Sourcepub fn new(
base_url: impl AsRef<str>,
bearer: impl Into<String>,
) -> Result<Self, ClientError>
pub fn new( base_url: impl AsRef<str>, bearer: impl Into<String>, ) -> Result<Self, ClientError>
Builds a client for base_url (e.g. DEFAULT_BASE_URL) authenticating
as bearer. Refuses a non-loopback base by default so a typo cannot
point HQ mail at a remote host during local smoke — pass
MailClient::builder when a non-loopback target is intentional.
Sourcepub fn new_unchecked(
base_url: impl AsRef<str>,
bearer: impl Into<String>,
) -> Result<Self, ClientError>
pub fn new_unchecked( base_url: impl AsRef<str>, bearer: impl Into<String>, ) -> Result<Self, ClientError>
pub fn builder( base_url: impl AsRef<str>, ) -> Result<MailClientBuilder, ClientError>
pub fn base_url(&self) -> &Url
Sourcepub async fn health_at(
base_url: impl AsRef<str>,
) -> Result<HealthReport, ClientError>
pub async fn health_at( base_url: impl AsRef<str>, ) -> Result<HealthReport, ClientError>
GET /health — no bearer. Convenience that builds a one-shot client
against base_url without storing credentials.
Sourcepub async fn health(&self) -> Result<HealthReport, ClientError>
pub async fn health(&self) -> Result<HealthReport, ClientError>
GET /health on this client’s base URL.
pub async fn send( &self, request: SendRequest, ) -> Result<SendResponse, ClientError>
pub async fn inbox( &self, request: InboxRequest, ) -> Result<InboxPage, ClientError>
pub async fn ack(&self, request: AckRequest) -> Result<AckResponse, ClientError>
pub async fn get_message( &self, request: MessageGetRequest, ) -> Result<Message, ClientError>
pub async fn unread( &self, request: UnreadCountRequest, ) -> Result<UnreadCount, ClientError>
Sourcepub async fn directory(&self) -> Result<Directory, ClientError>
pub async fn directory(&self) -> Result<Directory, ClientError>
POST /mail/directory — empty body.
Sourcepub async fn whoami(&self) -> Result<WhoAmIResponse, ClientError>
pub async fn whoami(&self) -> Result<WhoAmIResponse, ClientError>
POST /mail/whoami — empty body.
pub async fn status( &self, request: SessionDeclared, ) -> Result<StatusResponse, ClientError>
Sourcepub async fn admin_register_participant(
&self,
request: RegisterParticipantRequest,
) -> Result<SecretResponse, ClientError>
pub async fn admin_register_participant( &self, request: RegisterParticipantRequest, ) -> Result<SecretResponse, ClientError>
Operator: register a participant; returns the one-time secret.
pub async fn admin_rotate_participant( &self, id: ParticipantId, ) -> Result<SecretResponse, ClientError>
pub async fn admin_remove_participant( &self, id: ParticipantId, ) -> Result<(), ClientError>
pub async fn admin_create_room(&self, id: RoomId) -> Result<(), ClientError>
pub async fn admin_add_room_member( &self, room: RoomId, participant: ParticipantId, ) -> Result<(), ClientError>
pub async fn admin_remove_room_member( &self, room: RoomId, participant: ParticipantId, ) -> Result<(), ClientError>
Sourcepub async fn send_direct(
&self,
to: ParticipantId,
subject: impl Into<String>,
body: impl Into<String>,
) -> Result<SendResponse, ClientError>
pub async fn send_direct( &self, to: ParticipantId, subject: impl Into<String>, body: impl Into<String>, ) -> Result<SendResponse, ClientError>
Convenience: send a direct message to to with subject/body.
Sourcepub async fn list_inbox(&self) -> Result<InboxPage, ClientError>
pub async fn list_inbox(&self) -> Result<InboxPage, ClientError>
Convenience: list inbox with default limit, no wait.