pub struct SandboxedPlugin { /* private fields */ }Expand description
A sandboxed plugin, ready to mount.
Clone shares the compiled host, the concurrency permits, the capability
backends and the activity log rather than copying them — so registering a
clone with RenderSlots and then installing the
original as a Plugin gives one plugin with one ceiling and one ledger,
not two of each.
Implementations§
Source§impl SandboxedPlugin
impl SandboxedPlugin
Sourcepub fn new(host: SandboxHost) -> Self
pub fn new(host: SandboxHost) -> Self
Wrap an already-compiled host.
Sourcepub fn with_services(self, services: CapabilityServices) -> Self
pub fn with_services(self, services: CapabilityServices) -> Self
Wire the backends this plugin’s granted capabilities need (issue #1632).
Anything left unwired stays unwired: a call to a capability with no
backend is answered
unavailable and
recorded, which is the same shape as every other refusal and not a
silent success.
services.tenant is ignored — the tenant is the request’s, resolved
per request — and services.rate may replace the limiter built from the
manifest, for an embedder that wants one shared across a fleet.
May, not does: a replacement is taken only when it is no looser than
the manifest’s. Sharing limiting state across instances is what this is
for; raising the ceiling is not, and silently allowing it would make the
calls_per_second on the consent screen a number the operator approved
and the plugin need not obey. A looser limiter is ignored and the
manifest’s kept, so wiring one by mistake costs coordination rather than
containment.
Sourcepub fn activity(&self) -> Arc<PluginActivityLog> ⓘ
pub fn activity(&self) -> Arc<PluginActivityLog> ⓘ
What this plugin has done, for the operator audit surface.
Shared with every mounted route, so a caller that keeps this handle sees activity as it happens rather than a copy taken at mount.
Sourcepub fn from_artifact(
artifact: &SandboxArtifact,
) -> Result<Self, SandboxPluginError>
pub fn from_artifact( artifact: &SandboxArtifact, ) -> Result<Self, SandboxPluginError>
Load a verified artifact.
§Errors
Returns SandboxPluginError::Load if the module does not compile or
imports something the sandbox does not provide.
Sourcepub fn from_file(path: &Path) -> Result<Self, SandboxPluginError>
pub fn from_file(path: &Path) -> Result<Self, SandboxPluginError>
Read, verify and load a .autumn-plugin file.
§Errors
Returns SandboxPluginError::Artifact if the file is missing,
malformed, or does not match its declared digest, and
SandboxPluginError::Load if the module cannot be sandboxed.
Sourcepub fn manifest(&self) -> &SandboxManifest
pub fn manifest(&self) -> &SandboxManifest
The manifest this plugin is mounted under.
Sourcepub async fn render_slot(
&self,
slot: &str,
context: &[(String, String)],
) -> Option<String>
pub async fn render_slot( &self, slot: &str, context: &[(String, String)], ) -> Option<String>
Fill one render slot (issue #1632).
Returns None — meaning omit the fragment — for every failure there
is: the slot was not granted, the guest trapped, it ran out of fuel, it
answered with something this build will not emit, or it overran the
render_bytes quota. A render hook is decoration on somebody else’s
page, and there is no failure of a plugin’s that should become a failure
of the page.
Runs on a blocking worker for the same reason a request does, and holds a concurrency permit for the same reason: a slot on a hot page is as many concurrent interpreters as the page has readers.
Sourcepub fn mounted_router<S>(&self) -> Router<S>
pub fn mounted_router<S>(&self) -> Router<S>
This plugin, mounted at the prefix its own manifest declares.
The public door, for a test or an embedder that wants the routes without
an AppBuilder. It nests at self.manifest().prefix and nowhere else:
a caller that could choose the prefix could mount a plugin over a
namespace its manifest never named, and the prefix would stop being a
containment boundary.
Generic over the router’s state because the handlers use none — a sandboxed plugin has no access to application state, which is the point.
Prefer installing it as a Plugin, which also logs the capability
grant and declares the routes for autumn routes and
autumn plugin-check.
Trait Implementations§
Source§impl Clone for SandboxedPlugin
impl Clone for SandboxedPlugin
Source§impl Debug for SandboxedPlugin
impl Debug for SandboxedPlugin
Auto Trait Implementations§
impl !RefUnwindSafe for SandboxedPlugin
impl !UnwindSafe for SandboxedPlugin
impl Freeze for SandboxedPlugin
impl Send for SandboxedPlugin
impl Sync for SandboxedPlugin
impl Unpin for SandboxedPlugin
impl UnsafeUnpin for SandboxedPlugin
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> AutumnCounterCaches for Twhere
T: 'static,
impl<T> AutumnCounterCaches for Twhere
T: 'static,
Source§const HAS_COUNTER_CACHES: bool = false
const HAS_COUNTER_CACHES: bool = false
Source§fn counter_caches() -> &'static [CounterCacheSpec<Self>]
fn counter_caches() -> &'static [CounterCacheSpec<Self>]
Source§impl<T> AutumnDependents for Twhere
T: ?Sized,
impl<T> AutumnDependents for Twhere
T: ?Sized,
Source§fn dependents() -> &'static [RuntimeDependentSpec]
fn dependents() -> &'static [RuntimeDependentSpec]
#[model] overrides via an inherent shadow when dependents exist.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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read moreSource§impl<P> Plugins for Pwhere
P: Plugin,
impl<P> Plugins for Pwhere
P: Plugin,
Source§fn apply(self, app: AppBuilder) -> AppBuilder
fn apply(self, app: AppBuilder) -> AppBuilder
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> RepositoryHooksClone for Twhere
T: Clone,
impl<T> RepositoryHooksClone for Twhere
T: Clone,
Source§fn autumn_clone(&self) -> T
fn autumn_clone(&self) -> T
Source§impl<T, Conn> RunQueryDsl<Conn> for T
impl<T, Conn> RunQueryDsl<Conn> for T
Source§fn execute<'conn, 'query>(
self,
conn: &'conn mut Conn,
) -> <Conn as AsyncConnectionCore>::ExecuteFuture<'conn, 'query>
fn execute<'conn, 'query>( self, conn: &'conn mut Conn, ) -> <Conn as AsyncConnectionCore>::ExecuteFuture<'conn, 'query>
Source§fn load<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
fn load<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
Source§fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnectionCore,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnectionCore,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
Stream] with the returned rows. Read moreSource§fn get_result<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, LoadNext<Pin<Box<Self::Stream<'conn>>>>>
fn get_result<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, LoadNext<Pin<Box<Self::Stream<'conn>>>>>
Source§fn get_results<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
fn get_results<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
Vec with the affected rows. Read moreSource§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.