Skip to main content

AppState

Struct AppState 

Source
pub struct AppState {
    pub llm_activity: LlmActivityTracker,
    /* private fields */
}
Expand description

Global application state

Fields§

§llm_activity: LlmActivityTracker

Implementations§

Source§

impl AppState

Source

pub fn new() -> Self

Create a new application state

Source

pub fn new_with_options( include_disabled_protocols: bool, ollama_url: String, ) -> Self

Create a new application state with options

Source

pub async fn get_mode(&self) -> Mode

Get the current mode

Source

pub async fn set_mode(&self, mode: Mode)

Set the mode

Source

pub async fn add_server(&self, server: ServerInstance) -> ServerId

Add a new server instance and return its ID

Source

pub async fn remove_server(&self, id: ServerId) -> Option<ServerInstance>

Remove a server instance, aborting its background tasks and cancelling the scheduled tasks scoped to it.

The cleanup is done here rather than left to callers: MCP’s stop_server and stop_all did the removal without it, so every server- and connection-scoped scheduled task survived its server and kept firing on its interval.

Source

pub async fn add_pipe( &self, from: ServerId, on: String, to: ServerId, as_action: String, map: BTreeMap<String, String>, ) -> Result<PipeId>

Declare a pipe: forward from’s on events into to as as_action, rendering map templates against the event data.

Fails cleanly if either endpoint does not exist, or if the edge would close a cycle among existing pipes (including the self-loop from == to).

Source

pub async fn remove_pipe(&self, id: PipeId) -> Option<PipeSpec>

Remove a pipe by id, returning it if present.

Source

pub async fn list_pipes(&self) -> Vec<PipeSpec>

All declared pipes (cloned).

Source

pub async fn pipes_matching( &self, from: ServerId, event_id: &str, ) -> Vec<PipeSpec>

Pipes whose source is from and that tap event_id.

Source

pub fn register_server_task( &self, id: ServerId, handle: JoinHandle<()>, ) -> impl Future<Output = ()> + Send + '_

Register a background task owned by a server so it can be aborted on stop.

Protocol spawn implementations call this with the JoinHandle of every long-lived task they spawn — accept loop, datagram reader, interface reader — right after spawning it. Handles ACCUMULATE: registering a second task no longer discards the first, so a protocol with two loops gets both aborted.

Finished handles are pruned on each registration so a protocol that registers a task per connection cannot grow the vector without bound.

If the server was already removed (raced with stop), the task is aborted immediately to avoid leaking the listener. Cancellation, including dropping the returned future before its first poll, aborts the child until ownership has transferred into the registry.

Source

pub async fn spawn_server_task<F>(&self, id: ServerId, future: F) -> AbortHandle
where F: Future<Output = ()> + Send + 'static,

Spawn a task the server owns and register it, in one call.

Prefer this over tokio::spawn + register_server_task for per-connection tasks. A measurement on 15 September 2026 found 301 tokio::spawn calls across src/server/*/mod.rs against 159 register_server_task calls, in 102 protocols — and the unregistered ones are almost entirely the per-connection tasks, because the accept loop is the handle a protocol remembers to register and the connection it just accepted is the one it forgets. The consequence is the one the root CLAUDE.md records: stop_server releases the listening socket and in-flight connections keep running, still answering, still costing LLM budget, on a server the operator has stopped.

Two properties make this safe to call per connection, both inherited from Self::register_server_task: finished handles are pruned on every registration, so the vector cannot grow without bound however many connections arrive; and a task spawned against an already-removed server is aborted immediately rather than leaking past its owner, which closes the accept-then-stop race.

Returns an tokio::task::AbortHandle for the rare caller that needs to cancel the task itself before the server stops; most callers discard it.

Source

pub async fn spawn_client_task<F>(&self, id: ClientId, future: F) -> AbortHandle
where F: Future<Output = ()> + Send + 'static,

The client-side twin of Self::spawn_server_task. Same reasoning: a client that spawns a task per request should not have to remember two calls.

Source

pub async fn register_server_handle<T: Any + Send + Sync>( &self, id: ServerId, handle: Arc<T>, )

Register a handle to the running instance of a server, so protocol actions can reach its live state.

A protocol’s spawn() calls this with whatever type carries its live state — typically a struct of mpsc::Senders and shared views. The type is erased here so AppState never learns any protocol’s types; the protocol recovers it with Self::server_handle.

Registering against an already-removed server is a no-op: the handle is dropped rather than resurrecting an entry for a server that is gone.

§Reaching this from an action

Async actions are dispatched through Server::execute_action() on the stateless protocol struct, which is why they can only return NoAction today. Making this registry reachable needs one change in src/llm/actions/, both parts mechanical:

ⓘ
// src/llm/actions/protocol_trait.rs, in `trait Server`:
fn execute_action_with_state(
    &self,
    action: serde_json::Value,
    state: AppState,                       // cheap: AppState is an Arc
    server_id: Option<crate::state::ServerId>,
) -> std::pin::Pin<
    Box<dyn std::future::Future<Output = anyhow::Result<ActionResult>> + Send + '_>,
> {
    // Default keeps every existing protocol working untouched.
    let _ = (state, server_id);
    let result = self.execute_action(action);
    Box::pin(async move { result })
}

// src/llm/actions/executor.rs, replacing the `proto.execute_action(...)` call:
match proto
    .execute_action_with_state(action.clone(), state.clone(), server_id)
    .await
{ /* unchanged */ }

A protocol that needs live state then overrides execute_action_with_state, calls state.server_handle::<MyHandle>(server_id?), and talks to its own running server. Nothing about the stateless path changes.

Source

pub async fn server_handle<T: Any + Send + Sync>( &self, id: ServerId, ) -> Option<Arc<T>>

Look up the live-instance handle of a server, downcast to the protocol’s own handle type.

Returns None if the server is gone, never registered a handle, or registered one of a different type — a protocol asking for someone else’s handle gets a miss, not a panic.

Source

pub async fn has_server_handle(&self, id: ServerId) -> bool

Whether a server has registered a live-instance handle

Source

pub async fn park_intercept( &self, owner: InterceptOwner, connection_id: Option<u32>, event_type: &str, description: &str, event_data: Option<Value>, timeout_secs: u64, ) -> (u64, Receiver<Vec<Value>>)

Park an event for a human to answer. Returns the intercept id and the receiver the dispatcher must await (under its own timeout).

Source

pub async fn list_intercepts(&self) -> Vec<InterceptView>

Pending intercepts, oldest first, with dead entries pruned.

Source

pub async fn resolve_intercept( &self, id: u64, actions: Vec<Value>, ) -> Result<(), String>

Answer a parked event with the operator’s actions.

Errors if the intercept is gone — already answered, dismissed, or the waiting dispatcher gave up (timeout / connection closed). The answer is then NOT delivered anywhere; the peer has already received the fail-closed reply.

Source

pub async fn dismiss_intercept(&self, id: u64) -> bool

Refuse a parked event: the dispatcher sees “no answer” immediately and takes the fail-closed path instead of waiting out its timeout.

Source

pub async fn remove_intercept(&self, id: u64)

Drop a parked entry without answering (the dispatcher cleans up after its own timeout so the list never shows a question nobody is waiting on).

Source

pub async fn register_peer_handle( &self, server_id: ServerId, connection_id: u32, handle: ClientHandle, )

Register a command channel into one connection of a server. Only protocols that adopted peer messaging call this; the dashboard offers “message this peer” exactly where a handle exists.

Source

pub async fn has_peer_handle( &self, server_id: ServerId, connection_id: u32, ) -> bool

Whether a connection accepts injected actions.

Source

pub async fn remove_peer_handle(&self, server_id: ServerId, connection_id: u32)

Drop a connection’s command handle (the owning loop does this when the connection closes).

Source

pub fn register_peer_task( &self, server_id: ServerId, connection_id: u32, handle: JoinHandle<()>, ) -> impl Future<Output = ()> + Send + '_

Track a peer worker under its connection. A close racing registration aborts it immediately; registration never revives a removed handle.

Source

pub async fn send_to_peer( &self, server_id: ServerId, connection_id: u32, action: Value, timeout: Duration, ) -> Result<ClientSendOutcome>

Execute one action inside a server connection’s own task and wait for the outcome. Same lock discipline as send_to_client: clone the handle out, drop the guard, then await.

Source

pub async fn register_client_handle(&self, id: ClientId, handle: ClientHandle)

Register the command channel for a running client. No-op if the client row is already gone (raced with stop_client) — the caller’s receiver is then the only reference and sends fail cleanly.

Source

pub async fn client_handle(&self, id: ClientId) -> Option<ClientHandle>

The command handle for a client, if its loop registered one.

Source

pub async fn has_client_handle(&self, id: ClientId) -> bool

Whether a running client accepts injected commands. The UI uses this to grey out [send] for clients that have not adopted the channel.

Source

pub async fn remove_client_handle(&self, id: ClientId)

Drop a client’s command handle (called by the loop on exit; also done by remove_client).

Source

pub async fn send_to_client( &self, id: ClientId, action: Value, timeout: Duration, ) -> Result<ClientSendOutcome>

Execute one action inside a running client’s connection loop and wait for the outcome.

Lock discipline: the handle is cloned out under the read guard and the guard dropped before any await on the channel.

Source

pub async fn server_task_count(&self, id: ServerId) -> usize

Number of background tasks currently tracked for a server

Source

pub async fn get_server(&self, id: ServerId) -> Option<ServerInstance>

Get a server instance (cloned)

Source

pub async fn get_all_server_ids(&self) -> Vec<ServerId>

Get all server IDs

Source

pub async fn get_all_servers(&self) -> Vec<ServerInstance>

Get all servers (cloned)

Source

pub async fn update_server_status(&self, id: ServerId, status: ServerStatus)

Update server status

Source

pub async fn update_server_local_addr( &self, id: ServerId, local_addr: SocketAddr, )

Update server local listening address

Source

pub async fn get_instruction(&self, server_id: ServerId) -> Option<String>

Get instruction for a specific server

Source

pub async fn set_instruction(&self, server_id: ServerId, instruction: String)

Set instruction for a specific server

Source

pub async fn get_memory(&self, server_id: ServerId) -> Option<String>

Get memory for a specific server

Source

pub async fn set_memory(&self, server_id: ServerId, memory: String)

Set memory for a specific server

Source

pub async fn append_memory(&self, server_id: ServerId, text: String)

Append to memory for a specific server

Source

pub async fn add_server_feedback( &self, server_id: ServerId, feedback: Value, ) -> Result<()>

Add feedback to a server’s feedback buffer

Feedback is accumulated and processed later via debounced LLM invocation Returns Ok if feedback was added, Err if server not found or feedback_instructions not set

Source

pub async fn take_due_feedback(&self, debounce: Duration) -> Vec<DueFeedback>

Take the feedback that is due for processing, emptying those buffers.

Leading-edge debounce: an instance is due as soon as it has any buffered feedback and debounce has elapsed since its last processing (so the first feedback after a quiet period is acted on at the next tick, and a burst is coalesced into one call). last_feedback_processed is stamped here rather than after the LLM answers, so a slow or failing call cannot re-trigger itself on every tick.

Draining here — under the same write lock that stamps the timestamp — is what makes the caller safe to run from a 1s timer: two ticks can never take the same entries.

Source

pub async fn add_client_feedback( &self, client_id: ClientId, feedback: Value, ) -> Result<()>

Add feedback to a client’s feedback buffer

Feedback is accumulated and processed later via debounced LLM invocation Returns Ok if feedback was added, Err if client not found or feedback_instructions not set

Source

pub fn get_first_server_id_sync(&self) -> Option<ServerId>

Get first server ID (synchronous version for use in non-async contexts)

This is a non-blocking helper that attempts to get the first server ID Returns None if unable to acquire lock or no servers exist

Source

pub async fn get_ollama_model(&self) -> Option<String>

Get the Ollama model name

Source

pub async fn set_ollama_model(&self, model: Option<String>)

Set the Ollama model name

Source

pub async fn get_scripting_env(&self) -> ScriptingEnvironment

Get the scripting environment information

Source

pub async fn set_scripting_env(&self, env: ScriptingEnvironment)

Set scripting environment

This is primarily used for testing to inject a mock environment. In production, the environment is auto-detected at startup.

Source

pub async fn get_selected_scripting_mode(&self) -> ScriptingMode

Get the currently selected scripting mode

Source

pub async fn set_selected_scripting_mode(&self, mode: ScriptingMode)

Set the selected scripting mode

Source

pub async fn cycle_scripting_mode(&self) -> (ScriptingMode, bool)

Cycle between ON and OFF scripting modes Returns the new mode and whether any switch occurred

Source

pub async fn is_server_docs_read(&self) -> bool

Check if server documentation has been read (enables open_server)

Source

pub async fn is_client_docs_read(&self) -> bool

Check if client documentation has been read (enables open_client)

Source

pub async fn mark_server_protocols_documented(&self, protocols: &[String])

Mark server protocols as documented

Source

pub async fn mark_client_protocols_documented(&self, protocols: &[String])

Mark client protocols as documented

Source

pub async fn get_documented_server_protocols(&self) -> HashSet<String>

Get all documented server protocols

Source

pub async fn get_documented_client_protocols(&self) -> HashSet<String>

Get all documented client protocols

Source

pub async fn get_event_handler_mode(&self) -> EventHandlerMode

Get the currently selected event handler mode

Source

pub async fn set_event_handler_mode(&self, mode: EventHandlerMode)

Set the event handler mode

Source

pub async fn cycle_event_handler_mode(&self) -> EventHandlerMode

Cycle event handler mode through ANY -> SCRIPT -> STATIC -> LLM -> ANY Returns the new mode

Source

pub async fn get_web_search_mode(&self) -> WebSearchMode

Get the current web search mode

Source

pub async fn set_web_search_mode(&self, mode: WebSearchMode)

Set the web search mode

Source

pub async fn cycle_web_search_mode(&self) -> WebSearchMode

Cycle web search mode through ON -> ASK -> OFF -> ON and return the new state

Source

pub async fn set_web_approval_channel( &self, tx: UnboundedSender<WebApprovalRequest>, )

Set the web approval channel (called by TUI on startup)

Source

pub async fn get_web_approval_channel( &self, ) -> Option<UnboundedSender<WebApprovalRequest>>

Get a clone of the web approval channel

Source

pub async fn get_include_disabled_protocols(&self) -> bool

Get whether disabled protocols should be included

Source

pub async fn get_min_stability(&self) -> Option<DevelopmentState>

Get the minimum stability required to start a protocol, if any (None = no gate).

Source

pub async fn set_min_stability(&self, min: Option<DevelopmentState>)

Set the minimum stability required to start a protocol (from --min-stability). None disables the gate.

Source

pub async fn get_ollama_url(&self) -> String

Get the Ollama API base URL

Source

pub async fn set_llm_client(&self, client: OllamaClient)

Set the configured LLM client

Source

pub async fn get_llm_client(&self) -> Option<OllamaClient>

Get the configured LLM client

Source

pub async fn get_rate_limiter(&self) -> RateLimiter

Get the rate limiter

Source

pub async fn configure_rate_limiter( &self, config: RateLimiterConfig, ) -> Result<()>

Configure the rate limiter

Source

pub async fn get_instance_id(&self) -> String

Get the unique instance ID for this NetGet process

Source

pub async fn get_system_capabilities(&self) -> SystemCapabilities

Get system capabilities detected at startup

Source

pub async fn get_next_unified_id(&self) -> u32

Get the next unified ID (for connections) This ensures all IDs (servers, connections, clients) are unique across all types

Source

pub async fn set_event_handler_config( &self, server_id: ServerId, config: Option<EventHandlerConfig>, )

Update event handler configuration for a server

Source

pub async fn get_event_handler_config( &self, server_id: ServerId, ) -> Option<EventHandlerConfig>

Get event handler configuration for a server

Source

pub async fn get_summary(&self) -> String

Get a summary of current state for LLM context

Source

pub async fn get_protocol_name(&self, server_id: ServerId) -> Option<String>

Get protocol name for a server

Source

pub async fn cleanup_old_connections(&self, max_age_secs: u64)

Reap idle bookkeeping entries on connectionless servers (UDP, raw IP, link-level): their “connections” are per-remote-address records that nothing ever closes, so staleness is the only signal.

Connection-oriented servers are skipped on purpose. This used to run over every server, and an idle TCP-style connection — a telnet peer whose line was parked ten seconds for a human’s manual answer, a BGP session between keepalives — was evicted from the state map and shown as (closed) while its socket was alive; every later stat update and the real close then targeted an entry that was already gone. Which servers qualify comes from ProtocolMetadataV2::connectionless, so a protocol the registry does not know is left alone.

Source

pub async fn cleanup_closed_connections(&self, max_age_secs: u64)

Cleanup old closed connections (removes connections that have been closed for more than max_age_secs)

Source

pub async fn cleanup_old_servers(&self, max_age_secs: u64)

Cleanup old stopped/error servers (removes servers that have been stopped/error for more than max_age_secs)

Reaping a server here runs the same teardown as Self::remove_server: background tasks aborted, scoped scheduled tasks cancelled. It previously dropped the map entry alone, which detached (rather than aborted) whatever the server was still running and left its scheduled tasks firing.

Must be driven by some loop or it never runs. The TUI ticks it; MCP mode has its own reaper (mcp_stdio::tools::spawn_state_reaper), without which an LLM-initiated close_server left entries in AppState forever.

Source

pub async fn add_connection_to_server( &self, server_id: ServerId, connection: ConnectionState, )

Add a connection to a specific server

Source

pub async fn close_connection_on_server( &self, server_id: ServerId, connection_id: ConnectionId, )

Mark a connection as closed (instead of removing it immediately)

Source

pub async fn remove_connection_from_server( &self, server_id: ServerId, connection_id: ConnectionId, )

Remove a connection from a specific server (used by cleanup task)

Source

pub async fn get_recent_connections( &self, server_id: ServerId, ) -> Vec<ClosedConnectionSummary>

Recently closed connections for a server, newest first. Empty when the server does not exist.

Source

pub async fn get_proxy_filter_config( &self, server_id: ServerId, ) -> Option<ProxyFilterConfig>

Get proxy filter configuration for a server

Source

pub async fn set_proxy_filter_config( &self, server_id: ServerId, config: ProxyFilterConfig, )

Set proxy filter configuration for a server

Source

pub async fn update_proxy_filter_config( &self, server_id: ServerId, update_fn: impl FnOnce(&mut ProxyFilterConfig), )

Update proxy filter configuration by merging with existing config

Source

pub async fn get_socks5_filter_config( &self, server_id: ServerId, ) -> Option<Socks5FilterConfig>

Get SOCKS5 filter configuration for a server

Source

pub async fn set_socks5_filter_config( &self, server_id: ServerId, config: Socks5FilterConfig, )

Set SOCKS5 filter configuration for a server

Source

pub async fn update_socks5_target( &self, server_id: ServerId, connection_id: ConnectionId, target_addr: Option<String>, username: Option<String>, )

Update SOCKS5 connection target address

Source

pub async fn update_imap_session_state( &self, server_id: ServerId, connection_id: ConnectionId, session_state: ImapSessionState, )

Update IMAP connection session state

Source

pub async fn update_imap_connection_state( &self, server_id: ServerId, connection_id: ConnectionId, session_state: Option<ImapSessionState>, authenticated_user: Option<Option<String>>, selected_mailbox: Option<Option<String>>, mailbox_read_only: Option<bool>, )

Update IMAP connection full state (session, user, mailbox)

Source

pub async fn get_imap_connection_state( &self, server_id: ServerId, connection_id: ConnectionId, ) -> Option<(ImapSessionState, Option<String>, Option<String>)>

Get IMAP connection state

Source

pub async fn update_imap_protocol_state( &self, server_id: ServerId, connection_id: ConnectionId, protocol_state: ProtocolState, )

Update IMAP protocol state (Idle/Processing/Accumulating)

Source

pub async fn update_connection_stats( &self, server_id: ServerId, connection_id: ConnectionId, bytes_received: Option<u64>, bytes_sent: Option<u64>, packets_received: Option<u64>, packets_sent: Option<u64>, )

Update connection stats (bytes/packets)

Source

pub async fn update_connection_status( &self, server_id: ServerId, connection_id: ConnectionId, status: ConnectionStatus, )

Update connection status

Source

pub async fn update_vnc_connection_auth( &self, server_id: ServerId, connection_id: ConnectionId, authenticated: bool, username: Option<String>, )

Update VNC connection authentication status

Source

pub async fn update_bitcoin_connection_info( &self, server_id: ServerId, connection_id: ConnectionId, last_message_type: String, )

Update Bitcoin connection info

Source

pub async fn update_tftp_connection_block( &self, server_id: ServerId, connection_id: ConnectionId, block_number: u16, block_bytes: usize, )

Update TFTP connection block number and total bytes

Source

pub async fn get_vnc_write_half( &self, _connection_id: ConnectionId, ) -> Option<Arc<Mutex<WriteHalf<TcpStream>>>>

Get VNC write half for sending framebuffer updates

Note: This method is deprecated. Write halves are now managed locally within protocol modules and not stored in centralized state.

Source

pub async fn add_client(&self, client: ClientInstance) -> ClientId

Add a new client instance and return its ID

Source

pub async fn disconnect_client(&self, id: ClientId) -> bool

Remove a client instance, aborting every background task it owns.

Dropping a JoinHandle only DETACHES the task in Tokio — it keeps running, keeps its socket open and keeps calling the LLM. Every handle registered via Self::register_client_task is therefore aborted explicitly here, which is what makes stop_client actually stop a client rather than just forgetting it. Disconnect a client but KEEP its row, so it can be reconnected later.

Aborts the connection tasks (which closes the socket), drops the command handle, and marks the client Disconnected. Scheduled tasks and configuration survive — this is “hang up”, not “remove”.

Source

pub async fn remove_client(&self, id: ClientId) -> Option<ClientInstance>

Source

pub fn register_client_task( &self, id: ClientId, handle: JoinHandle<()>, ) -> impl Future<Output = ()> + Send + '_

Register a background task owned by a client so it can be aborted on stop.

Client connect() implementations call this with the JoinHandle of every task they spawn — read loop, transport driver, in-flight request — right after spawning it. Like register_server_task, handles accumulate: a client that spawns three tasks gets all three aborted, none silently dropped.

If the client is already gone (raced with stop_client), the task is aborted on the spot so it cannot outlive its owner. Dropping its future, even before polling or while waiting for the state lock, aborts the child until the registry has taken ownership.

Source

pub async fn client_task_count(&self, id: ClientId) -> usize

Number of background tasks currently tracked for a client

Source

pub async fn try_consume_client_llm_call( &self, id: ClientId, ) -> Result<u32, String>

Consume one LLM call from a client’s budget.

Returns Ok(calls_used) while the client is under its cap, and Err(message) once the cap is reached. Clients hand-roll their own event loops and at least one of them (DNS) could re-enter the LLM path indefinitely; an unbounded loop burns real money against a paid endpoint, so the budget is a hard stop rather than a warning.

The limit is per client session (not per event) and is configurable via Self::set_client_llm_call_limit or NETGET_CLIENT_LLM_CALL_LIMIT (0 disables the cap entirely).

Source

pub async fn get_client_llm_calls(&self, id: ClientId) -> u32

Number of LLM calls a client has consumed so far

Source

pub async fn get_client_llm_call_limit(&self) -> u32

Get the per-client LLM call cap (0 = unlimited)

Source

pub async fn set_client_llm_call_limit(&self, limit: u32)

Set the per-client LLM call cap (0 = unlimited)

Source

pub async fn get_client(&self, id: ClientId) -> Option<ClientInstance>

Get a client instance (cloned)

Source

pub async fn get_all_client_ids(&self) -> Vec<ClientId>

Get all client IDs

Source

pub async fn get_all_clients(&self) -> Vec<ClientInstance>

Get all clients (cloned)

Source

pub async fn update_client_status(&self, id: ClientId, status: ClientStatus)

Update client status

Source

pub async fn get_instruction_for_client( &self, client_id: ClientId, ) -> Option<String>

Get instruction for a specific client

Source

pub async fn set_instruction_for_client( &self, client_id: ClientId, instruction: String, )

Set instruction for a specific client

Source

pub async fn get_memory_for_client(&self, client_id: ClientId) -> Option<String>

Get memory for a specific client

Source

pub async fn set_memory_for_client(&self, client_id: ClientId, memory: String)

Set memory for a specific client

Source

pub async fn append_memory_for_client(&self, client_id: ClientId, text: String)

Append to memory for a specific client

Source

pub async fn get_protocol_name_for_client( &self, client_id: ClientId, ) -> Option<String>

Get protocol name for a client

Source

pub async fn with_client_mut<F, R>( &self, client_id: ClientId, f: F, ) -> Option<R>
where F: FnOnce(&mut ClientInstance) -> R,

Execute a closure with mutable access to a client

Source

pub async fn set_client_event_handler_config( &self, client_id: ClientId, config: Option<EventHandlerConfig>, )

Update event handler configuration for a client

Source

pub async fn get_client_event_handler_config( &self, client_id: ClientId, ) -> Option<EventHandlerConfig>

Get event handler configuration for a client

Source

pub async fn cleanup_old_clients(&self, max_age_secs: u64)

Cleanup old disconnected clients (removes clients that have been disconnected for more than max_age_secs)

Source

pub async fn add_easy_instance(&self, easy_instance: EasyInstance) -> EasyId

Add a new easy protocol instance

Source

pub async fn remove_easy_instance(&self, id: EasyId) -> Option<EasyInstance>

Remove an easy protocol instance

Link an underlying server to an easy protocol instance (for event routing)

Link an underlying client to an easy protocol instance (for event routing)

Source

pub async fn get_easy_for_server(&self, server_id: ServerId) -> Option<EasyId>

Get easy ID for a given server ID (returns None if server is not managed by an easy protocol)

Source

pub async fn get_easy_for_client(&self, client_id: ClientId) -> Option<EasyId>

Get easy ID for a given client ID (returns None if client is not managed by an easy protocol)

Source

pub async fn get_easy_instance(&self, id: EasyId) -> Option<EasyInstance>

Get easy protocol instance

Source

pub async fn update_easy_status(&self, id: EasyId, status: EasyStatus)

Update easy protocol status

Source

pub async fn get_all_easy_instances(&self) -> Vec<EasyInstance>

Get all easy protocol instances

Source

pub async fn with_easy_mut<F, R>(&self, easy_id: EasyId, f: F) -> Option<R>
where F: FnOnce(&mut EasyInstance) -> R,

Execute a closure with mutable access to an easy instance

Source

pub async fn get_port(&self) -> Option<u16>

Get the first server’s port (for backwards compat)

Source

pub async fn get_first_protocol_name(&self) -> Option<String>

Get the first server’s protocol name (for backwards compat)

Source

pub async fn get_first_instruction(&self) -> String

Get the first server’s instruction (for backwards compat)

Source

pub async fn get_first_memory(&self) -> String

Get the first server’s memory (for backwards compat)

Source

pub async fn get_first_server_id(&self) -> Option<ServerId>

Get the first server’s ID (for backwards compat)

Source

pub async fn get_first_client_id(&self) -> Option<ClientId>

Get the first client’s ID (for backwards compat)

Source

pub async fn get_local_addr(&self) -> Option<SocketAddr>

Get local address of first server (for backwards compat)

Source

pub async fn with_server_mut<F, R>( &self, server_id: ServerId, f: F, ) -> Option<R>
where F: FnOnce(&mut ServerInstance) -> R,

Execute a closure with mutable access to a server

Source

pub async fn add_task(&self, task: ScheduledTask) -> TaskId

Add a new scheduled task

Source

pub async fn get_task(&self, id_or_name: &str) -> Option<ScheduledTask>

Get a task by ID or name

Source

pub async fn remove_task(&self, id: TaskId) -> Option<ScheduledTask>

Remove a task

Source

pub async fn spawn_scheduled_task<F>(&self, id: TaskId, future: F) -> bool
where F: Future<Output = ()> + Send + 'static,

Start a claimed task while holding its ownership lock. Removal cannot race between spawn and registration; a previously removed claim is skipped.

Source

pub async fn get_all_tasks(&self) -> Vec<ScheduledTask>

Get all tasks

Source

pub async fn claim_due_tasks(&self) -> Vec<ScheduledTask>

Atomically claim scheduled tasks whose deadline has arrived.

A separate snapshot and status update lets concurrent timer ticks both execute the same task. Mark each task while holding the selection lock.

Source

pub async fn get_server_tasks(&self, server_id: ServerId) -> Vec<ScheduledTask>

Get tasks for a specific server

Source

pub async fn get_connection_tasks( &self, server_id: ServerId, connection_id: ConnectionId, ) -> Vec<ScheduledTask>

Get tasks for a specific connection

Source

pub async fn update_task_status(&self, id: TaskId, status: TaskStatus)

Update task status

Source

pub async fn update_task_next_execution(&self, id: TaskId, next: Instant)

Update task next execution time

Source

pub async fn record_task_execution( &self, id: TaskId, result: &TaskExecutionResult, )

Record task execution result

Source

pub async fn cleanup_server_tasks(&self, server_id: ServerId)

Clean up the scheduled tasks associated with a server.

Both server-scoped tasks and the connection-scoped tasks of that server’s connections are removed: a connection cannot outlive its server, so leaving its tasks behind leaves them firing against a server that no longer exists.

Callers rarely need this — Self::remove_server and Self::cleanup_old_servers already do it. It stays public for the TUI, which marks a server Stopped and leaves the entry in place for the reaper.

Source

pub async fn cleanup_connection_tasks( &self, server_id: ServerId, connection_id: ConnectionId, )

Clean up tasks associated with a connection

Source

pub async fn cleanup_client_tasks(&self, client_id: ClientId)

Clean up tasks associated with a client

Source

pub async fn register_conversation( &self, id: String, source: ConversationSource, details: String, )

Register a new conversation

Source

pub async fn end_conversation(&self, id: &str)

Mark a conversation as ended

Source

pub async fn get_active_conversations(&self) -> Vec<ConversationInfo>

Get all active conversations and recently-completed ones (within 1 second)

Source

pub async fn get_input_conversations(&self) -> Vec<ConversationInfo>

Get conversations for the “Running” column (User + Global tasks)

Source

pub async fn cleanup_old_conversations(&self)

Clean up old completed conversations (older than 1 second)

Source

pub async fn get_or_create_user_conversation_state( &self, ) -> Arc<Mutex<ConversationState>> ⓘ

Get or create the user conversation state

Source

pub async fn clear_user_conversation_history(&self)

Clear user conversation history

Source

pub async fn get_user_conversation_history(&self) -> Option<String>

Get formatted conversation history for prompts

Source

pub async fn record_access_log( &self, owner: AccessLogOwner, protocol: &str, connection_id: Option<u32>, event_type: &str, request: Value, response: Vec<Value>, ) -> u64

Record a request/response access-log entry (ring buffer, oldest dropped past capacity). Returns the assigned entry id.

Source

pub async fn access_log_total(&self) -> u64

How many access-log entries have ever been recorded — one per network event a server or client handled (whatever answered it: handler, model or operator), plus one per injected action. Unlike the ring buffer this never shrinks, so it is a monotonic count of handled events for the life of the process (--exit-after-events reads it).

Source

pub async fn list_access_logs( &self, limit: Option<usize>, ) -> Vec<AccessLogEntry>

Return the most recent access-log entries, newest first (up to limit). Pass None for the full retained buffer.

Source

pub async fn list_access_logs_for( &self, owner: Option<AccessLogOwner>, limit: Option<usize>, ) -> Vec<AccessLogEntry>

Return the most recent access-log entries for one instance (or all, with owner: None), newest first (up to limit).

Source

pub async fn get_access_log(&self, id: u64) -> Option<AccessLogEntry>

Look up a single access-log entry by id.

Source

pub async fn record_llm_tokens(&self, input_tokens: u64, output_tokens: u64)

Record LLM call tokens

Source

pub async fn get_llm_stats(&self) -> (u64, u64, u64)

Get LLM token statistics

Source

pub async fn reset_llm_stats(&self)

Reset LLM token statistics

Source

pub async fn create_database( &self, name: String, path: String, owner: DatabaseOwner, init_sql: Option<&str>, ) -> Result<DatabaseId>

Create a new database

Source

pub async fn execute_sql( &self, db_id: DatabaseId, sql: &str, ) -> Result<QueryResult>

Execute a SQL query on a database

Source

pub async fn get_all_databases(&self) -> Vec<DatabaseInstance>

Get all databases

Source

pub async fn get_database(&self, db_id: DatabaseId) -> Option<DatabaseInstance>

Get a database by ID

Source

pub async fn delete_database(&self, db_id: DatabaseId) -> Result<()>

Delete a database

Source

pub async fn get_databases_by_server( &self, server_id: ServerId, ) -> Vec<DatabaseInstance>

Get databases owned by a server

Source

pub async fn get_databases_by_client( &self, client_id: ClientId, ) -> Vec<DatabaseInstance>

Get databases owned by a client

Source

pub async fn cleanup_databases_for_server( &self, server_id: ServerId, ) -> Result<()>

Delete all databases owned by a server (called when server closes)

Source

pub async fn cleanup_databases_for_client( &self, client_id: ClientId, ) -> Result<()>

Delete all databases owned by a client (called when client disconnects)

Source

pub async fn add_server_with_id(&self, server: ServerInstance)

Test-only helper to add a server with a specific ID (bypasses auto-increment)

WARNING: This method is intended for testing only. In production code, use add_server() which properly assigns server IDs.

Source

pub async fn set_tor_client( &self, client_id: ClientId, tor_client: Arc<TorClient<PreferredRuntime>>, )

Store Tor client instance for directory queries

Source

pub async fn get_tor_client( &self, client_id: ClientId, ) -> Option<Arc<TorClient<PreferredRuntime>>>

Get Tor client instance by client ID

Source

pub async fn remove_tor_client(&self, client_id: ClientId)

Remove Tor client instance (called when client closes)

Trait Implementations§

Source§

impl Clone for AppState

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for AppState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<Source> AccessAs for Source

Source§

fn ref_as<T>(&self) -> <Source as IGuardRef<T>>::Guard<'_>
where Source: IGuardRef<T>, T: ?Sized,

Provides immutable access to a type as if it were its ABI-unstable equivalent.
Source§

fn mut_as<T>(&mut self) -> <Source as IGuardMut<T>>::GuardMut<'_>
where Source: IGuardMut<T>, T: ?Sized,

Provides mutable access to a type as if it were its ABI-unstable equivalent.
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> AsNode<T> for T

Source§

fn as_node(&self) -> &T

Source§

impl<T> AsNodeMut<T> for T

Source§

fn as_node_mut(&mut self) -> &mut T

Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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

Source§

fn len(&self) -> usize

The number of items that this chain link consists of.
Source§

fn append_to(self, v: &mut Vec<T>)

Append the elements in this link to the chain.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CompatExt for T

Source§

fn compat(self) -> Compat<T> ⓘ
where T: Sized,

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T> ⓘ

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T> ⓘ

Applies the Compat adapter by mutable reference. Read more
Source§

impl<T> Container<T> for T
where T: Clone,

Source§

type Iter = Once<T>

An iterator over the items within this container, by value.
Source§

fn get_iter(&self) -> <T as Container<T>>::Iter

Iterate over the elements of the container (using internal iteration because GATs are unstable).
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<Choices> CoproductSubsetter<CNil, HNil> for Choices

Source§

type Remainder = Choices

Source§

fn subset( self, ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T, As> IGuardMut<As> for T
where T: Into<As>, As: Into<T>,

Source§

type GuardMut<'a> = MutAs<'a, T, As> where T: 'a

The type of the guard which will clean up the temporary after applying its changes to the original.
Source§

fn guard_mut_inner(&mut self) -> <T as IGuardMut<As>>::GuardMut<'_>

Construct the temporary and guard it through a mutable reference.
Source§

impl<T, As> IGuardRef<As> for T
where T: Into<As>, As: Into<T>,

Source§

type Guard<'a> = RefAs<'a, T, As> where T: 'a

The type of the guard which will clean up the temporary.
Source§

fn guard_ref_inner(&self) -> <T as IGuardRef<As>>::Guard<'_>

Construct the temporary and guard it through an immutable reference.
Source§

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

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
Source§

impl<T> Includes<End> for T

Source§

type Output = End

The result
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> 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> IntoAnyArc for T
where T: Send + Sync + 'static,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Upcast to Arc<dyn Any>.
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

Source§

fn lift_into(self) -> U

Performs the indexed conversion.
Source§

impl<T> OrderedContainer<T> for T
where T: Clone,

Source§

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

Source§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
Source§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
Source§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
Source§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
Source§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling Attribute value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
Source§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
Source§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi Quirk value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
Source§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
Source§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1:

renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
Source§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the Condition value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
Source§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
Source§

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Source> Sculptor<HNil, HNil> for Source

Source§

type Remainder = Source

Source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. Read more
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
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<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<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = Result<U, <U as TryFrom<T>>::Error>> + 'async_trait>>
where T: 'async_trait,

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
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