pub trait JmapChatExt: Sealed {
// Required method
fn with_chat_session(&self, session: Session) -> SessionClient;
}Expand description
Extension trait adding JMAP Chat methods to jmap_base_client::JmapClient.
Import this trait to use: use jmap_chat_client::JmapChatExt;
All JMAP Chat method calls are made through the SessionClient returned
by with_chat_session.
This trait is sealed: implementations outside this crate are not
permitted. The crate adds an impl only for
jmap_base_client::JmapClient. Sealing prevents downstream
divergence (e.g. impl JmapChatExt for MySimulator) and keeps
adding methods to the trait a non-breaking change.
Required Methods§
Sourcefn with_chat_session(&self, session: Session) -> SessionClient
fn with_chat_session(&self, session: Session) -> SessionClient
Create a SessionClient bound to this client and session.
All JMAP Chat method calls are made through the returned SessionClient.
§Deferred session-capability validation
This constructor accepts ANY jmap_base_client::Session,
including one whose advertised capabilities do not include
urn:ietf:params:jmap:chat or whose primaryAccounts map has
no entry for the chat capability. The constructor performs no
up-front validation and never fails — its return type is the
infallible methods::SessionClient, not a Result.
Capability and primary-account validation is deferred to every
individual method call on the returned SessionClient. If
the session is unsuitable, those per-method calls return
ClientError::InvalidSession with a description like
"no primary account for urn:ietf:params:jmap:chat".
Callers that want to guard at the binding site can pre-check the session before calling this method:
if session
.primary_account_id("urn:ietf:params:jmap:chat")
.is_none()
{
// Session does not advertise a primary account for chat;
// every subsequent SessionClient method call would fail
// with ClientError::InvalidSession. Refuse here.
return Err(MyAppError::SessionMissingChatCapability);
}
let sc = client.with_chat_session(session);Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".