pub struct LocalVault { /* private fields */ }Expand description
A repository directory on the local filesystem.
Implementations§
Source§impl LocalVault
impl LocalVault
Sourcepub fn new(root: impl Into<PathBuf>) -> Self
pub fn new(root: impl Into<PathBuf>) -> Self
A vault rooted at root, canonicalized when it exists.
Canonical because every path this vault produces is relativized against
it: canonicalize on a child returns a canonical path, and on macOS a
temp dir (/var/…) or on Windows any path (\\?\C:\…) differs from its
canonical spelling, which would make every child look like it is outside
the root. Falls back to the path as given when it cannot be
canonicalized (it does not exist yet); every operation then fails with
the real error rather than here.
Sourcepub fn with_availability_probe(self, probe: AvailabilityProbe) -> Self
pub fn with_availability_probe(self, probe: AvailabilityProbe) -> Self
Classifies files with probe (see AvailabilityProbe) in every
Entry this vault produces and in Vault::availability.
Sourcepub fn with_mounts(root: impl Into<PathBuf>, policy: MountPolicy) -> Self
pub fn with_mounts(root: impl Into<PathBuf>, policy: MountPolicy) -> Self
A vault rooted at root (canonicalized, as Self::new) that serves
links out of it as read-only mounts under policy — see
[super::mount]. This is what the repository and its external static
overlay are built with (crate::repo::Repo::init).
Trait Implementations§
Source§impl Clone for LocalVault
impl Clone for LocalVault
Source§impl Debug for LocalVault
impl Debug for LocalVault
Source§impl Vault for LocalVault
impl Vault for LocalVault
Source§fn root(&self) -> &Path
fn root(&self) -> &Path
Vault::keys live under. For LocalVault, the
canonical repository root; for any other vault, an identifier that is
never opened.Source§fn stat(&self, path: &VaultPath) -> Result<Option<Entry>, VaultError>
fn stat(&self, path: &VaultPath) -> Result<Option<Entry>, VaultError>
path (following symlinks), or None when nothing is
there.Source§fn list_dir(&self, dir: &VaultPath) -> Result<Vec<Entry>, VaultError>
fn list_dir(&self, dir: &VaultPath) -> Result<Vec<Entry>, VaultError>
dir, in no particular order. Read moreSource§fn canonicalize(&self, path: &VaultPath) -> Result<VaultPath, VaultError>
fn canonicalize(&self, path: &VaultPath) -> Result<VaultPath, VaultError>
path and returns where it really is inside the
vault. Read moreSource§fn read_prefix(
&self,
path: &VaultPath,
max_len: usize,
) -> Result<Vec<u8>, VaultError>
fn read_prefix( &self, path: &VaultPath, max_len: usize, ) -> Result<Vec<u8>, VaultError>
max_len bytes (frontmatter extraction reads 8 KB).Source§fn read_range(
&self,
path: &VaultPath,
offset: u64,
len: usize,
) -> Result<Vec<u8>, VaultError>
fn read_range( &self, path: &VaultPath, offset: u64, len: usize, ) -> Result<Vec<u8>, VaultError>
len bytes starting at byte offset: fewer at the end of the
file, none past it. The streaming and Range path for files a vault
has no Vault::local_path for (mbr_server serves those in chunks). Read moreSource§fn availability(&self, path: &VaultPath) -> Availability
fn availability(&self, path: &VaultPath) -> Availability
path is on this device, decided without reading
it — the check a server makes before handing a file to a reader that
would block on (or fail half-way through) a not-downloaded one. Read moreSource§fn write_atomic(&self, path: &VaultPath, bytes: &[u8]) -> Result<(), VaultError>
fn write_atomic(&self, path: &VaultPath, bytes: &[u8]) -> Result<(), VaultError>
path with bytes atomically: readers see the
old content or the new, never a mix, and a failure leaves the old file.
The parent directory must exist. An existing file’s permissions are
kept. Read moreSource§fn create_dir_all(&self, path: &VaultPath) -> Result<(), VaultError>
fn create_dir_all(&self, path: &VaultPath) -> Result<(), VaultError>
path and any missing ancestors as directories.Source§fn remove_file(&self, path: &VaultPath) -> Result<(), VaultError>
fn remove_file(&self, path: &VaultPath) -> Result<(), VaultError>
path.Source§fn rename(&self, from: &VaultPath, to: &VaultPath) -> Result<(), VaultError>
fn rename(&self, from: &VaultPath, to: &VaultPath) -> Result<(), VaultError>
from to to, replacing a file at to.Source§fn local_path(&self, path: &VaultPath) -> Option<PathBuf>
fn local_path(&self, path: &VaultPath) -> Option<PathBuf>
path, when one exists — the fast path for
consumers that need one (ServeFile, grep’s search_path, ffmpeg,
pdfium, mmap). None means “read it through the vault”.Source§fn is_read_only(&self, path: &VaultPath) -> bool
fn is_read_only(&self, path: &VaultPath) -> bool
path lies in a read-only part of the vault — a symlink
mount’s location or anything under it. Lexical: callers pass resolved
(canonical) paths, and the vault’s own write methods re-check the
canonical form. false for vaults without mounts.Source§fn mounts(&self) -> Vec<Mount>
fn mounts(&self) -> Vec<Mount>
Mount). They are discovered
as paths through them are first resolved, so the list grows during the
first scan. Empty for vaults without mounts.Source§fn request_download(&self, _paths: &[VaultPath])
fn request_download(&self, _paths: &[VaultPath])
Source§fn read_to_string(&self, path: &VaultPath) -> Result<String, VaultError>
fn read_to_string(&self, path: &VaultPath) -> Result<String, VaultError>
VaultError::Io with
ErrorKind::InvalidData, as std::fs::read_to_string reports it.Source§fn vault_path(&self, key: &Path) -> Result<VaultPath, VaultError>
fn vault_path(&self, key: &Path) -> Result<VaultPath, VaultError>
Vault::key.
Lexical: it does not resolve symlinks.Auto Trait Implementations§
impl Freeze for LocalVault
impl RefUnwindSafe for LocalVault
impl Send for LocalVault
impl Sync for LocalVault
impl Unpin for LocalVault
impl UnsafeUnpin for LocalVault
impl UnwindSafe for LocalVault
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
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 bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
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>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
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 rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
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 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.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
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);