Skip to main content

alpr/
models.rs

1// Code generated by sdk/generator. DO NOT EDIT.
2
3//! The resources Alpr.sh's API answers and the bodies its calls take.
4
5// A field is documented when the contract describes it; its name says the rest.
6#![allow(missing_docs)]
7
8use std::fmt;
9
10use serde::{Deserialize, Deserializer, Serialize, Serializer};
11
12/// Camera is a resource of Alpr.sh's API.
13#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
14#[non_exhaustive]
15pub struct Camera {
16    #[serde(rename = "createdAt")]
17    pub created_at: String,
18    pub enabled: bool,
19    pub id: String,
20    /// O endereço da câmera como texto; vazio se não foi informado.
21    pub location: String,
22    pub name: String,
23    /// Como a câmera é lida. Nunca traz o endereço do stream, usuário nem senha.
24    pub protocol: CameraProtocol,
25    /// Nulo quando a câmera lê a imagem inteira.
26    #[serde(rename = "readingArea")]
27    pub reading_area: Option<ReadingArea>,
28}
29
30/// DetectedPlate is a resource of Alpr.sh's API.
31#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
32#[non_exhaustive]
33pub struct DetectedPlate {
34    /// Confiança do detector, de 0 a 100, com uma casa.
35    pub conf: f64,
36    #[serde(rename = "coordinateBottom")]
37    pub coordinate_bottom: i64,
38    #[serde(rename = "coordinateLeft")]
39    pub coordinate_left: i64,
40    #[serde(rename = "coordinateRight")]
41    pub coordinate_right: i64,
42    #[serde(rename = "coordinateTop")]
43    pub coordinate_top: i64,
44    #[serde(rename = "createdAt")]
45    pub created_at: String,
46    #[serde(rename = "plateType")]
47    pub plate_type: DetectedPlatePlatetype,
48    pub time: String,
49}
50
51/// DetectionImageLink is a resource of Alpr.sh's API.
52#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
53#[non_exhaustive]
54pub struct DetectionImageLink {
55    #[serde(rename = "detectionId")]
56    pub detection_id: String,
57    /// Segundos de validade do link (300).
58    #[serde(rename = "expiresIn")]
59    pub expires_in: i64,
60    /// Endereço absoluto de GET /api/v1/detections/{id}/image/file, assinado; abra-o como veio.
61    #[serde(rename = "imageUrl")]
62    pub image_url: String,
63}
64
65/// PhotoDetection is a resource of Alpr.sh's API.
66#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
67#[non_exhaustive]
68pub struct PhotoDetection {
69    #[serde(rename = "imageHeight")]
70    pub image_height: i64,
71    #[serde(rename = "imageWidth")]
72    pub image_width: i64,
73    /// Onde há placa, sem o texto; o detector não filtra pelo formato brasileiro. Sem placa, [].
74    pub plates: Vec<DetectedPlate>,
75    #[serde(rename = "processingTimeMs")]
76    pub processing_time_ms: i64,
77}
78
79/// PhotoRecognition is a resource of Alpr.sh's API.
80#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
81#[non_exhaustive]
82pub struct PhotoRecognition {
83    /// Créditos que sobraram depois desta leitura.
84    #[serde(rename = "creditsRemaining")]
85    pub credits_remaining: i64,
86    #[serde(rename = "imageHeight")]
87    pub image_height: i64,
88    #[serde(rename = "imageWidth")]
89    pub image_width: i64,
90    /// Só as placas válidas no Brasil (ABC1234 ou ABC1D23); sem placa, [].
91    pub plates: Vec<RecognizedPlate>,
92    #[serde(rename = "processingTimeMs")]
93    pub processing_time_ms: i64,
94}
95
96/// PlateReading is a resource of Alpr.sh's API.
97#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
98#[non_exhaustive]
99pub struct PlateReading {
100    /// Confiança da leitura, de 0 a 1 com quatro casas (nas outras rotas conf vai de 0 a 100).
101    pub confidence: f64,
102    /// Créditos que sobraram depois desta leitura.
103    #[serde(rename = "creditsRemaining")]
104    pub credits_remaining: i64,
105    /// Hoje sempre nulo: a leitura de uma placa recortada não é guardada.
106    #[serde(rename = "detectionId")]
107    pub detection_id: Option<String>,
108    #[serde(rename = "latencyMs")]
109    pub latency_ms: i64,
110    /// O texto lido, sem hífen, maiúsculo; não é validado pelo formato brasileiro.
111    pub plate: String,
112}
113
114/// ReadingArea is a resource of Alpr.sh's API.
115#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
116#[non_exhaustive]
117pub struct ReadingArea {
118    /// A caixa envolvente, em frações da imagem (0 a 1); é o que o motor lê.
119    #[serde(rename = "box")]
120    pub box_: ReadingAreaBox,
121    /// Os cantos do polígono, de 3 a 16 pares [x, y] em frações da imagem; um retângulo traz os quatro cantos. Placas fora dele são ignoradas.
122    pub points: Vec<Vec<f64>>,
123}
124
125/// A caixa envolvente, em frações da imagem (0 a 1); é o que o motor lê.
126#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
127#[non_exhaustive]
128pub struct ReadingAreaBox {
129    pub height: f64,
130    pub width: f64,
131    pub x: f64,
132    pub y: f64,
133}
134
135/// Recognition is a resource of Alpr.sh's API.
136#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
137#[non_exhaustive]
138pub struct Recognition {
139    /// Nulo numa leitura feita pela API por foto.
140    #[serde(rename = "cameraId")]
141    pub camera_id: Option<String>,
142    /// Com o deslocamento do fuso do Alpr.sh.
143    #[serde(rename = "capturedAt")]
144    pub captured_at: String,
145    /// De 0 a 100, com uma casa.
146    pub conf: f64,
147    pub id: String,
148    pub plate: String,
149    /// camera: lida por uma câmera; api: enviada por foto.
150    pub source: RecognitionSource,
151}
152
153/// RecognizedPlate is a resource of Alpr.sh's API.
154#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
155#[non_exhaustive]
156pub struct RecognizedPlate {
157    /// Confiança de cada caractere, de 0 a 1 com duas casas, separadas por ponto e vírgula ("0.99;0.98").
158    #[serde(rename = "charConfs")]
159    pub char_confs: String,
160    /// Confiança da placa, de 0 a 100, com uma casa.
161    pub conf: f64,
162    /// Pixels da foto enviada.
163    #[serde(rename = "coordinateBottom")]
164    pub coordinate_bottom: i64,
165    #[serde(rename = "coordinateLeft")]
166    pub coordinate_left: i64,
167    #[serde(rename = "coordinateRight")]
168    pub coordinate_right: i64,
169    #[serde(rename = "coordinateTop")]
170    pub coordinate_top: i64,
171    /// Igual a time.
172    #[serde(rename = "createdAt")]
173    pub created_at: String,
174    /// Sete caracteres, maiúsculos: ABC1234 ou ABC1D23 (Mercosul).
175    pub plate: String,
176    /// Sempre car; a API não informa país nem formato.
177    #[serde(rename = "plateType")]
178    pub plate_type: RecognizedPlatePlatetype,
179    /// Instante da leitura, com o deslocamento do fuso do Alpr.sh.
180    pub time: String,
181}
182
183/// WebhookAlertTriggered is a resource of Alpr.sh's API.
184#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
185#[non_exhaustive]
186pub struct WebhookAlertTriggered {
187    /// Ausente se a leitura não veio de uma câmera.
188    #[serde(default, skip_serializing_if = "Option::is_none")]
189    pub camera_id: Option<String>,
190    pub captured_at: String,
191    /// De 0 a 1.
192    pub confidence: f64,
193    pub event: WebhookAlertTriggeredEvent,
194    /// O id do disparo.
195    pub id: String,
196    pub plate: String,
197    /// A leitura que disparou o alerta.
198    pub recognition_id: String,
199    pub rule_id: String,
200    pub rule_name: String,
201    /// Os destinos que as listas de permitidos e de bloqueados excluíram deste disparo (internal, channel:<id>, partner:<id>). Presente só quando algum foi excluído; é informação, não há o que fazer com ela.
202    #[serde(default, skip_serializing_if = "Option::is_none")]
203    pub skip: Option<Vec<String>>,
204    pub tenant_id: String,
205}
206
207/// WebhookRecognitionCreated is a resource of Alpr.sh's API.
208#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
209#[non_exhaustive]
210pub struct WebhookRecognitionCreated {
211    /// Ausente numa leitura enviada por foto.
212    #[serde(default, skip_serializing_if = "Option::is_none")]
213    pub camera_id: Option<String>,
214    /// UTC, com fração de segundo.
215    pub captured_at: String,
216    /// De 0 a 1 (na API de chave, conf vai de 0 a 100).
217    pub confidence: f64,
218    pub event: WebhookRecognitionCreatedEvent,
219    /// O id da leitura; é o mesmo id de GET /api/v1/recognitions e de GET /api/v1/detections/{id}/image.
220    pub id: String,
221    pub plate: String,
222    /// camera: lida por uma câmera; api: enviada por foto.
223    pub source: WebhookRecognitionCreatedSource,
224    /// O espaço de trabalho dono da leitura.
225    pub tenant_id: String,
226}
227
228/// WebhookTest is a resource of Alpr.sh's API.
229#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
230#[non_exhaustive]
231pub struct WebhookTest {
232    pub event: WebhookTestEvent,
233    pub id: String,
234    pub sent_at: String,
235    pub tenant_id: String,
236}
237
238/// The body of photos:detect.
239///
240/// [`PhotosDetectParams::new`] takes the required fields; each optional one is set by
241/// the method of its name. The body is sent as `multipart/form-data`, so
242/// nothing here is JSON: the photo is its bytes.
243#[derive(Debug, Clone, PartialEq)]
244#[non_exhaustive]
245pub struct PhotosDetectParams {
246    /// A foto, JPEG ou PNG.
247    pub image: Vec<u8>,
248    /// Só NONE é aceito.
249    pub image_mode: Option<PhotosDetectParamsImageMode>,
250    /// Piso de confiança do detector de placas.
251    pub lpr_confidence: Option<f64>,
252    /// Piso de confiança da leitura dos caracteres.
253    pub min_ocr_confidence: Option<f64>,
254}
255
256impl PhotosDetectParams {
257    /// A body with its required fields.
258    pub fn new(image: impl Into<Vec<u8>>) -> Self {
259        Self {
260            image: image.into(),
261            image_mode: None,
262            lpr_confidence: None,
263            min_ocr_confidence: None,
264        }
265    }
266
267    /// Só NONE é aceito.
268    pub fn image_mode(mut self, image_mode: impl Into<PhotosDetectParamsImageMode>) -> Self {
269        self.image_mode = Some(image_mode.into());
270        self
271    }
272
273    /// Piso de confiança do detector de placas.
274    pub fn lpr_confidence(mut self, lpr_confidence: f64) -> Self {
275        self.lpr_confidence = Some(lpr_confidence);
276        self
277    }
278
279    /// Piso de confiança da leitura dos caracteres.
280    pub fn min_ocr_confidence(mut self, min_ocr_confidence: f64) -> Self {
281        self.min_ocr_confidence = Some(min_ocr_confidence);
282        self
283    }
284}
285
286/// The body of photos:ocr.
287///
288/// [`PhotosOCRParams::new`] takes the required fields; each optional one is set by
289/// the method of its name. The body is sent as `multipart/form-data`, so
290/// nothing here is JSON: the photo is its bytes.
291#[derive(Debug, Clone, PartialEq)]
292#[non_exhaustive]
293pub struct PhotosOCRParams {
294    /// A imagem da placa já recortada, JPEG ou PNG.
295    pub image: Vec<u8>,
296}
297
298impl PhotosOCRParams {
299    /// A body with its required fields.
300    pub fn new(image: impl Into<Vec<u8>>) -> Self {
301        Self {
302            image: image.into(),
303        }
304    }
305}
306
307/// The body of photos:recognize.
308///
309/// [`PhotosRecognizeParams::new`] takes the required fields; each optional one is set by
310/// the method of its name. The body is sent as `multipart/form-data`, so
311/// nothing here is JSON: the photo is its bytes.
312#[derive(Debug, Clone, PartialEq)]
313#[non_exhaustive]
314pub struct PhotosRecognizeParams {
315    /// A foto, JPEG ou PNG.
316    pub image: Vec<u8>,
317    /// Só NONE é aceito.
318    pub image_mode: Option<PhotosRecognizeParamsImageMode>,
319    /// Piso de confiança do detector de placas.
320    pub lpr_confidence: Option<f64>,
321    /// Piso de confiança da leitura dos caracteres.
322    pub min_ocr_confidence: Option<f64>,
323}
324
325impl PhotosRecognizeParams {
326    /// A body with its required fields.
327    pub fn new(image: impl Into<Vec<u8>>) -> Self {
328        Self {
329            image: image.into(),
330            image_mode: None,
331            lpr_confidence: None,
332            min_ocr_confidence: None,
333        }
334    }
335
336    /// Só NONE é aceito.
337    pub fn image_mode(mut self, image_mode: impl Into<PhotosRecognizeParamsImageMode>) -> Self {
338        self.image_mode = Some(image_mode.into());
339        self
340    }
341
342    /// Piso de confiança do detector de placas.
343    pub fn lpr_confidence(mut self, lpr_confidence: f64) -> Self {
344        self.lpr_confidence = Some(lpr_confidence);
345        self
346    }
347
348    /// Piso de confiança da leitura dos caracteres.
349    pub fn min_ocr_confidence(mut self, min_ocr_confidence: f64) -> Self {
350        self.min_ocr_confidence = Some(min_ocr_confidence);
351        self
352    }
353}
354
355/// The values of `Camera.protocol`. Como a câmera é lida. Nunca traz o endereço do stream, usuário nem senha.
356///
357/// A value this SDK does not know yet is kept, as it came, in
358/// [`CameraProtocol::Unrecognized`].
359#[derive(Debug, Clone, PartialEq, Eq, Hash)]
360#[non_exhaustive]
361pub enum CameraProtocol {
362    /// `rtsp`
363    Rtsp,
364    /// `rtmp`
365    Rtmp,
366    /// `hls`
367    Hls,
368    /// `http`
369    Http,
370    /// `hikconnect`
371    Hikconnect,
372    /// `hikcloud`
373    Hikcloud,
374    /// `rtmppush`
375    Rtmppush,
376    /// A value this SDK does not know yet.
377    Unrecognized(String),
378}
379
380impl CameraProtocol {
381    /// The value as the API writes it.
382    pub fn as_str(&self) -> &str {
383        match self {
384            CameraProtocol::Rtsp => "rtsp",
385            CameraProtocol::Rtmp => "rtmp",
386            CameraProtocol::Hls => "hls",
387            CameraProtocol::Http => "http",
388            CameraProtocol::Hikconnect => "hikconnect",
389            CameraProtocol::Hikcloud => "hikcloud",
390            CameraProtocol::Rtmppush => "rtmppush",
391            CameraProtocol::Unrecognized(value) => value,
392        }
393    }
394}
395
396impl From<&str> for CameraProtocol {
397    fn from(value: &str) -> Self {
398        match value {
399            "rtsp" => CameraProtocol::Rtsp,
400            "rtmp" => CameraProtocol::Rtmp,
401            "hls" => CameraProtocol::Hls,
402            "http" => CameraProtocol::Http,
403            "hikconnect" => CameraProtocol::Hikconnect,
404            "hikcloud" => CameraProtocol::Hikcloud,
405            "rtmppush" => CameraProtocol::Rtmppush,
406            other => CameraProtocol::Unrecognized(other.to_owned()),
407        }
408    }
409}
410
411impl From<String> for CameraProtocol {
412    fn from(value: String) -> Self {
413        Self::from(value.as_str())
414    }
415}
416
417impl fmt::Display for CameraProtocol {
418    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
419        f.write_str(self.as_str())
420    }
421}
422
423impl Serialize for CameraProtocol {
424    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
425        serializer.serialize_str(self.as_str())
426    }
427}
428
429impl<'de> Deserialize<'de> for CameraProtocol {
430    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
431        String::deserialize(deserializer).map(Self::from)
432    }
433}
434
435/// The values of `DetectedPlate.plateType`.
436///
437/// A value this SDK does not know yet is kept, as it came, in
438/// [`DetectedPlatePlatetype::Unrecognized`].
439#[derive(Debug, Clone, PartialEq, Eq, Hash)]
440#[non_exhaustive]
441pub enum DetectedPlatePlatetype {
442    /// `car`
443    Car,
444    /// A value this SDK does not know yet.
445    Unrecognized(String),
446}
447
448impl DetectedPlatePlatetype {
449    /// The value as the API writes it.
450    pub fn as_str(&self) -> &str {
451        match self {
452            DetectedPlatePlatetype::Car => "car",
453            DetectedPlatePlatetype::Unrecognized(value) => value,
454        }
455    }
456}
457
458impl From<&str> for DetectedPlatePlatetype {
459    fn from(value: &str) -> Self {
460        match value {
461            "car" => DetectedPlatePlatetype::Car,
462            other => DetectedPlatePlatetype::Unrecognized(other.to_owned()),
463        }
464    }
465}
466
467impl From<String> for DetectedPlatePlatetype {
468    fn from(value: String) -> Self {
469        Self::from(value.as_str())
470    }
471}
472
473impl fmt::Display for DetectedPlatePlatetype {
474    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
475        f.write_str(self.as_str())
476    }
477}
478
479impl Serialize for DetectedPlatePlatetype {
480    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
481        serializer.serialize_str(self.as_str())
482    }
483}
484
485impl<'de> Deserialize<'de> for DetectedPlatePlatetype {
486    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
487        String::deserialize(deserializer).map(Self::from)
488    }
489}
490
491/// The values of `PhotosDetectParams.image_mode`. Só NONE é aceito.
492///
493/// A value this SDK does not know yet is kept, as it came, in
494/// [`PhotosDetectParamsImageMode::Unrecognized`].
495#[derive(Debug, Clone, PartialEq, Eq, Hash)]
496#[non_exhaustive]
497pub enum PhotosDetectParamsImageMode {
498    /// `NONE`
499    None,
500    /// A value this SDK does not know yet.
501    Unrecognized(String),
502}
503
504impl PhotosDetectParamsImageMode {
505    /// The value as the API writes it.
506    pub fn as_str(&self) -> &str {
507        match self {
508            PhotosDetectParamsImageMode::None => "NONE",
509            PhotosDetectParamsImageMode::Unrecognized(value) => value,
510        }
511    }
512}
513
514impl From<&str> for PhotosDetectParamsImageMode {
515    fn from(value: &str) -> Self {
516        match value {
517            "NONE" => PhotosDetectParamsImageMode::None,
518            other => PhotosDetectParamsImageMode::Unrecognized(other.to_owned()),
519        }
520    }
521}
522
523impl From<String> for PhotosDetectParamsImageMode {
524    fn from(value: String) -> Self {
525        Self::from(value.as_str())
526    }
527}
528
529impl fmt::Display for PhotosDetectParamsImageMode {
530    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
531        f.write_str(self.as_str())
532    }
533}
534
535impl Serialize for PhotosDetectParamsImageMode {
536    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
537        serializer.serialize_str(self.as_str())
538    }
539}
540
541impl<'de> Deserialize<'de> for PhotosDetectParamsImageMode {
542    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
543        String::deserialize(deserializer).map(Self::from)
544    }
545}
546
547/// The values of `PhotosRecognizeParams.image_mode`. Só NONE é aceito.
548///
549/// A value this SDK does not know yet is kept, as it came, in
550/// [`PhotosRecognizeParamsImageMode::Unrecognized`].
551#[derive(Debug, Clone, PartialEq, Eq, Hash)]
552#[non_exhaustive]
553pub enum PhotosRecognizeParamsImageMode {
554    /// `NONE`
555    None,
556    /// A value this SDK does not know yet.
557    Unrecognized(String),
558}
559
560impl PhotosRecognizeParamsImageMode {
561    /// The value as the API writes it.
562    pub fn as_str(&self) -> &str {
563        match self {
564            PhotosRecognizeParamsImageMode::None => "NONE",
565            PhotosRecognizeParamsImageMode::Unrecognized(value) => value,
566        }
567    }
568}
569
570impl From<&str> for PhotosRecognizeParamsImageMode {
571    fn from(value: &str) -> Self {
572        match value {
573            "NONE" => PhotosRecognizeParamsImageMode::None,
574            other => PhotosRecognizeParamsImageMode::Unrecognized(other.to_owned()),
575        }
576    }
577}
578
579impl From<String> for PhotosRecognizeParamsImageMode {
580    fn from(value: String) -> Self {
581        Self::from(value.as_str())
582    }
583}
584
585impl fmt::Display for PhotosRecognizeParamsImageMode {
586    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
587        f.write_str(self.as_str())
588    }
589}
590
591impl Serialize for PhotosRecognizeParamsImageMode {
592    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
593        serializer.serialize_str(self.as_str())
594    }
595}
596
597impl<'de> Deserialize<'de> for PhotosRecognizeParamsImageMode {
598    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
599        String::deserialize(deserializer).map(Self::from)
600    }
601}
602
603/// The values of `Recognition.source`. camera: lida por uma câmera; api: enviada por foto.
604///
605/// A value this SDK does not know yet is kept, as it came, in
606/// [`RecognitionSource::Unrecognized`].
607#[derive(Debug, Clone, PartialEq, Eq, Hash)]
608#[non_exhaustive]
609pub enum RecognitionSource {
610    /// `camera`
611    Camera,
612    /// `api`
613    Api,
614    /// A value this SDK does not know yet.
615    Unrecognized(String),
616}
617
618impl RecognitionSource {
619    /// The value as the API writes it.
620    pub fn as_str(&self) -> &str {
621        match self {
622            RecognitionSource::Camera => "camera",
623            RecognitionSource::Api => "api",
624            RecognitionSource::Unrecognized(value) => value,
625        }
626    }
627}
628
629impl From<&str> for RecognitionSource {
630    fn from(value: &str) -> Self {
631        match value {
632            "camera" => RecognitionSource::Camera,
633            "api" => RecognitionSource::Api,
634            other => RecognitionSource::Unrecognized(other.to_owned()),
635        }
636    }
637}
638
639impl From<String> for RecognitionSource {
640    fn from(value: String) -> Self {
641        Self::from(value.as_str())
642    }
643}
644
645impl fmt::Display for RecognitionSource {
646    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
647        f.write_str(self.as_str())
648    }
649}
650
651impl Serialize for RecognitionSource {
652    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
653        serializer.serialize_str(self.as_str())
654    }
655}
656
657impl<'de> Deserialize<'de> for RecognitionSource {
658    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
659        String::deserialize(deserializer).map(Self::from)
660    }
661}
662
663/// The values of `RecognizedPlate.plateType`. Sempre car; a API não informa país nem formato.
664///
665/// A value this SDK does not know yet is kept, as it came, in
666/// [`RecognizedPlatePlatetype::Unrecognized`].
667#[derive(Debug, Clone, PartialEq, Eq, Hash)]
668#[non_exhaustive]
669pub enum RecognizedPlatePlatetype {
670    /// `car`
671    Car,
672    /// A value this SDK does not know yet.
673    Unrecognized(String),
674}
675
676impl RecognizedPlatePlatetype {
677    /// The value as the API writes it.
678    pub fn as_str(&self) -> &str {
679        match self {
680            RecognizedPlatePlatetype::Car => "car",
681            RecognizedPlatePlatetype::Unrecognized(value) => value,
682        }
683    }
684}
685
686impl From<&str> for RecognizedPlatePlatetype {
687    fn from(value: &str) -> Self {
688        match value {
689            "car" => RecognizedPlatePlatetype::Car,
690            other => RecognizedPlatePlatetype::Unrecognized(other.to_owned()),
691        }
692    }
693}
694
695impl From<String> for RecognizedPlatePlatetype {
696    fn from(value: String) -> Self {
697        Self::from(value.as_str())
698    }
699}
700
701impl fmt::Display for RecognizedPlatePlatetype {
702    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
703        f.write_str(self.as_str())
704    }
705}
706
707impl Serialize for RecognizedPlatePlatetype {
708    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
709        serializer.serialize_str(self.as_str())
710    }
711}
712
713impl<'de> Deserialize<'de> for RecognizedPlatePlatetype {
714    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
715        String::deserialize(deserializer).map(Self::from)
716    }
717}
718
719/// The values of `WebhookAlertTriggered.event`.
720///
721/// A value this SDK does not know yet is kept, as it came, in
722/// [`WebhookAlertTriggeredEvent::Unrecognized`].
723#[derive(Debug, Clone, PartialEq, Eq, Hash)]
724#[non_exhaustive]
725pub enum WebhookAlertTriggeredEvent {
726    /// `alert.triggered`
727    AlertTriggered,
728    /// A value this SDK does not know yet.
729    Unrecognized(String),
730}
731
732impl WebhookAlertTriggeredEvent {
733    /// The value as the API writes it.
734    pub fn as_str(&self) -> &str {
735        match self {
736            WebhookAlertTriggeredEvent::AlertTriggered => "alert.triggered",
737            WebhookAlertTriggeredEvent::Unrecognized(value) => value,
738        }
739    }
740}
741
742impl From<&str> for WebhookAlertTriggeredEvent {
743    fn from(value: &str) -> Self {
744        match value {
745            "alert.triggered" => WebhookAlertTriggeredEvent::AlertTriggered,
746            other => WebhookAlertTriggeredEvent::Unrecognized(other.to_owned()),
747        }
748    }
749}
750
751impl From<String> for WebhookAlertTriggeredEvent {
752    fn from(value: String) -> Self {
753        Self::from(value.as_str())
754    }
755}
756
757impl fmt::Display for WebhookAlertTriggeredEvent {
758    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
759        f.write_str(self.as_str())
760    }
761}
762
763impl Serialize for WebhookAlertTriggeredEvent {
764    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
765        serializer.serialize_str(self.as_str())
766    }
767}
768
769impl<'de> Deserialize<'de> for WebhookAlertTriggeredEvent {
770    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
771        String::deserialize(deserializer).map(Self::from)
772    }
773}
774
775/// The values of `WebhookRecognitionCreated.event`.
776///
777/// A value this SDK does not know yet is kept, as it came, in
778/// [`WebhookRecognitionCreatedEvent::Unrecognized`].
779#[derive(Debug, Clone, PartialEq, Eq, Hash)]
780#[non_exhaustive]
781pub enum WebhookRecognitionCreatedEvent {
782    /// `recognition.created`
783    RecognitionCreated,
784    /// A value this SDK does not know yet.
785    Unrecognized(String),
786}
787
788impl WebhookRecognitionCreatedEvent {
789    /// The value as the API writes it.
790    pub fn as_str(&self) -> &str {
791        match self {
792            WebhookRecognitionCreatedEvent::RecognitionCreated => "recognition.created",
793            WebhookRecognitionCreatedEvent::Unrecognized(value) => value,
794        }
795    }
796}
797
798impl From<&str> for WebhookRecognitionCreatedEvent {
799    fn from(value: &str) -> Self {
800        match value {
801            "recognition.created" => WebhookRecognitionCreatedEvent::RecognitionCreated,
802            other => WebhookRecognitionCreatedEvent::Unrecognized(other.to_owned()),
803        }
804    }
805}
806
807impl From<String> for WebhookRecognitionCreatedEvent {
808    fn from(value: String) -> Self {
809        Self::from(value.as_str())
810    }
811}
812
813impl fmt::Display for WebhookRecognitionCreatedEvent {
814    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
815        f.write_str(self.as_str())
816    }
817}
818
819impl Serialize for WebhookRecognitionCreatedEvent {
820    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
821        serializer.serialize_str(self.as_str())
822    }
823}
824
825impl<'de> Deserialize<'de> for WebhookRecognitionCreatedEvent {
826    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
827        String::deserialize(deserializer).map(Self::from)
828    }
829}
830
831/// The values of `WebhookRecognitionCreated.source`. camera: lida por uma câmera; api: enviada por foto.
832///
833/// A value this SDK does not know yet is kept, as it came, in
834/// [`WebhookRecognitionCreatedSource::Unrecognized`].
835#[derive(Debug, Clone, PartialEq, Eq, Hash)]
836#[non_exhaustive]
837pub enum WebhookRecognitionCreatedSource {
838    /// `camera`
839    Camera,
840    /// `api`
841    Api,
842    /// A value this SDK does not know yet.
843    Unrecognized(String),
844}
845
846impl WebhookRecognitionCreatedSource {
847    /// The value as the API writes it.
848    pub fn as_str(&self) -> &str {
849        match self {
850            WebhookRecognitionCreatedSource::Camera => "camera",
851            WebhookRecognitionCreatedSource::Api => "api",
852            WebhookRecognitionCreatedSource::Unrecognized(value) => value,
853        }
854    }
855}
856
857impl From<&str> for WebhookRecognitionCreatedSource {
858    fn from(value: &str) -> Self {
859        match value {
860            "camera" => WebhookRecognitionCreatedSource::Camera,
861            "api" => WebhookRecognitionCreatedSource::Api,
862            other => WebhookRecognitionCreatedSource::Unrecognized(other.to_owned()),
863        }
864    }
865}
866
867impl From<String> for WebhookRecognitionCreatedSource {
868    fn from(value: String) -> Self {
869        Self::from(value.as_str())
870    }
871}
872
873impl fmt::Display for WebhookRecognitionCreatedSource {
874    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
875        f.write_str(self.as_str())
876    }
877}
878
879impl Serialize for WebhookRecognitionCreatedSource {
880    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
881        serializer.serialize_str(self.as_str())
882    }
883}
884
885impl<'de> Deserialize<'de> for WebhookRecognitionCreatedSource {
886    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
887        String::deserialize(deserializer).map(Self::from)
888    }
889}
890
891/// The values of `WebhookTest.event`.
892///
893/// A value this SDK does not know yet is kept, as it came, in
894/// [`WebhookTestEvent::Unrecognized`].
895#[derive(Debug, Clone, PartialEq, Eq, Hash)]
896#[non_exhaustive]
897pub enum WebhookTestEvent {
898    /// `webhook.test`
899    WebhookTest,
900    /// A value this SDK does not know yet.
901    Unrecognized(String),
902}
903
904impl WebhookTestEvent {
905    /// The value as the API writes it.
906    pub fn as_str(&self) -> &str {
907        match self {
908            WebhookTestEvent::WebhookTest => "webhook.test",
909            WebhookTestEvent::Unrecognized(value) => value,
910        }
911    }
912}
913
914impl From<&str> for WebhookTestEvent {
915    fn from(value: &str) -> Self {
916        match value {
917            "webhook.test" => WebhookTestEvent::WebhookTest,
918            other => WebhookTestEvent::Unrecognized(other.to_owned()),
919        }
920    }
921}
922
923impl From<String> for WebhookTestEvent {
924    fn from(value: String) -> Self {
925        Self::from(value.as_str())
926    }
927}
928
929impl fmt::Display for WebhookTestEvent {
930    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
931        f.write_str(self.as_str())
932    }
933}
934
935impl Serialize for WebhookTestEvent {
936    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
937        serializer.serialize_str(self.as_str())
938    }
939}
940
941impl<'de> Deserialize<'de> for WebhookTestEvent {
942    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
943        String::deserialize(deserializer).map(Self::from)
944    }
945}
946