macro_rules! bare_resource_options {
($resource:ty) => { ... };
}Available on crate feature
runtime only.Expand description
The options a resource mounted with NO document section runs at — Some at the options’
Default, None where the type has none.
bare_options!’s sibling one tier over, and the probe under it is the
same one for the same reason: the answer exists only where the type is CONCRETE, so a macro is
what puts the question at a call site that has one. What differs is the projection — a resource’s
options are <R as AsyncResource>::Options — and what does not is everything else, including the
honest tooth BareOptions records.
It is what the emitted create walk hands
declared_resource for a #[ingraph(resource)] field: the
section where the deployment wrote one, and this where it did not.
§Examples
use ingraph::AsyncResource;
struct Egemma;
struct EgemmaOptions {
weights: String,
}
impl AsyncResource for Egemma {
type Options = EgemmaOptions;
type Error = core::convert::Infallible;
async fn build(_ctx: &Resources, _options: EgemmaOptions) -> Result<Self, Self::Error> {
Ok(Self)
}
}
// No `Default`, so a resource nobody wrote a section for has nothing to load from.
assert!(ingraph::bare_resource_options!(Egemma).is_none());
struct Clock;
impl AsyncResource for Clock {
type Options = ();
type Error = core::convert::Infallible;
async fn build(_ctx: &Resources, (): ()) -> Result<Self, Self::Error> {
Ok(Self)
}
}
// A zero-knob resource needs no section at all.
assert_eq!(ingraph::bare_resource_options!(Clock), Some(()));