Skip to main content

Platform

Trait Platform 

Source
pub trait Platform {
    // Required methods
    fn filesystem_facts(
        &self,
        path: &Path,
    ) -> Result<(FilesystemKind, u64), PrimitiveError>;
    fn is_subvolume_root(&self, path: &Path) -> Result<bool, PrimitiveError>;
    fn create_subvolume(&self, path: &Path) -> Result<(), PrimitiveError>;
    fn destroy_subvolume(&self, path: &Path) -> Result<(), PrimitiveError>;
    fn removal_allowed(&self, path: &Path) -> bool;
    fn is_mount_point(&self, path: &Path) -> bool;
    fn clone_file(
        &self,
        source: &File,
        destination: &File,
        path: &Path,
    ) -> Result<(), PrimitiveError>;
    fn exchange(
        &self,
        first: &Path,
        second: &Path,
    ) -> Result<(), PrimitiveError>;

    // Provided methods
    fn hard_link(&self, existing: &Path, new: &Path) -> Result<()> { ... }
    fn conversion_environment(&self) -> ConversionEnvironment { ... }
}
Expand description

What: The operations of the migration that depend on the kind of filesystem. &self borrows the platform read-only so one platform serves a whole run; dyn Platform is how a caller holds “any implementation” (TS interface). Why: See the module description.

In TS you’d write (pseudocode):

interface Platform { ... }

Required Methods§

Source

fn filesystem_facts( &self, path: &Path, ) -> Result<(FilesystemKind, u64), PrimitiveError>

The filesystem kind holding path and the bytes free there.

Source

fn is_subvolume_root(&self, path: &Path) -> Result<bool, PrimitiveError>

Whether path is the root of a subvolume.

Source

fn create_subvolume(&self, path: &Path) -> Result<(), PrimitiveError>

Create an empty subvolume at path.

Source

fn destroy_subvolume(&self, path: &Path) -> Result<(), PrimitiveError>

Destroy the subvolume at path with the kernel call (the caller falls back to emptying and rmdir).

Source

fn removal_allowed(&self, path: &Path) -> bool

Whether an unprivileged subvolume destroy is allowed on the mount holding path.

Source

fn is_mount_point(&self, path: &Path) -> bool

Whether path is itself a mount point (a mount point cannot be exchanged).

Source

fn clone_file( &self, source: &File, destination: &File, path: &Path, ) -> Result<(), PrimitiveError>

Clone a whole file’s data blocks.

Source

fn exchange(&self, first: &Path, second: &Path) -> Result<(), PrimitiveError>

Swap two paths atomically.

Provided Methods§

Make new another name of the file existing; fails with EXDEV where the two sit in different subvolumes.

Source

fn conversion_environment(&self) -> ConversionEnvironment

Which configuration files and system attributes file Git reads here. The default names no Git and no variables, so the system files are unknown and a content decision that needs them refuses; a stand-in overrides it with what a control needs, and the real platform answers for the Git it forwards to.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Platform for LinuxPlatform

The primitives, called as they are.