alpr-sdk 0.1.0

Alpr.sh's SDK for Rust: license plate recognition from photos, cameras, readings and webhooks.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
// Code generated by sdk/generator. DO NOT EDIT.

//! The resources Alpr.sh's API answers and the bodies its calls take.

// A field is documented when the contract describes it; its name says the rest.
#![allow(missing_docs)]

use std::fmt;

use serde::{Deserialize, Deserializer, Serialize, Serializer};

/// Camera is a resource of Alpr.sh's API.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Camera {
    #[serde(rename = "createdAt")]
    pub created_at: String,
    pub enabled: bool,
    pub id: String,
    /// O endereço da câmera como texto; vazio se não foi informado.
    pub location: String,
    pub name: String,
    /// Como a câmera é lida. Nunca traz o endereço do stream, usuário nem senha.
    pub protocol: CameraProtocol,
    /// Nulo quando a câmera lê a imagem inteira.
    #[serde(rename = "readingArea")]
    pub reading_area: Option<ReadingArea>,
}

/// DetectedPlate is a resource of Alpr.sh's API.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DetectedPlate {
    /// Confiança do detector, de 0 a 100, com uma casa.
    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,
}

/// DetectionImageLink is a resource of Alpr.sh's API.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct DetectionImageLink {
    #[serde(rename = "detectionId")]
    pub detection_id: String,
    /// Segundos de validade do link (300).
    #[serde(rename = "expiresIn")]
    pub expires_in: i64,
    /// Endereço absoluto de GET /api/v1/detections/{id}/image/file, assinado; abra-o como veio.
    #[serde(rename = "imageUrl")]
    pub image_url: String,
}

/// PhotoDetection is a resource of Alpr.sh's API.
#[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,
    /// Onde há placa, sem o texto; o detector não filtra pelo formato brasileiro. Sem placa, [].
    pub plates: Vec<DetectedPlate>,
    #[serde(rename = "processingTimeMs")]
    pub processing_time_ms: i64,
}

/// PhotoRecognition is a resource of Alpr.sh's API.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PhotoRecognition {
    /// Créditos que sobraram depois desta leitura.
    #[serde(rename = "creditsRemaining")]
    pub credits_remaining: i64,
    #[serde(rename = "imageHeight")]
    pub image_height: i64,
    #[serde(rename = "imageWidth")]
    pub image_width: i64,
    /// Só as placas válidas no Brasil (ABC1234 ou ABC1D23); sem placa, [].
    pub plates: Vec<RecognizedPlate>,
    #[serde(rename = "processingTimeMs")]
    pub processing_time_ms: i64,
}

/// PlateReading is a resource of Alpr.sh's API.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct PlateReading {
    /// Confiança da leitura, de 0 a 1 com quatro casas (nas outras rotas conf vai de 0 a 100).
    pub confidence: f64,
    /// Créditos que sobraram depois desta leitura.
    #[serde(rename = "creditsRemaining")]
    pub credits_remaining: i64,
    /// Hoje sempre nulo: a leitura de uma placa recortada não é guardada.
    #[serde(rename = "detectionId")]
    pub detection_id: Option<String>,
    #[serde(rename = "latencyMs")]
    pub latency_ms: i64,
    /// O texto lido, sem hífen, maiúsculo; não é validado pelo formato brasileiro.
    pub plate: String,
}

/// ReadingArea is a resource of Alpr.sh's API.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ReadingArea {
    /// A caixa envolvente, em frações da imagem (0 a 1); é o que o motor lê.
    #[serde(rename = "box")]
    pub box_: ReadingAreaBox,
    /// 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.
    pub points: Vec<Vec<f64>>,
}

/// A caixa envolvente, em frações da imagem (0 a 1); é o que o motor lê.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct ReadingAreaBox {
    pub height: f64,
    pub width: f64,
    pub x: f64,
    pub y: f64,
}

/// Recognition is a resource of Alpr.sh's API.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Recognition {
    /// Nulo numa leitura feita pela API por foto.
    #[serde(rename = "cameraId")]
    pub camera_id: Option<String>,
    /// Com o deslocamento do fuso do Alpr.sh.
    #[serde(rename = "capturedAt")]
    pub captured_at: String,
    /// De 0 a 100, com uma casa.
    pub conf: f64,
    pub id: String,
    pub plate: String,
    /// camera: lida por uma câmera; api: enviada por foto.
    pub source: RecognitionSource,
}

/// RecognizedPlate is a resource of Alpr.sh's API.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct RecognizedPlate {
    /// Confiança de cada caractere, de 0 a 1 com duas casas, separadas por ponto e vírgula ("0.99;0.98").
    #[serde(rename = "charConfs")]
    pub char_confs: String,
    /// Confiança da placa, de 0 a 100, com uma casa.
    pub conf: f64,
    /// Pixels da foto enviada.
    #[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,
    /// Igual a time.
    #[serde(rename = "createdAt")]
    pub created_at: String,
    /// Sete caracteres, maiúsculos: ABC1234 ou ABC1D23 (Mercosul).
    pub plate: String,
    /// Sempre car; a API não informa país nem formato.
    #[serde(rename = "plateType")]
    pub plate_type: RecognizedPlatePlatetype,
    /// Instante da leitura, com o deslocamento do fuso do Alpr.sh.
    pub time: String,
}

/// WebhookAlertTriggered is a resource of Alpr.sh's API.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WebhookAlertTriggered {
    /// Ausente se a leitura não veio de uma câmera.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub camera_id: Option<String>,
    pub captured_at: String,
    /// De 0 a 1.
    pub confidence: f64,
    pub event: WebhookAlertTriggeredEvent,
    /// O id do disparo.
    pub id: String,
    pub plate: String,
    /// A leitura que disparou o alerta.
    pub recognition_id: String,
    pub rule_id: String,
    pub rule_name: String,
    /// 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.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub skip: Option<Vec<String>>,
    pub tenant_id: String,
}

/// WebhookRecognitionCreated is a resource of Alpr.sh's API.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct WebhookRecognitionCreated {
    /// Ausente numa leitura enviada por foto.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub camera_id: Option<String>,
    /// UTC, com fração de segundo.
    pub captured_at: String,
    /// De 0 a 1 (na API de chave, conf vai de 0 a 100).
    pub confidence: f64,
    pub event: WebhookRecognitionCreatedEvent,
    /// O id da leitura; é o mesmo id de GET /api/v1/recognitions e de GET /api/v1/detections/{id}/image.
    pub id: String,
    pub plate: String,
    /// camera: lida por uma câmera; api: enviada por foto.
    pub source: WebhookRecognitionCreatedSource,
    /// O espaço de trabalho dono da leitura.
    pub tenant_id: String,
}

/// WebhookTest is a resource of Alpr.sh's API.
#[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,
}

/// The body of photos:detect.
///
/// [`PhotosDetectParams::new`] takes the required fields; each optional one is set by
/// the method of its name. The body is sent as `multipart/form-data`, so
/// nothing here is JSON: the photo is its bytes.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct PhotosDetectParams {
    /// A foto, JPEG ou PNG.
    pub image: Vec<u8>,
    /// Só NONE é aceito.
    pub image_mode: Option<PhotosDetectParamsImageMode>,
    /// Piso de confiança do detector de placas.
    pub lpr_confidence: Option<f64>,
    /// Piso de confiança da leitura dos caracteres.
    pub min_ocr_confidence: Option<f64>,
}

impl PhotosDetectParams {
    /// A body with its required fields.
    pub fn new(image: impl Into<Vec<u8>>) -> Self {
        Self {
            image: image.into(),
            image_mode: None,
            lpr_confidence: None,
            min_ocr_confidence: None,
        }
    }

    /// Só NONE é aceito.
    pub fn image_mode(mut self, image_mode: impl Into<PhotosDetectParamsImageMode>) -> Self {
        self.image_mode = Some(image_mode.into());
        self
    }

    /// Piso de confiança do detector de placas.
    pub fn lpr_confidence(mut self, lpr_confidence: f64) -> Self {
        self.lpr_confidence = Some(lpr_confidence);
        self
    }

    /// Piso de confiança da leitura dos caracteres.
    pub fn min_ocr_confidence(mut self, min_ocr_confidence: f64) -> Self {
        self.min_ocr_confidence = Some(min_ocr_confidence);
        self
    }
}

/// The body of photos:ocr.
///
/// [`PhotosOCRParams::new`] takes the required fields; each optional one is set by
/// the method of its name. The body is sent as `multipart/form-data`, so
/// nothing here is JSON: the photo is its bytes.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct PhotosOCRParams {
    /// A imagem da placa já recortada, JPEG ou PNG.
    pub image: Vec<u8>,
}

impl PhotosOCRParams {
    /// A body with its required fields.
    pub fn new(image: impl Into<Vec<u8>>) -> Self {
        Self {
            image: image.into(),
        }
    }
}

/// The body of photos:recognize.
///
/// [`PhotosRecognizeParams::new`] takes the required fields; each optional one is set by
/// the method of its name. The body is sent as `multipart/form-data`, so
/// nothing here is JSON: the photo is its bytes.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct PhotosRecognizeParams {
    /// A foto, JPEG ou PNG.
    pub image: Vec<u8>,
    /// Só NONE é aceito.
    pub image_mode: Option<PhotosRecognizeParamsImageMode>,
    /// Piso de confiança do detector de placas.
    pub lpr_confidence: Option<f64>,
    /// Piso de confiança da leitura dos caracteres.
    pub min_ocr_confidence: Option<f64>,
}

impl PhotosRecognizeParams {
    /// A body with its required fields.
    pub fn new(image: impl Into<Vec<u8>>) -> Self {
        Self {
            image: image.into(),
            image_mode: None,
            lpr_confidence: None,
            min_ocr_confidence: None,
        }
    }

    /// Só NONE é aceito.
    pub fn image_mode(mut self, image_mode: impl Into<PhotosRecognizeParamsImageMode>) -> Self {
        self.image_mode = Some(image_mode.into());
        self
    }

    /// Piso de confiança do detector de placas.
    pub fn lpr_confidence(mut self, lpr_confidence: f64) -> Self {
        self.lpr_confidence = Some(lpr_confidence);
        self
    }

    /// Piso de confiança da leitura dos caracteres.
    pub fn min_ocr_confidence(mut self, min_ocr_confidence: f64) -> Self {
        self.min_ocr_confidence = Some(min_ocr_confidence);
        self
    }
}

/// The values of `Camera.protocol`. Como a câmera é lida. Nunca traz o endereço do stream, usuário nem senha.
///
/// A value this SDK does not know yet is kept, as it came, in
/// [`CameraProtocol::Unrecognized`].
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum CameraProtocol {
    /// `rtsp`
    Rtsp,
    /// `rtmp`
    Rtmp,
    /// `hls`
    Hls,
    /// `http`
    Http,
    /// `hikconnect`
    Hikconnect,
    /// `hikcloud`
    Hikcloud,
    /// `rtmppush`
    Rtmppush,
    /// A value this SDK does not know yet.
    Unrecognized(String),
}

impl CameraProtocol {
    /// The value as the API writes it.
    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)
    }
}

/// The values of `DetectedPlate.plateType`.
///
/// A value this SDK does not know yet is kept, as it came, in
/// [`DetectedPlatePlatetype::Unrecognized`].
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum DetectedPlatePlatetype {
    /// `car`
    Car,
    /// A value this SDK does not know yet.
    Unrecognized(String),
}

impl DetectedPlatePlatetype {
    /// The value as the API writes it.
    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)
    }
}

/// The values of `PhotosDetectParams.image_mode`. Só NONE é aceito.
///
/// A value this SDK does not know yet is kept, as it came, in
/// [`PhotosDetectParamsImageMode::Unrecognized`].
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum PhotosDetectParamsImageMode {
    /// `NONE`
    None,
    /// A value this SDK does not know yet.
    Unrecognized(String),
}

impl PhotosDetectParamsImageMode {
    /// The value as the API writes it.
    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)
    }
}

/// The values of `PhotosRecognizeParams.image_mode`. Só NONE é aceito.
///
/// A value this SDK does not know yet is kept, as it came, in
/// [`PhotosRecognizeParamsImageMode::Unrecognized`].
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum PhotosRecognizeParamsImageMode {
    /// `NONE`
    None,
    /// A value this SDK does not know yet.
    Unrecognized(String),
}

impl PhotosRecognizeParamsImageMode {
    /// The value as the API writes it.
    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)
    }
}

/// The values of `Recognition.source`. camera: lida por uma câmera; api: enviada por foto.
///
/// A value this SDK does not know yet is kept, as it came, in
/// [`RecognitionSource::Unrecognized`].
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum RecognitionSource {
    /// `camera`
    Camera,
    /// `api`
    Api,
    /// A value this SDK does not know yet.
    Unrecognized(String),
}

impl RecognitionSource {
    /// The value as the API writes it.
    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)
    }
}

/// The values of `RecognizedPlate.plateType`. Sempre car; a API não informa país nem formato.
///
/// A value this SDK does not know yet is kept, as it came, in
/// [`RecognizedPlatePlatetype::Unrecognized`].
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum RecognizedPlatePlatetype {
    /// `car`
    Car,
    /// A value this SDK does not know yet.
    Unrecognized(String),
}

impl RecognizedPlatePlatetype {
    /// The value as the API writes it.
    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)
    }
}

/// The values of `WebhookAlertTriggered.event`.
///
/// A value this SDK does not know yet is kept, as it came, in
/// [`WebhookAlertTriggeredEvent::Unrecognized`].
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum WebhookAlertTriggeredEvent {
    /// `alert.triggered`
    AlertTriggered,
    /// A value this SDK does not know yet.
    Unrecognized(String),
}

impl WebhookAlertTriggeredEvent {
    /// The value as the API writes it.
    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)
    }
}

/// The values of `WebhookRecognitionCreated.event`.
///
/// A value this SDK does not know yet is kept, as it came, in
/// [`WebhookRecognitionCreatedEvent::Unrecognized`].
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum WebhookRecognitionCreatedEvent {
    /// `recognition.created`
    RecognitionCreated,
    /// A value this SDK does not know yet.
    Unrecognized(String),
}

impl WebhookRecognitionCreatedEvent {
    /// The value as the API writes it.
    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)
    }
}

/// The values of `WebhookRecognitionCreated.source`. camera: lida por uma câmera; api: enviada por foto.
///
/// A value this SDK does not know yet is kept, as it came, in
/// [`WebhookRecognitionCreatedSource::Unrecognized`].
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum WebhookRecognitionCreatedSource {
    /// `camera`
    Camera,
    /// `api`
    Api,
    /// A value this SDK does not know yet.
    Unrecognized(String),
}

impl WebhookRecognitionCreatedSource {
    /// The value as the API writes it.
    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)
    }
}

/// The values of `WebhookTest.event`.
///
/// A value this SDK does not know yet is kept, as it came, in
/// [`WebhookTestEvent::Unrecognized`].
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum WebhookTestEvent {
    /// `webhook.test`
    WebhookTest,
    /// A value this SDK does not know yet.
    Unrecognized(String),
}

impl WebhookTestEvent {
    /// The value as the API writes it.
    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)
    }
}