pub struct FileNameStore { /* private fields */ }Expand description
The CLI’s registry: one JSON file per name in a directory, owner-only on Unix.
Implementations§
Source§impl FileNameStore
impl FileNameStore
Sourcepub fn new(dir: impl Into<PathBuf>) -> FileNameStore
pub fn new(dir: impl Into<PathBuf>) -> FileNameStore
A store over the directory that holds the name files themselves.
Sourcepub fn in_state_root(state_root: &Path) -> FileNameStore
pub fn in_state_root(state_root: &Path) -> FileNameStore
The registry under state_root/names — where the CLI keeps it.
A subdirectory rather than the state root because the run ledger’s *.json glob
must never read a name record as a ledger.
Sourcepub fn default_location(env: &dyn Fn(&str) -> Option<String>) -> FileNameStore
pub fn default_location(env: &dyn Fn(&str) -> Option<String>) -> FileNameStore
The registry the CLI would use in this environment.
If no absolute home can be resolved, the returned store refuses every storage operation with a precondition error and its directory is empty.
Trait Implementations§
Source§impl Clone for FileNameStore
impl Clone for FileNameStore
Source§fn clone(&self) -> FileNameStore
fn clone(&self) -> FileNameStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileNameStore
impl Debug for FileNameStore
Source§impl NameStore for FileNameStore
impl NameStore for FileNameStore
Source§fn get(&self, name: &str) -> Result<Option<NameRecord>, Error>
fn get(&self, name: &str) -> Result<Option<NameRecord>, Error>
A file that exists but does not parse is an error, not a free name: a torn record is what a killed write leaves, and treating it as free would let a second VM claim a name whose first holder may still be billing.
Source§fn list(&self) -> Result<Vec<NameRecord>, Error>
fn list(&self) -> Result<Vec<NameRecord>, Error>
Skips files that are not records: a torn file is reported by NameStore::get
for its own name, and must not make every other name unlistable.
Source§fn put(&self, record: &NameRecord) -> Result<(), Error>
fn put(&self, record: &NameRecord) -> Result<(), Error>
record under its name, replacing any earlier record.Auto Trait Implementations§
impl Freeze for FileNameStore
impl RefUnwindSafe for FileNameStore
impl Send for FileNameStore
impl Sync for FileNameStore
impl Unpin for FileNameStore
impl UnsafeUnpin for FileNameStore
impl UnwindSafe for FileNameStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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