Struct DataStream

Source
pub struct DataStream { /* private fields */ }
Expand description

The IDataStream interface is used to retrieve a data stream.

Reference to the official documentation:

https://www.virtualbox.org/sdkref/interface_i_data_stream.html

Implementations§

Source§

impl DataStream

Source

pub fn get_read_size(&self) -> Result<u32, VboxError>

Recommended size of a read.

Requesting a larger read may be possible in certain situations, but it is not guaranteed.

§Returns

Returns u32, or a VboxError on failure.

§Example

use virtualbox_rs::enums::PartitionTableType;
use virtualbox_rs::VirtualBox;

let vbox = VirtualBox::init().unwrap();
let mediums = vbox.get_floppy_images().unwrap();
let medium = mediums.get(0).unwrap();
let medium_io = medium.open_for_io(true, "").unwrap();
let (stream, progress) = medium_io.convert_to_stream("VDI", vec![], 1024).unwrap();
progress.wait_for_completion(-1).unwrap();
let read_size = stream.get_read_size().unwrap();
Source

pub fn read(&self, size: u32, timeout_ms: u32) -> Result<&[u8], VboxError>

Read data from the stream.

§Arguments
  • size - How many bytes to try read.
  • timeout_ms - Timeout (in ms) for limiting the wait time for data to be available. Pass 0 for an infinite timeout.
§Returns

Returns [&[u8]], or a VboxError on failure. -Array of data read. This may be shorter than the specified size. Returning a zero-sized array indicates the end of the stream, if the status is successful.

§Example

use virtualbox_rs::enums::PartitionTableType;
use virtualbox_rs::VirtualBox;

let vbox = VirtualBox::init().unwrap();
let mediums = vbox.get_floppy_images().unwrap();
let medium = mediums.get(0).unwrap();
let medium_io = medium.open_for_io(true, "").unwrap();
let (stream, progress) = medium_io.convert_to_stream("VDI", vec![], 1024).unwrap();
progress.wait_for_completion(-1).unwrap();
let read_size = stream.get_read_size().unwrap();
let data = stream.read(read_size, 1000).unwrap();

Trait Implementations§

Source§

impl Debug for DataStream

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for DataStream

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.