pub struct TagRegistry { /* private fields */ }Expand description
In-memory tag store, persisted to a single TOML file.
Backing collection is a HashSet<String> — tag names are unique and
case-sensitive (qBt parity). list() returns a sorted Vec<String> so
HTTP responses are deterministic.
Implementations§
Source§impl TagRegistry
impl TagRegistry
Sourcepub fn new(path: PathBuf) -> Self
pub fn new(path: PathBuf) -> Self
Create a new empty registry associated with path. Does not touch
disk; call Self::save to materialise.
Sourcepub fn load(path: PathBuf) -> Self
pub fn load(path: PathBuf) -> Self
Load a registry from disk, soft-recovering from failures.
- If the file is absent → empty registry.
- If the TOML is malformed OR the schema version is unknown → rename
the broken file aside (
.bak/.bak.N) and return an empty registry. WARN log. - Other I/O errors (permission, etc.) → empty registry. WARN log.
Sourcepub fn contains(&self, name: &str) -> bool
pub fn contains(&self, name: &str) -> bool
Does a tag with the given name exist? Case-sensitive. Empty-string is rejected (never matches).
Sourcepub fn create(&mut self, name: String) -> Result<(), TagError>
pub fn create(&mut self, name: String) -> Result<(), TagError>
Create a new tag. Returns:
Err(InvalidName)if the name fails validation.Err(AlreadyExists)if a tag with the same name already exists (case-sensitive). This is stricter than the HTTP surface, which is idempotent; the HTTP handler swallowsAlreadyExistsoncreateTagsto match qBt’s wire semantics.Ok(())on success. The new tag is in-memory only untilSelf::saveis called.
§Errors
Returns an error if the session is shut down.
Trait Implementations§
Source§impl Clone for TagRegistry
impl Clone for TagRegistry
Source§fn clone(&self) -> TagRegistry
fn clone(&self) -> TagRegistry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TagRegistry
impl Debug for TagRegistry
Source§impl Default for TagRegistry
impl Default for TagRegistry
Source§fn default() -> TagRegistry
fn default() -> TagRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TagRegistry
impl RefUnwindSafe for TagRegistry
impl Send for TagRegistry
impl Sync for TagRegistry
impl Unpin for TagRegistry
impl UnsafeUnpin for TagRegistry
impl UnwindSafe for TagRegistry
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