pub struct PanelHandle { /* private fields */ }Expand description
A panel’s mounted resources and its database, which a background job or a test keeps to build
a context per run without declaring the panel again. A router’s mounted panel gives it through
panel_handle, a panel no router mounts through
Panel::handle. Cloning it is cheap.
let builder = Router::builder()
.discover()
.app_context(db)
.panel(Panel::new("admin").resource::<PostResource>())?;
let admin = builder.panel_handle("admin").expect("mounted above");
let router = builder.build();
// In the job, once per run:
let cx = admin.context().with(Tenant(tenant));
let posts = scoped_query::<PostResource>(&cx)?;Implementations§
Source§impl PanelHandle
impl PanelHandle
Sourcepub fn context(&self) -> Cx
pub fn context(&self) -> Cx
A context outside any request in which the panel’s resources answer as the panel mounted
them: what a job or a test passes to scoped_query,
can, write_create and the other entry points that
answer from a mounted def. It holds the database and the resources, and no request,
session or tenant. Add a tenant with cx.with(Tenant(id)).
The context is one unit of work, as a request is: loads it memoizes stay cached for its lifetime, so a job builds one per run.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PanelHandle
impl !UnwindSafe for PanelHandle
impl Freeze for PanelHandle
impl Send for PanelHandle
impl Sync for PanelHandle
impl Unpin for PanelHandle
impl UnsafeUnpin for PanelHandle
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
Mutably borrows from an owned value. Read more