pub struct SourceRoot { /* private fields */ }Implementations§
Source§impl SourceRoot
impl SourceRoot
pub fn new(path: impl Into<PathBuf>) -> SourceRoot
pub fn path(&self) -> &Path
Sourcepub fn host_path(&self, logical: &Path) -> PathBuf
pub fn host_path(&self, logical: &Path) -> PathBuf
Map a logical path onto the host without following symlinks.
Sourcepub fn resolve(&self, logical: &Path) -> Result<Option<Resolved>>
pub fn resolve(&self, logical: &Path) -> Result<Option<Resolved>>
Resolve a logical path, following symlinks within the root.
Returns Ok(None) when the path does not exist. Anything else — an
unreadable directory, a component that is not a directory — is an error,
because a caller reaching this way named the path. Use probe for a
candidate the caller only guessed at.
Sourcepub fn probe(&self, logical: &Path) -> Result<Option<Resolved>>
pub fn probe(&self, logical: &Path) -> Result<Option<Resolved>>
As resolve, but every failure to stat a component answers “nothing
usable here”.
This is what a library lookup needs: glibc’s open_path treats each
failed candidate the same way and moves on to the next directory, so a
stale search-path entry naming a regular file, or a directory this
process cannot enter, must not fail a build the loader would complete.
Sourcepub fn read(&self, logical: &Path) -> Result<Option<Vec<u8>>>
pub fn read(&self, logical: &Path) -> Result<Option<Vec<u8>>>
Read a file identified by a logical path.
Sourcepub fn read_bounded(
&self,
logical: &Path,
limit_bytes: usize,
) -> Result<Option<Vec<u8>>>
pub fn read_bounded( &self, logical: &Path, limit_bytes: usize, ) -> Result<Option<Vec<u8>>>
As SourceRoot::read, but reading at most limit_bytes.
A file in the source filesystem is as large as that filesystem says, so anything read to decide something small — a configuration file naming a few directories — says how much of it it is willing to look at. Content past the limit is truncated rather than being an error: the reader’s answer is a hint, and a partial one beats failing the build.
pub fn exists(&self, logical: &Path) -> bool
pub fn is_dir(&self, logical: &Path) -> bool
Trait Implementations§
Source§impl Clone for SourceRoot
impl Clone for SourceRoot
Source§fn clone(&self) -> SourceRoot
fn clone(&self) -> SourceRoot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more