pub struct RailLayout {
pub v: u32,
pub nodes: Vec<RailNode>,
}Expand description
The stored arrangement.
Fields§
§v: u32§nodes: Vec<RailNode>Implementations§
Source§impl RailLayout
impl RailLayout
Sourcepub fn from_json(s: &str) -> Self
pub fn from_json(s: &str) -> Self
Tolerant parse, node by node: a malformed or future node is skipped rather than costing the whole arrangement. One bad entry must not wedge a rail the user can otherwise still use.
pub fn to_json(&self) -> String
Sourcepub fn is_editable(&self) -> bool
pub fn is_editable(&self) -> bool
Whether this build may rewrite the document. A newer version can hold node types this one drops on parse, so editing would publish a lossy copy over the device that understands it.
Sourcepub fn flatten(&self) -> Vec<String>
pub fn flatten(&self) -> Vec<String>
Every community key in visual order, folders flattened in place.
pub fn contains(&self, key: &str) -> bool
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
One key appears once, a folder id appears once, and a folder holding a single community becomes that community again — a folder of one is a box with nothing to group, and dragging the second-to-last member out is how you say you are done with it.
Sourcepub fn merged_with(&self, live_keys: &[String]) -> RailLayout
pub fn merged_with(&self, live_keys: &[String]) -> RailLayout
The arrangement as it should paint: the stored one, plus any community the user has joined but never arranged, appended in the order the caller discovered them.
Nothing is written here. A user who has never dragged anything stores no document at all, and their rail still orders itself.
Sourcepub fn remove_key(&mut self, key: &str)
pub fn remove_key(&mut self, key: &str)
Drop a community from the arrangement for good.
Destructive on purpose, unlike the render-time skip: the layout keeps keys it cannot resolve forever, so without this a user who left a community and rejoined it later would find it back inside its old folder.
Sourcepub fn apply_drop(
&mut self,
source: &RailDrag,
target: &RailDrop,
new_folder_id: &str,
) -> Result<(), String>
pub fn apply_drop( &mut self, source: &RailDrag, target: &RailDrop, new_folder_id: &str, ) -> Result<(), String>
Apply a completed drag. new_folder_id supplies the id for a folder
born from a combine drop, taken as a parameter so the whole thing stays
pure and testable.
Sourcepub fn rename_folder(
&mut self,
folder_id: &str,
name: &str,
) -> Result<(), String>
pub fn rename_folder( &mut self, folder_id: &str, name: &str, ) -> Result<(), String>
Name a folder. An empty name is allowed and means “unnamed” — the rail shows the avatars alone, exactly as it does before anyone names one.
Sourcepub fn set_folder_hue(
&mut self,
folder_id: &str,
hue: Option<u16>,
) -> Result<(), String>
pub fn set_folder_hue( &mut self, folder_id: &str, hue: Option<u16>, ) -> Result<(), String>
Colour a folder, or clear it back to the default grey with None.
Sourcepub fn dissolve_folder(&mut self, folder_id: &str) -> Result<(), String>
pub fn dissolve_folder(&mut self, folder_id: &str) -> Result<(), String>
Unpack a folder, leaving its communities loose and in place.
Sourcepub fn assign_folder_ids(&mut self, next_id: impl FnMut() -> String)
pub fn assign_folder_ids(&mut self, next_id: impl FnMut() -> String)
Give every folder born without one a stable id. Ids are minted by the caller so the pure ops stay free of randomness.
Trait Implementations§
Source§impl Clone for RailLayout
impl Clone for RailLayout
Source§impl Debug for RailLayout
impl Debug for RailLayout
Source§impl Default for RailLayout
impl Default for RailLayout
Source§impl<'de> Deserialize<'de> for RailLayout
impl<'de> Deserialize<'de> for RailLayout
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>,
impl Eq for RailLayout
Source§impl PartialEq for RailLayout
impl PartialEq for RailLayout
Source§impl Serialize for RailLayout
impl Serialize for RailLayout
impl StructuralPartialEq for RailLayout
Auto Trait Implementations§
impl Freeze for RailLayout
impl RefUnwindSafe for RailLayout
impl Send for RailLayout
impl Sync for RailLayout
impl Unpin for RailLayout
impl UnsafeUnpin for RailLayout
impl UnwindSafe for RailLayout
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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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