tool: Support for owned and unowned generic Ec

This commit is contained in:
Ian Douglas Scott
2021-02-18 13:40:42 -08:00
committed by Jeremy Soller
parent f4458aebca
commit 0c1584385c
2 changed files with 37 additions and 0 deletions

View File

@ -24,3 +24,23 @@ pub trait Access {
/// The maximum size that can be provided for the data argument
fn data_size(&self) -> usize;
}
impl Access for &mut dyn Access {
unsafe fn command(&mut self, cmd: u8, data: &mut [u8]) -> Result<u8, Error> {
(**self).command(cmd, data)
}
fn data_size(&self) -> usize {
(**self).data_size()
}
}
impl Access for Box<dyn Access> {
unsafe fn command(&mut self, cmd: u8, data: &mut [u8]) -> Result<u8, Error> {
(**self).command(cmd, data)
}
fn data_size(&self) -> usize {
(**self).data_size()
}
}