Skip to main content

Layer

Struct Layer 

Source
pub struct Layer { /* private fields */ }
Expand description

Represents an overlay layer with its metadata and content.

Implementations§

Source§

impl Layer

Source

pub fn open(storage: &Storage, id: &str) -> Result<Self>

Open a layer by ID using fd-relative operations.

§Errors

Returns an error if the layer directory doesn’t exist or cannot be opened.

Source

pub fn id(&self) -> &str

Get the layer ID.

Get the short link ID for this layer.

Get the parent link IDs for this layer.

Source

pub fn parents(&self, storage: &Storage) -> Result<Vec<String>>

Get parent layer IDs (resolved from link IDs).

This resolves the short link IDs from the lower file to full layer IDs by reading the symlinks in the overlay/l/ directory.

§Errors

Returns an error if any link cannot be resolved.

Source

pub fn layer_dir(&self) -> &Dir

Get a reference to the layer directory handle.

Source

pub fn diff_dir(&self) -> &Dir

Get a reference to the diff directory handle.

Source

pub fn layer_chain(self, storage: &Storage) -> Result<Vec<Layer>>

Get the complete chain of layers from this layer to the base.

Returns layers in order: [self, parent, grandparent, …, base]

§Errors

Returns an error if the layer chain exceeds the maximum depth of 500 layers.

Source

pub fn open_file(&self, path: impl AsRef<Path>) -> Result<File>

Open a file in the layer’s diff directory using fd-relative operations.

§Errors

Returns an error if the file doesn’t exist or cannot be opened.

Source

pub fn open_file_std(&self, path: impl AsRef<Path>) -> Result<File>

Open a file and return a standard library File.

§Errors

Returns an error if the file doesn’t exist or cannot be opened.

Source

pub fn metadata(&self, path: impl AsRef<Path>) -> Result<Metadata>

Get metadata for a file in the layer’s diff directory.

§Errors

Returns an error if the file doesn’t exist.

Source

pub fn read_dir(&self, path: impl AsRef<Path>) -> Result<ReadDir>

Read directory entries using Dir handle.

§Errors

Returns an error if the directory doesn’t exist.

Source

pub fn has_whiteout(&self, parent_path: &str, filename: &str) -> Result<bool>

Check if a whiteout file exists for the given filename.

Whiteout format: .wh.<filename>

§Arguments
  • parent_path - The directory path containing the file (empty string or “.” for root)
  • filename - The name of the file to check for whiteout
§Errors

Returns an error if the directory cannot be accessed.

Source

pub fn is_opaque_dir(&self, path: &str) -> Result<bool>

Check if a directory is marked as opaque (hides lower layers).

Opaque marker: .wh..wh..opq

§Errors

Returns an error if the directory cannot be accessed.

Trait Implementations§

Source§

impl Debug for Layer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Layer

§

impl RefUnwindSafe for Layer

§

impl Send for Layer

§

impl Sync for Layer

§

impl Unpin for Layer

§

impl UnsafeUnpin for Layer

§

impl UnwindSafe for Layer

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.