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§
Required Methods§
Sourcefn offset_minutes(&self) -> i32
fn offset_minutes(&self) -> i32
The device’s offset from UTC, in minutes, at the current time.
Sourcefn passphrase_params(&self) -> PassphraseParams
fn passphrase_params(&self) -> PassphraseParams
How much work deriving a key from a new passphrase takes.
Sourcefn computer_name(&self) -> String
fn computer_name(&self) -> String
The computer’s name, the default name of a device.
Sourcefn account(&self) -> Account
fn account(&self) -> Account
The person’s account on this computer, after which a new library’s user is named.
Sourcefn current_dir(&self) -> Result<PathBuf>
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.
Sourcefn default_library(&self) -> Option<PathBuf>
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.
Provided Methods§
Sourcefn time_zone(&self) -> TimeZone
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.
Sourcefn ceiling(&self) -> Option<PathBuf>
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.
Sourcefn downloads(&self) -> Option<PathBuf>
fn downloads(&self) -> Option<PathBuf>
This device’s downloads folder, as the platform names it, if it has one.
Sourcefn note(&mut self, line: &str)
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.
Sourcefn ask(&mut self, question: &str) -> Result<Option<String>>
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.
Sourcefn can_ask(&self) -> bool
fn can_ask(&self) -> bool
Whether Environment::ask has someone to ask, as before showing a code that would
be spent without an answer.
Sourcefn clipboard(&mut self) -> Result<Box<dyn Board>, ClipboardError>
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.
Sourcefn interruptible(&mut self)
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.
Sourcefn wait(&mut self, duration: Duration) -> bool
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.
Sourcefn stop_on_interrupt(&mut self, stop: Arc<AtomicBool>)
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.
Sourcefn state_folder(&self) -> Option<PathBuf>
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.
Sourcefn sync_program(&self) -> Option<PathBuf>
fn sync_program(&self) -> Option<PathBuf>
The copy of nibkeep-sync installed beside nib, if there is one.
Sourcefn nib_program(&self) -> Option<PathBuf>
fn nib_program(&self) -> Option<PathBuf>
The program of nib itself, which AI clients run as a library’s server.
Sourcefn ai_client(&self, program: &str) -> Option<Command>
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.
Sourcefn git(&self) -> Command
fn git(&self) -> Command
The person’s own Git, with their settings and credentials, as a command to give arguments to (technical design).
Sourcefn login_entry(&self) -> Option<LoginEntry>
fn login_entry(&self) -> Option<LoginEntry>
The login entry that starts nibkeep-sync, where the platform has one.
Sourcefn open_firewall(&mut self) -> Firewall
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.
Sourcefn sync_version(&self, program: &Path) -> Option<String>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".