pub struct PanelHandle { /* private fields */ }Expand description
A mounted panel’s resources and the router’s database, which a background job keeps to build a context per run without declaring the panel again. 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, as Panel::context builds: 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