Skip to main content

MachineClient

Struct MachineClient 

Source
pub struct MachineClient { /* private fields */ }

Implementations§

Source§

impl MachineClient

Source

pub fn open( homeserver_url: &str, store_root: &Path, sessions: Vec<HostSession>, ) -> Result<Self, ShellError>

Registers sessions and opens each sealed store under store_root.

The host built sessions. This does not look for bot processes. The first drive publishes public keys to the homeserver and mirrors them onto the in-process bus. A long-poll left by that drive is dropped so it is not a second sync loop.

Source

pub fn open_session_dir( homeserver_url: &str, store_root: &Path, sessions_dir: &Path, ) -> Result<Self, ShellError>

load_session_records then Self::open. Records have no bearer and no routine URL; those stay unset.

Source

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

Web machine client open path.

HOMESERVER_URL_ENV, STORE_ROOT_ENV. Discovery uses AGENTS_DIR_ENV only when it names a directory; otherwise SESSIONS_DIR_ENV. The home Grok Bot directory is not a default. A webhook routine is read only when [GATEWAY_FILE_ENV] is set. The token is the file’s token, or [GATEWAY_TOKEN_ENV] when the host injected one. A missing file leaves routines unset and does not fail this open. URLs and keys are not written back. crate::LEADER_SOCK_ENV is not read.

Source

pub fn from_env_for(nick: &str) -> Result<Self, ShellError>

Self::from_env with only the session whose nick is nick: the path m4a-send takes when no client is running. Does not listen for sends.

Source

pub fn poll_agent_directory(&mut self) -> Result<Vec<RoutineReport>, ShellError>

Rescans the agents directory when this client was opened from one.

For every bot not skipped and not ready yet: ensures the local mirror and asks for the credential again. A bot that just created its own routine turns ready here; when that bot has an open session, its wake is set in place and saved to the keychain file. A bot that appeared after open gets its mirror now; its sealed store opens with the next process. When AGENT_RESCAN_SECS_ENV is set and greater than zero, returns without scanning until that many seconds have passed since the last poll. Reports carry no URL and no key.

Source

pub fn error_streak(&self) -> u32

Consecutive failed ticks seen so far (zero after a clean one); the daemon backs off on it.

Source

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

Agent ids of open sessions that still have no wake.

Source

pub fn set_local_delivery(&mut self, enabled: bool)

While enabled, drive does not call the homeserver. Requests are answered by the in-process bus. Turn this on for an exchange whose peer is a session Self::open holds, and off again before reaching a session that exists only on the homeserver.

A public channel is not given a separate transport: with this off, create and send use the homeserver, which is what a public channel and a group with a remote member already do. An encrypted direct room between two local sessions uses the bus while this is on, and the room stays encrypted.

Source

pub fn homeserver_hits(&self) -> u64

Homeserver calls counted across every session since Self::open. In-process bus calls are not included. Registration before the first drive is not included either.

Source

pub fn session_mut( &mut self, name_or_nick: &str, ) -> Result<&mut OpenedStore, ShellError>

The open session whose nick matches name_or_nick.

Source

pub fn store_dir(&self, name_or_nick: &str) -> Result<PathBuf, ShellError>

Sealed directory for that nick.

Source

pub fn deliver_pushed(&mut self) -> usize

Hands pushed room text to the session named by recipient. Another session on this client does not receive it. This does not start /sync and it does not post a routine.

Source

pub fn tick(&mut self, now_ms: i64, full_drive_secs: u64) -> TickReport

One step of the long-running client loop.

Drains the push socket and hands each pushed event to its session, then drives exactly those sessions (waiting for the /sync the push announced), which decrypts the text and POSTs the wake to that session’s own routine. Every full_drive_secs it also drives every session once, which is how DM invites get joined (OpenedStore::accept_direct_invites) and how a missed push is caught up. Errors are returned per session, without secrets.

Source

pub fn listen_for_sends(&mut self, path: &Path) -> Result<(), ShellError>

Listens on path for m4a-send requests (one JSON line each, see crate::SendRequest). A stale socket file is replaced; a live listener is refused. Unix is mode 0600. Windows is loopback TCP and the file holds 127.0.0.1:{port}. The file is removed when the client drops. Self::tick answers requests: the as session opens (or reuses) the encrypted DM with to, waits up to two minutes for to to join, and sends.

Source

pub fn listen_for_sends_from_env(&mut self) -> Result<PathBuf, ShellError>

Self::listen_for_sends on crate::SEND_SOCK_ENV, or crate::DEFAULT_SOCK_NAME under the store root. Returns the path.

Source

pub fn send_blocking( &mut self, as_nick: &str, to: &str, text: &str, wait: Duration, ) -> SendReply

Sends text from session as_nick to to in their encrypted DM, driving until to has joined (up to wait). The direct path of m4a-send when no client is running.

Source

pub fn wake_log(&self) -> Vec<(String, WakeAttempt)>

Every routine POST attempted by every session, as (nick, attempt). Event ids and HTTP statuses only.

Source

pub fn holds(&self, name_or_nick: &str) -> bool

Whether name_or_nick is a session this client holds.

Trait Implementations§

Source§

impl Drop for MachineClient

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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