pub struct Files { /* private fields */ }Expand description
Reads and writes a sandbox’s filesystem. Relative paths resolve against /work. Every call is a
small shell program run in the sandbox, so each costs one round trip (about 0.15 s once the
sandbox is warm); batch with write_files and
upload_dir where you can.
Implementations§
Source§impl Files
impl Files
Sourcepub async fn read(&self, p: &str) -> Result<Vec<u8>>
pub async fn read(&self, p: &str) -> Result<Vec<u8>>
A file’s contents. A missing file is Error::NotFound.
Sourcepub async fn read_text(&self, p: &str) -> Result<String>
pub async fn read_text(&self, p: &str) -> Result<String>
A file’s contents as a string (invalid UTF-8 is replaced).
Sourcepub async fn write(
&self,
p: &str,
data: impl Into<Vec<u8>>,
) -> Result<WriteInfo>
pub async fn write( &self, p: &str, data: impl Into<Vec<u8>>, ) -> Result<WriteInfo>
Creates or replaces a file (atomically, mode 0644), creating parent directories. Any size works: data over 15 MiB is staged in pieces.
Sourcepub async fn write_files(
&self,
files: Vec<WriteEntry>,
) -> Result<Vec<WriteInfo>>
pub async fn write_files( &self, files: Vec<WriteEntry>, ) -> Result<Vec<WriteInfo>>
Writes several files in one upload (one tar), creating parent directories. Files are owned by root.
Sourcepub async fn list(&self, p: &str) -> Result<Vec<EntryInfo>>
pub async fn list(&self, p: &str) -> Result<Vec<EntryInfo>>
The entries of a directory (one level), sorted by name.
Sourcepub async fn exists(&self, p: &str) -> Result<bool>
pub async fn exists(&self, p: &str) -> Result<bool>
Whether a path exists (a dangling symlink counts).
Sourcepub async fn get_info(&self, p: &str) -> Result<EntryInfo>
pub async fn get_info(&self, p: &str) -> Result<EntryInfo>
Describes a path without following a final symlink.
Sourcepub async fn make_dir(&self, p: &str) -> Result<bool>
pub async fn make_dir(&self, p: &str) -> Result<bool>
Creates a directory and its parents. Returns false if it already existed.
Sourcepub async fn remove(&self, p: &str) -> Result<()>
pub async fn remove(&self, p: &str) -> Result<()>
Deletes a file or a directory tree. A missing path is Error::NotFound.
Sourcepub async fn rename(&self, old_path: &str, new_path: &str) -> Result<EntryInfo>
pub async fn rename(&self, old_path: &str, new_path: &str) -> Result<EntryInfo>
Moves a file or directory, creating the destination’s parents, and describes it at its new path.
Sourcepub async fn upload(
&self,
local_path: impl AsRef<Path>,
remote_path: &str,
) -> Result<()>
pub async fn upload( &self, local_path: impl AsRef<Path>, remote_path: &str, ) -> Result<()>
Copies a local file into the sandbox, keeping its permission bits.
Sourcepub async fn download(
&self,
remote_path: &str,
local_path: impl AsRef<Path>,
) -> Result<()>
pub async fn download( &self, remote_path: &str, local_path: impl AsRef<Path>, ) -> Result<()>
Copies a file from the sandbox to local_path, creating local parent directories.
Sourcepub async fn upload_dir(
&self,
local_dir: impl AsRef<Path>,
remote_dir: &str,
) -> Result<()>
pub async fn upload_dir( &self, local_dir: impl AsRef<Path>, remote_dir: &str, ) -> Result<()>
Copies a local directory tree into remote_dir (created if missing), as one tar. Symlinks
are copied as links; sockets and devices are skipped. Files are owned by root.
Sourcepub async fn download_dir(
&self,
remote_dir: &str,
local_dir: impl AsRef<Path>,
) -> Result<()>
pub async fn download_dir( &self, remote_dir: &str, local_dir: impl AsRef<Path>, ) -> Result<()>
Copies a directory tree from the sandbox into local_dir (created if missing). Nothing is
written outside local_dir: absolute names and “..” are refused, an entry is never written
through a symbolic link, and a link that leads outside local_dir (directly or through
other links) is removed and reported as an error.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Files
impl !RefUnwindSafe for Files
impl Send for Files
impl Sync for Files
impl Unpin for Files
impl UnsafeUnpin for Files
impl !UnwindSafe for Files
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].