pub struct VendoredFileSystem { /* private fields */ }Expand description
File system that stores all content in a static zip archive bundled as part of the Ruff binary.
“Files” in the VendoredFileSystem are read-only and immutable.
Directories are supported, but symlinks and hardlinks cannot exist.
§Path separators
At time of writing (2025-07-11), this implementation always uses / as a
path separator, even in Windows environments where \ is traditionally
used as a file path separator. Namely, this is only currently used with zip
files built by crates/ty_vendored/build.rs.
Callers using this may provide paths that use a \ as a separator. It will
be transparently normalized to /.
This is particularly important because the presence of a trailing separator in a zip file is conventionally used to indicate a directory entry.
Implementations§
Source§impl VendoredFileSystem
impl VendoredFileSystem
pub fn new_static(raw_bytes: &'static [u8]) -> Result<Self>
pub fn new(raw_bytes: Vec<u8>) -> Result<Self>
pub fn exists(&self, path: impl AsRef<VendoredPath>) -> bool
pub fn metadata(&self, path: impl AsRef<VendoredPath>) -> Result<Metadata>
pub fn is_directory(&self, path: impl AsRef<VendoredPath>) -> bool
pub fn is_file(&self, path: impl AsRef<VendoredPath>) -> bool
Sourcepub fn read_to_string(&self, path: impl AsRef<VendoredPath>) -> Result<String>
pub fn read_to_string(&self, path: impl AsRef<VendoredPath>) -> Result<String>
Read the entire contents of the zip file at path into a string
Returns an Err() if any of the following are true:
- The path does not exist in the underlying zip archive
- The path exists in the underlying zip archive, but represents a directory
- The contents of the zip file at
pathcontain invalid UTF-8
Sourcepub fn read_directory(
&self,
dir: impl AsRef<VendoredPath>,
) -> impl Iterator<Item = DirectoryEntry> + '_
pub fn read_directory( &self, dir: impl AsRef<VendoredPath>, ) -> impl Iterator<Item = DirectoryEntry> + '_
Read the direct children of the directory
identified by path.
If path is not a directory, then this will
return an empty iterator.
Trait Implementations§
Source§impl Clone for VendoredFileSystem
impl Clone for VendoredFileSystem
Source§fn clone(&self) -> VendoredFileSystem
fn clone(&self) -> VendoredFileSystem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VendoredFileSystem
impl Debug for VendoredFileSystem
Auto Trait Implementations§
impl Freeze for VendoredFileSystem
impl RefUnwindSafe for VendoredFileSystem
impl Send for VendoredFileSystem
impl Sync for VendoredFileSystem
impl Unpin for VendoredFileSystem
impl UnsafeUnpin for VendoredFileSystem
impl UnwindSafe for VendoredFileSystem
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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