use std::{collections::HashMap, future::Future};
use crate::{
protocol::{Attrs, Data, FileAttributes, Handle, Name, OpenFlags, Packet, Status, Version},
server::StatusReply,
};
#[cfg_attr(feature = "async-trait", async_trait::async_trait)]
pub trait Handler: Sized {
type Error: Into<StatusReply> + Send;
fn unimplemented(&self) -> Self::Error;
#[allow(unused_variables)]
fn init(
&mut self,
version: u32,
extensions: HashMap<String, String>,
) -> impl Future<Output = Result<Version, Self::Error>> + Send {
async { Ok(Version::new()) }
}
#[allow(unused_variables)]
fn open(
&mut self,
id: u32,
filename: String,
pflags: OpenFlags,
attrs: FileAttributes,
) -> impl Future<Output = Result<Handle, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn close(
&mut self,
id: u32,
handle: String,
) -> impl Future<Output = Result<Status, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn read(
&mut self,
id: u32,
handle: String,
offset: u64,
len: u32,
) -> impl Future<Output = Result<Data, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn write(
&mut self,
id: u32,
handle: String,
offset: u64,
data: Vec<u8>,
) -> impl Future<Output = Result<Status, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn lstat(
&mut self,
id: u32,
path: String,
) -> impl Future<Output = Result<Attrs, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn fstat(
&mut self,
id: u32,
handle: String,
) -> impl Future<Output = Result<Attrs, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn setstat(
&mut self,
id: u32,
path: String,
attrs: FileAttributes,
) -> impl Future<Output = Result<Status, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn fsetstat(
&mut self,
id: u32,
handle: String,
attrs: FileAttributes,
) -> impl Future<Output = Result<Status, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn opendir(
&mut self,
id: u32,
path: String,
) -> impl Future<Output = Result<Handle, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn readdir(
&mut self,
id: u32,
handle: String,
) -> impl Future<Output = Result<Name, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn remove(
&mut self,
id: u32,
filename: String,
) -> impl Future<Output = Result<Status, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn mkdir(
&mut self,
id: u32,
path: String,
attrs: FileAttributes,
) -> impl Future<Output = Result<Status, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn rmdir(
&mut self,
id: u32,
path: String,
) -> impl Future<Output = Result<Status, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn realpath(
&mut self,
id: u32,
path: String,
) -> impl Future<Output = Result<Name, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn stat(
&mut self,
id: u32,
path: String,
) -> impl Future<Output = Result<Attrs, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn rename(
&mut self,
id: u32,
oldpath: String,
newpath: String,
) -> impl Future<Output = Result<Status, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn readlink(
&mut self,
id: u32,
path: String,
) -> impl Future<Output = Result<Name, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn symlink(
&mut self,
id: u32,
linkpath: String,
targetpath: String,
) -> impl Future<Output = Result<Status, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
#[allow(unused_variables)]
fn extended(
&mut self,
id: u32,
request: String,
data: Vec<u8>,
) -> impl Future<Output = Result<Packet, Self::Error>> + Send {
let err = self.unimplemented();
async { Err(err) }
}
}