pub trait PluginHandler<B: Backend> {
type CreateArgs: Args;
type Create: Create<B>;
type Open: Open<B>;
Show 21 methods
// Required methods
fn plugin_info(&self) -> PluginInfo;
fn info_to_hash(&self, info: B::Info) -> Option<HashMap<String, String>>;
fn open_builder(&self, args: &OpenArgs) -> Option<Self::Open>;
fn create_builder(
&self,
args: &CreateArgs<Self::CreateArgs>,
) -> Option<Self::Create>;
// Provided methods
fn handle_plugin_info(
&self,
) -> Result<HashMap<String, String>, ErrorResponse> { ... }
fn handle_settings(
&self,
args: &CreateArgs<Self::CreateArgs>,
) -> Result<Vec<u8>, ErrorResponse> { ... }
fn handle_open(
&self,
args: &OpenArgs,
settings: &[u8],
) -> Result<B, ErrorResponse> { ... }
fn handle_create(
&self,
args: &CreateArgs<Self::CreateArgs>,
header: &[u8],
overwrite: bool,
) -> Result<B, ErrorResponse> { ... }
fn handle_id_size(&self) -> Result<usize, ErrorResponse> { ... }
fn handle_block_size(&self, backend: &B) -> Result<u32, ErrorResponse> { ... }
fn handle_id_to_bytes(&self, str: &str) -> Result<Vec<u8>, ErrorResponse> { ... }
fn handle_id_to_string(&self, bytes: &[u8]) -> Result<String, ErrorResponse> { ... }
fn handle_info(
&self,
backend: &B,
) -> Result<HashMap<String, String>, ErrorResponse> { ... }
fn handle_aquire(
&self,
backend: &mut B,
bytes: &[u8],
) -> Result<Vec<u8>, ErrorResponse> { ... }
fn handle_release(
&self,
backend: &mut B,
id: &[u8],
) -> Result<(), ErrorResponse> { ... }
fn handle_read_header<T: ReceiveHeader<B>>(
&self,
header: &mut T,
) -> Result<Vec<u8>, ErrorResponse> { ... }
fn handle_write_header(
&self,
backend: &mut B,
header: &[u8],
) -> Result<(), ErrorResponse> { ... }
fn handle_read(
&self,
backend: &mut B,
id: &[u8],
) -> Result<Vec<u8>, ErrorResponse> { ... }
fn handle_write(
&self,
backend: &mut B,
id: &[u8],
bytes: &[u8],
) -> Result<usize, ErrorResponse> { ... }
fn handle_delete(&self, backend: B) -> Result<(), ErrorResponse> { ... }
fn handle_quit(&self) -> Result<(), ErrorResponse> { ... }
}
Expand description
Trait enriches the generic implementation of the plugin with plugin-specific behavior.
You need to implement a set of functions that provide plugin-specific information.
There are several handle_*
functions, which are already implemented. They
encapsulates the handling for all the request types.
Required Associated Types§
Sourcetype CreateArgs: Args
type CreateArgs: Args
Extra (plugin-specific) arguments passed to the create
command.
Required Methods§
Sourcefn plugin_info(&self) -> PluginInfo
fn plugin_info(&self) -> PluginInfo
Returns information of the plugin.
Sourcefn open_builder(&self, args: &OpenArgs) -> Option<Self::Open>
fn open_builder(&self, args: &OpenArgs) -> Option<Self::Open>
Creates a builder instance used to open an already existing backend instance.
Sourcefn create_builder(
&self,
args: &CreateArgs<Self::CreateArgs>,
) -> Option<Self::Create>
fn create_builder( &self, args: &CreateArgs<Self::CreateArgs>, ) -> Option<Self::Create>
Creates a builder instance used to create a new backend instance.
Provided Methods§
Sourcefn handle_plugin_info(&self) -> Result<HashMap<String, String>, ErrorResponse>
fn handle_plugin_info(&self) -> Result<HashMap<String, String>, ErrorResponse>
Handles the Request::PluginInfo
command.
Sourcefn handle_settings(
&self,
args: &CreateArgs<Self::CreateArgs>,
) -> Result<Vec<u8>, ErrorResponse>
fn handle_settings( &self, args: &CreateArgs<Self::CreateArgs>, ) -> Result<Vec<u8>, ErrorResponse>
Handles the Request::Settings
command.
Sourcefn handle_open(
&self,
args: &OpenArgs,
settings: &[u8],
) -> Result<B, ErrorResponse>
fn handle_open( &self, args: &OpenArgs, settings: &[u8], ) -> Result<B, ErrorResponse>
Handles the Request::Open
command.
Sourcefn handle_create(
&self,
args: &CreateArgs<Self::CreateArgs>,
header: &[u8],
overwrite: bool,
) -> Result<B, ErrorResponse>
fn handle_create( &self, args: &CreateArgs<Self::CreateArgs>, header: &[u8], overwrite: bool, ) -> Result<B, ErrorResponse>
Handles the Request::Create
command.
Sourcefn handle_id_size(&self) -> Result<usize, ErrorResponse>
fn handle_id_size(&self) -> Result<usize, ErrorResponse>
Handles the Request::IdSize
command.
Sourcefn handle_block_size(&self, backend: &B) -> Result<u32, ErrorResponse>
fn handle_block_size(&self, backend: &B) -> Result<u32, ErrorResponse>
Handles the Request::BlockSize
command.
Sourcefn handle_id_to_bytes(&self, str: &str) -> Result<Vec<u8>, ErrorResponse>
fn handle_id_to_bytes(&self, str: &str) -> Result<Vec<u8>, ErrorResponse>
Handles the Request::IdToBytes
command.
Sourcefn handle_id_to_string(&self, bytes: &[u8]) -> Result<String, ErrorResponse>
fn handle_id_to_string(&self, bytes: &[u8]) -> Result<String, ErrorResponse>
Handles the Request::IdToString
command.
Sourcefn handle_info(
&self,
backend: &B,
) -> Result<HashMap<String, String>, ErrorResponse>
fn handle_info( &self, backend: &B, ) -> Result<HashMap<String, String>, ErrorResponse>
Handles the Request::Info
command.
Sourcefn handle_aquire(
&self,
backend: &mut B,
bytes: &[u8],
) -> Result<Vec<u8>, ErrorResponse>
fn handle_aquire( &self, backend: &mut B, bytes: &[u8], ) -> Result<Vec<u8>, ErrorResponse>
Handles the Request::Aquire
command.
Sourcefn handle_release(
&self,
backend: &mut B,
id: &[u8],
) -> Result<(), ErrorResponse>
fn handle_release( &self, backend: &mut B, id: &[u8], ) -> Result<(), ErrorResponse>
Handles the Request::Release
command.
Sourcefn handle_read_header<T: ReceiveHeader<B>>(
&self,
header: &mut T,
) -> Result<Vec<u8>, ErrorResponse>
fn handle_read_header<T: ReceiveHeader<B>>( &self, header: &mut T, ) -> Result<Vec<u8>, ErrorResponse>
Handles the Request::ReadHeader
command.
Sourcefn handle_write_header(
&self,
backend: &mut B,
header: &[u8],
) -> Result<(), ErrorResponse>
fn handle_write_header( &self, backend: &mut B, header: &[u8], ) -> Result<(), ErrorResponse>
Handles the Request::WriteHeader
command.
Sourcefn handle_read(
&self,
backend: &mut B,
id: &[u8],
) -> Result<Vec<u8>, ErrorResponse>
fn handle_read( &self, backend: &mut B, id: &[u8], ) -> Result<Vec<u8>, ErrorResponse>
Handles the Request::Read
command.
Sourcefn handle_write(
&self,
backend: &mut B,
id: &[u8],
bytes: &[u8],
) -> Result<usize, ErrorResponse>
fn handle_write( &self, backend: &mut B, id: &[u8], bytes: &[u8], ) -> Result<usize, ErrorResponse>
Handles the Request::Write
command.
fn handle_delete(&self, backend: B) -> Result<(), ErrorResponse>
fn handle_quit(&self) -> Result<(), ErrorResponse>
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.