pub struct Files<'a> { /* private fields */ }Expand description
The ergonomic files accessor returned by Sandbox::files().
Implementations§
Source§impl<'a> Files<'a>
impl<'a> Files<'a>
Sourcepub async fn read(&self, path: &str) -> Result<Vec<u8>, SolariError>
pub async fn read(&self, path: &str) -> Result<Vec<u8>, SolariError>
Read a file’s raw bytes. It reads in 4 MiB chunks (download), so a large file never travels as one
frame; a guest image that predates fs.download is read in one frame (fs.read).
Sourcepub async fn download(&self, path: &str) -> Result<Vec<u8>, SolariError>
pub async fn download(&self, path: &str) -> Result<Vec<u8>, SolariError>
Read a whole file in 4 MiB chunks (fs.download) until the guest reports the end.
Sourcepub async fn upload(
&self,
path: &str,
data: impl AsRef<[u8]>,
) -> Result<(), SolariError>
pub async fn upload( &self, path: &str, data: impl AsRef<[u8]>, ) -> Result<(), SolariError>
Write data to a file in 4 MiB chunks (fs.upload): the first call truncates, later calls append at their offset.
An empty file is one zero-length call. Unlike write there is no size limit.
Sourcepub async fn read_text(&self, path: &str) -> Result<String, SolariError>
pub async fn read_text(&self, path: &str) -> Result<String, SolariError>
Read a file as UTF-8 text.
Sourcepub async fn write(
&self,
path: &str,
data: impl AsRef<[u8]>,
mode: Option<i64>,
) -> Result<(), SolariError>
pub async fn write( &self, path: &str, data: impl AsRef<[u8]>, mode: Option<i64>, ) -> Result<(), SolariError>
Write bytes to a file (fs.write). mode is an optional unix mode. The data travels as one frame, so more than
32 MiB is refused before anything is sent (a frame that large would close the control channel and fail every call
on it): use upload.
Sourcepub async fn list(&self, path: &str) -> Result<Vec<FsEntry>, SolariError>
pub async fn list(&self, path: &str) -> Result<Vec<FsEntry>, SolariError>
List a directory (fs.list).
Sourcepub async fn mkdir(&self, path: &str) -> Result<(), SolariError>
pub async fn mkdir(&self, path: &str) -> Result<(), SolariError>
Create a directory and parents (fs.mkdir).