Skip to main content

OpenedStore

Struct OpenedStore 

Source
pub struct OpenedStore { /* private fields */ }
Expand description

A sealed messenger core opened for one session, plus the homeserver it performs released requests against. The Olm account was loaded or created into it. Private key material stays here. The device bearer stays in memory and is zeroed when this value is dropped.

Implementations§

Source§

impl OpenedStore

Source

pub fn run_command(&mut self, req: &CmdRequest, now_ms: i64) -> CmdReply

Runs one rich command for this session.

Source§

impl OpenedStore

Source

pub fn open( dir: &Path, session_id: &str, device_id: DeviceId, user_id: &str, server_name: &str, backend: Arc<dyn Backend>, device_token: &str, ) -> Result<Self, ShellError>

Derives the seal key from session_id, reads dir, and opens the core. A different session id cannot open records this session sealed.

The host keychain injects device_token. STORE_ROOT_ENV plus session_id (session_store_dir) picks dir. This does not read a routine URL or a leader socket. The web machine client and the node CLI set wake on their own open paths. The device bearer stays in memory and is not written under dir.

Source

pub fn connect(config: &SessionConfig) -> Result<Self, ShellError>

Registers this Grok Bot web session, then opens its sealed store.

POST /client/v3/register with the derived nick, the session id, and a public id equal to that nick. The bearer from a creating response stays in memory. A repeat of the same session id returns no bearer; [DEVICE_TOKEN_ENV] (already copied into config) is used instead. One Self::drive publishes this device’s public keys. The private Olm account stays in the store.

Source

pub fn connect_from_env() -> Result<Self, ShellError>

SessionConfig::from_env then Self::connect. No routine URL and no leader socket. The web machine client is MachineClient::from_env. The node CLI is Self::connect_node_from_env.

Source

pub fn connect_node_from_env() -> Result<Self, ShellError>

Node CLI open path. One session from the host environment, woken by ACP on LEADER_SOCK_ENV. ROUTINE_URL_ENV or ROUTINE_BEARER_ENV is refused before register, is not stored, and is not logged. This does not read a session json.

Source

pub fn device_bearer(&self) -> &str

Source

pub fn nick(&self) -> Option<&str>

This session’s derived nick, when Self::connect stored one. Self::open leaves this empty.

Source

pub fn session_id(&self) -> &str

Session / device id used for the seal and for ACP sessionId.

Source

pub fn homeserver_url(&self) -> &str

Homeserver origin this store performs Client-Server calls against.

Source

pub fn has_leader(&self) -> bool

Whether an ACP leader socket is configured for wake.

Source

pub fn store_dir(&self) -> &Path

Directory this store seals into. Not shared with another session.

Source

pub fn homeserver_hits(&self) -> u64

Homeserver calls this store’s client has counted. In-process bus calls are not included. Zero when this store has no bus.

Source

pub fn pushed_room_events(&self) -> &[PushedRoomEvent]

Room texts this session received on the machine push socket.

Source

pub fn user_id(&self) -> &str

This account’s Matrix user id.

Source

pub fn member_joined(&self, room_id: &str, user_id: &str) -> bool

Whether user_id is a joined member of room_id in this store.

Source

pub fn find_nick( &mut self, name_or_nick: &str, now_ms: i64, ) -> Result<FoundSession, ShellError>

Looks up name_or_nick in the user directory. A display name is derived first when it is not already a nick. The hit is nick plus user id. No routine URL is returned or sent.

Source

pub fn ensure_dm( &mut self, name_or_nick: &str, now_ms: i64, ) -> Result<String, ShellError>

Looks name_or_nick up and opens the encrypted DM, creating it when this account does not already have one. Does not send. The peer may still be invited: Self::write_to_nick sends only after they join.

Source

pub fn accept_direct_invites( &mut self, now_ms: i64, ) -> Result<Vec<String>, ShellError>

Joins direct-message invites already visible to this store.

Returns the room ids this call asked to join. A room that is not an is_direct invite is left alone. This does not register the inviter.

Source

pub fn write_to_nick( &mut self, name_or_nick: &str, text: &str, now_ms: i64, ) -> Result<String, ShellError>

Writes text to the session named by name_or_nick.

The caller is already registered. This looks the nick up, reuses the encrypted DM when one exists, otherwise creates one, and sends only after the peer’s membership is join. A peer who is still invited gets no ciphertext: the caller joins them first (Self::accept_direct_invites) and calls this again. It does not register the other session and it does not put a routine URL in the room.

Source

pub fn set_wake(&mut self, wake: SessionWake)

Replaces the wake targets. None or empty turns that trigger off. The bearer is stored in Zeroizing memory and is not written to disk. Self::open does not read a wake; the web machine client and the node CLI set one on their open paths.

Source

pub fn set_wake_chain(&mut self, session: ProviderSession, chain: WakeChain)

Installs the provider wake chain (provider::plan_chain). Used only while no leader socket is set; the Grok leader path and the routine POST are unchanged by it.

Source

pub fn wake_chain_ids(&self) -> Vec<&'static str>

Link ids of the installed chain, in order. Empty when none.

Source

pub fn wake_route(&self) -> Option<&str>

<link id> delivered|queued for the newest chain wake.

Source

pub fn take_wake_route(&mut self) -> Option<String>

Self::wake_route, cleared, so a listener prints it once.

Source

pub fn has_routine(&self) -> bool

Whether this store has a routine to wake (URL set).

Source

pub fn wake_note(&self) -> Option<&str>

Last wake failure that did not drop the room text. None if the last attempt worked or nothing has been attempted. The bearer and the plaintext are not included.

Source

pub fn wake_log(&self) -> &[WakeAttempt]

Routine POSTs this store attempted since open, oldest first. Holds the event id and the HTTP status only: no URL, key, or body.

Source

pub fn dispatch( &mut self, command: MessengerCommand, now_ms: i64, ) -> Result<(), ShellError>

Queues command on the engine. It does not perform HTTP; Self::drive does that for whatever the engine then releases.

Source

pub fn send_room_message( &mut self, room_id: &str, text: &str, now_ms: i64, ) -> Result<Vec<OutgoingRequest>, ShellError>

Queues MessengerCommand::SendMessage and releases whatever the engine will send next. That is a room send on an unencrypted room, or the key-setup requests the engine emits first when the room is encrypted. Nothing here calls the old mailbox. The returned requests are already in flight; a caller that wants them performed uses Self::drive instead of this method.

Source

pub fn drive( &mut self, now_ms: i64, wait_for_sync: bool, ) -> Result<(), ShellError>

Performs every released request against base_url.

/sync with timeout=0 is always waited on. A long-poll /sync is started immediately and joined only when wait_for_sync is set, and at most once per call, so an idle 30s poll does not run back to back while key-setup requests are still in flight. The long-poll that is left on the wire is the engine’s own request, including its timeout. A homeserver that wakes that poll (this server does) delivers the event without the shell polling twice.

Source

pub fn rooms(&self) -> Vec<RoomView>

Rooms this account has state for.

Source

pub fn texts(&self) -> Vec<TextView>

Text-like timeline rows. Encrypted payloads that have not decrypted are reported as undecryptable without their ciphertext.

Source

pub fn sync_inflight(&self) -> bool

HTTP status codes this store has seen, oldest first. Bodies are not kept.

Source

pub fn http_trace(&self) -> Vec<String>

Source

pub fn take_ingest_error(&mut self) -> Option<String>

The last response this core failed to ingest, once.

Source

pub fn take_security_alerts(&mut self) -> Vec<String>

Drains peer key-change alerts (M3).

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> JsonCastable<CanonicalJsonValue> for T

Source§

impl<T> JsonCastable<Value> for T

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more