pub struct PathDiscovery { /* private fields */ }Expand description
Discovers fonts by walking filesystem paths.
Give it one or more root directories. It recurses into every subdirectory, checks each file’s extension, and collects anything that looks like a font.
Symlink behavior matters in practice: macOS /System/Library/Fonts contains
symlinks into sealed system volumes, and many Linux setups symlink font
directories across partitions. Enable follow_symlinks
when you want to reach fonts behind those links. Leave it off (the default)
to avoid infinite loops from circular symlinks.
§Example
use typg_core::discovery::{PathDiscovery, FontDiscovery};
let fonts = PathDiscovery::new(["/usr/share/fonts", "/home/me/.fonts"])
.follow_symlinks(true)
.discover()?;
println!("Found {} font files", fonts.len());Implementations§
Source§impl PathDiscovery
impl PathDiscovery
Sourcepub fn new<I, P>(roots: I) -> Self
pub fn new<I, P>(roots: I) -> Self
Create a discovery instance for the given root paths.
Each path should be a directory. If you pass a file path, walkdir
will yield just that one file (which is fine for single-file checks).
Sourcepub fn follow_symlinks(self, follow: bool) -> Self
pub fn follow_symlinks(self, follow: bool) -> Self
Enable or disable symlink following during traversal.
Trait Implementations§
Source§impl Clone for PathDiscovery
impl Clone for PathDiscovery
Source§fn clone(&self) -> PathDiscovery
fn clone(&self) -> PathDiscovery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PathDiscovery
impl Debug for PathDiscovery
Source§impl FontDiscovery for PathDiscovery
impl FontDiscovery for PathDiscovery
Source§fn discover(&self) -> Result<Vec<TypgFontSourceRef>>
fn discover(&self) -> Result<Vec<TypgFontSourceRef>>
Walk all root paths and return every font file found.
The walk is resilient: directories that can’t be read (permission denied, broken symlinks, vanished network mounts) are silently skipped. One unreadable folder won’t abort a scan of thousands.
Returns Err only if a root path itself doesn’t exist — that’s
likely a typo, and the caller should know about it.
Auto Trait Implementations§
impl Freeze for PathDiscovery
impl RefUnwindSafe for PathDiscovery
impl Send for PathDiscovery
impl Sync for PathDiscovery
impl Unpin for PathDiscovery
impl UnsafeUnpin for PathDiscovery
impl UnwindSafe for PathDiscovery
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,
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