pub struct DataReaderWriter {
    _data_handle: i32,
    _block_number: MemoryBlockNumber,
    pub memory_block_byte_size: usize,
}
Expand description

Represents a data reader/writer to a caller. Adapts the functions from the Adapter_BackEnd DLL (as wrapped by the functions in adapter_backend.rs).

Fields§

§_data_handle: i32§_block_number: MemoryBlockNumber§memory_block_byte_size: usize

Number of bytes in the currently opened memory block.

Implementations§

source§

impl DataReaderWriter

source

pub fn new(block_number: MemoryBlockNumber) -> DataReaderWriter

Constructor for DataReaderWriter struct.

Parameters
  • blockNumber

    A value from the MemoryBlockNumber enumeration indicating the block of memory to open.

source

pub fn open(&mut self) -> Result<(), String>

Open a memory block for access. Which memory block to open is specified in the constructor. If this is successful, the memory block is open for reading and writing. Call close() to shut down access to the memory block.

source

pub fn close(&mut self) -> Result<(), String>

Closes a memory block from access. If this is successful, the same memory block can be opened again by a call to open(). Otherwise, instantiate the DataReaderWriter structure again to specify a different memory block.

source

fn _drop_close(&mut self)

Called by Drop::drop() to ensure the memory handle is closed. Does nothing if the handle is already closed (or was never opened). Ignores any errors returned from close() if the memory handle was left opened.

source

pub fn read(&self, byte_offset: i32, max_bytes: usize) -> Result<Vec<u8>, String>

Read a requested number of bytes from the currently opened memory block.

Parameters
  • byte_offset

    Offset into the memory block to start reading from.

  • maxBytes

    The number of bytes to read.

Returns

If successful, returns Ok(Vec<u8>) containing the bytes that were actually read; otherwise, returns Err(String) containing the reason for the failure.

source

pub fn write( &self, byte_offset: i32, bytes_to_write: &Vec<u8> ) -> Result<usize, String>

Write a requested number of bytes to the currently opened memory block.

Parameters
  • byte_offset

    Byte offset into the memory block indicating where to start writing.

  • bytes_to_write

    Vector of bytes to write to the memory block. All of the bytes will be written – up to the end of the memory block.

Returns

If successful, returns Ok(i32) containing the number of bytes actually written; otherwise, returns Err(String) containing the reason for the failure.

Trait Implementations§

source§

impl Drop for DataReaderWriter

source§

fn drop(&mut self)

Makes sure the current memory block is closed in the event that an error caused an early return from the function that owned the DataReaderWriter instance.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V