pub struct Files<'a> { /* private fields */ }Expand description
The file operations of one task: paths resolve against the task directory, and every access is recorded, with every file a write changed.
Implementations§
Source§impl<'a> Files<'a>
impl<'a> Files<'a>
Sourcepub const fn new(
dir: &'a AbsolutePath,
accesses: &'a mut Accesses,
changes: &'a mut FileChanges,
) -> Self
pub const fn new( dir: &'a AbsolutePath, accesses: &'a mut Accesses, changes: &'a mut FileChanges, ) -> Self
The file operations of the task in dir, recording into accesses and,
for writes that change a file, into changes.
Sourcepub fn noting(self, outcomes: Option<&'a mut AccessOutcomes>) -> Self
pub fn noting(self, outcomes: Option<&'a mut AccessOutcomes>) -> Self
The file operations, which also note how each access ended into outcomes
when it is Some, for the observation report of kizz run --output.
Sourcepub fn resolve(&self, path: &str) -> AbsolutePath
pub fn resolve(&self, path: &str) -> AbsolutePath
The absolute path of path, relative to the task directory unless absolute.
Sourcepub fn read_bytes_if_present(
&mut self,
path: &AbsolutePath,
) -> Result<Option<Vec<u8>>, FileError>
pub fn read_bytes_if_present( &mut self, path: &AbsolutePath, ) -> Result<Option<Vec<u8>>, FileError>
Sourcepub fn read_bytes(&mut self, path: &AbsolutePath) -> Result<Vec<u8>, FileError>
pub fn read_bytes(&mut self, path: &AbsolutePath) -> Result<Vec<u8>, FileError>
Sourcepub fn write_bytes(
&mut self,
path: &str,
content: &[u8],
) -> Result<bool, FileError>
pub fn write_bytes( &mut self, path: &str, content: &[u8], ) -> Result<bool, FileError>
Write content to the file at path, creating parent directories, unless
the file already holds exactly content. Returns whether the file was
written; a written file is noted as changed. A write that leaves the file as
it was succeeds; each parent directory it created has the outcome of
creating them.
§Errors
Returns FileError when a directory cannot be created or the file cannot
be written.
Sourcepub fn write_json(
&mut self,
path: &str,
value: &Value,
indent: usize,
) -> Result<bool, FileError>
pub fn write_json( &mut self, path: &str, value: &Value, indent: usize, ) -> Result<bool, FileError>
Sourcepub fn exists(&mut self, path: &str) -> bool
pub fn exists(&mut self, path: &str) -> bool
Whether path exists, following symbolic links; the path is recorded as
probed.
Sourcepub fn glob(&mut self, pattern: &str) -> Result<Vec<String>, FileError>
pub fn glob(&mut self, pattern: &str) -> Result<Vec<String>, FileError>
The paths that match the glob pattern, sorted.
The pattern is split at its first component with a glob character: the
components before it name the directory the search starts in, relative to
the task directory unless absolute, and the rest is matched against paths
below it. *, ?, [...], and {a,b} stay within one component, and **
matches any number of components. Names that start with . match like any
other. Each match is the starting directory as written, joined with the
matching path. Every directory read is recorded as listed, and a missing one
as probed; a pattern without glob characters probes its one path.
§Errors
Returns FileError when the pattern is not valid or a directory cannot be
read.
Auto Trait Implementations§
impl<'a> !UnwindSafe for Files<'a>
impl<'a> Freeze for Files<'a>
impl<'a> RefUnwindSafe for Files<'a>
impl<'a> Send for Files<'a>
impl<'a> Sync for Files<'a>
impl<'a> Unpin for Files<'a>
impl<'a> UnsafeUnpin for Files<'a>
Blanket Implementations§
impl<T> AsTypeStaticRegistered for T
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
impl<T> HasTyVTable for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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