Skip to main content

Backend

Trait Backend 

Source
pub trait Backend: Send + Sync {
    // Required methods
    fn kind(&self) -> BackendKind;
    fn capabilities(&self) -> Capabilities;
    fn server_ref(&self) -> &str;
    fn ensure_session(
        &self,
        ids: &IdentityStore,
        id: &mut SessionIdentity,
        invite: Option<&str>,
    ) -> Result<Session>;
    fn execute(
        &self,
        request: &OutgoingRequest,
    ) -> Result<HttpResponseDescriptor>;
    fn whoami(&self) -> Result<(String, String)>;
    fn keep_prefix(&self) -> bool;
    fn wait_for_news(&self, timeout: Duration) -> Result<News>;

    // Provided method
    fn frozen(&self) -> Option<Arc<dyn Backend>> { ... }
}

Required Methods§

Source

fn kind(&self) -> BackendKind

Source

fn capabilities(&self) -> Capabilities

Source

fn server_ref(&self) -> &str

The normalized server base URL this backend talks to (the identity is bound to it).

Source

fn ensure_session( &self, ids: &IdentityStore, id: &mut SessionIdentity, invite: Option<&str>, ) -> Result<Session>

A live session for id. First time: redeems the operator’s invite (enroll the public key, proving possession of the private one); afterwards: logs in by signing a fresh challenge. Reuses the stored token while the server still accepts it. Persists what it learns.

Source

fn execute(&self, request: &OutgoingRequest) -> Result<HttpResponseDescriptor>

Performs one request of the engine as this session (bearer added, token refreshed once by signature if the server forgot it). Callable from any thread. Needs ensure_session first.

Source

fn whoami(&self) -> Result<(String, String)>

(user_id, device_id) of the session (what the engine needs to open a core).

Source

fn keep_prefix(&self) -> bool

Whether this server serves the Matrix paths under /_matrix (found out, not assumed).

Source

fn wait_for_news(&self, timeout: Duration) -> Result<News>

Waits up to timeout for news for this session: room events pushed on the server’s push socket, or Idle (timeout, or the server has no push channel and the sync long poll is the wait).

Provided Methods§

Source

fn frozen(&self) -> Option<Arc<dyn Backend>>

A copy of this backend whose routing choices are frozen now, for a request that will run later on a worker (a long poll started for a local exchange must stay local). None: the backend has no such choices.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§