1#![allow(missing_docs)]
7
8use std::fmt;
9
10use serde::{Deserialize, Deserializer, Serialize, Serializer};
11
12#[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 pub location: String,
22 pub name: String,
23 pub protocol: CameraProtocol,
25 #[serde(rename = "readingArea")]
27 pub reading_area: Option<ReadingArea>,
28}
29
30#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
32#[non_exhaustive]
33pub struct DetectedPlate {
34 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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
53#[non_exhaustive]
54pub struct DetectionImageLink {
55 #[serde(rename = "detectionId")]
56 pub detection_id: String,
57 #[serde(rename = "expiresIn")]
59 pub expires_in: i64,
60 #[serde(rename = "imageUrl")]
62 pub image_url: String,
63}
64
65#[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 pub plates: Vec<DetectedPlate>,
75 #[serde(rename = "processingTimeMs")]
76 pub processing_time_ms: i64,
77}
78
79#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
81#[non_exhaustive]
82pub struct PhotoRecognition {
83 #[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 pub plates: Vec<RecognizedPlate>,
92 #[serde(rename = "processingTimeMs")]
93 pub processing_time_ms: i64,
94}
95
96#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
98#[non_exhaustive]
99pub struct PlateReading {
100 pub confidence: f64,
102 #[serde(rename = "creditsRemaining")]
104 pub credits_remaining: i64,
105 #[serde(rename = "detectionId")]
107 pub detection_id: Option<String>,
108 #[serde(rename = "latencyMs")]
109 pub latency_ms: i64,
110 pub plate: String,
112}
113
114#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
116#[non_exhaustive]
117pub struct ReadingArea {
118 #[serde(rename = "box")]
120 pub box_: ReadingAreaBox,
121 pub points: Vec<Vec<f64>>,
123}
124
125#[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#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
137#[non_exhaustive]
138pub struct Recognition {
139 #[serde(rename = "cameraId")]
141 pub camera_id: Option<String>,
142 #[serde(rename = "capturedAt")]
144 pub captured_at: String,
145 pub conf: f64,
147 pub id: String,
148 pub plate: String,
149 pub source: RecognitionSource,
151}
152
153#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
155#[non_exhaustive]
156pub struct RecognizedPlate {
157 #[serde(rename = "charConfs")]
159 pub char_confs: String,
160 pub conf: f64,
162 #[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 #[serde(rename = "createdAt")]
173 pub created_at: String,
174 pub plate: String,
176 #[serde(rename = "plateType")]
178 pub plate_type: RecognizedPlatePlatetype,
179 pub time: String,
181}
182
183#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
185#[non_exhaustive]
186pub struct WebhookAlertTriggered {
187 #[serde(default, skip_serializing_if = "Option::is_none")]
189 pub camera_id: Option<String>,
190 pub captured_at: String,
191 pub confidence: f64,
193 pub event: WebhookAlertTriggeredEvent,
194 pub id: String,
196 pub plate: String,
197 pub recognition_id: String,
199 pub rule_id: String,
200 pub rule_name: String,
201 #[serde(default, skip_serializing_if = "Option::is_none")]
203 pub skip: Option<Vec<String>>,
204 pub tenant_id: String,
205}
206
207#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
209#[non_exhaustive]
210pub struct WebhookRecognitionCreated {
211 #[serde(default, skip_serializing_if = "Option::is_none")]
213 pub camera_id: Option<String>,
214 pub captured_at: String,
216 pub confidence: f64,
218 pub event: WebhookRecognitionCreatedEvent,
219 pub id: String,
221 pub plate: String,
222 pub source: WebhookRecognitionCreatedSource,
224 pub tenant_id: String,
226}
227
228#[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#[derive(Debug, Clone, PartialEq)]
244#[non_exhaustive]
245pub struct PhotosDetectParams {
246 pub image: Vec<u8>,
248 pub image_mode: Option<PhotosDetectParamsImageMode>,
250 pub lpr_confidence: Option<f64>,
252 pub min_ocr_confidence: Option<f64>,
254}
255
256impl PhotosDetectParams {
257 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 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 pub fn lpr_confidence(mut self, lpr_confidence: f64) -> Self {
275 self.lpr_confidence = Some(lpr_confidence);
276 self
277 }
278
279 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#[derive(Debug, Clone, PartialEq)]
292#[non_exhaustive]
293pub struct PhotosOCRParams {
294 pub image: Vec<u8>,
296}
297
298impl PhotosOCRParams {
299 pub fn new(image: impl Into<Vec<u8>>) -> Self {
301 Self {
302 image: image.into(),
303 }
304 }
305}
306
307#[derive(Debug, Clone, PartialEq)]
313#[non_exhaustive]
314pub struct PhotosRecognizeParams {
315 pub image: Vec<u8>,
317 pub image_mode: Option<PhotosRecognizeParamsImageMode>,
319 pub lpr_confidence: Option<f64>,
321 pub min_ocr_confidence: Option<f64>,
323}
324
325impl PhotosRecognizeParams {
326 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 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 pub fn lpr_confidence(mut self, lpr_confidence: f64) -> Self {
344 self.lpr_confidence = Some(lpr_confidence);
345 self
346 }
347
348 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#[derive(Debug, Clone, PartialEq, Eq, Hash)]
360#[non_exhaustive]
361pub enum CameraProtocol {
362 Rtsp,
364 Rtmp,
366 Hls,
368 Http,
370 Hikconnect,
372 Hikcloud,
374 Rtmppush,
376 Unrecognized(String),
378}
379
380impl CameraProtocol {
381 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#[derive(Debug, Clone, PartialEq, Eq, Hash)]
440#[non_exhaustive]
441pub enum DetectedPlatePlatetype {
442 Car,
444 Unrecognized(String),
446}
447
448impl DetectedPlatePlatetype {
449 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#[derive(Debug, Clone, PartialEq, Eq, Hash)]
496#[non_exhaustive]
497pub enum PhotosDetectParamsImageMode {
498 None,
500 Unrecognized(String),
502}
503
504impl PhotosDetectParamsImageMode {
505 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#[derive(Debug, Clone, PartialEq, Eq, Hash)]
552#[non_exhaustive]
553pub enum PhotosRecognizeParamsImageMode {
554 None,
556 Unrecognized(String),
558}
559
560impl PhotosRecognizeParamsImageMode {
561 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#[derive(Debug, Clone, PartialEq, Eq, Hash)]
608#[non_exhaustive]
609pub enum RecognitionSource {
610 Camera,
612 Api,
614 Unrecognized(String),
616}
617
618impl RecognitionSource {
619 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#[derive(Debug, Clone, PartialEq, Eq, Hash)]
668#[non_exhaustive]
669pub enum RecognizedPlatePlatetype {
670 Car,
672 Unrecognized(String),
674}
675
676impl RecognizedPlatePlatetype {
677 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#[derive(Debug, Clone, PartialEq, Eq, Hash)]
724#[non_exhaustive]
725pub enum WebhookAlertTriggeredEvent {
726 AlertTriggered,
728 Unrecognized(String),
730}
731
732impl WebhookAlertTriggeredEvent {
733 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#[derive(Debug, Clone, PartialEq, Eq, Hash)]
780#[non_exhaustive]
781pub enum WebhookRecognitionCreatedEvent {
782 RecognitionCreated,
784 Unrecognized(String),
786}
787
788impl WebhookRecognitionCreatedEvent {
789 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#[derive(Debug, Clone, PartialEq, Eq, Hash)]
836#[non_exhaustive]
837pub enum WebhookRecognitionCreatedSource {
838 Camera,
840 Api,
842 Unrecognized(String),
844}
845
846impl WebhookRecognitionCreatedSource {
847 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#[derive(Debug, Clone, PartialEq, Eq, Hash)]
896#[non_exhaustive]
897pub enum WebhookTestEvent {
898 WebhookTest,
900 Unrecognized(String),
902}
903
904impl WebhookTestEvent {
905 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