alibabacloud-imm 0.1.0

A modern, easy-to-use, and reqwest-powered Rust SDK for Alibaba Cloud Intelligent Media Management (IMM)
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
//! Detection operations.

use std::future::Future;

use serde::{Deserialize, Serialize};

use crate::error::Result;
use crate::response::BodyResponseProcessor;
use crate::{Client, Ops, Request};

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageFacesQuery {
    pub project_name: String,
    #[serde(rename = "SourceURI", skip_serializing_if = "Option::is_none")]
    pub source_uri: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub credential_config: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageFacesResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub faces: Vec<serde_json::Value>,
}

/// Detect faces in an image with boundary, attribute, and quality information.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagefaces>
pub struct DetectImageFaces {
    pub query: DetectImageFacesQuery,
}

impl Ops for DetectImageFaces {
    const ACTION: &'static str = "DetectImageFaces";
    type Query = DetectImageFacesQuery;
    type Body = ();
    type Response = BodyResponseProcessor<DetectImageFacesResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, ())
    }
}

pub trait DetectImageFacesOps {
    /// Detect faces in an image with boundary, attribute, and quality information.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagefaces>
    fn detect_image_faces(
        &self,
        query: DetectImageFacesQuery,
    ) -> impl Future<Output = Result<DetectImageFacesResponse>>;
}

impl DetectImageFacesOps for Client {
    async fn detect_image_faces(&self, query: DetectImageFacesQuery) -> Result<DetectImageFacesResponse> {
        self.request(DetectImageFaces { query }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageBodiesQuery {
    pub project_name: String,
    #[serde(rename = "SourceURI", skip_serializing_if = "Option::is_none")]
    pub source_uri: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sensitivity: Option<f64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub credential_config: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageBodiesResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub bodies: Vec<serde_json::Value>,
}

/// Detect human bodies in an image, including confidence scores and bounding boxes.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagebodies>
pub struct DetectImageBodies {
    pub query: DetectImageBodiesQuery,
}

impl Ops for DetectImageBodies {
    const ACTION: &'static str = "DetectImageBodies";
    type Query = DetectImageBodiesQuery;
    type Body = ();
    type Response = BodyResponseProcessor<DetectImageBodiesResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, ())
    }
}

pub trait DetectImageBodiesOps {
    /// Detect human bodies in an image, including confidence scores and bounding boxes.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagebodies>
    fn detect_image_bodies(
        &self,
        query: DetectImageBodiesQuery,
    ) -> impl Future<Output = Result<DetectImageBodiesResponse>>;
}

impl DetectImageBodiesOps for Client {
    async fn detect_image_bodies(&self, query: DetectImageBodiesQuery) -> Result<DetectImageBodiesResponse> {
        self.request(DetectImageBodies { query }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageCarsQuery {
    pub project_name: String,
    #[serde(rename = "SourceURI")]
    pub source_uri: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub credential_config: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageCarsResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub cars: Vec<serde_json::Value>,
}

/// Detect vehicles in an image, including car color, type, and license plate information.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagecars>
pub struct DetectImageCars {
    pub query: DetectImageCarsQuery,
}

impl Ops for DetectImageCars {
    const ACTION: &'static str = "DetectImageCars";
    type Query = DetectImageCarsQuery;
    type Body = ();
    type Response = BodyResponseProcessor<DetectImageCarsResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, ())
    }
}

pub trait DetectImageCarsOps {
    /// Detect vehicles in an image, including car color, type, and license plate information.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagecars>
    fn detect_image_cars(
        &self,
        query: DetectImageCarsQuery,
    ) -> impl Future<Output = Result<DetectImageCarsResponse>>;
}

impl DetectImageCarsOps for Client {
    async fn detect_image_cars(&self, query: DetectImageCarsQuery) -> Result<DetectImageCarsResponse> {
        self.request(DetectImageCars { query }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageCodesQuery {
    pub project_name: String,
    #[serde(rename = "SourceURI")]
    pub source_uri: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub credential_config: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageCodesResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub codes: Vec<serde_json::Value>,
}

/// Detect barcodes and QR codes in an image.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagecodes>
pub struct DetectImageCodes {
    pub query: DetectImageCodesQuery,
}

impl Ops for DetectImageCodes {
    const ACTION: &'static str = "DetectImageCodes";
    type Query = DetectImageCodesQuery;
    type Body = ();
    type Response = BodyResponseProcessor<DetectImageCodesResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, ())
    }
}

pub trait DetectImageCodesOps {
    /// Detect barcodes and QR codes in an image.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagecodes>
    fn detect_image_codes(
        &self,
        query: DetectImageCodesQuery,
    ) -> impl Future<Output = Result<DetectImageCodesResponse>>;
}

impl DetectImageCodesOps for Client {
    async fn detect_image_codes(&self, query: DetectImageCodesQuery) -> Result<DetectImageCodesResponse> {
        self.request(DetectImageCodes { query }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageCroppingQuery {
    pub project_name: String,
    #[serde(rename = "SourceURI", skip_serializing_if = "Option::is_none")]
    pub source_uri: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub aspect_ratios: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub credential_config: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageCroppingResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub croppings: Vec<serde_json::Value>,
}

/// Detect visually optimal cropping regions for a given target aspect ratio.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagecropping>
pub struct DetectImageCropping {
    pub query: DetectImageCroppingQuery,
}

impl Ops for DetectImageCropping {
    const ACTION: &'static str = "DetectImageCropping";
    type Query = DetectImageCroppingQuery;
    type Body = ();
    type Response = BodyResponseProcessor<DetectImageCroppingResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, ())
    }
}

pub trait DetectImageCroppingOps {
    /// Detect visually optimal cropping regions for a given target aspect ratio.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagecropping>
    fn detect_image_cropping(
        &self,
        query: DetectImageCroppingQuery,
    ) -> impl Future<Output = Result<DetectImageCroppingResponse>>;
}

impl DetectImageCroppingOps for Client {
    async fn detect_image_cropping(
        &self,
        query: DetectImageCroppingQuery,
    ) -> Result<DetectImageCroppingResponse> {
        self.request(DetectImageCropping { query }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageLabelsQuery {
    pub project_name: String,
    #[serde(rename = "SourceURI")]
    pub source_uri: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub threshold: Option<f64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub credential_config: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageLabelsResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub labels: Vec<serde_json::Value>,
}

/// Detect scene, object, and event labels in an image.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagelabels>
pub struct DetectImageLabels {
    pub query: DetectImageLabelsQuery,
}

impl Ops for DetectImageLabels {
    const ACTION: &'static str = "DetectImageLabels";
    type Query = DetectImageLabelsQuery;
    type Body = ();
    type Response = BodyResponseProcessor<DetectImageLabelsResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, ())
    }
}

pub trait DetectImageLabelsOps {
    /// Detect scene, object, and event labels in an image.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagelabels>
    fn detect_image_labels(
        &self,
        query: DetectImageLabelsQuery,
    ) -> impl Future<Output = Result<DetectImageLabelsResponse>>;
}

impl DetectImageLabelsOps for Client {
    async fn detect_image_labels(&self, query: DetectImageLabelsQuery) -> Result<DetectImageLabelsResponse> {
        self.request(DetectImageLabels { query }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageScoreQuery {
    pub project_name: String,
    #[serde(rename = "SourceURI", skip_serializing_if = "Option::is_none")]
    pub source_uri: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub credential_config: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageScoreResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub image_score: Option<serde_json::Value>,
}

/// Evaluate image visual quality based on composition, brightness, contrast, color, and sharpness.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagescore>
pub struct DetectImageScore {
    pub query: DetectImageScoreQuery,
}

impl Ops for DetectImageScore {
    const ACTION: &'static str = "DetectImageScore";
    type Query = DetectImageScoreQuery;
    type Body = ();
    type Response = BodyResponseProcessor<DetectImageScoreResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, ())
    }
}

pub trait DetectImageScoreOps {
    /// Evaluate image visual quality based on composition, brightness, contrast, color, and sharpness.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagescore>
    fn detect_image_score(
        &self,
        query: DetectImageScoreQuery,
    ) -> impl Future<Output = Result<DetectImageScoreResponse>>;
}

impl DetectImageScoreOps for Client {
    async fn detect_image_score(&self, query: DetectImageScoreQuery) -> Result<DetectImageScoreResponse> {
        self.request(DetectImageScore { query }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageTextsQuery {
    pub project_name: String,
    #[serde(rename = "SourceURI")]
    pub source_uri: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub credential_config: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectImageTextsResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(rename = "OCRTexts", default)]
    pub ocr_texts: Option<String>,
    #[serde(rename = "OCRContents", default)]
    pub ocr_contents: Vec<serde_json::Value>,
}

/// Detect and recognize text content in an image (OCR).
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagetexts>
pub struct DetectImageTexts {
    pub query: DetectImageTextsQuery,
}

impl Ops for DetectImageTexts {
    const ACTION: &'static str = "DetectImageTexts";
    type Query = DetectImageTextsQuery;
    type Body = ();
    type Response = BodyResponseProcessor<DetectImageTextsResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, ())
    }
}

pub trait DetectImageTextsOps {
    /// Detect and recognize text content in an image (OCR).
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectimagetexts>
    fn detect_image_texts(
        &self,
        query: DetectImageTextsQuery,
    ) -> impl Future<Output = Result<DetectImageTextsResponse>>;
}

impl DetectImageTextsOps for Client {
    async fn detect_image_texts(&self, query: DetectImageTextsQuery) -> Result<DetectImageTextsResponse> {
        self.request(DetectImageTexts { query }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectMediaMetaQuery {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub project_name: Option<String>,
    #[serde(rename = "SourceURI", skip_serializing_if = "Option::is_none")]
    pub source_uri: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub credential_config: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectMediaMetaResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub language: Option<String>,
    #[serde(default)]
    pub title: Option<String>,
    #[serde(default)]
    pub video_streams: Vec<serde_json::Value>,
    #[serde(default)]
    pub audio_streams: Vec<serde_json::Value>,
    #[serde(default)]
    pub subtitles: Vec<serde_json::Value>,
    #[serde(default)]
    pub stream_count: Option<i64>,
    #[serde(default)]
    pub program_count: Option<i64>,
    #[serde(default)]
    pub format_name: Option<String>,
    #[serde(default)]
    pub format_long_name: Option<String>,
    #[serde(default)]
    pub size: Option<i64>,
    #[serde(default)]
    pub start_time: Option<f64>,
    #[serde(default)]
    pub bitrate: Option<i64>,
    #[serde(default)]
    pub artist: Option<String>,
    #[serde(default)]
    pub album_artist: Option<String>,
    #[serde(default)]
    pub composer: Option<String>,
    #[serde(default)]
    pub performer: Option<String>,
    #[serde(default)]
    pub album: Option<String>,
    #[serde(default)]
    pub duration: Option<f64>,
    #[serde(default)]
    pub produce_time: Option<String>,
    #[serde(default)]
    pub lat_long: Option<String>,
    #[serde(default)]
    pub video_width: Option<i64>,
    #[serde(default)]
    pub video_height: Option<i64>,
    #[serde(default)]
    pub addresses: Vec<serde_json::Value>,
}

/// Get media file metadata including format and stream information.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectmediameta>
pub struct DetectMediaMeta {
    pub query: DetectMediaMetaQuery,
}

impl Ops for DetectMediaMeta {
    const ACTION: &'static str = "DetectMediaMeta";
    type Query = DetectMediaMetaQuery;
    type Body = ();
    type Response = BodyResponseProcessor<DetectMediaMetaResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, ())
    }
}

pub trait DetectMediaMetaOps {
    /// Get media file metadata including format and stream information.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detectmediameta>
    fn detect_media_meta(
        &self,
        query: DetectMediaMetaQuery,
    ) -> impl Future<Output = Result<DetectMediaMetaResponse>>;
}

impl DetectMediaMetaOps for Client {
    async fn detect_media_meta(&self, query: DetectMediaMetaQuery) -> Result<DetectMediaMetaResponse> {
        self.request(DetectMediaMeta { query }).await
    }
}

#[derive(Debug, Clone, Default, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectTextAnomalyQuery {
    pub project_name: String,
    pub content: String,
}

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct DetectTextAnomalyResponse {
    #[serde(default)]
    pub request_id: String,
    #[serde(default)]
    pub suggestion: Option<String>,
}

/// Detect inappropriate content in text including pornography, advertising, spam, and abuse.
///
/// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detecttextanomaly>
pub struct DetectTextAnomaly {
    pub query: DetectTextAnomalyQuery,
}

impl Ops for DetectTextAnomaly {
    const ACTION: &'static str = "DetectTextAnomaly";
    type Query = DetectTextAnomalyQuery;
    type Body = ();
    type Response = BodyResponseProcessor<DetectTextAnomalyResponse>;

    fn into_parts(self) -> (Self::Query, Self::Body) {
        (self.query, ())
    }
}

pub trait DetectTextAnomalyOps {
    /// Detect inappropriate content in text including pornography, advertising, spam, and abuse.
    ///
    /// Official documentation: <https://www.alibabacloud.com/help/en/imm/developer-reference/api-imm-2020-09-30-detecttextanomaly>
    fn detect_text_anomaly(
        &self,
        query: DetectTextAnomalyQuery,
    ) -> impl Future<Output = Result<DetectTextAnomalyResponse>>;
}

impl DetectTextAnomalyOps for Client {
    async fn detect_text_anomaly(&self, query: DetectTextAnomalyQuery) -> Result<DetectTextAnomalyResponse> {
        self.request(DetectTextAnomaly { query }).await
    }
}

pub trait DetectionOperations:
    DetectImageFacesOps
    + DetectImageBodiesOps
    + DetectImageCarsOps
    + DetectImageCodesOps
    + DetectImageCroppingOps
    + DetectImageLabelsOps
    + DetectImageScoreOps
    + DetectImageTextsOps
    + DetectMediaMetaOps
    + DetectTextAnomalyOps
{
}
impl<T> DetectionOperations for T where
    T: DetectImageFacesOps
        + DetectImageBodiesOps
        + DetectImageCarsOps
        + DetectImageCodesOps
        + DetectImageCroppingOps
        + DetectImageLabelsOps
        + DetectImageScoreOps
        + DetectImageTextsOps
        + DetectMediaMetaOps
        + DetectTextAnomalyOps
{
}