Skip to main content

dagger_sdk/
lib.rs

1pub mod core;
2pub mod errors;
3
4pub mod logging;
5mod querybuilder;
6
7pub use crate::core::config::Config;
8
9#[cfg(feature = "gen")]
10#[allow(dead_code)]
11mod client;
12
13#[cfg(feature = "gen")]
14#[allow(dead_code)]
15mod gen;
16
17#[cfg(feature = "gen")]
18pub use client::*;
19
20#[cfg(feature = "gen")]
21pub use gen::*;
22
23pub mod id {
24    use std::pin::Pin;
25
26    use crate::errors::DaggerError;
27
28    pub trait IntoID<T>: Sized + Clone + Sync + Send + 'static {
29        fn into_id(
30            self,
31        ) -> Pin<Box<dyn core::future::Future<Output = Result<T, DaggerError>> + Send>>;
32    }
33}
34
35pub use querybuilder::Selection;
36
37pub mod loadable {
38    use std::sync::Arc;
39
40    use crate::core::cli_session::DaggerSessionProc;
41    use crate::core::graphql_client::DynGraphQLClient;
42    use crate::querybuilder::Selection;
43
44    /// Types that can be loaded from an ID via `node(id:)` + inline
45    /// fragments. Every generated object and interface client type
46    /// with an `id` field implements this.
47    pub trait Loadable: Sized {
48        /// The GraphQL type name (e.g. `"Container"`).
49        fn graphql_type() -> &'static str;
50
51        /// Construct this type from a query selection.
52        fn from_query(
53            proc: Option<Arc<DaggerSessionProc>>,
54            selection: Selection,
55            graphql_client: DynGraphQLClient,
56        ) -> Self;
57    }
58}