#[non_exhaustive]pub struct Places {
pub groups: Vec<PlaceGroup>,
}Expand description
Storage for user-defined and code-defined places.
This is intentionally dependency-free (no serde). The compact persistence format is designed to be stable and forward-compatible.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.groups: Vec<PlaceGroup>Places groups shown in UI.
Implementations§
Source§impl Places
impl Places
Sourcepub const SYSTEM_GROUP: &'static str = "System"
pub const SYSTEM_GROUP: &'static str = "System"
Default system group label.
Sourcepub const BOOKMARKS_GROUP: &'static str = "Bookmarks"
pub const BOOKMARKS_GROUP: &'static str = "Bookmarks"
Default bookmarks group label.
Sourcepub fn ensure_default_groups(&mut self)
pub fn ensure_default_groups(&mut self)
Ensures the default groups exist.
Sourcepub fn refresh_system_places(&mut self)
pub fn refresh_system_places(&mut self)
Rebuilds the system places group (home/root/drives).
This is a best-effort operation and may produce different results across platforms.
Sourcepub fn add_place(&mut self, group_label: impl Into<String>, place: Place)
pub fn add_place(&mut self, group_label: impl Into<String>, place: Place)
Adds a place to a group if its path isn’t already present in that group.
Sourcepub fn add_place_separator(
&mut self,
group_label: impl Into<String>,
thickness: u32,
)
pub fn add_place_separator( &mut self, group_label: impl Into<String>, thickness: u32, )
Adds a separator row to a group.
Sourcepub fn add_bookmark(&mut self, label: impl Into<String>, path: PathBuf)
pub fn add_bookmark(&mut self, label: impl Into<String>, path: PathBuf)
Adds a bookmark (user place) into the default bookmarks group.
Sourcepub fn add_bookmark_path(&mut self, path: PathBuf)
pub fn add_bookmark_path(&mut self, path: PathBuf)
Adds a bookmark using a default label derived from the path.
Sourcepub fn remove_place_path(&mut self, group_label: &str, path: &Path) -> bool
pub fn remove_place_path(&mut self, group_label: &str, path: &Path) -> bool
Removes a place by exact path match from the given group.
Sourcepub fn add_group(&mut self, label: impl Into<String>) -> bool
pub fn add_group(&mut self, label: impl Into<String>) -> bool
Adds a group if it does not exist.
Returns true if the group was added.
Sourcepub fn remove_group(&mut self, label: &str) -> bool
pub fn remove_group(&mut self, label: &str) -> bool
Removes a group by exact label match.
Returns true if a group was removed.
Sourcepub fn rename_group(&mut self, from: &str, to: impl Into<String>) -> bool
pub fn rename_group(&mut self, from: &str, to: impl Into<String>) -> bool
Renames a group by exact label match.
Returns true if the group was found and renamed.
Sourcepub fn edit_place_by_path(
&mut self,
group_label: &str,
from_path: &Path,
new_label: impl Into<String>,
new_path: PathBuf,
) -> bool
pub fn edit_place_by_path( &mut self, group_label: &str, from_path: &Path, new_label: impl Into<String>, new_path: PathBuf, ) -> bool
Edits a place identified by its current path within a group.
Returns true if a place was found and updated.
Sourcepub fn serialize_compact(&self, opts: PlacesSerializeOptions) -> String
pub fn serialize_compact(&self, opts: PlacesSerializeOptions) -> String
Serializes places into a compact, line-based format.
Format (v1):
- First non-empty line:
v1 - Group header:
g<TAB>group<TAB>order<TAB>opened - Place entry:
p<TAB>group<TAB>origin<TAB>label<TAB>path - Separator:
s<TAB>group<TAB>thickness
All string fields are escaped and separated by tabs.
Sourcepub fn deserialize_compact(input: &str) -> Result<Self, PlacesDeserializeError>
pub fn deserialize_compact(input: &str) -> Result<Self, PlacesDeserializeError>
Deserializes places from the compact format produced by
Places::serialize_compact.
Sourcepub fn merge_from(&mut self, other: Places, opts: PlacesMergeOptions)
pub fn merge_from(&mut self, other: Places, opts: PlacesMergeOptions)
Merges another places store into self.
- Groups are merged by label.
- Places are merged via
Places::add_place(dedupes by path; separators are always added). - The system group is never merged (it is machine-specific).