Struct Context

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

Type describing a RealSense context, used by the rest of the API.

Implementations§

Source§

impl Context

Source

pub fn new() -> Result<Self, ContextConstructionError>

Construct a new context.

§Errors

Returns ContextConstructionError if the context cannot be created.

Source

pub fn create_device_hub(&self) -> Result<DeviceHub, CouldNotGetDeviceHubError>

Creates a device hub from the context.

§Errors

Returns CouldNotGetDeviceHubError if the device hub cannot be created.

Source

pub fn query_devices( &self, product_mask: HashSet<Rs2ProductLine>, ) -> Vec<Device>

Get a list of devices that are already connected to the host.

Source

pub fn add_device<P>(&mut self, file: P) -> Result<Device>
where P: AsRef<Path>,

Create a new device and add it to the context.

This adds a “device” at a particular file on the system to the RealSense context. Returns a handle to the device, or an error if this call fails.

§Errors

Returns NulError if the provided file path cannot be cleanly represented as a CString. This usually only occurs if you have null characters in the path. Constructing a path using the utilties in Rust’s std::fs are expected to work.

Returns CouldNotAddDeviceError if the device cannot be added.

Source

pub fn remove_device<P>(&mut self, file: P) -> Result<()>
where P: AsRef<Path>,

Removes a playback device from the context, if it exists

This removes a “device” at a particular file on the system from the RealSense context. Returns nothing (null tuple) or an Error if the device cannot be removed.

§Errors

Returns CouldNotRemoveDeviceError if the device cannot be removed for any reason.

Trait Implementations§

Source§

impl Debug for Context

Source§

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

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

impl Drop for Context

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl TryFrom<&Context> for InactivePipeline

Source§

type Error = Error

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

fn try_from(context: &Context) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Send for Context

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.