SandboxFs
Filesystem handle for a running sandbox. Obtained viasb.fs(). All operations go through the same host-guest channel as command execution - no SSH, no network involved. For bulk file operations, consider using volumes instead, which give the guest direct filesystem access.
copy()
| Name | Type | Description |
|---|---|---|
| from | &str | Source path |
| to | &str | Destination path |
copy_from_host()
| Name | Type | Description |
|---|---|---|
| host_path | impl AsRef<Path> | Path on the host filesystem |
| guest_path | &str | Destination path inside the sandbox |
copy_to_host()
| Name | Type | Description |
|---|---|---|
| guest_path | &str | Path inside the sandbox |
| host_path | impl AsRef<Path> | Destination path on the host |
exists()
| Name | Type | Description |
|---|---|---|
| path | &str | Absolute path inside the guest |
| Type | Description |
|---|---|
bool | true if the path exists |
list()
| Name | Type | Description |
|---|---|---|
| path | &str | Absolute directory path inside the guest |
| Type | Description |
|---|---|
Vec<FsEntry> | Directory entries |
mkdir()
| Name | Type | Description |
|---|---|---|
| path | &str | Absolute directory path |
read()
| Name | Type | Description |
|---|---|---|
| path | &str | Absolute path inside the guest (e.g. "/app/config.json") |
| Type | Description |
|---|---|
Bytes | File contents as raw bytes |
read_stream()
| Name | Type | Description |
|---|---|---|
| path | &str | Absolute path inside the guest |
| Type | Description |
|---|---|
FsReadStream | Async stream that yields chunks of file data |
read_to_string()
| Name | Type | Description |
|---|---|---|
| path | &str | Absolute path inside the guest |
| Type | Description |
|---|---|
String | File contents as a UTF-8 string |
remove()
| Name | Type | Description |
|---|---|---|
| path | &str | Absolute file path |
remove_dir()
| Name | Type | Description |
|---|---|---|
| path | &str | Absolute directory path |
rename()
| Name | Type | Description |
|---|---|---|
| from | &str | Current path |
| to | &str | New path |
stat()
| Name | Type | Description |
|---|---|---|
| path | &str | Absolute path inside the guest |
| Type | Description |
|---|---|
FsMetadata | File metadata |
write()
| Name | Type | Description |
|---|---|---|
| path | &str | Absolute path inside the guest |
| data | impl AsRef<[u8]> | File content |
write_stream()
| Name | Type | Description |
|---|---|---|
| path | &str | Absolute path inside the guest |
| Type | Description |
|---|---|
FsWriteSink | Async writer for sending chunks |
Types
FsEntry
Metadata for a single directory entry, returned bylist().
| Field | Type | Description |
|---|---|---|
| kind | FsEntryKind | Type of entry |
| mode | u32 | Unix permission bits (e.g. 0o644) |
| modified | Option<DateTime<Utc>> | Last modified timestamp |
| path | String | File path |
| size | u64 | File size in bytes |
FsEntryKind
The type of a filesystem entry.| Value | Description |
|---|---|
Directory | Directory |
File | Regular file |
Other | Other entry type (device, socket, etc.) |
Symlink | Symbolic link |
FsMetadata
Detailed file metadata, returned bystat().
| Field | Type | Description |
|---|---|---|
| created | Option<DateTime<Utc>> | Creation timestamp (not available on all filesystems) |
| kind | FsEntryKind | Type of entry |
| mode | u32 | Unix permission bits |
| modified | Option<DateTime<Utc>> | Last modified timestamp |
| readonly | bool | Whether the file is read-only |
| size | u64 | File size in bytes |
FsReadStream
Async stream for reading a file in chunks. Obtained viaread_stream().
| Method | Returns | Description |
|---|---|---|
| collect() | Bytes | Collect all remaining chunks into a single Bytes buffer. |
| recv() | Option<Bytes> | Receive the next chunk. Returns None when the file has been fully read. |
FsWriteSink
Async writer for streaming data into a file. Obtained viawrite_stream().
| Method | Parameters | Description |
|---|---|---|
| close() | - | Finalize the write and close the stream. Must be called to ensure all data is flushed. |
| write() | data: impl AsRef<[u8]> | Write a chunk of data to the file. |