Skip to main content

BashBuilder

Struct BashBuilder 

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

Implementations§

Source§

impl BashBuilder

Source

pub fn fs(self, fs: Arc<dyn FileSystem>) -> Self

Set a custom filesystem.

Source

pub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self

Set an environment variable.

Source

pub fn cwd(self, cwd: impl Into<PathBuf>) -> Self

Set the current working directory.

Source

pub fn limits(self, limits: ExecutionLimits) -> Self

Set execution limits.

Source

pub fn session_limits(self, limits: SessionLimits) -> Self

Set session-level resource limits.

Session limits persist across exec() calls and prevent tenants from circumventing per-execution limits by splitting work.

Source

pub fn memory_limits(self, limits: MemoryLimits) -> Self

Set per-instance memory limits.

Controls the maximum variables, arrays, and functions a Bash instance can hold. Prevents memory exhaustion in multi-tenant use.

Source

pub fn max_memory(self, bytes: usize) -> Self

Cap total interpreter memory to bytes.

Convenience wrapper over memory_limits that sets max_total_variable_bytes to bytes and clamps max_function_body_bytes to min(bytes, default). Count-based sub-limits (variable count, array entries, function count) stay at their defaults.

§Example
let bash = Bash::builder()
    .max_memory(10 * 1024 * 1024)   // 10 MB
    .build();
Source

pub fn trace_mode(self, mode: TraceMode) -> Self

Set the trace mode for structured execution tracing.

  • TraceMode::Off (default): No events, zero overhead
  • TraceMode::Redacted: Events with secrets scrubbed
  • TraceMode::Full: Raw events, no redaction
Source

pub fn on_trace_event(self, callback: TraceCallback) -> Self

Set a real-time callback for trace events.

The callback is invoked for each trace event as it occurs. Requires trace_mode to be set to Redacted or Full.

Source

pub fn username(self, username: impl Into<String>) -> Self

Set the sandbox username.

This configures whoami and id builtins to return this username, and automatically sets the USER environment variable.

Source

pub fn hostname(self, hostname: impl Into<String>) -> Self

Set the sandbox hostname.

This configures hostname and uname -n builtins to return this hostname.

Source

pub fn tty(self, fd: u32, is_terminal: bool) -> Self

Configure whether a file descriptor is reported as a terminal by [ -t fd ].

In a sandboxed VFS environment, all FDs default to non-terminal (false). Use this to simulate interactive mode for scripts that check [ -t 0 ] (stdin), [ -t 1 ] (stdout), or [ -t 2 ] (stderr).

let bash = Bash::builder()
    .tty(0, true)  // stdin is a terminal
    .tty(1, true)  // stdout is a terminal
    .build();
Source

pub fn fixed_epoch(self, epoch: i64) -> Self

Set a fixed Unix epoch for the date builtin.

THREAT[TM-INF-018]: Prevents date from leaking real host time. When set, date returns this fixed time instead of the real clock.

Source

pub fn epoch_offset(self, seconds: i64) -> Self

Apply a constant offset (in seconds) to the real system clock for the date builtin. Use this when scripts need time to advance at real-clock rate but you want to obscure the absolute wall-clock time from the sandbox (timing-correlation resistance).

THREAT[TM-INF-018]: A non-zero offset prevents date from exposing the host’s exact wall-clock time while still letting time-sensitive scripts observe elapsed-time deltas.

fixed_epoch and epoch_offset are mutually exclusive — the last builder call wins.

Source

pub fn history_file(self, path: impl Into<PathBuf>) -> Self

Enable persistent history stored at the given VFS path.

History entries are loaded from this file at startup and saved after each exec() call. The file is stored in the virtual filesystem.

Source

pub fn network(self, allowlist: NetworkAllowlist) -> Self

Configure network access for curl/wget builtins.

Network access is disabled by default. Use this method to enable HTTP requests from scripts with a URL allowlist for security.

§Security

The allowlist uses a default-deny model:

  • Only URLs matching allowlist patterns can be accessed
  • Pattern matching is literal (no DNS resolution) to prevent DNS rebinding
  • Scheme, host, port, and path prefix are all validated
§Example
use bashkit::{Bash, NetworkAllowlist};

// Allow access to specific APIs only
let allowlist = NetworkAllowlist::new()
    .allow("https://api.example.com")
    .allow("https://cdn.example.com/assets");

let bash = Bash::builder()
    .network(allowlist)
    .build();
§Warning

Using NetworkAllowlist::allow_all() is dangerous and should only be used for testing or when the script is fully trusted.

Source

pub fn http_handler(self, handler: Box<dyn HttpHandler>) -> Self

Set a custom HTTP handler for request interception.

The handler is called after the URL allowlist check, so the security boundary stays in bashkit. Use this for:

  • Corporate proxies
  • Logging/auditing
  • Caching responses
  • Rate limiting
  • Mocking HTTP responses in tests
§Example
use bashkit::network::HttpHandler;

struct MyHandler;

#[async_trait::async_trait]
impl HttpHandler for MyHandler {
    async fn request(
        &self,
        method: &str,
        url: &str,
        body: Option<&[u8]>,
        headers: &[(String, String)],
    ) -> Result<bashkit::network::Response, String> {
        Ok(bashkit::network::Response {
            status: 200,
            headers: vec![],
            body: b"mocked".to_vec(),
        })
    }
}

let bash = Bash::builder()
    .network(NetworkAllowlist::allow_all())
    .http_handler(Box::new(MyHandler))
    .build();
Source

pub fn bot_auth(self, config: BotAuthConfig) -> Self

Enable transparent request signing for all outbound HTTP requests.

When configured, every HTTP request made by curl/wget/http builtins is signed with Ed25519 per RFC 9421 / web-bot-auth profile. No CLI arguments or script changes needed — signing is fully transparent.

Signing failures are non-blocking: the request is sent unsigned.

§Example
use bashkit::{Bash, NetworkAllowlist};
use bashkit::network::BotAuthConfig;

let bash = Bash::builder()
    .network(NetworkAllowlist::new().allow("https://api.example.com"))
    .bot_auth(BotAuthConfig::from_seed([42u8; 32])
        .with_agent_fqdn("bot.example.com"))
    .build();
Source

pub fn log_config(self, config: LogConfig) -> Self

Configure logging behavior.

When the logging feature is enabled, Bashkit can emit structured logs at various levels (error, warn, info, debug, trace) during execution.

§Log Levels
  • ERROR: Unrecoverable failures, exceptions, security violations
  • WARN: Recoverable issues, limit warnings, deprecated usage
  • INFO: Session lifecycle (start/end), high-level execution flow
  • DEBUG: Command execution, variable expansion, control flow
  • TRACE: Internal parser/interpreter state, detailed data flow
§Security (TM-LOG-001)

By default, sensitive data is redacted from logs:

  • Environment variables matching secret patterns (PASSWORD, TOKEN, etc.)
  • URL credentials (user:pass@host)
  • Values that look like API keys or JWTs
§Example
use bashkit::{Bash, LogConfig};

let bash = Bash::builder()
    .log_config(LogConfig::new()
        .redact_env("MY_CUSTOM_SECRET"))
    .build();
§Warning

Do not use LogConfig::unsafe_disable_redaction() or LogConfig::unsafe_log_scripts() in production, as they may expose sensitive data in logs.

Source

pub fn git(self, config: GitConfig) -> Self

Configure git support for git commands.

Git access is disabled by default. Use this method to enable git commands with the specified configuration.

§Security
  • All operations are confined to the virtual filesystem
  • Author identity is sandboxed (configurable, never from host)
  • Remote operations (Phase 2) require URL allowlist
  • No access to host git config or credentials
§Example
use bashkit::{Bash, GitConfig};

let bash = Bash::builder()
    .git(GitConfig::new()
        .author("CI Bot", "ci@example.com"))
    .build();
§Threat Mitigations
  • TM-GIT-002: Host identity leak - uses configured author, never host
  • TM-GIT-003: Host config access - no filesystem access outside VFS
  • TM-GIT-005: Repository escape - all paths within VFS
Source

pub fn ssh(self, config: SshConfig) -> Self

Configure SSH access for ssh/scp/sftp builtins.

§Example
use bashkit::{Bash, SshConfig};

let bash = Bash::builder()
    .ssh(SshConfig::new()
        .allow("*.supabase.co")
        .default_user("root"))
    .build();
§Threat Mitigations
  • TM-SSH-001: Unauthorized host access - host allowlist (default-deny)
  • TM-SSH-002: Credential leakage - keys from VFS only
  • TM-SSH-005: Connection hang - configurable timeouts
Source

pub fn ssh_handler(self, handler: Box<dyn SshHandler>) -> Self

Set a custom SSH handler for transport interception.

Embedders can implement SshHandler to mock, proxy, log, or rate-limit SSH operations. The allowlist check happens before the handler is called.

Source

pub fn sqlite(self) -> Self

Enable embedded SQLite (sqlite/sqlite3 builtins) via Turso.

Registers both names with the default SqliteLimits. The Turso engine is BETA upstream — for security, execution is runtime-gated: set BASHKIT_ALLOW_INPROCESS_SQLITE=1 via builder .env(...) (or export) before invoking sqlite.

Requires the sqlite feature flag. Database files are loaded from / flushed to the virtual filesystem at command boundaries.

§Example
let bash = Bash::builder()
    .sqlite()
    .env("BASHKIT_ALLOW_INPROCESS_SQLITE", "1")
    .build();
Source

pub fn sqlite_with_limits(self, limits: SqliteLimits) -> Self

Enable embedded SQLite with custom limits and backend selection.

See BashBuilder::sqlite for details. Use SqliteLimits::backend to switch between the in-memory shim (Phase 1, default) and the VFS-backed adapter (Phase 2).

§Example
use bashkit::{SqliteBackend, SqliteLimits};

let bash = Bash::builder()
    .sqlite_with_limits(
        SqliteLimits::default()
            .backend(SqliteBackend::Vfs)
            .max_db_bytes(8 * 1024 * 1024),
    )
    .build();
Source

pub fn typescript(self) -> Self

Enable embedded TypeScript/JavaScript execution via ZapCode with defaults.

Registers ts, typescript, node, deno, and bun builtins. Requires the typescript feature.

§Example
let bash = Bash::builder().typescript().build();
bash.exec("ts -c \"console.log('hello')\"").await?;
Source

pub fn typescript_with_limits(self, limits: TypeScriptLimits) -> Self

Enable embedded TypeScript with custom resource limits.

See BashBuilder::typescript for details.

Source

pub fn typescript_with_config(self, config: TypeScriptConfig) -> Self

Enable embedded TypeScript with full configuration control.

§Example
use bashkit::{TypeScriptConfig, TypeScriptLimits};
use std::time::Duration;

// Only ts/typescript commands, no node/deno/bun aliases
let bash = Bash::builder()
    .typescript_with_config(TypeScriptConfig::default().compat_aliases(false))
    .build();

// Disable unsupported-mode hints
let bash = Bash::builder()
    .typescript_with_config(TypeScriptConfig::default().unsupported_mode_hint(false))
    .build();

// Custom limits + no compat aliases
let bash = Bash::builder()
    .typescript_with_config(
        TypeScriptConfig::default()
            .limits(TypeScriptLimits::default().max_duration(Duration::from_secs(5)))
            .compat_aliases(false)
    )
    .build();
Source

pub fn typescript_with_external_handler( self, limits: TypeScriptLimits, external_fns: Vec<String>, handler: TypeScriptExternalFnHandler, ) -> Self

Enable embedded TypeScript with external function handlers.

See TypeScriptExternalFnHandler for handler details.

Source

pub fn builtin(self, name: impl Into<String>, builtin: Box<dyn Builtin>) -> Self

Register a custom builtin command.

Custom builtins extend bashkit with domain-specific commands that can be invoked from bash scripts. They have full access to the execution context including arguments, environment, shell variables, and the virtual filesystem.

Custom builtins can override default builtins if registered with the same name.

§Arguments
  • name - The command name (e.g., “psql”, “kubectl”)
  • builtin - A boxed implementation of the Builtin trait
§Example
use bashkit::{Bash, Builtin, BuiltinContext, ExecResult, async_trait};

struct Greet {
    default_name: String,
}

#[async_trait]
impl Builtin for Greet {
    async fn execute(&self, ctx: BuiltinContext<'_>) -> bashkit::Result<ExecResult> {
        let name = ctx.args.first()
            .map(|s| s.as_str())
            .unwrap_or(&self.default_name);
        Ok(ExecResult::ok(format!("Hello, {}!\n", name)))
    }
}

let bash = Bash::builder()
    .builtin("greet", Box::new(Greet { default_name: "World".into() }))
    .build();
Source

pub fn builtin_registry(self, registry: BuiltinRegistry) -> Self

Attach a host-owned mutable builtin registry.

Unlike BashBuilder::builtin, entries in a BuiltinRegistry can be inserted and removed after the Bash instance has been built. The registry is host-owned, so its contents survive exec() calls unchanged. This is intended for embedders (FFI bindings, REPLs) that want to register host callbacks at runtime without rebuilding the interpreter.

The registry is consulted during command dispatch after shell functions and POSIX special builtins, but before baked-in builtins — so entries can override baked-in commands of the same name.

The registry handle is Clone; clones share the same underlying storage. Keep a clone after calling this method to retain post-build mutation access.

Source

pub fn extension<E>(self, extension: E) -> Self
where E: Extension,

Register a capability extension.

Extensions contribute a related set of builtins as one unit. Commands registered by an extension follow the same override rules as BashBuilder::builtin: later registrations replace earlier ones with the same name.

§Example
use bashkit::{Bash, Builtin, BuiltinContext, ExecResult, Extension, async_trait};

struct Hello;

#[async_trait]
impl Builtin for Hello {
    async fn execute(&self, _ctx: BuiltinContext<'_>) -> bashkit::Result<ExecResult> {
        Ok(ExecResult::ok("hello\n".to_string()))
    }
}

struct HelloExtension;

impl Extension for HelloExtension {
    fn builtins(&self) -> Vec<(String, Box<dyn Builtin>)> {
        vec![("hello".to_string(), Box::new(Hello))]
    }
}

let bash = Bash::builder().extension(HelloExtension).build();
Source

pub fn on_exit(self, hook: Interceptor<ExitEvent>) -> Self

Register an on_exit interceptor hook.

Fired when the exit builtin runs. The hook can inspect or modify the ExitEvent, or cancel the exit. Multiple hooks run in registration order.

§Example
use bashkit::hooks::{HookAction, ExitEvent};
use std::sync::{Arc, atomic::{AtomicBool, Ordering}};

let exited = Arc::new(AtomicBool::new(false));
let flag = exited.clone();

let bash = bashkit::Bash::builder()
    .on_exit(Box::new(move |event: ExitEvent| {
        flag.store(true, Ordering::Relaxed);
        HookAction::Continue(event)
    }))
    .build();
Source

pub fn before_exec(self, hook: Interceptor<ExecInput>) -> Self

Register a before_exec interceptor hook.

Fires before a script is executed. Can modify the script text or cancel execution entirely.

Source

pub fn after_exec(self, hook: Interceptor<ExecOutput>) -> Self

Register an after_exec interceptor hook.

Fires after script execution completes. Can modify or inspect the output (stdout, stderr, exit code).

Source

pub fn before_tool(self, hook: Interceptor<ToolEvent>) -> Self

Register a before_tool interceptor hook.

Fires before a builtin command is executed. Can modify args or cancel the tool invocation.

Source

pub fn after_tool(self, hook: Interceptor<ToolResult>) -> Self

Register an after_tool interceptor hook.

Fires after a builtin command completes.

Source

pub fn on_error(self, hook: Interceptor<ErrorEvent>) -> Self

Register an on_error interceptor hook.

Fires when the interpreter encounters an error.

Source

pub fn before_http(self, hook: Interceptor<HttpRequestEvent>) -> Self

Register a before_http interceptor hook.

Fires before each HTTP request (after allowlist validation). Can modify the URL/headers or cancel the request.

§Example
use bashkit::{Bash, hooks::{HookAction, HttpRequestEvent}};

let bash = Bash::builder()
    .before_http(Box::new(|req: HttpRequestEvent| {
        if req.url.contains("blocked") {
            HookAction::Cancel("blocked by policy".into())
        } else {
            HookAction::Continue(req)
        }
    }))
    .build();
Source

pub fn after_http(self, hook: Interceptor<HttpResponseEvent>) -> Self

Register an after_http interceptor hook.

Fires after each HTTP response is received. Can inspect response status and headers.

Source

pub fn credential(self, pattern: &str, cred: Credential) -> Self

Inject credentials for outbound HTTP requests matching the given URL pattern.

The pattern uses the same matching as NetworkAllowlist (scheme + host + port + path prefix). Injected headers overwrite any existing headers with the same name set by the script, preventing credential spoofing.

The script never sees the real credential — it is injected transparently by a before_http hook after the allowlist check.

§Example
use bashkit::{Bash, Credential, NetworkAllowlist};

let bash = Bash::builder()
    .network(NetworkAllowlist::new()
        .allow("https://api.github.com"))
    .credential("https://api.github.com",
        Credential::bearer("ghp_xxxx"))
    .build();
// Scripts can now: curl -s https://api.github.com/repos/foo/bar
// Authorization: Bearer ghp_xxxx is added transparently.

See credential_injection_guide for the full guide.

Source

pub fn credential_placeholder( self, env_name: &str, pattern: &str, cred: Credential, ) -> Self

Inject credentials via a placeholder env var visible to scripts.

Sets environment variable env_name to an opaque placeholder string. When a request to pattern contains the placeholder in any header value, it is replaced with the real credential on the wire.

The placeholder is a random string (bk_placeholder_<hex>) that:

  • Cannot be reversed to the real credential
  • Is only replaced for requests matching the URL pattern
  • Passes most SDK non-empty validation checks
§Example
use bashkit::{Bash, Credential, NetworkAllowlist};

let bash = Bash::builder()
    .network(NetworkAllowlist::new()
        .allow("https://api.openai.com"))
    .credential_placeholder("OPENAI_API_KEY",
        "https://api.openai.com",
        Credential::bearer("sk-real-key"))
    .build();
// Scripts see $OPENAI_API_KEY as "bk_placeholder_..." and use it normally.
// The placeholder is replaced with the real key in outbound headers.

See credential_injection_guide for the full guide.

Source

pub fn mount_text( self, path: impl Into<PathBuf>, content: impl Into<String>, ) -> Self

Mount a text file in the virtual filesystem.

This creates a regular file (mode 0o644) with the specified content at the given path. Parent directories are created automatically.

Mounted files are added via an OverlayFs layer on top of the base filesystem. This means:

  • The base filesystem remains unchanged
  • Mounted files take precedence over base filesystem files
  • Works with any filesystem implementation
§Example
use bashkit::Bash;

let mut bash = Bash::builder()
    .mount_text("/config/app.conf", "debug=true\nport=8080\n")
    .mount_text("/data/users.json", r#"["alice", "bob"]"#)
    .build();

let result = bash.exec("cat /config/app.conf").await?;
assert_eq!(result.stdout, "debug=true\nport=8080\n");
Source

pub fn mount_readonly_text( self, path: impl Into<PathBuf>, content: impl Into<String>, ) -> Self

Mount a readonly text file in the virtual filesystem.

This creates a readonly file (mode 0o444) with the specified content. Parent directories are created automatically.

Readonly files are useful for:

  • Configuration that shouldn’t be modified by scripts
  • Reference data that should remain immutable
  • Simulating system files like /etc/passwd

Mounted files are added via an OverlayFs layer on top of the base filesystem. This means:

  • The base filesystem remains unchanged
  • Mounted files take precedence over base filesystem files
  • Works with any filesystem implementation
§Example
use bashkit::Bash;

let mut bash = Bash::builder()
    .mount_readonly_text("/etc/version", "1.2.3")
    .mount_readonly_text("/etc/app.conf", "production=true\n")
    .build();

// Can read the file
let result = bash.exec("cat /etc/version").await?;
assert_eq!(result.stdout, "1.2.3");

// File has readonly permissions
let stat = bash.fs().stat(std::path::Path::new("/etc/version")).await?;
assert_eq!(stat.mode, 0o444);
Source

pub fn mount_lazy( self, path: impl Into<PathBuf>, size_hint: u64, loader: LazyLoader, ) -> Self

Mount a lazy file whose content is loaded on first read.

The loader closure is called at most once when the file is first read. If the file is overwritten before being read, the loader is never called. stat() returns metadata using size_hint without triggering the load.

§Example
use bashkit::Bash;
use std::sync::Arc;

let mut bash = Bash::builder()
    .mount_lazy("/data/large.csv", 1024, Arc::new(|| {
        b"id,name\n1,Alice\n".to_vec()
    }))
    .build();

let result = bash.exec("cat /data/large.csv").await?;
assert_eq!(result.stdout, "id,name\n1,Alice\n");
Source

pub fn mount_real_readonly(self, host_path: impl Into<PathBuf>) -> Self

Mount a real host directory as a readonly overlay at the VFS root.

Files from host_path become visible at the same paths inside the VFS. For example, if the host directory contains src/main.rs, it will be available as /src/main.rs inside the virtual bash session.

The host directory is read-only: scripts cannot modify host files.

Requires the realfs feature flag.

§Example
let bash = Bash::builder()
    .mount_real_readonly("/path/to/project")
    .build();
Source

pub fn mount_real_readonly_at( self, host_path: impl Into<PathBuf>, vfs_mount: impl Into<PathBuf>, ) -> Self

Mount a real host directory as a readonly filesystem at a specific VFS path.

Files from host_path become visible under vfs_mount inside the VFS. For example, mounting /home/user/data at /mnt/data makes /home/user/data/file.txt available as /mnt/data/file.txt.

The host directory is read-only: scripts cannot modify host files.

Requires the realfs feature flag.

§Example
let bash = Bash::builder()
    .mount_real_readonly_at("/path/to/data", "/mnt/data")
    .build();
Source

pub fn mount_real_readwrite(self, host_path: impl Into<PathBuf>) -> Self

Mount a real host directory with read-write access at the VFS root.

WARNING: This breaks the sandbox boundary. Scripts can modify files on the host filesystem. Only use when:

  • The script is fully trusted
  • The host directory is appropriately scoped

Requires the realfs feature flag.

§Example
let bash = Bash::builder()
    .mount_real_readwrite("/path/to/workspace")
    .build();
Source

pub fn mount_real_readwrite_at( self, host_path: impl Into<PathBuf>, vfs_mount: impl Into<PathBuf>, ) -> Self

Mount a real host directory with read-write access at a specific VFS path.

WARNING: This breaks the sandbox boundary. Scripts can modify files on the host filesystem.

Requires the realfs feature flag.

§Example
let bash = Bash::builder()
    .mount_real_readwrite_at("/path/to/workspace", "/mnt/workspace")
    .build();
Source

pub fn allowed_mount_paths( self, paths: impl IntoIterator<Item = impl Into<PathBuf>>, ) -> Self

Set an allowlist of host paths that may be mounted.

When set, only host paths starting with an allowed prefix are accepted by mount_real_* methods. Paths outside the allowlist are rejected with a warning at build time.

§Example
let bash = Bash::builder()
    .allowed_mount_paths(["/home/user/projects", "/tmp"])
    .mount_real_readonly("/home/user/projects/data")  // OK
    .mount_real_readonly("/etc/passwd")                // rejected
    .build();
Source

pub fn readonly_filesystem(self, readonly: bool) -> Self

Make the final virtual filesystem read-only.

This is stronger than mounting real directories read-only: writes to any VFS location fail, including /tmp, redirections, cp, mv, rm, mkdir, and chmod.

Source

pub fn build(self) -> Bash

Build the Bash instance.

If mounted files are specified, they are added via an OverlayFs layer on top of the base filesystem. This means:

  • The base filesystem remains unchanged
  • Mounted files take precedence over base filesystem files
  • Works with any filesystem implementation
§Example
use bashkit::{Bash, InMemoryFs};
use std::sync::Arc;

// Works with default InMemoryFs
let mut bash = Bash::builder()
    .mount_text("/config/app.conf", "debug=true\n")
    .build();

// Also works with custom filesystems
let custom_fs = Arc::new(InMemoryFs::new());
let mut bash = Bash::builder()
    .fs(custom_fs)
    .mount_text("/config/app.conf", "debug=true\n")
    .mount_readonly_text("/etc/version", "1.0.0")
    .build();

let result = bash.exec("cat /config/app.conf").await?;
assert_eq!(result.stdout, "debug=true\n");

Trait Implementations§

Source§

impl Default for BashBuilder

Source§

fn default() -> BashBuilder

Returns the “default value” for a type. 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, T> FromIn<'a, T> for T

Source§

fn from_in(t: T, _: &'a Allocator) -> T

Converts to this type from the input type within the given allocator.
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> 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<'a, T, U> IntoIn<'a, U> for T
where U: FromIn<'a, T>,

Source§

fn into_in(self, allocator: &'a Allocator) -> U

Converts this type into the (usually inferred) input type within the given allocator.
Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
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: 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: 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::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(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