Skip to main content

Environment

Trait Environment 

Source
pub trait Environment {
    type Rng: CryptoRng;

Show 30 methods // Required methods fn rng(&mut self) -> &mut Self::Rng; fn now(&self) -> u64; fn offset_minutes(&self) -> i32; fn passphrase(&mut self, prompt: &str) -> Result<Zeroizing<String>>; fn passphrase_params(&self) -> PassphraseParams; fn computer_name(&self) -> String; fn account(&self) -> Account; fn current_dir(&self) -> Result<PathBuf>; fn default_library(&self) -> Option<PathBuf>; fn keystore(&mut self) -> bool; fn languages(&self) -> Vec<String>; // Provided methods fn time_zone(&self) -> TimeZone { ... } fn ceiling(&self) -> Option<PathBuf> { ... } fn downloads(&self) -> Option<PathBuf> { ... } fn note(&mut self, line: &str) { ... } fn ask(&mut self, question: &str) -> Result<Option<String>> { ... } fn can_ask(&self) -> bool { ... } fn clipboard(&mut self) -> Result<Box<dyn Board>, ClipboardError> { ... } fn interruptible(&mut self) { ... } fn wait(&mut self, duration: Duration) -> bool { ... } fn stop_on_interrupt(&mut self, stop: Arc<AtomicBool>) { ... } fn state_folder(&self) -> Option<PathBuf> { ... } fn sync_program(&self) -> Option<PathBuf> { ... } fn nib_program(&self) -> Option<PathBuf> { ... } fn ai_client(&self, program: &str) -> Option<Command> { ... } fn git(&self) -> Command { ... } fn login_entry(&self) -> Option<LoginEntry> { ... } fn open_firewall(&mut self) -> Firewall { ... } fn sync_version(&self, program: &Path) -> Option<String> { ... } fn start_sync(&mut self, program: &Path) -> Result<(), NodeError> { ... }
}
Expand description

What commands need from the world.

Required Associated Types§

Source

type Rng: CryptoRng

The kind of random number generator.

Required Methods§

Source

fn rng(&mut self) -> &mut Self::Rng

A cryptographically secure random number generator.

Source

fn now(&self) -> u64

The wall clock time, in milliseconds since 1970 (UTC).

Source

fn offset_minutes(&self) -> i32

The device’s offset from UTC, in minutes, at the current time.

Source

fn passphrase(&mut self, prompt: &str) -> Result<Zeroizing<String>>

Asks the person for a passphrase.

§Errors

Returns an error if the passphrase cannot be read.

Source

fn passphrase_params(&self) -> PassphraseParams

How much work deriving a key from a new passphrase takes.

Source

fn computer_name(&self) -> String

The computer’s name, the default name of a device.

Source

fn account(&self) -> Account

The person’s account on this computer, after which a new library’s user is named.

Source

fn current_dir(&self) -> Result<PathBuf>

The current folder: nib init makes it a library, and the other commands look for their library in it and in the folders it is in.

§Errors

Returns an error if the current folder cannot be found, such as one deleted since.

Source

fn default_library(&self) -> Option<PathBuf>

The folder of the library that commands work in outside every library’s folder, if the person names one: NIBKEEP_LIBRARY.

Source

fn keystore(&mut self) -> bool

Whether the platform has a keystore to keep a library’s keys in, connecting to it the first time.

Source

fn languages(&self) -> Vec<String>

The languages the system is set to, first the one it uses, as the platform names them, such as en_US.UTF-8 or en-US.

Provided Methods§

Source

fn time_zone(&self) -> TimeZone

The device’s time zone, by which times are read and shown: a fixed offset from UTC, Environment::offset_minutes, unless the environment knows the zone’s rules.

Source

fn ceiling(&self) -> Option<PathBuf>

A folder in which, and above which, commands do not look for their library, as Git’s GIT_CEILING_DIRECTORIES says: tests keep to their own folders with it, and the end-to-end tests name it in NIBKEEP_CEILING.

Source

fn downloads(&self) -> Option<PathBuf>

This device’s downloads folder, as the platform names it, if it has one.

Source

fn note(&mut self, line: &str)

Tells the person something beside what the command writes: on standard error, so that output that other programs read stays as it is.

Source

fn ask(&mut self, question: &str) -> Result<Option<String>>

Asks the person a question on the terminal, and returns the answer, or None if there is no terminal to ask on, as for a script or an AI agent.

§Errors

Returns an error if the answer cannot be read.

Source

fn can_ask(&self) -> bool

Whether Environment::ask has someone to ask, as before showing a code that would be spent without an answer.

Source

fn clipboard(&mut self) -> Result<Box<dyn Board>, ClipboardError>

The clipboard, to copy secrets to: none, unless the environment has one.

§Errors

Returns an error if there is no clipboard, such as on a computer without a display.

Source

fn interruptible(&mut self)

Makes an interruption, as with Ctrl+C, end the next wait rather than nib, from now on: before nib copies a secret, so that an interruption never leaves it on the clipboard.

Source

fn wait(&mut self, duration: Duration) -> bool

Waits for duration, or until the person interrupts nib, as with Ctrl+C, whichever comes first. Returns whether the person interrupted it.

Source

fn stop_on_interrupt(&mut self, stop: Arc<AtomicBool>)

Makes an interruption, as with Ctrl+C, set stop rather than end nib: for a command that runs until stopped, and lets go of what it holds as it ends.

Source

fn state_folder(&self) -> Option<PathBuf>

This computer’s folder of NibKeep’s state, where the list of libraries synced from login is (technical design): None where there is none.

Source

fn sync_program(&self) -> Option<PathBuf>

The copy of nibkeep-sync installed beside nib, if there is one.

Source

fn nib_program(&self) -> Option<PathBuf>

The program of nib itself, which AI clients run as a library’s server.

Source

fn ai_client(&self, program: &str) -> Option<Command>

A command of the AI client’s program program, such as claude, if it is installed here, to tell the client of a server or take it away: none unless the environment finds it.

Source

fn git(&self) -> Command

The person’s own Git, with their settings and credentials, as a command to give arguments to (technical design).

Source

fn login_entry(&self) -> Option<LoginEntry>

The login entry that starts nibkeep-sync, where the platform has one.

Source

fn open_firewall(&mut self) -> Firewall

Lets the person’s other devices reach this computer through its firewall, where nib does that, as on Windows, asking for the administrator’s consent.

Source

fn sync_version(&self, program: &Path) -> Option<String>

The engine’s version that a copy of nibkeep-sync tells, or None if it is gone.

Source

fn start_sync(&mut self, program: &Path) -> Result<(), NodeError>

Starts a copy of nibkeep-sync, apart from nib, so that it runs on when nib ends.

§Errors

Returns an error if it cannot be started.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§