pub trait SyncFsOps {
Show 26 methods
// Required methods
fn chmod_sync(&self, mode: u32) -> Result<()>;
fn chown_sync(&self, uid: Option<u32>, gid: Option<u32>) -> Result<()>;
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 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_sync(&self) -> Result<Vec<u8>>;
fn read_dir_sync(&self) -> Result<ReadDir>;
fn read_json_sync<T: DeserializeOwned>(&self) -> Result<T>;
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 truncate_sync(&self, len: Option<u64>) -> Result<()>;
fn write_sync(&self, contents: impl AsRef<[u8]>) -> Result<()>;
fn write_json_sync(&self, data: impl Serialize) -> 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§
fn chmod_sync(&self, mode: u32) -> Result<()>
fn chown_sync(&self, uid: Option<u32>, gid: Option<u32>) -> Result<()>
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 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_sync(&self) -> Result<Vec<u8>>
fn read_dir_sync(&self) -> Result<ReadDir>
fn read_json_sync<T: DeserializeOwned>(&self) -> Result<T>
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 truncate_sync(&self, len: Option<u64>) -> Result<()>
fn write_sync(&self, contents: impl AsRef<[u8]>) -> Result<()>
fn write_json_sync(&self, data: impl Serialize) -> 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.