use crate::{
kind::{Rs2Exception, Rs2Extension, Rs2FrameMetadata, Rs2StreamKind, Rs2TimestampDomain},
sensor::Sensor,
stream_profile::StreamProfile,
};
use anyhow::Result;
use realsense_sys as sys;
use std::ptr::NonNull;
use thiserror::Error;
pub const BITS_PER_BYTE: i32 = 8;
#[derive(Error, Debug)]
pub enum FrameConstructionError {
#[error("Could not get frame width. Type: {0}; Reason: {1}")]
CouldNotGetWidth(Rs2Exception, String),
#[error("Could not get frame height. Type: {0}; Reason: {1}")]
CouldNotGetHeight(Rs2Exception, String),
#[error("Could not get stride. Type: {0}; Reason: {1}")]
CouldNotGetStride(Rs2Exception, String),
#[error("Could not get bits-per-pixel. Type: {0}; Reason: {1}")]
CouldNotGetBitsPerPixel(Rs2Exception, String),
#[error("Could not get timestamp. Type: {0}; Reason: {1}")]
CouldNotGetTimestamp(Rs2Exception, String),
#[error("Could not get timestamp domain. Type: {0}; Reason: {1}")]
CouldNotGetTimestampDomain(Rs2Exception, String),
#[error("Could not get frame number. Type: {0}; Reason: {1}")]
CouldNotGetFrameNumber(Rs2Exception, String),
#[error("Could not get frame stream profile. Type: {0}; Reason: {1}")]
CouldNotGetFrameStreamProfile(Rs2Exception, String),
#[error("Could not get data size (in bytes). Type: {0}; Reason: {1}")]
CouldNotGetDataSize(Rs2Exception, String),
#[error("Could not get pointer to frame data. Type: {0}; Reason: {1}")]
CouldNotGetData(Rs2Exception, String),
#[error("Could not get number of points: Type: {0}; Reason: {1}")]
CouldNotGetPointCount(Rs2Exception, String),
}
#[derive(Error, Debug)]
pub enum DepthError {
#[error("Could not get distance. Type: {0}; Reason: {1}")]
CouldNotGetDistance(Rs2Exception, String),
#[error("Could not get depth units. Type: {0}; Reason: {1}")]
CouldNotGetDepthUnits(Rs2Exception, String),
}
#[derive(Error, Debug)]
#[error("Could not get baseline. Type: {0}; Reason: {1}")]
pub struct DisparityError(pub Rs2Exception, pub String);
#[derive(Error, Debug)]
#[error("Could not get frame sensor. Type: {0}; Reason: {1}")]
pub struct CouldNotGetFrameSensorError(pub Rs2Exception, pub String);
pub trait FrameEx {
fn stream_profile(&self) -> &StreamProfile;
fn sensor(&self) -> Result<Sensor>;
fn frame_number(&self) -> u64;
fn timestamp(&self) -> f64;
fn timestamp_domain(&self) -> Rs2TimestampDomain;
fn metadata(&self, metadata_kind: Rs2FrameMetadata) -> Option<std::os::raw::c_longlong>;
fn supports_metadata(&self, metadata_kind: Rs2FrameMetadata) -> bool;
unsafe fn get_owned_raw(self) -> NonNull<sys::rs2_frame>;
}
pub trait FrameCategory {
fn extension() -> Rs2Extension;
fn kind() -> Rs2StreamKind;
fn has_correct_kind(&self) -> bool;
}