Skip to main content

Crate rusmes_jmap

Crate rusmes_jmap 

Source
Expand description

JMAP protocol implementation for RusMES

This crate implements the JSON Meta Application Protocol (JMAP) for the RusMES mail server, providing an HTTP/JSON API for email access as defined in:

  • RFC 8620 — The JSON Meta Application Protocol (core protocol)
  • RFC 8621 — Using JMAP for Email (Email, Mailbox, Thread, EmailSubmission, VacationResponse, SearchSnippet, Identity)

§Module Overview

ModuleContents
apiAxum-based HTTP server (JmapServer), request dispatch, auth middleware
blobBlob upload (POST /upload/:account) and download (GET /download/…) endpoints
eventsourceServer-Sent Events push channel (GET /eventsource) for state-change notifications
sessionJMAP Session resource (GET /.well-known/jmap), capability advertisement
typesShared JSON types: Email, JmapRequest, JmapResponse, JmapError, etc.
methodsMethod handlers for all JMAP objects (see sub-modules below)

§Method Handlers

Sub-moduleRFCMethods
methods::mailboxRFC 8621 §2Mailbox/get, Mailbox/set, Mailbox/query, Mailbox/changes, Mailbox/queryChanges
methods::emailRFC 8621 §4Email/get, Email/set, Email/query
methods::email_advancedRFC 8621 §4Email/changes, Email/queryChanges, Email/copy, Email/import, Email/parse
methods::threadRFC 8621 §3Thread/get, Thread/changes
methods::submissionRFC 8621 §7EmailSubmission/get, EmailSubmission/set, EmailSubmission/query, EmailSubmission/changes
methods::identityRFC 8621 §5Identity/get, Identity/set, Identity/changes
methods::vacationRFC 8621 §8VacationResponse/get, VacationResponse/set
methods::search_snippetRFC 8621 §9SearchSnippet/get

§Example — Starting the JMAP server

use rusmes_jmap::JmapServer;
use axum::Router;

// Obtain the JMAP routes and nest them inside an Axum application.
let app: Router = JmapServer::routes();
// e.g. axum::serve(listener, app).await.unwrap();

§EventSource Push

The eventsource::EventSourceManager can be used to broadcast state-change notifications to JMAP clients that maintain a long-lived SSE connection:

use rusmes_jmap::EventSourceManager;

let manager = EventSourceManager::new();
// Notify all connected clients that the Email state has changed:
manager.notify_change("Email".to_string(), "new-state-token".to_string());

§Blob Handling

BlobStorage provides a content-addressed in-memory blob store keyed by SHA-256 hash. Uploaded blobs are referenced by blobId strings throughout JMAP Email import/parse operations.

Re-exports§

pub use api::JmapServer;
pub use blob::BlobStorage;
pub use blob::UploadError;
pub use blob::UploadResponse;
pub use eventsource::EventSourceManager;
pub use eventsource::PushSubscription;
pub use eventsource::StateChange;
pub use session::Account;
pub use session::AccountCapability;
pub use session::Capability;
pub use session::Session;
pub use types::Email;
pub use types::EmailAddress;
pub use types::EmailGetRequest;
pub use types::EmailGetResponse;
pub use types::EmailQueryRequest;
pub use types::EmailQueryResponse;
pub use types::EmailSetRequest;
pub use types::EmailSetResponse;
pub use types::JmapError;
pub use types::JmapErrorType;
pub use types::JmapMethod;
pub use types::JmapRequest;
pub use types::JmapResponse;

Modules§

api
JMAP API server
blob
Blob upload/download endpoints for JMAP
eventsource
EventSource (Server-Sent Events) endpoint for JMAP
methods
JMAP method handlers
session
JMAP Session Object (RFC 8620 Section 2)
types
JMAP type definitions