#[ext]Expand description
Declares extension methods and optionally gives each method a first-order operation type.
Arguments unrelated to defunctionalization are forwarded to extend::ext.
Plain defunc produces a hidden *Operation<Context> type implementing
OperationAlg and ApplyAlg. When every method already builds first-order
route syntax from routes(), plain defunc names those inferred programs
directly. A backend such as defunc(via = http) or defunc(via = jsonrpc)
additionally lifts convenient method references while producing named programs
and their interpreter evidence.
ⓘ
use alux_ext::ext;
#[ext(name = CounterExt, defunc)]
impl<This> This
where
This: CounterAlg,
{
async fn incremented(&self, by: u32) -> u32 {
self.increment(by).await
}
}
// The expansion also defines `IncrementedOperation<This>`.ⓘ
use alux_ext::ext;
use alux_http::http;
#[ext(name = StatusRoutesExt, defunc(via = http))]
impl<This> This
where
This: HttpApiAlg + JsonOutAlg,
{
/// Declares the status surface.
fn status_routes<Alg>(&self)
where
Alg: StatusAlg,
{
self.routes().get("/status", self.op(Alg::status_current).json())
}
}
// The expansion also defines `StatusRoutesProgram<Alg>`.