pub struct Directory {
pub proc: Option<Arc<DaggerSessionProc>>,
pub selection: Selection,
pub graphql_client: DynGraphQLClient,
}Fields§
§proc: Option<Arc<DaggerSessionProc>>§selection: Selection§graphql_client: DynGraphQLClientImplementations§
Source§impl Directory
impl Directory
Sourcepub fn as_git(&self) -> GitRepository
pub fn as_git(&self) -> GitRepository
Converts this directory to a local git repository
Sourcepub fn as_module(&self) -> Module
pub fn as_module(&self) -> Module
Load the directory as a Dagger module source
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn as_module_opts<'a>(&self, opts: DirectoryAsModuleOpts<'a>) -> Module
pub fn as_module_opts<'a>(&self, opts: DirectoryAsModuleOpts<'a>) -> Module
Load the directory as a Dagger module source
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn as_module_source(&self) -> ModuleSource
pub fn as_module_source(&self) -> ModuleSource
Load the directory as a Dagger module source
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn as_module_source_opts<'a>(
&self,
opts: DirectoryAsModuleSourceOpts<'a>,
) -> ModuleSource
pub fn as_module_source_opts<'a>( &self, opts: DirectoryAsModuleSourceOpts<'a>, ) -> ModuleSource
Load the directory as a Dagger module source
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn changes(&self, from: impl IntoID<DirectoryId>) -> Changeset
pub fn changes(&self, from: impl IntoID<DirectoryId>) -> Changeset
Return the difference between this directory and another directory, typically an older snapshot. The difference is encoded as a changeset, which also tracks removed files, and can be applied to other directories.
§Arguments
from- The base directory snapshot to compare against
Sourcepub fn chown(
&self,
path: impl Into<String>,
owner: impl Into<String>,
) -> Directory
pub fn chown( &self, path: impl Into<String>, owner: impl Into<String>, ) -> Directory
Change the owner of the directory contents recursively.
§Arguments
path- Path of the directory to change ownership of (e.g., “/”).owner- A user:group to set for the mounted directory and its contents.
The user and group must be an ID (1000:1000), not a name (foo:bar).
If the group is omitted, it defaults to the same as the user.
Sourcepub fn diff(&self, other: impl IntoID<DirectoryId>) -> Directory
pub fn diff(&self, other: impl IntoID<DirectoryId>) -> Directory
Return the difference between this directory and an another directory. The difference is encoded as a directory.
§Arguments
other- The directory to compare against
Sourcepub async fn digest(&self) -> Result<String, DaggerError>
pub async fn digest(&self) -> Result<String, DaggerError>
Return the directory’s digest. The format of the digest is not guaranteed to be stable between releases of Dagger. It is guaranteed to be stable between invocations of the same Dagger engine.
Sourcepub fn directory(&self, path: impl Into<String>) -> Directory
pub fn directory(&self, path: impl Into<String>) -> Directory
Retrieves a directory at the given path.
§Arguments
path- Location of the directory to retrieve. Example: “/src”
Sourcepub fn docker_build(&self) -> Container
pub fn docker_build(&self) -> Container
Use Dockerfile compatibility to build a container from this directory. Only use this function for Dockerfile compatibility. Otherwise use the native Container type directly, it is feature-complete and supports all Dockerfile features.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn docker_build_opts<'a>(
&self,
opts: DirectoryDockerBuildOpts<'a>,
) -> Container
pub fn docker_build_opts<'a>( &self, opts: DirectoryDockerBuildOpts<'a>, ) -> Container
Use Dockerfile compatibility to build a container from this directory. Only use this function for Dockerfile compatibility. Otherwise use the native Container type directly, it is feature-complete and supports all Dockerfile features.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn entries(&self) -> Result<Vec<String>, DaggerError>
pub async fn entries(&self) -> Result<Vec<String>, DaggerError>
Returns a list of files and directories at the given path.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn entries_opts<'a>(
&self,
opts: DirectoryEntriesOpts<'a>,
) -> Result<Vec<String>, DaggerError>
pub async fn entries_opts<'a>( &self, opts: DirectoryEntriesOpts<'a>, ) -> Result<Vec<String>, DaggerError>
Returns a list of files and directories at the given path.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn exists(&self, path: impl Into<String>) -> Result<bool, DaggerError>
pub async fn exists(&self, path: impl Into<String>) -> Result<bool, DaggerError>
check if a file or directory exists
§Arguments
path- Path to check (e.g., “/file.txt”).opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn exists_opts(
&self,
path: impl Into<String>,
opts: DirectoryExistsOpts,
) -> Result<bool, DaggerError>
pub async fn exists_opts( &self, path: impl Into<String>, opts: DirectoryExistsOpts, ) -> Result<bool, DaggerError>
check if a file or directory exists
§Arguments
path- Path to check (e.g., “/file.txt”).opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn export(
&self,
path: impl Into<String>,
) -> Result<String, DaggerError>
pub async fn export( &self, path: impl Into<String>, ) -> Result<String, DaggerError>
Writes the contents of the directory to a path on the host.
§Arguments
path- Location of the copied directory (e.g., “logs/”).opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn export_opts(
&self,
path: impl Into<String>,
opts: DirectoryExportOpts,
) -> Result<String, DaggerError>
pub async fn export_opts( &self, path: impl Into<String>, opts: DirectoryExportOpts, ) -> Result<String, DaggerError>
Writes the contents of the directory to a path on the host.
§Arguments
path- Location of the copied directory (e.g., “logs/”).opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn file(&self, path: impl Into<String>) -> File
pub fn file(&self, path: impl Into<String>) -> File
Retrieve a file at the given path.
§Arguments
path- Location of the file to retrieve (e.g., “README.md”).
Sourcepub fn filter(&self) -> Directory
pub fn filter(&self) -> Directory
Return a snapshot with some paths included or excluded
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn filter_opts<'a>(&self, opts: DirectoryFilterOpts<'a>) -> Directory
pub fn filter_opts<'a>(&self, opts: DirectoryFilterOpts<'a>) -> Directory
Return a snapshot with some paths included or excluded
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn find_up(
&self,
name: impl Into<String>,
start: impl Into<String>,
) -> Result<String, DaggerError>
pub async fn find_up( &self, name: impl Into<String>, start: impl Into<String>, ) -> Result<String, DaggerError>
Search up the directory tree for a file or directory, and return its path. If no match, return null
§Arguments
name- The name of the file or directory to search forstart- The path to start the search from
Sourcepub async fn glob(
&self,
pattern: impl Into<String>,
) -> Result<Vec<String>, DaggerError>
pub async fn glob( &self, pattern: impl Into<String>, ) -> Result<Vec<String>, DaggerError>
Returns a list of files and directories that matche the given pattern.
§Arguments
pattern- Pattern to match (e.g., “*.md”).
Sourcepub async fn id(&self) -> Result<DirectoryId, DaggerError>
pub async fn id(&self) -> Result<DirectoryId, DaggerError>
A unique identifier for this Directory.
Sourcepub async fn name(&self) -> Result<String, DaggerError>
pub async fn name(&self) -> Result<String, DaggerError>
Returns the name of the directory.
Sourcepub fn search(&self, pattern: impl Into<String>) -> Vec<SearchResult>
pub fn search(&self, pattern: impl Into<String>) -> Vec<SearchResult>
Searches for content matching the given regular expression or literal string. Uses Rust regex syntax; escape literal ., [, ], {, }, | with backslashes.
§Arguments
pattern- The text to match.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn search_opts<'a>(
&self,
pattern: impl Into<String>,
opts: DirectorySearchOpts<'a>,
) -> Vec<SearchResult>
pub fn search_opts<'a>( &self, pattern: impl Into<String>, opts: DirectorySearchOpts<'a>, ) -> Vec<SearchResult>
Searches for content matching the given regular expression or literal string. Uses Rust regex syntax; escape literal ., [, ], {, }, | with backslashes.
§Arguments
pattern- The text to match.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub async fn sync(&self) -> Result<DirectoryId, DaggerError>
pub async fn sync(&self) -> Result<DirectoryId, DaggerError>
Force evaluation in the engine.
Sourcepub fn terminal(&self) -> Directory
pub fn terminal(&self) -> Directory
Opens an interactive terminal in new container with this directory mounted inside.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn terminal_opts<'a>(&self, opts: DirectoryTerminalOpts<'a>) -> Directory
pub fn terminal_opts<'a>(&self, opts: DirectoryTerminalOpts<'a>) -> Directory
Opens an interactive terminal in new container with this directory mounted inside.
§Arguments
opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_changes(&self, changes: impl IntoID<ChangesetId>) -> Directory
pub fn with_changes(&self, changes: impl IntoID<ChangesetId>) -> Directory
Return a directory with changes from another directory applied to it.
§Arguments
changes- Changes to apply to the directory
Sourcepub fn with_directory(
&self,
path: impl Into<String>,
source: impl IntoID<DirectoryId>,
) -> Directory
pub fn with_directory( &self, path: impl Into<String>, source: impl IntoID<DirectoryId>, ) -> Directory
Return a snapshot with a directory added
§Arguments
path- Location of the written directory (e.g., “/src/”).source- Identifier of the directory to copy.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_directory_opts<'a>(
&self,
path: impl Into<String>,
source: impl IntoID<DirectoryId>,
opts: DirectoryWithDirectoryOpts<'a>,
) -> Directory
pub fn with_directory_opts<'a>( &self, path: impl Into<String>, source: impl IntoID<DirectoryId>, opts: DirectoryWithDirectoryOpts<'a>, ) -> Directory
Return a snapshot with a directory added
§Arguments
path- Location of the written directory (e.g., “/src/”).source- Identifier of the directory to copy.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_error(&self, err: impl Into<String>) -> Directory
pub fn with_error(&self, err: impl Into<String>) -> Directory
Raise an error.
§Arguments
err- Message of the error to raise. If empty, the error will be ignored.
Sourcepub fn with_file(
&self,
path: impl Into<String>,
source: impl IntoID<FileId>,
) -> Directory
pub fn with_file( &self, path: impl Into<String>, source: impl IntoID<FileId>, ) -> Directory
Retrieves this directory plus the contents of the given file copied to the given path.
§Arguments
path- Location of the copied file (e.g., “/file.txt”).source- Identifier of the file to copy.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_file_opts<'a>(
&self,
path: impl Into<String>,
source: impl IntoID<FileId>,
opts: DirectoryWithFileOpts<'a>,
) -> Directory
pub fn with_file_opts<'a>( &self, path: impl Into<String>, source: impl IntoID<FileId>, opts: DirectoryWithFileOpts<'a>, ) -> Directory
Retrieves this directory plus the contents of the given file copied to the given path.
§Arguments
path- Location of the copied file (e.g., “/file.txt”).source- Identifier of the file to copy.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_files(
&self,
path: impl Into<String>,
sources: Vec<FileId>,
) -> Directory
pub fn with_files( &self, path: impl Into<String>, sources: Vec<FileId>, ) -> Directory
Retrieves this directory plus the contents of the given files copied to the given path.
§Arguments
path- Location where copied files should be placed (e.g., “/src”).sources- Identifiers of the files to copy.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_files_opts(
&self,
path: impl Into<String>,
sources: Vec<FileId>,
opts: DirectoryWithFilesOpts,
) -> Directory
pub fn with_files_opts( &self, path: impl Into<String>, sources: Vec<FileId>, opts: DirectoryWithFilesOpts, ) -> Directory
Retrieves this directory plus the contents of the given files copied to the given path.
§Arguments
path- Location where copied files should be placed (e.g., “/src”).sources- Identifiers of the files to copy.opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_new_directory(&self, path: impl Into<String>) -> Directory
pub fn with_new_directory(&self, path: impl Into<String>) -> Directory
Retrieves this directory plus a new directory created at the given path.
§Arguments
path- Location of the directory created (e.g., “/logs”).opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_new_directory_opts(
&self,
path: impl Into<String>,
opts: DirectoryWithNewDirectoryOpts,
) -> Directory
pub fn with_new_directory_opts( &self, path: impl Into<String>, opts: DirectoryWithNewDirectoryOpts, ) -> Directory
Retrieves this directory plus a new directory created at the given path.
§Arguments
path- Location of the directory created (e.g., “/logs”).opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_new_file(
&self,
path: impl Into<String>,
contents: impl Into<String>,
) -> Directory
pub fn with_new_file( &self, path: impl Into<String>, contents: impl Into<String>, ) -> Directory
Return a snapshot with a new file added
§Arguments
path- Path of the new file. Example: “foo/bar.txt”contents- Contents of the new file. Example: “Hello world!”opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_new_file_opts(
&self,
path: impl Into<String>,
contents: impl Into<String>,
opts: DirectoryWithNewFileOpts,
) -> Directory
pub fn with_new_file_opts( &self, path: impl Into<String>, contents: impl Into<String>, opts: DirectoryWithNewFileOpts, ) -> Directory
Return a snapshot with a new file added
§Arguments
path- Path of the new file. Example: “foo/bar.txt”contents- Contents of the new file. Example: “Hello world!”opt- optional argument, see inner type for documentation, use_opts to use
Sourcepub fn with_patch(&self, patch: impl Into<String>) -> Directory
pub fn with_patch(&self, patch: impl Into<String>) -> Directory
Retrieves this directory with the given Git-compatible patch applied.
§Arguments
patch- Patch to apply (e.g., “diff –git a/file.txt b/file.txt\nindex 1234567..abcdef8 100644\n— a/file.txt\n+++ b/file.txt\n@@ -1,1 +1,1 @@\n-Hello\n+World\n”).
Sourcepub fn with_patch_file(&self, patch: impl IntoID<FileId>) -> Directory
pub fn with_patch_file(&self, patch: impl IntoID<FileId>) -> Directory
Retrieves this directory with the given Git-compatible patch file applied.
§Arguments
patch- File containing the patch to apply
Sourcepub fn with_symlink(
&self,
target: impl Into<String>,
link_name: impl Into<String>,
) -> Directory
pub fn with_symlink( &self, target: impl Into<String>, link_name: impl Into<String>, ) -> Directory
Return a snapshot with a symlink
§Arguments
target- Location of the file or directory to link to (e.g., “/existing/file”).link_name- Location where the symbolic link will be created (e.g., “/new-file-link”).
Sourcepub fn with_timestamps(&self, timestamp: isize) -> Directory
pub fn with_timestamps(&self, timestamp: isize) -> Directory
Retrieves this directory with all file/dir timestamps set to the given time.
§Arguments
timestamp- Timestamp to set dir/files in.
Formatted in seconds following Unix epoch (e.g., 1672531199).
Sourcepub fn without_directory(&self, path: impl Into<String>) -> Directory
pub fn without_directory(&self, path: impl Into<String>) -> Directory
Return a snapshot with a subdirectory removed
§Arguments
path- Path of the subdirectory to remove. Example: “.github/workflows”