Skip to main content

gproxy_protocol/aws/converse/
media.rs

1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4use crate::aws::{DocumentFormat, ImageFormat, Rest};
5
6#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7#[serde(rename_all = "camelCase")]
8#[derive(gproxy_protocol_macros::WireBuilder)]
9#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
10pub struct ImageBlock {
11    pub format: ImageFormat,
12    pub source: ImageSource,
13    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
14    pub rest: Rest,
15}
16
17#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
18#[serde(untagged)]
19#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
20pub enum ImageSource {
21    Bytes {
22        bytes: String,
23        #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
24        rest: Rest,
25    },
26    S3Location {
27        #[serde(rename = "s3Location")]
28        s3_location: S3Location,
29        #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
30        rest: Rest,
31    },
32    Raw(Value),
33}
34
35#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
36#[serde(rename_all = "camelCase")]
37#[derive(gproxy_protocol_macros::WireBuilder)]
38#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
39pub struct DocumentBlock {
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub format: Option<DocumentFormat>,
42    pub name: String,
43    pub source: DocumentSource,
44    #[serde(skip_serializing_if = "Option::is_none")]
45    pub context: Option<String>,
46    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
47    pub rest: Rest,
48}
49
50#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
51#[serde(untagged)]
52#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
53pub enum DocumentSource {
54    Bytes {
55        bytes: String,
56        #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
57        rest: Rest,
58    },
59    S3Location {
60        #[serde(rename = "s3Location")]
61        s3_location: S3Location,
62        #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
63        rest: Rest,
64    },
65    Text {
66        text: String,
67        #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
68        rest: Rest,
69    },
70    Raw(Value),
71}
72
73#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
74#[serde(rename_all = "camelCase")]
75#[derive(gproxy_protocol_macros::WireBuilder)]
76#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
77pub struct S3Location {
78    pub uri: String,
79    #[serde(skip_serializing_if = "Option::is_none")]
80    pub bucket_owner: Option<String>,
81    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
82    pub rest: Rest,
83}