Skip to main content

LayoutData

Struct LayoutData 

Source
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, Children, 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 children: Children, workspace: &Workspace) {
    ui.heading(&workspace.name);
    children.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>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Deref for LayoutData<'_, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<S: 'static, D, T: 'static> FromView<S, D> for LayoutData<'_, T>

Source§

type Item<'f> = LayoutData<'f, T>

Source§

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> Forget for LayoutData<'f, T>

§

impl<'f, T> Freeze for LayoutData<'f, T>
where Ref<'f, T>: Freeze,

§

impl<'f, T> Move for LayoutData<'f, T>

§

impl<'f, T> Unpin for LayoutData<'f, T>
where Ref<'f, T>: Unpin,

§

impl<'f, T> UnsafeUnpin for LayoutData<'f, T>
where Ref<'f, T>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromRef<S> for S

Source§

fn from_ref(state: &S) -> &S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.