pub struct Registry { /* private fields */ }Expand description
A loaded, validated collection of site definitions.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn default_embedded() -> Result<Self>
pub fn default_embedded() -> Result<Self>
Load the default site list embedded into the crate at build time.
Sourcepub fn from_json_str(json: &str) -> Result<Self>
pub fn from_json_str(json: &str) -> Result<Self>
Parse and validate a registry from a JSON string.
Sourcepub fn load_from_path(path: impl AsRef<Path>) -> Result<Self>
pub fn load_from_path(path: impl AsRef<Path>) -> Result<Self>
Read a registry from a JSON file.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
True if the registry has no sites (always false for a valid load, since we’d already have rejected it).
Sourcepub fn filter(
&self,
include: &[String],
exclude: &[String],
tags: &[String],
exclude_tags: &[String],
include_nsfw: bool,
) -> Vec<Site>
pub fn filter( &self, include: &[String], exclude: &[String], tags: &[String], exclude_tags: &[String], include_nsfw: bool, ) -> Vec<Site>
Apply include/exclude name filters and a tag filter.
- If
includeis non-empty, only sites whose name contains at least one include term (case-insensitive substring) are kept. - Sites whose name contains any exclude term are dropped.
- If
tagsis non-empty, only sites carrying at least one of the requested tags are kept (case-insensitive). A site with no tags is therefore dropped by a tag filter — asking for--tag socialmeans “only social-tagged sites”. - Sites carrying any tag in
exclude_tagsare dropped (e.g.--exclude-tag bot-protectedfor a fast clean run). - NSFW sites are auto-excluded (the
nsfwtag) unlessinclude_nsfwistrueortagsexplicitly asks fornsfw. This matches Sherlock’s--nsfwopt-in pattern and prevents the defaultadler <username>from surfacing adult-site URLs the user didn’t ask for. - Sites are returned by value (cloned) so the result is independent of the registry’s lifetime — convenient for handing to the executor.
Sourcepub fn tag_counts(&self) -> Vec<(String, usize)>
pub fn tag_counts(&self) -> Vec<(String, usize)>
Distinct tags across all sites, sorted, with the count of sites
carrying each. Powers --list-tags.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Registry
impl<'de> Deserialize<'de> for Registry
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Registry
impl RefUnwindSafe for Registry
impl Send for Registry
impl Sync for Registry
impl Unpin for Registry
impl UnsafeUnpin for Registry
impl UnwindSafe for Registry
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