pub struct Context { /* private fields */ }
Expand description
Type describing a RealSense context, used by the rest of the API.
Implementations§
Source§impl Context
impl Context
Sourcepub fn new() -> Result<Self, ContextConstructionError>
pub fn new() -> Result<Self, ContextConstructionError>
Sourcepub fn create_device_hub(&self) -> Result<DeviceHub, CouldNotGetDeviceHubError>
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.
Sourcepub fn query_devices(
&self,
product_mask: HashSet<Rs2ProductLine>,
) -> Vec<Device>
pub fn query_devices( &self, product_mask: HashSet<Rs2ProductLine>, ) -> Vec<Device>
Get a list of devices that are already connected to the host.
Sourcepub fn add_device<P>(&mut self, file: P) -> Result<Device>
pub fn add_device<P>(&mut self, file: P) -> Result<Device>
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.
Sourcepub fn remove_device<P>(&mut self, file: P) -> Result<()>
pub fn remove_device<P>(&mut self, file: P) -> Result<()>
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.