pub struct LayoutData<'f, T: 'static>(/* private fields */);Expand description
The data loaded by the nearest layout around the view that loaded a T: what
Parent is to loads, for views.
use egui::Ui;
use egui_kit::Rejection;
use egui_kit::extract::LayoutData;
use egui_kit::page::{Layout, Outlet, Page};
struct Workspace {
name: String,
}
async fn load_workspace() -> Result<Workspace, Rejection> {
Ok(Workspace { name: "Physio".into() })
}
// Takes its data as `&Workspace`, so the views below can read it too.
fn workspace_layout(ui: &mut Ui, mut outlet: Outlet, workspace: &Workspace) {
ui.heading(&workspace.name);
outlet.show(ui);
}
fn settings(ui: &mut Ui, workspace: LayoutData<Workspace>) {
ui.label(format!("Settings of {}", workspace.name));
}
let router = egui_kit::Router::<()>::new()
.layout(Layout::with_load(load_workspace, workspace_layout))
.page("/settings", Page::new(settings));§Panics
When no layout around the view loaded a T, or when the one that did takes its data as
&mut T in its view: it can’t be read while that view runs (and the views below run inside
it). Take it as &T to share it.
Trait Implementations§
Source§impl<T: Debug> Debug for LayoutData<'_, T>
impl<T: Debug> Debug for LayoutData<'_, T>
Source§impl<T> Deref for LayoutData<'_, T>
impl<T> Deref for LayoutData<'_, T>
Source§impl<S: 'static, D, T: 'static> FromView<S, D> for LayoutData<'_, T>
impl<S: 'static, D, T: 'static> FromView<S, D> for LayoutData<'_, T>
type Item<'f> = LayoutData<'f, T>
fn from_view<'f>(cx: &'f ViewContext<'_, S>) -> LayoutData<'f, T>
Auto Trait Implementations§
impl<'f, T> !RefUnwindSafe for LayoutData<'f, T>
impl<'f, T> !Send for LayoutData<'f, T>
impl<'f, T> !Sync for LayoutData<'f, T>
impl<'f, T> !UnwindSafe for LayoutData<'f, T>
impl<'f, T> Freeze for LayoutData<'f, T>
impl<'f, T> Unpin for LayoutData<'f, T>
impl<'f, T> UnsafeUnpin for LayoutData<'f, T>where
Ref<'f, T>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more