Expand description
Contains commonly used enumerations and configuration types used across the crate.
The Kind
module holds a variety of types useful across realsense-rust APIs as transient
values. The vast majority of types in this module are enums, which map to C-style enums in the
lower-level realsense-sys
bindings.
§Architecture
The low-level bindings for librealsense2 in realsense-sys
represent the C-style enums as
u32
constants. They are wrapped / transformed into fully qualified types here so as to
increase type safety across the API.
All of these “wrapper” enums in Rust implement the ToPrimitive
and
FromPrimitive
traits from the num_traits
crate. If you need to
access the original enum value, you can do so with the following code:
use num_traits::ToPrimitive;
use realsense_rust::kind::Rs2Extension;
let ext = Rs2Extension::ColorSensor;
println!("The extension is: {}", ext.to_u32().unwrap());
In practice, most of the time you shouldn’t need to wrap or unwrap u32
values, and the API
should never spit one out at you.
§What happened to COUNT
?
If you read through the librealsense2 C-API, you’ll find that every enumeration has a “count”
entry. Placing a “count” entry at the end of a C-style enum is a common pattern used to be able
to iterate over every possible enum variant. This works because C treats every enum variant as
a distinct u32
value, instead of a distinct variant of a type. In this crate, we take the
approach that this is unlikely to be something that is undertaken, so we don’t provide any
direct means to iterate through every value of each enum variant.
If you truly need to do this, let us know! There are crates that make this possible and integrate well with native Rust iterators, but we have chosen to avoid the extra depedencies for this crate.
If you need a workaround, you can always use the lower-level realsense-sys
API:
use num_traits::FromPrimitive;
use realsense_sys as sys;
use realsense_rust::kind::Rs2CameraInfo;
for i in 0..sys::rs2_camera_info_RS2_CAMERA_INFO_COUNT as i32 {
println!(
"The enum variant {:?} corresponds to the i32 value {}",
Rs2CameraInfo::from_i32(i).unwrap(),
i,
);
}
Structs§
- Rs2Option
Range - The range of available values of a supported option.
Enums§
- Color
Scheme - A type describing the various color scheme choices for colorizer processing blocks.
- Hole
Filling Mode - A type describing the method that will be used to fill invalid pixels.
- Option
SetError - Occur when an option cannot be set.
- Persistence
Control - An enumeration of the various persistence controls used in processing blocks.
- Rs2Camera
Info - A type describing the different keys used to access camera info from devices and sensors.
- Rs2Distortion
Model - An enum for the various kinds of distortion models provided by librealsense2.
- Rs2Exception
- Enumeration of possible exception types that can be returned via
rs2_error
- Rs2Extension
- Enumeration of interface extensions
- Rs2Format
- A type representing all possible data formats for raw frame data
- Rs2Frame
Metadata - A type describing the different metadata keys used to access frame metadata.
- Rs2Option
- The enumeration of options available in the RealSense SDK.
- Rs2Product
Line - Type describing possible options for RealSense-supported product lines.
- Rs2Stream
Kind - The enumeration of possible stream kinds.
- Rs2Timestamp
Domain - Enumeration of possible timestamp domains that frame timestamps are delivered in.
Constants§
- DEVICE_
EXTENSIONS - A collection of the various rs2 device extensions
- FILTER_
EXTENSIONS - A collection of the various rs2 filter extensions
- FRAME_
EXTENSIONS - A collection of the various rs2 frame extensions
- MISC_
EXTENSIONS - A collection of the various rs2 miscellaneous extensions
- PROFILE_
EXTENSIONS - A collection of the various rs2 profile extensions
- SENSOR_
EXTENSIONS - A collection of the various rs2 sensor extensions