pub struct ArclyPluginContext { /* private fields */ }Implementations§
Source§impl ArclyPluginContext
impl ArclyPluginContext
Sourcepub fn provide<T: Send + Sync + 'static>(&mut self, value: T)
pub fn provide<T: Send + Sync + 'static>(&mut self, value: T)
Inject a singleton of type T into the DI container. Resolves later
via Inject<T> in any controller / service / interceptor.
Order: every plugin’s on_init runs first, then all provide<T>
closures are applied in declaration order, then the container
freezes. So one plugin can read another’s provision in on_start
but not in on_init.
If T already has an #[Injectable] provider, launch fails loudly —
use override_provider to replace it
intentionally.
Sourcepub fn override_provider<T: Send + Sync + 'static>(&mut self, value: T)
pub fn override_provider<T: Send + Sync + 'static>(&mut self, value: T)
Replace a core #[Injectable] provider with this instance. The
descriptor is discarded; every Inject<T> in the app resolves to the
plugin’s value. Happens before the container freezes, so the swap is
race-free and the hot path stays lock-free.
Sourcepub fn add_interceptor(&mut self, ic: impl Interceptor)
pub fn add_interceptor(&mut self, ic: impl Interceptor)
Attach a boundary filter that runs on every request before the
body is read — the cheap early-reject point for signature checks,
IP allowlists, and rate limits. Returning Break(resp) short-circuits
without paying for body buffering or context assembly.
Ergonomic twin of Self::register_global_interceptor: takes ownership
and leaks internally (interceptors are process-lifetime objects) —
no Box::leak ceremony in plugin code.
Sourcepub fn add_boundary_filter(&mut self, f: impl BoundaryFilter)
pub fn add_boundary_filter(&mut self, f: impl BoundaryFilter)
Ergonomic twin of Self::register_boundary_filter: takes ownership and
leaks internally.
pub fn register_boundary_filter(&mut self, f: &'static dyn BoundaryFilter)
Sourcepub fn add_route<F, Fut>(
&mut self,
method: HttpMethod,
path: impl Into<String>,
handler: F,
)
pub fn add_route<F, Fut>( &mut self, method: HttpMethod, path: impl Into<String>, handler: F, )
Register a route. The handler receives a fully-built RequestContext
— including DI access via ctx.inject::<T>() — and returns a
Response. The path is mounted verbatim under the application root.
The path may be built at runtime (e.g. a config-driven prefix); it is
leaked to &'static str, which is fine because routes live for the
whole process anyway.
Sourcepub fn add_get<F, Fut>(&mut self, path: impl Into<String>, handler: F)
pub fn add_get<F, Fut>(&mut self, path: impl Into<String>, handler: F)
Shortcut: register a GET.
Sourcepub fn modify_openapi<F>(&mut self, f: F)
pub fn modify_openapi<F>(&mut self, f: F)
Mutate the assembled OpenAPI document at launch time.
Sourcepub fn require_env(&self, key: &str) -> Result<String, PluginError>
pub fn require_env(&self, key: &str) -> Result<String, PluginError>
Read a required environment variable.
Returns Err(PluginError) with stage Init if the variable is absent
or contains non-UTF-8 bytes, so callers can propagate it cleanly with ?.
Sourcepub fn env_or(&self, key: &str, default: impl Into<String>) -> String
pub fn env_or(&self, key: &str, default: impl Into<String>) -> String
Read an environment variable with a fallback default.
Sourcepub fn register_global_interceptor(&mut self, ic: &'static dyn Interceptor)
pub fn register_global_interceptor(&mut self, ic: &'static dyn Interceptor)
Attach an interceptor that fires on every mounted route — macro
routes and plugin-registered routes alike. Global interceptors compose
as the outermost layers, in registration order (first registered =
outermost), around any per-route #[UseInterceptors] chain.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ArclyPluginContext
impl !Sync for ArclyPluginContext
impl !UnwindSafe for ArclyPluginContext
impl Freeze for ArclyPluginContext
impl Send for ArclyPluginContext
impl Unpin for ArclyPluginContext
impl UnsafeUnpin for ArclyPluginContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request