diff --git a/aeron-rs/src/command/flyweight.rs b/aeron-rs/src/command/flyweight.rs index 1449cf1..8befdf4 100644 --- a/aeron-rs/src/command/flyweight.rs +++ b/aeron-rs/src/command/flyweight.rs @@ -11,20 +11,30 @@ where _phantom: PhantomData, } +pub struct Unchecked; + +impl Flyweight +where + A: AtomicBuffer, +{ + pub fn new(buffer: A, offset: IndexT) -> Result> + where + S: Sized + { + buffer.overlay::(offset)?; + Ok(Flyweight { + buffer, + base_offset: offset, + _phantom: PhantomData + }) + } +} + impl Flyweight where A: AtomicBuffer, S: Sized, { - pub fn new(buffer: A, offset: IndexT) -> Result> { - buffer.overlay::(offset)?; - Ok(Flyweight { - buffer, - base_offset: offset, - _phantom: PhantomData, - }) - } - pub(crate) fn get_struct(&self) -> &S { // UNWRAP: Bounds check performed during initialization self.buffer.overlay::(self.base_offset).unwrap() diff --git a/aeron-rs/src/driver_proxy.rs b/aeron-rs/src/driver_proxy.rs index 7e48026..4521bb7 100644 --- a/aeron-rs/src/driver_proxy.rs +++ b/aeron-rs/src/driver_proxy.rs @@ -36,9 +36,8 @@ where pub fn terminate_driver(&mut self, _token_buffer: Option<&[u8]>) -> Result<()> { let _client_id = self.client_id; self.write_command_to_driver(|buffer: &mut [u8], _length: &mut IndexT| { - // FIXME: This method signature is ugly. // UNWRAP: Buffer from `write_command` guaranteed to be long enough for `TerminateDriverDefn` - let _request: Flyweight<_, TerminateDriverDefn> = Flyweight::new(buffer, 0).unwrap(); + let _request = Flyweight::new::(buffer, 0).unwrap(); // FIXME: Uncommenting this causes termination to not succeed /*