#![allow(missing_docs)]
use std::fmt;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Camera {
#[serde(rename = "createdAt")]
pub created_at: String,
pub enabled: bool,
pub id: String,
pub location: String,
pub name: String,
pub protocol: CameraProtocol,
#[serde(rename = "readingArea")]
pub reading_area: Option<ReadingArea>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DetectedPlate {
pub conf: f64,
#[serde(rename = "coordinateBottom")]
pub coordinate_bottom: i64,
#[serde(rename = "coordinateLeft")]
pub coordinate_left: i64,
#[serde(rename = "coordinateRight")]
pub coordinate_right: i64,
#[serde(rename = "coordinateTop")]
pub coordinate_top: i64,
#[serde(rename = "createdAt")]
pub created_at: String,
#[serde(rename = "plateType")]
pub plate_type: DetectedPlatePlatetype,
pub time: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DetectionImageLink {
#[serde(rename = "detectionId")]
pub detection_id: String,
#[serde(rename = "expiresIn")]
pub expires_in: i64,
#[serde(rename = "imageUrl")]
pub image_url: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PhotoDetection {
#[serde(rename = "imageHeight")]
pub image_height: i64,
#[serde(rename = "imageWidth")]
pub image_width: i64,
pub plates: Vec<DetectedPlate>,
#[serde(rename = "processingTimeMs")]
pub processing_time_ms: i64,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PhotoRecognition {
#[serde(rename = "creditsRemaining")]
pub credits_remaining: i64,
#[serde(rename = "imageHeight")]
pub image_height: i64,
#[serde(rename = "imageWidth")]
pub image_width: i64,
pub plates: Vec<RecognizedPlate>,
#[serde(rename = "processingTimeMs")]
pub processing_time_ms: i64,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PlateReading {
pub confidence: f64,
#[serde(rename = "creditsRemaining")]
pub credits_remaining: i64,
#[serde(rename = "detectionId")]
pub detection_id: Option<String>,
#[serde(rename = "latencyMs")]
pub latency_ms: i64,
pub plate: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ReadingArea {
#[serde(rename = "box")]
pub box_: ReadingAreaBox,
pub points: Vec<Vec<f64>>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ReadingAreaBox {
pub height: f64,
pub width: f64,
pub x: f64,
pub y: f64,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Recognition {
#[serde(rename = "cameraId")]
pub camera_id: Option<String>,
#[serde(rename = "capturedAt")]
pub captured_at: String,
pub conf: f64,
pub id: String,
pub plate: String,
pub source: RecognitionSource,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct RecognizedPlate {
#[serde(rename = "charConfs")]
pub char_confs: String,
pub conf: f64,
#[serde(rename = "coordinateBottom")]
pub coordinate_bottom: i64,
#[serde(rename = "coordinateLeft")]
pub coordinate_left: i64,
#[serde(rename = "coordinateRight")]
pub coordinate_right: i64,
#[serde(rename = "coordinateTop")]
pub coordinate_top: i64,
#[serde(rename = "createdAt")]
pub created_at: String,
pub plate: String,
#[serde(rename = "plateType")]
pub plate_type: RecognizedPlatePlatetype,
pub time: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WebhookAlertTriggered {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub camera_id: Option<String>,
pub captured_at: String,
pub confidence: f64,
pub event: WebhookAlertTriggeredEvent,
pub id: String,
pub plate: String,
pub recognition_id: String,
pub rule_id: String,
pub rule_name: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub skip: Option<Vec<String>>,
pub tenant_id: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WebhookRecognitionCreated {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub camera_id: Option<String>,
pub captured_at: String,
pub confidence: f64,
pub event: WebhookRecognitionCreatedEvent,
pub id: String,
pub plate: String,
pub source: WebhookRecognitionCreatedSource,
pub tenant_id: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WebhookTest {
pub event: WebhookTestEvent,
pub id: String,
pub sent_at: String,
pub tenant_id: String,
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct PhotosDetectParams {
pub image: Vec<u8>,
pub image_mode: Option<PhotosDetectParamsImageMode>,
pub lpr_confidence: Option<f64>,
pub min_ocr_confidence: Option<f64>,
}
impl PhotosDetectParams {
pub fn new(image: impl Into<Vec<u8>>) -> Self {
Self {
image: image.into(),
image_mode: None,
lpr_confidence: None,
min_ocr_confidence: None,
}
}
pub fn image_mode(mut self, image_mode: impl Into<PhotosDetectParamsImageMode>) -> Self {
self.image_mode = Some(image_mode.into());
self
}
pub fn lpr_confidence(mut self, lpr_confidence: f64) -> Self {
self.lpr_confidence = Some(lpr_confidence);
self
}
pub fn min_ocr_confidence(mut self, min_ocr_confidence: f64) -> Self {
self.min_ocr_confidence = Some(min_ocr_confidence);
self
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct PhotosOCRParams {
pub image: Vec<u8>,
}
impl PhotosOCRParams {
pub fn new(image: impl Into<Vec<u8>>) -> Self {
Self {
image: image.into(),
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct PhotosRecognizeParams {
pub image: Vec<u8>,
pub image_mode: Option<PhotosRecognizeParamsImageMode>,
pub lpr_confidence: Option<f64>,
pub min_ocr_confidence: Option<f64>,
}
impl PhotosRecognizeParams {
pub fn new(image: impl Into<Vec<u8>>) -> Self {
Self {
image: image.into(),
image_mode: None,
lpr_confidence: None,
min_ocr_confidence: None,
}
}
pub fn image_mode(mut self, image_mode: impl Into<PhotosRecognizeParamsImageMode>) -> Self {
self.image_mode = Some(image_mode.into());
self
}
pub fn lpr_confidence(mut self, lpr_confidence: f64) -> Self {
self.lpr_confidence = Some(lpr_confidence);
self
}
pub fn min_ocr_confidence(mut self, min_ocr_confidence: f64) -> Self {
self.min_ocr_confidence = Some(min_ocr_confidence);
self
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum CameraProtocol {
Rtsp,
Rtmp,
Hls,
Http,
Hikconnect,
Hikcloud,
Rtmppush,
Unrecognized(String),
}
impl CameraProtocol {
pub fn as_str(&self) -> &str {
match self {
CameraProtocol::Rtsp => "rtsp",
CameraProtocol::Rtmp => "rtmp",
CameraProtocol::Hls => "hls",
CameraProtocol::Http => "http",
CameraProtocol::Hikconnect => "hikconnect",
CameraProtocol::Hikcloud => "hikcloud",
CameraProtocol::Rtmppush => "rtmppush",
CameraProtocol::Unrecognized(value) => value,
}
}
}
impl From<&str> for CameraProtocol {
fn from(value: &str) -> Self {
match value {
"rtsp" => CameraProtocol::Rtsp,
"rtmp" => CameraProtocol::Rtmp,
"hls" => CameraProtocol::Hls,
"http" => CameraProtocol::Http,
"hikconnect" => CameraProtocol::Hikconnect,
"hikcloud" => CameraProtocol::Hikcloud,
"rtmppush" => CameraProtocol::Rtmppush,
other => CameraProtocol::Unrecognized(other.to_owned()),
}
}
}
impl From<String> for CameraProtocol {
fn from(value: String) -> Self {
Self::from(value.as_str())
}
}
impl fmt::Display for CameraProtocol {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl Serialize for CameraProtocol {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for CameraProtocol {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
String::deserialize(deserializer).map(Self::from)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum DetectedPlatePlatetype {
Car,
Unrecognized(String),
}
impl DetectedPlatePlatetype {
pub fn as_str(&self) -> &str {
match self {
DetectedPlatePlatetype::Car => "car",
DetectedPlatePlatetype::Unrecognized(value) => value,
}
}
}
impl From<&str> for DetectedPlatePlatetype {
fn from(value: &str) -> Self {
match value {
"car" => DetectedPlatePlatetype::Car,
other => DetectedPlatePlatetype::Unrecognized(other.to_owned()),
}
}
}
impl From<String> for DetectedPlatePlatetype {
fn from(value: String) -> Self {
Self::from(value.as_str())
}
}
impl fmt::Display for DetectedPlatePlatetype {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl Serialize for DetectedPlatePlatetype {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for DetectedPlatePlatetype {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
String::deserialize(deserializer).map(Self::from)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum PhotosDetectParamsImageMode {
None,
Unrecognized(String),
}
impl PhotosDetectParamsImageMode {
pub fn as_str(&self) -> &str {
match self {
PhotosDetectParamsImageMode::None => "NONE",
PhotosDetectParamsImageMode::Unrecognized(value) => value,
}
}
}
impl From<&str> for PhotosDetectParamsImageMode {
fn from(value: &str) -> Self {
match value {
"NONE" => PhotosDetectParamsImageMode::None,
other => PhotosDetectParamsImageMode::Unrecognized(other.to_owned()),
}
}
}
impl From<String> for PhotosDetectParamsImageMode {
fn from(value: String) -> Self {
Self::from(value.as_str())
}
}
impl fmt::Display for PhotosDetectParamsImageMode {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl Serialize for PhotosDetectParamsImageMode {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for PhotosDetectParamsImageMode {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
String::deserialize(deserializer).map(Self::from)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum PhotosRecognizeParamsImageMode {
None,
Unrecognized(String),
}
impl PhotosRecognizeParamsImageMode {
pub fn as_str(&self) -> &str {
match self {
PhotosRecognizeParamsImageMode::None => "NONE",
PhotosRecognizeParamsImageMode::Unrecognized(value) => value,
}
}
}
impl From<&str> for PhotosRecognizeParamsImageMode {
fn from(value: &str) -> Self {
match value {
"NONE" => PhotosRecognizeParamsImageMode::None,
other => PhotosRecognizeParamsImageMode::Unrecognized(other.to_owned()),
}
}
}
impl From<String> for PhotosRecognizeParamsImageMode {
fn from(value: String) -> Self {
Self::from(value.as_str())
}
}
impl fmt::Display for PhotosRecognizeParamsImageMode {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl Serialize for PhotosRecognizeParamsImageMode {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for PhotosRecognizeParamsImageMode {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
String::deserialize(deserializer).map(Self::from)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum RecognitionSource {
Camera,
Api,
Unrecognized(String),
}
impl RecognitionSource {
pub fn as_str(&self) -> &str {
match self {
RecognitionSource::Camera => "camera",
RecognitionSource::Api => "api",
RecognitionSource::Unrecognized(value) => value,
}
}
}
impl From<&str> for RecognitionSource {
fn from(value: &str) -> Self {
match value {
"camera" => RecognitionSource::Camera,
"api" => RecognitionSource::Api,
other => RecognitionSource::Unrecognized(other.to_owned()),
}
}
}
impl From<String> for RecognitionSource {
fn from(value: String) -> Self {
Self::from(value.as_str())
}
}
impl fmt::Display for RecognitionSource {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl Serialize for RecognitionSource {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for RecognitionSource {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
String::deserialize(deserializer).map(Self::from)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum RecognizedPlatePlatetype {
Car,
Unrecognized(String),
}
impl RecognizedPlatePlatetype {
pub fn as_str(&self) -> &str {
match self {
RecognizedPlatePlatetype::Car => "car",
RecognizedPlatePlatetype::Unrecognized(value) => value,
}
}
}
impl From<&str> for RecognizedPlatePlatetype {
fn from(value: &str) -> Self {
match value {
"car" => RecognizedPlatePlatetype::Car,
other => RecognizedPlatePlatetype::Unrecognized(other.to_owned()),
}
}
}
impl From<String> for RecognizedPlatePlatetype {
fn from(value: String) -> Self {
Self::from(value.as_str())
}
}
impl fmt::Display for RecognizedPlatePlatetype {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl Serialize for RecognizedPlatePlatetype {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for RecognizedPlatePlatetype {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
String::deserialize(deserializer).map(Self::from)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum WebhookAlertTriggeredEvent {
AlertTriggered,
Unrecognized(String),
}
impl WebhookAlertTriggeredEvent {
pub fn as_str(&self) -> &str {
match self {
WebhookAlertTriggeredEvent::AlertTriggered => "alert.triggered",
WebhookAlertTriggeredEvent::Unrecognized(value) => value,
}
}
}
impl From<&str> for WebhookAlertTriggeredEvent {
fn from(value: &str) -> Self {
match value {
"alert.triggered" => WebhookAlertTriggeredEvent::AlertTriggered,
other => WebhookAlertTriggeredEvent::Unrecognized(other.to_owned()),
}
}
}
impl From<String> for WebhookAlertTriggeredEvent {
fn from(value: String) -> Self {
Self::from(value.as_str())
}
}
impl fmt::Display for WebhookAlertTriggeredEvent {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl Serialize for WebhookAlertTriggeredEvent {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for WebhookAlertTriggeredEvent {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
String::deserialize(deserializer).map(Self::from)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum WebhookRecognitionCreatedEvent {
RecognitionCreated,
Unrecognized(String),
}
impl WebhookRecognitionCreatedEvent {
pub fn as_str(&self) -> &str {
match self {
WebhookRecognitionCreatedEvent::RecognitionCreated => "recognition.created",
WebhookRecognitionCreatedEvent::Unrecognized(value) => value,
}
}
}
impl From<&str> for WebhookRecognitionCreatedEvent {
fn from(value: &str) -> Self {
match value {
"recognition.created" => WebhookRecognitionCreatedEvent::RecognitionCreated,
other => WebhookRecognitionCreatedEvent::Unrecognized(other.to_owned()),
}
}
}
impl From<String> for WebhookRecognitionCreatedEvent {
fn from(value: String) -> Self {
Self::from(value.as_str())
}
}
impl fmt::Display for WebhookRecognitionCreatedEvent {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl Serialize for WebhookRecognitionCreatedEvent {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for WebhookRecognitionCreatedEvent {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
String::deserialize(deserializer).map(Self::from)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum WebhookRecognitionCreatedSource {
Camera,
Api,
Unrecognized(String),
}
impl WebhookRecognitionCreatedSource {
pub fn as_str(&self) -> &str {
match self {
WebhookRecognitionCreatedSource::Camera => "camera",
WebhookRecognitionCreatedSource::Api => "api",
WebhookRecognitionCreatedSource::Unrecognized(value) => value,
}
}
}
impl From<&str> for WebhookRecognitionCreatedSource {
fn from(value: &str) -> Self {
match value {
"camera" => WebhookRecognitionCreatedSource::Camera,
"api" => WebhookRecognitionCreatedSource::Api,
other => WebhookRecognitionCreatedSource::Unrecognized(other.to_owned()),
}
}
}
impl From<String> for WebhookRecognitionCreatedSource {
fn from(value: String) -> Self {
Self::from(value.as_str())
}
}
impl fmt::Display for WebhookRecognitionCreatedSource {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl Serialize for WebhookRecognitionCreatedSource {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for WebhookRecognitionCreatedSource {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
String::deserialize(deserializer).map(Self::from)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum WebhookTestEvent {
WebhookTest,
Unrecognized(String),
}
impl WebhookTestEvent {
pub fn as_str(&self) -> &str {
match self {
WebhookTestEvent::WebhookTest => "webhook.test",
WebhookTestEvent::Unrecognized(value) => value,
}
}
}
impl From<&str> for WebhookTestEvent {
fn from(value: &str) -> Self {
match value {
"webhook.test" => WebhookTestEvent::WebhookTest,
other => WebhookTestEvent::Unrecognized(other.to_owned()),
}
}
}
impl From<String> for WebhookTestEvent {
fn from(value: String) -> Self {
Self::from(value.as_str())
}
}
impl fmt::Display for WebhookTestEvent {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
impl Serialize for WebhookTestEvent {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(self.as_str())
}
}
impl<'de> Deserialize<'de> for WebhookTestEvent {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
String::deserialize(deserializer).map(Self::from)
}
}