pub struct LayoutLibrary { /* private fields */ }Expand description
Named layouts per view id, for “Save Layout As…” and a layout picker, plus the layout each view opens with.
Plain data: the application stores it where it keeps its settings and serializes it with serde. A view id names the kind of grid (“trades”), not a panel: every panel of a view shares its layouts. Layouts are kept as given; the grid checks their version when it applies one.
Implementations§
Source§impl LayoutLibrary
impl LayoutLibrary
Sourcepub fn insert(
&mut self,
name: impl Into<String>,
layout: GridLayout,
) -> Result<(), LayoutError>
pub fn insert( &mut self, name: impl Into<String>, layout: GridLayout, ) -> Result<(), LayoutError>
Stores layout under its view id and name, replacing a layout with
that name. Fails with LayoutError::MissingViewId if the layout
has no view id.
Sourcepub fn get(&self, view_id: &str, name: &str) -> Option<&GridLayout>
pub fn get(&self, view_id: &str, name: &str) -> Option<&GridLayout>
The layout of a view with this name.
Sourcepub fn names<'a>(
&'a self,
view_id: &str,
) -> impl Iterator<Item = &'a str> + use<'a>
pub fn names<'a>( &'a self, view_id: &str, ) -> impl Iterator<Item = &'a str> + use<'a>
The names of a view’s layouts, sorted by their text (byte order).
Sourcepub fn remove(&mut self, view_id: &str, name: &str) -> Option<GridLayout>
pub fn remove(&mut self, view_id: &str, name: &str) -> Option<GridLayout>
Removes a layout. If it was the view’s default, the view has no default afterwards.
Sourcepub fn rename(
&mut self,
view_id: &str,
from: &str,
to: impl Into<String>,
) -> bool
pub fn rename( &mut self, view_id: &str, from: &str, to: impl Into<String>, ) -> bool
Renames a layout; the default follows it. Returns false, and changes
nothing, if there is no layout from or another layout is named
to.
Sourcepub fn set_default(&mut self, view_id: &str, name: Option<&str>) -> bool
pub fn set_default(&mut self, view_id: &str, name: Option<&str>) -> bool
Sets the layout a view opens with when nothing else is restored, or
clears it with None. Returns false, and changes nothing, if the
view has no layout with that name.
Sourcepub fn default_layout(&self, view_id: &str) -> Option<(&str, &GridLayout)>
pub fn default_layout(&self, view_id: &str) -> Option<(&str, &GridLayout)>
The name and layout a view opens with when nothing else is restored.
Trait Implementations§
Source§impl Clone for LayoutLibrary
impl Clone for LayoutLibrary
Source§fn clone(&self) -> LayoutLibrary
fn clone(&self) -> LayoutLibrary
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LayoutLibrary
impl Debug for LayoutLibrary
Source§impl Default for LayoutLibrary
impl Default for LayoutLibrary
Source§fn default() -> LayoutLibrary
fn default() -> LayoutLibrary
Source§impl<'de> Deserialize<'de> for LayoutLibrary
impl<'de> Deserialize<'de> for LayoutLibrary
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for LayoutLibrary
impl PartialEq for LayoutLibrary
Source§impl Serialize for LayoutLibrary
impl Serialize for LayoutLibrary
impl StructuralPartialEq for LayoutLibrary
Auto Trait Implementations§
impl Freeze for LayoutLibrary
impl !RefUnwindSafe for LayoutLibrary
impl Send for LayoutLibrary
impl Sync for LayoutLibrary
impl Unpin for LayoutLibrary
impl UnsafeUnpin for LayoutLibrary
impl !UnwindSafe for LayoutLibrary
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().