Skip to main content

Query

Struct Query 

Source
pub struct Query {
    pub proc: Option<Arc<DaggerSessionProc>>,
    pub selection: Selection,
    pub graphql_client: DynGraphQLClient,
}

Fields§

§proc: Option<Arc<DaggerSessionProc>>§selection: Selection§graphql_client: DynGraphQLClient

Implementations§

Source§

impl Query

Source

pub fn ref<T: Loadable>(&self, id: impl IntoID<Id>) -> T

Return a lazy reference to a node by its ID without making a network call. The returned value can be used to chain further queries.

ⓘ
let ctr: Container = client.r#ref(id);
let out = ctr.with_exec(vec!["echo", "hi"]).stdout().await?;
Source

pub async fn load<T: Loadable>( &self, id: impl IntoID<Id>, ) -> Result<T, DaggerError>

Load a node by its ID with type safety. Verifies the node exists and matches the expected type before returning.

ⓘ
let ctr: Container = client.load(id).await?;
Source§

impl Query

Source

pub async fn id(&self) -> Result<Id, DaggerError>

A unique identifier for this Query.

Source

pub async fn node( &self, id: impl IntoID<Id>, ) -> Result<Option<NodeClient>, DaggerError>

Load any object by its ID.

Source

pub async fn version(&self) -> Result<String, DaggerError>

Get the current Dagger Engine version.

Source

pub async fn current_timestamp(&self) -> Result<String, DaggerError>

The current UTC time in RFC3339 format. Never cached.

Source

pub async fn set_session_title( &self, title: impl Into<String>, ) -> Result<Void, DaggerError>

Name the current session. The title renames the session wherever its telemetry is shown (the calling client’s primary span, e.g. the CLI’s command span) and labels its engine archive, as listed by dagger agent –resume. The latest title wins. Only the session’s main client may set it.

§Arguments
  • title - The title, sanitized to a single printable line.
Source

pub fn directory(&self) -> Directory

Creates an empty directory.

Source

pub fn changeset(&self) -> Changeset

Creates an empty changeset

Source

pub fn file(&self, name: impl Into<String>, contents: impl Into<String>) -> File

Creates a file with the specified contents.

§Arguments
  • name - Name of the new file. Example: “foo.txt”
  • contents - Contents of the new file. Example: “Hello world!”
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn file_opts( &self, name: impl Into<String>, contents: impl Into<String>, opts: QueryFileOpts, ) -> File

Creates a file with the specified contents.

§Arguments
  • name - Name of the new file. Example: “foo.txt”
  • contents - Contents of the new file. Example: “Hello world!”
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn blob(&self, name: impl Into<String>, contents: Bytes) -> File

Creates a file from arbitrary binary contents.

§Arguments
  • name - Name of the new file. Example: “archive.tar”
  • contents - Binary contents of the new file, encoded as base64 at the GraphQL boundary.
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn blob_opts( &self, name: impl Into<String>, contents: Bytes, opts: QueryBlobOpts, ) -> File

Creates a file from arbitrary binary contents.

§Arguments
  • name - Name of the new file. Example: “archive.tar”
  • contents - Binary contents of the new file, encoded as base64 at the GraphQL boundary.
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn git(&self, url: impl Into<String>) -> GitRepository

Queries a Git repository.

§Arguments
  • url - URL of the git repository.

Can be formatted as https://{host}/{owner}/{repo}, git@{host}:{owner}/{repo}.

Suffix “.git” is optional.

  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn git_opts<'a>( &self, url: impl Into<String>, opts: QueryGitOpts<'a>, ) -> GitRepository

Queries a Git repository.

§Arguments
  • url - URL of the git repository.

Can be formatted as https://{host}/{owner}/{repo}, git@{host}:{owner}/{repo}.

Suffix “.git” is optional.

  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn container(&self) -> Container

Creates a scratch container, with no image or metadata. To pull an image, follow up with the “from” function.

§Arguments
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn container_opts(&self, opts: QueryContainerOpts) -> Container

Creates a scratch container, with no image or metadata. To pull an image, follow up with the “from” function.

§Arguments
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn cache_volume(&self, key: impl Into<String>) -> CacheVolume

Constructs a cache volume for a given cache key.

§Arguments
  • key - A string identifier to target this cache volume (e.g., “modules-cache”).
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn cache_volume_opts<'a>( &self, key: impl Into<String>, opts: QueryCacheVolumeOpts<'a>, ) -> CacheVolume

Constructs a cache volume for a given cache key.

§Arguments
  • key - A string identifier to target this cache volume (e.g., “modules-cache”).
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn engine_volume(&self, name: impl Into<String>) -> Volume

Constructs an engine-managed volume backed by operator-provided storage beneath the configured engine state root.

§Arguments
  • name - Canonical slash-separated volume name beneath the engine volume namespace.
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn engine_volume_opts<'a>( &self, name: impl Into<String>, opts: QueryEngineVolumeOpts<'a>, ) -> Volume

Constructs an engine-managed volume backed by operator-provided storage beneath the configured engine state root.

§Arguments
  • name - Canonical slash-separated volume name beneath the engine volume namespace.
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn sshfs_volume( &self, endpoint: impl Into<String>, private_key: impl IntoID<Id>, ) -> Volume

Constructs an SSHFS volume.

§Arguments
  • endpoint - SSHFS endpoint URL in the form sshfs://user@host[:port]/absolute/path.
  • private_key - Private key secret used to authenticate to the remote host.
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn sshfs_volume_opts<'a>( &self, endpoint: impl Into<String>, private_key: impl IntoID<Id>, opts: QuerySshfsVolumeOpts<'a>, ) -> Volume

Constructs an SSHFS volume.

§Arguments
  • endpoint - SSHFS endpoint URL in the form sshfs://user@host[:port]/absolute/path.
  • private_key - Private key secret used to authenticate to the remote host.
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn secret(&self, uri: impl Into<String>) -> Secret

Creates a new secret.

§Arguments
  • uri - The URI of the secret store
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn secret_opts<'a>( &self, uri: impl Into<String>, opts: QuerySecretOpts<'a>, ) -> Secret

Creates a new secret.

§Arguments
  • uri - The URI of the secret store
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn set_secret( &self, name: impl Into<String>, plaintext: impl Into<String>, ) -> Secret

Sets a secret given a user defined name to its plaintext and returns the secret. The plaintext value is limited to a size of 128000 bytes.

§Arguments
  • name - The user defined name for this secret
  • plaintext - The plaintext of the secret
Source

pub fn host(&self) -> Host

Queries the host environment.

Source

pub fn http(&self, url: impl Into<String>) -> File

Returns a file containing an http remote url content.

§Arguments
  • url - HTTP url to get the content from (e.g., “https://docs.dagger.io”).
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn http_opts<'a>( &self, url: impl Into<String>, opts: QueryHttpOpts<'a>, ) -> File

Returns a file containing an http remote url content.

§Arguments
  • url - HTTP url to get the content from (e.g., “https://docs.dagger.io”).
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub async fn default_platform(&self) -> Result<Platform, DaggerError>

The default platform of the engine.

Source

pub fn module_source(&self, ref_string: impl Into<String>) -> ModuleSource

Create a new module source instance from a source ref string

§Arguments
  • ref_string - The string ref representation of the module source
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn module_source_opts<'a>( &self, ref_string: impl Into<String>, opts: QueryModuleSourceOpts<'a>, ) -> ModuleSource

Create a new module source instance from a source ref string

§Arguments
  • ref_string - The string ref representation of the module source
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn module(&self) -> Module

Create a new module.

Source

pub fn type_def(&self) -> TypeDef

Create a new TypeDef.

Source

pub fn generated_code(&self, code: impl IntoID<Id>) -> GeneratedCode

Create a code generation result, given a directory containing the generated code.

Source

pub fn function( &self, name: impl Into<String>, return_type: impl IntoID<Id>, ) -> Function

Creates a function.

§Arguments
  • name - Name of the function, in its original format from the implementation language.
  • return_type - Return type of the function.
Source

pub fn source_map( &self, filename: impl Into<String>, line: isize, column: isize, ) -> SourceMap

Creates source map metadata.

§Arguments
  • filename - The filename from the module source.
  • line - The line number within the filename.
  • column - The column number within the line.
Source

pub fn current_module(&self) -> CurrentModule

The module currently being served in the session, if any.

Source

pub async fn current_type_defs(&self) -> Result<Vec<TypeDef>, DaggerError>

The TypeDef representations of the objects currently being served in the session.

§Arguments
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub async fn current_type_defs_opts( &self, opts: QueryCurrentTypeDefsOpts, ) -> Result<Vec<TypeDef>, DaggerError>

The TypeDef representations of the objects currently being served in the session.

§Arguments
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn current_function_call(&self) -> FunctionCall

The FunctionCall context that the SDK caller is currently executing in. If the caller is not currently executing in a function, this will return an error.

Source

pub async fn serve_module( &self, address: impl Into<String>, ) -> Result<Void, DaggerError>

Load the module at the given address and serve its API in the current session. A local address resolves against the caller’s workspace, so a generated client can serve the module it is bound to without reaching for the workspace itself.

§Arguments
  • address - A module address, or an explicit path into the caller’s workspace.

Absolute paths (e.g. “/.dagger/modules/hello”) resolve from the workspace root, relative ones (e.g. “./hello”) from the workspace cwd.

Installed module names are not accepted.

  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub async fn serve_module_opts<'a>( &self, address: impl Into<String>, opts: QueryServeModuleOpts<'a>, ) -> Result<Void, DaggerError>

Load the module at the given address and serve its API in the current session. A local address resolves against the caller’s workspace, so a generated client can serve the module it is bound to without reaching for the workspace itself.

§Arguments
  • address - A module address, or an explicit path into the caller’s workspace.

Absolute paths (e.g. “/.dagger/modules/hello”) resolve from the workspace root, relative ones (e.g. “./hello”) from the workspace cwd.

Installed module names are not accepted.

  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn current_node(&self) -> NodeClient

The object that received the current module function call, as a Node. Errors when there is no current call, or the call is top-level (e.g. a module constructor).

Source

pub fn error(&self, message: impl Into<String>) -> Error

Create a new error.

§Arguments
  • message - A brief description of the error.
Source

pub fn engine(&self) -> Engine

The Dagger engine container configuration and state

Source

pub fn cloud(&self) -> Cloud

Dagger Cloud configuration and state

Source

pub fn llm(&self) -> Llm

Initialize a new LLM conversation.

§Arguments
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn llm_opts<'a>(&self, opts: QueryLlmOpts<'a>) -> Llm

Initialize a new LLM conversation.

§Arguments
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn llm_content(&self) -> LlmContent

Start an empty run of text and media content, independent of any conversation. Add blocks with withText, withFile, and withData. A function exposed as an LLM tool can return the content to give the model text and media as the tool’s result, e.g. a caption and a screenshot for the model to look at.

Source

pub fn json(&self) -> JsonValue

Initialize a JSON value

Source

pub fn identifier(&self, name: impl Into<String>) -> Identifier

Parse a name in any casing into words. Known acronyms and terms come from the naming dictionary; everything else falls back to the case heuristic. Errors on non-ASCII input, input with no letters or digits, or input over 256 bytes.

§Arguments
  • name - The name to parse.
Source

pub async fn format_identifiers( &self, names: Vec<impl Into<String>>, casing: Casing, ) -> Result<Vec<String>, DaggerError>

Format many names at once, for codegen. Returns them in input order.

§Arguments
  • names - The names to format, in any casing.
  • casing - The casing to format the names in.
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub async fn format_identifiers_opts<'a>( &self, names: Vec<impl Into<String>>, casing: Casing, opts: QueryFormatIdentifiersOpts<'a>, ) -> Result<Vec<String>, DaggerError>

Format many names at once, for codegen. Returns them in input order.

§Arguments
  • names - The names to format, in any casing.
  • casing - The casing to format the names in.
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub async fn naming_dictionary(&self) -> Result<Vec<NamingTerm>, DaggerError>

The acronyms and terms used to parse and format identifiers.

Source

pub fn schema(&self, json: Json) -> Schema

Load a GraphQL introspection schema for merging.

§Arguments
  • json - The introspection schema JSON to load.
Source

pub fn env_file(&self) -> EnvFile

Initialize an environment file

§Arguments
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn env_file_opts(&self, opts: QueryEnvFileOpts) -> EnvFile

Initialize an environment file

§Arguments
  • opt - optional argument, see inner type for documentation, use _opts to use
Source

pub fn address(&self, value: impl Into<String>) -> Address

Resolve external references only.

Source

pub fn current_workspace(&self) -> Workspace

Detect and return the current workspace.

Trait Implementations§

Source§

impl Clone for Query

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl IntoID<Id> for Query

Source§

fn into_id( self, ) -> Pin<Box<dyn Future<Output = Result<Id, DaggerError>> + Send>>

Source§

impl Loadable for Query

Source§

fn graphql_type() -> &'static str

The GraphQL type name (e.g. "Container").
Source§

fn from_query( proc: Option<Arc<DaggerSessionProc>>, selection: Selection, graphql_client: DynGraphQLClient, ) -> Self

Construct this type from a query selection.
Source§

impl Node for Query

Source§

fn id(&self) -> impl Future<Output = Result<Id, DaggerError>> + Send

Auto Trait Implementations§

§

impl !RefUnwindSafe for Query

§

impl !UnwindSafe for Query

§

impl Freeze for Query

§

impl Send for Query

§

impl Sync for Query

§

impl Unpin for Query

§

impl UnsafeUnpin for Query

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more