use crate::futures::file::{
file_task::{CopyTask, MetadataTask, PathBufTask, PathTask, ReadDirTask, ReadTask, WriteTask},
open_file::OpenTask,
watch_task::WatchTask,
};
use std::{path::Path, sync::Arc};
pub struct File;
impl File {
pub fn read<P>(path: P) -> ReadTask
where
P: AsRef<Path>,
{
ReadTask::whole(path)
}
pub fn read_at<P>(path: P, offset: u64, len: usize) -> ReadTask
where
P: AsRef<Path>,
{
ReadTask::range(path, offset, len)
}
pub fn write<P>(path: P, data: impl Into<Arc<[u8]>>) -> WriteTask
where
P: AsRef<Path>,
{
WriteTask::truncate(path, data)
}
pub fn append<P>(path: P, data: impl Into<Arc<[u8]>>) -> WriteTask
where
P: AsRef<Path>,
{
WriteTask::append(path, data)
}
pub fn write_at<P>(path: P, offset: u64, data: impl Into<Arc<[u8]>>) -> WriteTask
where
P: AsRef<Path>,
{
WriteTask::at(path, offset, data)
}
pub fn metadata<P>(path: P) -> MetadataTask
where
P: AsRef<Path>,
{
MetadataTask::following(path)
}
pub fn symlink_metadata<P>(path: P) -> MetadataTask
where
P: AsRef<Path>,
{
MetadataTask::link(path)
}
pub fn read_dir<P>(path: P) -> ReadDirTask
where
P: AsRef<Path>,
{
ReadDirTask::new(path)
}
pub fn remove<P>(path: P) -> PathTask
where
P: AsRef<Path>,
{
PathTask::remove(path)
}
pub fn remove_dir<P>(path: P) -> PathTask
where
P: AsRef<Path>,
{
PathTask::remove_dir(path)
}
pub fn create_dir<P>(path: P) -> PathTask
where
P: AsRef<Path>,
{
PathTask::create_dir(path)
}
pub fn watch<P>(path: P) -> WatchTask
where
P: AsRef<Path>,
{
WatchTask::new(path)
}
pub fn rename<P, Q>(from: P, to: Q) -> PathTask
where
P: AsRef<Path>,
Q: AsRef<Path>,
{
PathTask::rename(from, to)
}
pub fn copy<P, Q>(from: P, to: Q) -> CopyTask
where
P: AsRef<Path>,
Q: AsRef<Path>,
{
CopyTask::new(from, to)
}
pub fn symlink<P, Q>(target: P, link: Q) -> PathTask
where
P: AsRef<Path>,
Q: AsRef<Path>,
{
PathTask::symlink(target, link)
}
pub fn hard_link<P, Q>(existing: P, new: Q) -> PathTask
where
P: AsRef<Path>,
Q: AsRef<Path>,
{
PathTask::hard_link(existing, new)
}
pub fn read_link<P>(path: P) -> PathBufTask
where
P: AsRef<Path>,
{
PathBufTask::read_link(path)
}
pub fn canonicalize<P>(path: P) -> PathBufTask
where
P: AsRef<Path>,
{
PathBufTask::canonical(path)
}
pub fn set_permissions<P>(path: P, mode: u32) -> PathTask
where
P: AsRef<Path>,
{
PathTask::set_permissions(path, mode)
}
pub fn set_len<P>(path: P, len: u64) -> PathTask
where
P: AsRef<Path>,
{
PathTask::set_len(path, len)
}
pub fn create_dir_all<P>(path: P) -> PathTask
where
P: AsRef<Path>,
{
PathTask::create_dir_all(path)
}
pub fn remove_dir_all<P>(path: P) -> PathTask
where
P: AsRef<Path>,
{
PathTask::remove_dir_all(path)
}
pub fn open<P>(path: P) -> OpenTask
where
P: AsRef<Path>,
{
OpenTask::new(path)
}
}