pub struct Config { /* private fields */ }
Expand description
Type representing the Pipeline
configuration.
Implementations§
Source§impl Config
impl Config
Sourcepub fn enable_stream(
&mut self,
stream: Rs2StreamKind,
index: Option<usize>,
width: usize,
height: usize,
format: Rs2Format,
framerate: usize,
) -> Result<&mut Self, ConfigurationError>
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
.
Sourcepub fn enable_all_streams(&mut self) -> Result<&mut Self, ConfigurationError>
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.
Sourcepub fn enable_device_from_serial(
&mut self,
serial: &CStr,
) -> Result<&mut Self, ConfigurationError>
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.
Sourcepub fn enable_device_from_file<P>(
&mut self,
file: P,
loop_playback: bool,
) -> Result<&mut Self>
pub fn enable_device_from_file<P>( &mut self, file: P, loop_playback: bool, ) -> Result<&mut Self>
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.
Sourcepub fn enable_record_to_file<P>(&mut self, file: P) -> Result<&mut Self>
pub fn enable_record_to_file<P>(&mut self, file: P) -> Result<&mut Self>
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.
Sourcepub fn disable_stream_at_index(
&mut self,
stream: Rs2StreamKind,
index: usize,
) -> Result<&mut Self, ConfigurationError>
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.
Sourcepub fn disable_stream(
&mut self,
stream: Rs2StreamKind,
) -> Result<&mut Self, ConfigurationError>
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.
Sourcepub fn disable_all_streams(&mut self) -> Result<&mut Self, ConfigurationError>
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.