Struct Config

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

Type representing the Pipeline configuration.

Implementations§

Source§

impl Config

Source

pub fn new() -> Self

Construct a new configuration.

Source

pub fn enable_stream( &mut self, stream: Rs2StreamKind, index: Option<usize>, width: usize, height: usize, format: Rs2Format, framerate: usize, ) -> Result<&mut Self, ConfigurationError>

Enable the stream of kind stream with the provided attributes.

Returns a mutable reference to self, or a configuration error if the underlying FFI call fails.

§Arguments

It is not an error if stream and format do not match appropriately, but you may find that the configuration will never resolve if they do not.. E.g. you cannot pass in Rs2StreamKind::Color alongside Rs2Format::Z16. If you’re unsure, pass in Rs2Format::Any and librealsense2 will determine what the most appropriate format is for a given stream.

The index is can be optionally provided. If it is not provided, then librealsense2 will pick the most suitable stream index it can find.

If either width or height (but not both) are zero, librealsense2 will find the most appropriate value to match the non-zero one. E.g. if width is 640 and height is 0, then librealsense2 will return 640x480 images (the closest appropriate format).

§Errors

Returns ConfigurationError::CouldNotEnableStream if any internal exceptions occur while making this call. Note that this does not independently check the values passed into each of the provided arguments / attributes. If those are invalid, they will be checked when you call InactivePipeline::start or InactivePipeline::resolve.

Source

pub fn enable_all_streams(&mut self) -> Result<&mut Self, ConfigurationError>

Enable all device streams explicitly.

This enables all streams with the default configuration. What this means is that librealsense2 will pick the format, resolution, and framerate. If you want to specify those values yourself, see Config::enable_stream.

Returns a mutable reference to self if it succeeds or a configuration error.

§Errors

Returns ConfigurationError::CouldNotEnableAllStreams if this call fails for whatever reason.

Source

pub fn enable_device_from_serial( &mut self, serial: &CStr, ) -> Result<&mut Self, ConfigurationError>

Enable device from a serial number.

This is useful if you want to mandate that your configuration is only applied to a device with a specific serial number. The serial can be obtained from the Device method by passing in Rs2CameraInfo::SerialNumber.

Returns a mutable reference to self if it succeeds or a configuration error.

§Errors

Returns ConfigurationError::CouldNotEnableDevice if the device could not be enabled.

Source

pub fn enable_device_from_file<P>( &mut self, file: P, loop_playback: bool, ) -> Result<&mut Self>
where P: AsRef<Path>,

Enable device from a file path.

Enables a virtual “device” whose observations have been recorded to a file. If loop_playback is true, then the device will continue to stream observations once it has reached the end of the file by continuously looping back to the first observations in the serialized streams.

Returns a mutable reference to self if it succeeds or a configuration error.

§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 a ConfigurationError::CouldNotEnableDevice if the device cannot be enabled for any reason. e.g. if your file is valid and can be converted into a CString, but is actually a path to a directory, you’ll likely see an error here.

Source

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

Enable recording data streams to file.

Configuration option for writing / serializing data from the pipeline to a file. This happens independently of any frame delivery once the pipeline has been started. It is an error if you attempt to record to file if you are streaming from a file (see Config::enable_device_from_file).

Returns a mutable reference to self if it succeeds or an error.

§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 ConfigurationError::CouldNotEnableRecordingToFile if the path is not a valid path to a file or if you are trying to record to a file while streaming from a file.

Source

pub fn disable_stream_at_index( &mut self, stream: Rs2StreamKind, index: usize, ) -> Result<&mut Self, ConfigurationError>

Disable a specific data stream by stream index.

Returns a mutable reference to self or a configuration error.

§Errors

Returns ConfigurationError::CouldNotDisableStream if the stream cannot be disabled.

Source

pub fn disable_stream( &mut self, stream: Rs2StreamKind, ) -> Result<&mut Self, ConfigurationError>

Disable data stream by stream kind.

This method removes the first stream of the given stream kind.

Returns a mutable reference to self or a configuration error.

§Errors

Returns ConfigurationError::CouldNotDisableStream if the stream cannot be disabled.

Source

pub fn disable_all_streams(&mut self) -> Result<&mut Self, ConfigurationError>

Disable all device streams explicitly.

This method disables every stream.

Returns a mutable reference to self or a configuration error.

§Errors

Returns ConfigurationError::CouldNotDisableAllStreams if the streams cannot be disabled.

Trait Implementations§

Source§

impl Debug for Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for Config

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Config

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.