Skip to main content

SyncFsOps

Trait SyncFsOps 

Source
pub trait SyncFsOps {
Show 34 methods // Required methods fn chmod_sync(&self, mode: u32) -> Result<()>; fn chown_sync(&self, uid: Option<u32>, gid: Option<u32>) -> Result<()>; fn copy_file_sync(&self, dest: impl AsRef<PathBuf>) -> Result<u64>; fn create_dir_all_sync(&self) -> Result<()>; fn create_dir_sync(&self) -> Result<()>; fn empty_dir_sync(&self) -> Result<()>; fn exists_sync(&self) -> Result<bool>; fn get_file_size_sync(&self) -> Result<u64>; fn hard_link_sync(&self, link: impl AsRef<PathBuf>) -> Result<()>; fn is_block_device_sync(&self) -> Result<bool>; fn is_char_device_sync(&self) -> Result<bool>; fn is_dir_sync(&self) -> Result<bool>; fn is_fifo_sync(&self) -> Result<bool>; fn is_file_sync(&self) -> Result<bool>; fn is_socket_sync(&self) -> Result<bool>; fn is_symlink_sync(&self) -> Result<bool>; fn metadata_sync(&self) -> Result<Metadata>; fn read_dir_names_sync(&self) -> Result<Vec<String>>; fn read_dir_paths_sync(&self) -> Result<Vec<Path>>; fn read_dir_sync(&self) -> Result<ReadDir>; fn read_json_sync<T: DeserializeOwned>(&self) -> Result<T>; fn read_link_sync(&self) -> Result<Path>; fn read_sync(&self) -> Result<Vec<u8>>; fn read_to_string_sync(&self) -> Result<String>; fn remove_dir_all_sync(&self) -> Result<()>; fn remove_dir_sync(&self) -> Result<()>; fn remove_file_sync(&self) -> Result<()>; fn set_permissions_sync(&self, permissions: Permissions) -> Result<()>; fn soft_link_sync(&self, link: impl AsRef<PathBuf>) -> Result<()>; fn symlink_metadata_sync(&self) -> Result<Metadata>; fn touch_sync(&self) -> Result<()>; fn truncate_sync(&self, len: Option<u64>) -> Result<()>; fn write_json_sync<T: Serialize>(&self, data: T) -> Result<()>; fn write_sync(&self, contents: impl AsRef<[u8]>) -> Result<()>;
}
Expand description

Trait for synchronous file system operations.

This trait provides blocking file system operations similar to Python’s pathlib. It is implemented for Path but can be implemented for other types as well.

§Example

use pathkit::{Path, SyncFsOps};

let path = Path::new("/tmp/test.txt");

// Check if file exists
if path.exists_sync()? {
    // Read file contents
    let content = path.read_sync()?;
}

// Write to file
path.write_sync(b"Hello, world!")?;

// Get file size
let size = path.get_file_size_sync()?;

Required Methods§

Source

fn chmod_sync(&self, mode: u32) -> Result<()>

Source

fn chown_sync(&self, uid: Option<u32>, gid: Option<u32>) -> Result<()>

Source

fn copy_file_sync(&self, dest: impl AsRef<PathBuf>) -> Result<u64>

Source

fn create_dir_all_sync(&self) -> Result<()>

Source

fn create_dir_sync(&self) -> Result<()>

Source

fn empty_dir_sync(&self) -> Result<()>

Source

fn exists_sync(&self) -> Result<bool>

Source

fn get_file_size_sync(&self) -> Result<u64>

Source

fn is_block_device_sync(&self) -> Result<bool>

Source

fn is_char_device_sync(&self) -> Result<bool>

Source

fn is_dir_sync(&self) -> Result<bool>

Source

fn is_fifo_sync(&self) -> Result<bool>

Source

fn is_file_sync(&self) -> Result<bool>

Source

fn is_socket_sync(&self) -> Result<bool>

Source

fn metadata_sync(&self) -> Result<Metadata>

Source

fn read_dir_names_sync(&self) -> Result<Vec<String>>

Source

fn read_dir_paths_sync(&self) -> Result<Vec<Path>>

Source

fn read_dir_sync(&self) -> Result<ReadDir>

Source

fn read_json_sync<T: DeserializeOwned>(&self) -> Result<T>

Source

fn read_sync(&self) -> Result<Vec<u8>>

Source

fn read_to_string_sync(&self) -> Result<String>

Source

fn remove_dir_all_sync(&self) -> Result<()>

Source

fn remove_dir_sync(&self) -> Result<()>

Source

fn remove_file_sync(&self) -> Result<()>

Source

fn set_permissions_sync(&self, permissions: Permissions) -> Result<()>

Source

fn touch_sync(&self) -> Result<()>

Source

fn truncate_sync(&self, len: Option<u64>) -> Result<()>

Source

fn write_json_sync<T: Serialize>(&self, data: T) -> Result<()>

Source

fn write_sync(&self, contents: impl AsRef<[u8]>) -> Result<()>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§