dropbox_sdk/generated/types/
files.rs

1// DO NOT EDIT
2// This file was @generated by Stone
3
4#![allow(
5    clippy::too_many_arguments,
6    clippy::large_enum_variant,
7    clippy::result_large_err,
8    clippy::doc_markdown,
9)]
10
11//! This namespace contains endpoints and data types for basic file operations.
12
13pub type CopyBatchArg = RelocationBatchArgBase;
14pub type FileId = String;
15pub type Id = String;
16pub type ListFolderCursor = String;
17pub type MalformedPathError = Option<String>;
18pub type Path = String;
19pub type PathOrId = String;
20pub type PathR = String;
21pub type PathROrId = String;
22pub type ReadPath = String;
23pub type Rev = String;
24pub type SearchV2Cursor = String;
25pub type Sha256HexHash = String;
26pub type SharedLinkUrl = String;
27pub type TagText = String;
28pub type WritePath = String;
29pub type WritePathOrId = String;
30
31#[derive(Debug, Clone, PartialEq, Eq)]
32#[non_exhaustive] // structs may have more fields added in the future.
33pub struct AddTagArg {
34    /// Path to the item to be tagged.
35    pub path: Path,
36    /// The value of the tag to add. Will be automatically converted to lowercase letters.
37    pub tag_text: TagText,
38}
39
40impl AddTagArg {
41    pub fn new(path: Path, tag_text: TagText) -> Self {
42        AddTagArg {
43            path,
44            tag_text,
45        }
46    }
47}
48
49const ADD_TAG_ARG_FIELDS: &[&str] = &["path",
50                                      "tag_text"];
51impl AddTagArg {
52    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
53        map: V,
54    ) -> Result<AddTagArg, V::Error> {
55        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
56    }
57
58    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
59        mut map: V,
60        optional: bool,
61    ) -> Result<Option<AddTagArg>, V::Error> {
62        let mut field_path = None;
63        let mut field_tag_text = None;
64        let mut nothing = true;
65        while let Some(key) = map.next_key::<&str>()? {
66            nothing = false;
67            match key {
68                "path" => {
69                    if field_path.is_some() {
70                        return Err(::serde::de::Error::duplicate_field("path"));
71                    }
72                    field_path = Some(map.next_value()?);
73                }
74                "tag_text" => {
75                    if field_tag_text.is_some() {
76                        return Err(::serde::de::Error::duplicate_field("tag_text"));
77                    }
78                    field_tag_text = Some(map.next_value()?);
79                }
80                _ => {
81                    // unknown field allowed and ignored
82                    map.next_value::<::serde_json::Value>()?;
83                }
84            }
85        }
86        if optional && nothing {
87            return Ok(None);
88        }
89        let result = AddTagArg {
90            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
91            tag_text: field_tag_text.ok_or_else(|| ::serde::de::Error::missing_field("tag_text"))?,
92        };
93        Ok(Some(result))
94    }
95
96    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
97        &self,
98        s: &mut S::SerializeStruct,
99    ) -> Result<(), S::Error> {
100        use serde::ser::SerializeStruct;
101        s.serialize_field("path", &self.path)?;
102        s.serialize_field("tag_text", &self.tag_text)?;
103        Ok(())
104    }
105}
106
107impl<'de> ::serde::de::Deserialize<'de> for AddTagArg {
108    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
109        // struct deserializer
110        use serde::de::{MapAccess, Visitor};
111        struct StructVisitor;
112        impl<'de> Visitor<'de> for StructVisitor {
113            type Value = AddTagArg;
114            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
115                f.write_str("a AddTagArg struct")
116            }
117            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
118                AddTagArg::internal_deserialize(map)
119            }
120        }
121        deserializer.deserialize_struct("AddTagArg", ADD_TAG_ARG_FIELDS, StructVisitor)
122    }
123}
124
125impl ::serde::ser::Serialize for AddTagArg {
126    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
127        // struct serializer
128        use serde::ser::SerializeStruct;
129        let mut s = serializer.serialize_struct("AddTagArg", 2)?;
130        self.internal_serialize::<S>(&mut s)?;
131        s.end()
132    }
133}
134
135#[derive(Debug, Clone, PartialEq, Eq)]
136#[non_exhaustive] // variants may be added in the future
137pub enum AddTagError {
138    Path(LookupError),
139    /// The item already has the maximum supported number of tags.
140    TooManyTags,
141    /// Catch-all used for unrecognized values returned from the server. Encountering this value
142    /// typically indicates that this SDK version is out of date.
143    Other,
144}
145
146impl<'de> ::serde::de::Deserialize<'de> for AddTagError {
147    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
148        // union deserializer
149        use serde::de::{self, MapAccess, Visitor};
150        struct EnumVisitor;
151        impl<'de> Visitor<'de> for EnumVisitor {
152            type Value = AddTagError;
153            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
154                f.write_str("a AddTagError structure")
155            }
156            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
157                let tag: &str = match map.next_key()? {
158                    Some(".tag") => map.next_value()?,
159                    _ => return Err(de::Error::missing_field(".tag"))
160                };
161                let value = match tag {
162                    "path" => {
163                        match map.next_key()? {
164                            Some("path") => AddTagError::Path(map.next_value()?),
165                            None => return Err(de::Error::missing_field("path")),
166                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
167                        }
168                    }
169                    "too_many_tags" => AddTagError::TooManyTags,
170                    _ => AddTagError::Other,
171                };
172                crate::eat_json_fields(&mut map)?;
173                Ok(value)
174            }
175        }
176        const VARIANTS: &[&str] = &["path",
177                                    "other",
178                                    "too_many_tags"];
179        deserializer.deserialize_struct("AddTagError", VARIANTS, EnumVisitor)
180    }
181}
182
183impl ::serde::ser::Serialize for AddTagError {
184    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
185        // union serializer
186        use serde::ser::SerializeStruct;
187        match self {
188            AddTagError::Path(x) => {
189                // union or polymporphic struct
190                let mut s = serializer.serialize_struct("AddTagError", 2)?;
191                s.serialize_field(".tag", "path")?;
192                s.serialize_field("path", x)?;
193                s.end()
194            }
195            AddTagError::TooManyTags => {
196                // unit
197                let mut s = serializer.serialize_struct("AddTagError", 1)?;
198                s.serialize_field(".tag", "too_many_tags")?;
199                s.end()
200            }
201            AddTagError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
202        }
203    }
204}
205
206impl ::std::error::Error for AddTagError {
207    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
208        match self {
209            AddTagError::Path(inner) => Some(inner),
210            _ => None,
211        }
212    }
213}
214
215impl ::std::fmt::Display for AddTagError {
216    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
217        match self {
218            AddTagError::Path(inner) => write!(f, "AddTagError: {}", inner),
219            AddTagError::TooManyTags => f.write_str("The item already has the maximum supported number of tags."),
220            _ => write!(f, "{:?}", *self),
221        }
222    }
223}
224
225// union extends BaseTagError
226impl From<BaseTagError> for AddTagError {
227    fn from(parent: BaseTagError) -> Self {
228        match parent {
229            BaseTagError::Path(x) => AddTagError::Path(x),
230            BaseTagError::Other => AddTagError::Other,
231        }
232    }
233}
234#[derive(Debug, Clone, PartialEq, Eq)]
235#[non_exhaustive] // structs may have more fields added in the future.
236pub struct AlphaGetMetadataArg {
237    /// The path of a file or folder on Dropbox.
238    pub path: ReadPath,
239    /// If true, [`FileMetadata::media_info`](FileMetadata) is set for photo and video.
240    pub include_media_info: bool,
241    /// If true, [`DeletedMetadata`] will be returned for deleted file or folder, otherwise
242    /// [`LookupError::NotFound`] will be returned.
243    pub include_deleted: bool,
244    /// If true, the results will include a flag for each file indicating whether or not  that file
245    /// has any explicit members.
246    pub include_has_explicit_shared_members: bool,
247    /// If set to a valid list of template IDs, [`FileMetadata::property_groups`](FileMetadata) is
248    /// set if there exists property data associated with the file and each of the listed templates.
249    pub include_property_groups: Option<crate::types::file_properties::TemplateFilterBase>,
250    /// If set to a valid list of template IDs, [`FileMetadata::property_groups`](FileMetadata) is
251    /// set for files with custom properties.
252    pub include_property_templates: Option<Vec<crate::types::file_properties::TemplateId>>,
253}
254
255impl AlphaGetMetadataArg {
256    pub fn new(path: ReadPath) -> Self {
257        AlphaGetMetadataArg {
258            path,
259            include_media_info: false,
260            include_deleted: false,
261            include_has_explicit_shared_members: false,
262            include_property_groups: None,
263            include_property_templates: None,
264        }
265    }
266
267    pub fn with_include_media_info(mut self, value: bool) -> Self {
268        self.include_media_info = value;
269        self
270    }
271
272    pub fn with_include_deleted(mut self, value: bool) -> Self {
273        self.include_deleted = value;
274        self
275    }
276
277    pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
278        self.include_has_explicit_shared_members = value;
279        self
280    }
281
282    pub fn with_include_property_groups(
283        mut self,
284        value: crate::types::file_properties::TemplateFilterBase,
285    ) -> Self {
286        self.include_property_groups = Some(value);
287        self
288    }
289
290    pub fn with_include_property_templates(
291        mut self,
292        value: Vec<crate::types::file_properties::TemplateId>,
293    ) -> Self {
294        self.include_property_templates = Some(value);
295        self
296    }
297}
298
299const ALPHA_GET_METADATA_ARG_FIELDS: &[&str] = &["path",
300                                                 "include_media_info",
301                                                 "include_deleted",
302                                                 "include_has_explicit_shared_members",
303                                                 "include_property_groups",
304                                                 "include_property_templates"];
305impl AlphaGetMetadataArg {
306    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
307        map: V,
308    ) -> Result<AlphaGetMetadataArg, V::Error> {
309        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
310    }
311
312    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
313        mut map: V,
314        optional: bool,
315    ) -> Result<Option<AlphaGetMetadataArg>, V::Error> {
316        let mut field_path = None;
317        let mut field_include_media_info = None;
318        let mut field_include_deleted = None;
319        let mut field_include_has_explicit_shared_members = None;
320        let mut field_include_property_groups = None;
321        let mut field_include_property_templates = None;
322        let mut nothing = true;
323        while let Some(key) = map.next_key::<&str>()? {
324            nothing = false;
325            match key {
326                "path" => {
327                    if field_path.is_some() {
328                        return Err(::serde::de::Error::duplicate_field("path"));
329                    }
330                    field_path = Some(map.next_value()?);
331                }
332                "include_media_info" => {
333                    if field_include_media_info.is_some() {
334                        return Err(::serde::de::Error::duplicate_field("include_media_info"));
335                    }
336                    field_include_media_info = Some(map.next_value()?);
337                }
338                "include_deleted" => {
339                    if field_include_deleted.is_some() {
340                        return Err(::serde::de::Error::duplicate_field("include_deleted"));
341                    }
342                    field_include_deleted = Some(map.next_value()?);
343                }
344                "include_has_explicit_shared_members" => {
345                    if field_include_has_explicit_shared_members.is_some() {
346                        return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
347                    }
348                    field_include_has_explicit_shared_members = Some(map.next_value()?);
349                }
350                "include_property_groups" => {
351                    if field_include_property_groups.is_some() {
352                        return Err(::serde::de::Error::duplicate_field("include_property_groups"));
353                    }
354                    field_include_property_groups = Some(map.next_value()?);
355                }
356                "include_property_templates" => {
357                    if field_include_property_templates.is_some() {
358                        return Err(::serde::de::Error::duplicate_field("include_property_templates"));
359                    }
360                    field_include_property_templates = Some(map.next_value()?);
361                }
362                _ => {
363                    // unknown field allowed and ignored
364                    map.next_value::<::serde_json::Value>()?;
365                }
366            }
367        }
368        if optional && nothing {
369            return Ok(None);
370        }
371        let result = AlphaGetMetadataArg {
372            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
373            include_media_info: field_include_media_info.unwrap_or(false),
374            include_deleted: field_include_deleted.unwrap_or(false),
375            include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
376            include_property_groups: field_include_property_groups.and_then(Option::flatten),
377            include_property_templates: field_include_property_templates.and_then(Option::flatten),
378        };
379        Ok(Some(result))
380    }
381
382    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
383        &self,
384        s: &mut S::SerializeStruct,
385    ) -> Result<(), S::Error> {
386        use serde::ser::SerializeStruct;
387        s.serialize_field("path", &self.path)?;
388        if self.include_media_info {
389            s.serialize_field("include_media_info", &self.include_media_info)?;
390        }
391        if self.include_deleted {
392            s.serialize_field("include_deleted", &self.include_deleted)?;
393        }
394        if self.include_has_explicit_shared_members {
395            s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
396        }
397        if let Some(val) = &self.include_property_groups {
398            s.serialize_field("include_property_groups", val)?;
399        }
400        if let Some(val) = &self.include_property_templates {
401            s.serialize_field("include_property_templates", val)?;
402        }
403        Ok(())
404    }
405}
406
407impl<'de> ::serde::de::Deserialize<'de> for AlphaGetMetadataArg {
408    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
409        // struct deserializer
410        use serde::de::{MapAccess, Visitor};
411        struct StructVisitor;
412        impl<'de> Visitor<'de> for StructVisitor {
413            type Value = AlphaGetMetadataArg;
414            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
415                f.write_str("a AlphaGetMetadataArg struct")
416            }
417            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
418                AlphaGetMetadataArg::internal_deserialize(map)
419            }
420        }
421        deserializer.deserialize_struct("AlphaGetMetadataArg", ALPHA_GET_METADATA_ARG_FIELDS, StructVisitor)
422    }
423}
424
425impl ::serde::ser::Serialize for AlphaGetMetadataArg {
426    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
427        // struct serializer
428        use serde::ser::SerializeStruct;
429        let mut s = serializer.serialize_struct("AlphaGetMetadataArg", 6)?;
430        self.internal_serialize::<S>(&mut s)?;
431        s.end()
432    }
433}
434
435// struct extends GetMetadataArg
436impl From<AlphaGetMetadataArg> for GetMetadataArg {
437    fn from(subtype: AlphaGetMetadataArg) -> Self {
438        Self {
439            path: subtype.path,
440            include_media_info: subtype.include_media_info,
441            include_deleted: subtype.include_deleted,
442            include_has_explicit_shared_members: subtype.include_has_explicit_shared_members,
443            include_property_groups: subtype.include_property_groups,
444        }
445    }
446}
447#[derive(Debug, Clone, PartialEq, Eq)]
448pub enum AlphaGetMetadataError {
449    Path(LookupError),
450    PropertiesError(crate::types::file_properties::LookUpPropertiesError),
451}
452
453impl<'de> ::serde::de::Deserialize<'de> for AlphaGetMetadataError {
454    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
455        // union deserializer
456        use serde::de::{self, MapAccess, Visitor};
457        struct EnumVisitor;
458        impl<'de> Visitor<'de> for EnumVisitor {
459            type Value = AlphaGetMetadataError;
460            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
461                f.write_str("a AlphaGetMetadataError structure")
462            }
463            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
464                let tag: &str = match map.next_key()? {
465                    Some(".tag") => map.next_value()?,
466                    _ => return Err(de::Error::missing_field(".tag"))
467                };
468                let value = match tag {
469                    "path" => {
470                        match map.next_key()? {
471                            Some("path") => AlphaGetMetadataError::Path(map.next_value()?),
472                            None => return Err(de::Error::missing_field("path")),
473                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
474                        }
475                    }
476                    "properties_error" => {
477                        match map.next_key()? {
478                            Some("properties_error") => AlphaGetMetadataError::PropertiesError(map.next_value()?),
479                            None => return Err(de::Error::missing_field("properties_error")),
480                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
481                        }
482                    }
483                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
484                };
485                crate::eat_json_fields(&mut map)?;
486                Ok(value)
487            }
488        }
489        const VARIANTS: &[&str] = &["path",
490                                    "properties_error"];
491        deserializer.deserialize_struct("AlphaGetMetadataError", VARIANTS, EnumVisitor)
492    }
493}
494
495impl ::serde::ser::Serialize for AlphaGetMetadataError {
496    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
497        // union serializer
498        use serde::ser::SerializeStruct;
499        match self {
500            AlphaGetMetadataError::Path(x) => {
501                // union or polymporphic struct
502                let mut s = serializer.serialize_struct("AlphaGetMetadataError", 2)?;
503                s.serialize_field(".tag", "path")?;
504                s.serialize_field("path", x)?;
505                s.end()
506            }
507            AlphaGetMetadataError::PropertiesError(x) => {
508                // union or polymporphic struct
509                let mut s = serializer.serialize_struct("AlphaGetMetadataError", 2)?;
510                s.serialize_field(".tag", "properties_error")?;
511                s.serialize_field("properties_error", x)?;
512                s.end()
513            }
514        }
515    }
516}
517
518impl ::std::error::Error for AlphaGetMetadataError {
519    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
520        match self {
521            AlphaGetMetadataError::Path(inner) => Some(inner),
522            AlphaGetMetadataError::PropertiesError(inner) => Some(inner),
523        }
524    }
525}
526
527impl ::std::fmt::Display for AlphaGetMetadataError {
528    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
529        match self {
530            AlphaGetMetadataError::Path(inner) => write!(f, "AlphaGetMetadataError: {}", inner),
531            AlphaGetMetadataError::PropertiesError(inner) => write!(f, "AlphaGetMetadataError: {}", inner),
532        }
533    }
534}
535
536// union extends GetMetadataError
537impl From<GetMetadataError> for AlphaGetMetadataError {
538    fn from(parent: GetMetadataError) -> Self {
539        match parent {
540            GetMetadataError::Path(x) => AlphaGetMetadataError::Path(x),
541        }
542    }
543}
544#[derive(Debug, Clone, PartialEq, Eq)]
545#[non_exhaustive] // variants may be added in the future
546pub enum BaseTagError {
547    Path(LookupError),
548    /// Catch-all used for unrecognized values returned from the server. Encountering this value
549    /// typically indicates that this SDK version is out of date.
550    Other,
551}
552
553impl<'de> ::serde::de::Deserialize<'de> for BaseTagError {
554    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
555        // union deserializer
556        use serde::de::{self, MapAccess, Visitor};
557        struct EnumVisitor;
558        impl<'de> Visitor<'de> for EnumVisitor {
559            type Value = BaseTagError;
560            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
561                f.write_str("a BaseTagError structure")
562            }
563            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
564                let tag: &str = match map.next_key()? {
565                    Some(".tag") => map.next_value()?,
566                    _ => return Err(de::Error::missing_field(".tag"))
567                };
568                let value = match tag {
569                    "path" => {
570                        match map.next_key()? {
571                            Some("path") => BaseTagError::Path(map.next_value()?),
572                            None => return Err(de::Error::missing_field("path")),
573                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
574                        }
575                    }
576                    _ => BaseTagError::Other,
577                };
578                crate::eat_json_fields(&mut map)?;
579                Ok(value)
580            }
581        }
582        const VARIANTS: &[&str] = &["path",
583                                    "other"];
584        deserializer.deserialize_struct("BaseTagError", VARIANTS, EnumVisitor)
585    }
586}
587
588impl ::serde::ser::Serialize for BaseTagError {
589    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
590        // union serializer
591        use serde::ser::SerializeStruct;
592        match self {
593            BaseTagError::Path(x) => {
594                // union or polymporphic struct
595                let mut s = serializer.serialize_struct("BaseTagError", 2)?;
596                s.serialize_field(".tag", "path")?;
597                s.serialize_field("path", x)?;
598                s.end()
599            }
600            BaseTagError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
601        }
602    }
603}
604
605impl ::std::error::Error for BaseTagError {
606    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
607        match self {
608            BaseTagError::Path(inner) => Some(inner),
609            _ => None,
610        }
611    }
612}
613
614impl ::std::fmt::Display for BaseTagError {
615    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
616        match self {
617            BaseTagError::Path(inner) => write!(f, "BaseTagError: {}", inner),
618            _ => write!(f, "{:?}", *self),
619        }
620    }
621}
622
623#[derive(Debug, Clone, PartialEq, Eq)]
624#[non_exhaustive] // structs may have more fields added in the future.
625pub struct CommitInfo {
626    /// Path in the user's Dropbox to save the file.
627    pub path: WritePathOrId,
628    /// Selects what to do if the file already exists.
629    pub mode: WriteMode,
630    /// If there's a conflict, as determined by `mode`, have the Dropbox server try to autorename
631    /// the file to avoid conflict.
632    pub autorename: bool,
633    /// The value to store as the `client_modified` timestamp. Dropbox automatically records the
634    /// time at which the file was written to the Dropbox servers. It can also record an additional
635    /// timestamp, provided by Dropbox desktop clients, mobile clients, and API apps of when the
636    /// file was actually created or modified.
637    pub client_modified: Option<crate::types::common::DropboxTimestamp>,
638    /// Normally, users are made aware of any file modifications in their Dropbox account via
639    /// notifications in the client software. If `true`, this tells the clients that this
640    /// modification shouldn't result in a user notification.
641    pub mute: bool,
642    /// List of custom properties to add to file.
643    pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
644    /// Be more strict about how each [`WriteMode`] detects conflict. For example, always return a
645    /// conflict error when `mode` = [`WriteMode::Update`] and the given "rev" doesn't match the
646    /// existing file's "rev", even if the existing file has been deleted. This also forces a
647    /// conflict even when the target path refers to a file with identical contents.
648    pub strict_conflict: bool,
649}
650
651impl CommitInfo {
652    pub fn new(path: WritePathOrId) -> Self {
653        CommitInfo {
654            path,
655            mode: WriteMode::Add,
656            autorename: false,
657            client_modified: None,
658            mute: false,
659            property_groups: None,
660            strict_conflict: false,
661        }
662    }
663
664    pub fn with_mode(mut self, value: WriteMode) -> Self {
665        self.mode = value;
666        self
667    }
668
669    pub fn with_autorename(mut self, value: bool) -> Self {
670        self.autorename = value;
671        self
672    }
673
674    pub fn with_client_modified(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
675        self.client_modified = Some(value);
676        self
677    }
678
679    pub fn with_mute(mut self, value: bool) -> Self {
680        self.mute = value;
681        self
682    }
683
684    pub fn with_property_groups(
685        mut self,
686        value: Vec<crate::types::file_properties::PropertyGroup>,
687    ) -> Self {
688        self.property_groups = Some(value);
689        self
690    }
691
692    pub fn with_strict_conflict(mut self, value: bool) -> Self {
693        self.strict_conflict = value;
694        self
695    }
696}
697
698const COMMIT_INFO_FIELDS: &[&str] = &["path",
699                                      "mode",
700                                      "autorename",
701                                      "client_modified",
702                                      "mute",
703                                      "property_groups",
704                                      "strict_conflict"];
705impl CommitInfo {
706    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
707        map: V,
708    ) -> Result<CommitInfo, V::Error> {
709        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
710    }
711
712    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
713        mut map: V,
714        optional: bool,
715    ) -> Result<Option<CommitInfo>, V::Error> {
716        let mut field_path = None;
717        let mut field_mode = None;
718        let mut field_autorename = None;
719        let mut field_client_modified = None;
720        let mut field_mute = None;
721        let mut field_property_groups = None;
722        let mut field_strict_conflict = None;
723        let mut nothing = true;
724        while let Some(key) = map.next_key::<&str>()? {
725            nothing = false;
726            match key {
727                "path" => {
728                    if field_path.is_some() {
729                        return Err(::serde::de::Error::duplicate_field("path"));
730                    }
731                    field_path = Some(map.next_value()?);
732                }
733                "mode" => {
734                    if field_mode.is_some() {
735                        return Err(::serde::de::Error::duplicate_field("mode"));
736                    }
737                    field_mode = Some(map.next_value()?);
738                }
739                "autorename" => {
740                    if field_autorename.is_some() {
741                        return Err(::serde::de::Error::duplicate_field("autorename"));
742                    }
743                    field_autorename = Some(map.next_value()?);
744                }
745                "client_modified" => {
746                    if field_client_modified.is_some() {
747                        return Err(::serde::de::Error::duplicate_field("client_modified"));
748                    }
749                    field_client_modified = Some(map.next_value()?);
750                }
751                "mute" => {
752                    if field_mute.is_some() {
753                        return Err(::serde::de::Error::duplicate_field("mute"));
754                    }
755                    field_mute = Some(map.next_value()?);
756                }
757                "property_groups" => {
758                    if field_property_groups.is_some() {
759                        return Err(::serde::de::Error::duplicate_field("property_groups"));
760                    }
761                    field_property_groups = Some(map.next_value()?);
762                }
763                "strict_conflict" => {
764                    if field_strict_conflict.is_some() {
765                        return Err(::serde::de::Error::duplicate_field("strict_conflict"));
766                    }
767                    field_strict_conflict = Some(map.next_value()?);
768                }
769                _ => {
770                    // unknown field allowed and ignored
771                    map.next_value::<::serde_json::Value>()?;
772                }
773            }
774        }
775        if optional && nothing {
776            return Ok(None);
777        }
778        let result = CommitInfo {
779            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
780            mode: field_mode.unwrap_or(WriteMode::Add),
781            autorename: field_autorename.unwrap_or(false),
782            client_modified: field_client_modified.and_then(Option::flatten),
783            mute: field_mute.unwrap_or(false),
784            property_groups: field_property_groups.and_then(Option::flatten),
785            strict_conflict: field_strict_conflict.unwrap_or(false),
786        };
787        Ok(Some(result))
788    }
789
790    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
791        &self,
792        s: &mut S::SerializeStruct,
793    ) -> Result<(), S::Error> {
794        use serde::ser::SerializeStruct;
795        s.serialize_field("path", &self.path)?;
796        if self.mode != WriteMode::Add {
797            s.serialize_field("mode", &self.mode)?;
798        }
799        if self.autorename {
800            s.serialize_field("autorename", &self.autorename)?;
801        }
802        if let Some(val) = &self.client_modified {
803            s.serialize_field("client_modified", val)?;
804        }
805        if self.mute {
806            s.serialize_field("mute", &self.mute)?;
807        }
808        if let Some(val) = &self.property_groups {
809            s.serialize_field("property_groups", val)?;
810        }
811        if self.strict_conflict {
812            s.serialize_field("strict_conflict", &self.strict_conflict)?;
813        }
814        Ok(())
815    }
816}
817
818impl<'de> ::serde::de::Deserialize<'de> for CommitInfo {
819    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
820        // struct deserializer
821        use serde::de::{MapAccess, Visitor};
822        struct StructVisitor;
823        impl<'de> Visitor<'de> for StructVisitor {
824            type Value = CommitInfo;
825            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
826                f.write_str("a CommitInfo struct")
827            }
828            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
829                CommitInfo::internal_deserialize(map)
830            }
831        }
832        deserializer.deserialize_struct("CommitInfo", COMMIT_INFO_FIELDS, StructVisitor)
833    }
834}
835
836impl ::serde::ser::Serialize for CommitInfo {
837    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
838        // struct serializer
839        use serde::ser::SerializeStruct;
840        let mut s = serializer.serialize_struct("CommitInfo", 7)?;
841        self.internal_serialize::<S>(&mut s)?;
842        s.end()
843    }
844}
845
846#[derive(Debug, Clone, PartialEq, Eq)]
847#[non_exhaustive] // structs may have more fields added in the future.
848pub struct ContentSyncSetting {
849    /// Id of the item this setting is applied to.
850    pub id: FileId,
851    /// Setting for this item.
852    pub sync_setting: SyncSetting,
853}
854
855impl ContentSyncSetting {
856    pub fn new(id: FileId, sync_setting: SyncSetting) -> Self {
857        ContentSyncSetting {
858            id,
859            sync_setting,
860        }
861    }
862}
863
864const CONTENT_SYNC_SETTING_FIELDS: &[&str] = &["id",
865                                               "sync_setting"];
866impl ContentSyncSetting {
867    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
868        map: V,
869    ) -> Result<ContentSyncSetting, V::Error> {
870        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
871    }
872
873    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
874        mut map: V,
875        optional: bool,
876    ) -> Result<Option<ContentSyncSetting>, V::Error> {
877        let mut field_id = None;
878        let mut field_sync_setting = None;
879        let mut nothing = true;
880        while let Some(key) = map.next_key::<&str>()? {
881            nothing = false;
882            match key {
883                "id" => {
884                    if field_id.is_some() {
885                        return Err(::serde::de::Error::duplicate_field("id"));
886                    }
887                    field_id = Some(map.next_value()?);
888                }
889                "sync_setting" => {
890                    if field_sync_setting.is_some() {
891                        return Err(::serde::de::Error::duplicate_field("sync_setting"));
892                    }
893                    field_sync_setting = Some(map.next_value()?);
894                }
895                _ => {
896                    // unknown field allowed and ignored
897                    map.next_value::<::serde_json::Value>()?;
898                }
899            }
900        }
901        if optional && nothing {
902            return Ok(None);
903        }
904        let result = ContentSyncSetting {
905            id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
906            sync_setting: field_sync_setting.ok_or_else(|| ::serde::de::Error::missing_field("sync_setting"))?,
907        };
908        Ok(Some(result))
909    }
910
911    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
912        &self,
913        s: &mut S::SerializeStruct,
914    ) -> Result<(), S::Error> {
915        use serde::ser::SerializeStruct;
916        s.serialize_field("id", &self.id)?;
917        s.serialize_field("sync_setting", &self.sync_setting)?;
918        Ok(())
919    }
920}
921
922impl<'de> ::serde::de::Deserialize<'de> for ContentSyncSetting {
923    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
924        // struct deserializer
925        use serde::de::{MapAccess, Visitor};
926        struct StructVisitor;
927        impl<'de> Visitor<'de> for StructVisitor {
928            type Value = ContentSyncSetting;
929            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
930                f.write_str("a ContentSyncSetting struct")
931            }
932            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
933                ContentSyncSetting::internal_deserialize(map)
934            }
935        }
936        deserializer.deserialize_struct("ContentSyncSetting", CONTENT_SYNC_SETTING_FIELDS, StructVisitor)
937    }
938}
939
940impl ::serde::ser::Serialize for ContentSyncSetting {
941    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
942        // struct serializer
943        use serde::ser::SerializeStruct;
944        let mut s = serializer.serialize_struct("ContentSyncSetting", 2)?;
945        self.internal_serialize::<S>(&mut s)?;
946        s.end()
947    }
948}
949
950#[derive(Debug, Clone, PartialEq, Eq)]
951#[non_exhaustive] // structs may have more fields added in the future.
952pub struct ContentSyncSettingArg {
953    /// Id of the item this setting is applied to.
954    pub id: FileId,
955    /// Setting for this item.
956    pub sync_setting: SyncSettingArg,
957}
958
959impl ContentSyncSettingArg {
960    pub fn new(id: FileId, sync_setting: SyncSettingArg) -> Self {
961        ContentSyncSettingArg {
962            id,
963            sync_setting,
964        }
965    }
966}
967
968const CONTENT_SYNC_SETTING_ARG_FIELDS: &[&str] = &["id",
969                                                   "sync_setting"];
970impl ContentSyncSettingArg {
971    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
972        map: V,
973    ) -> Result<ContentSyncSettingArg, V::Error> {
974        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
975    }
976
977    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
978        mut map: V,
979        optional: bool,
980    ) -> Result<Option<ContentSyncSettingArg>, V::Error> {
981        let mut field_id = None;
982        let mut field_sync_setting = None;
983        let mut nothing = true;
984        while let Some(key) = map.next_key::<&str>()? {
985            nothing = false;
986            match key {
987                "id" => {
988                    if field_id.is_some() {
989                        return Err(::serde::de::Error::duplicate_field("id"));
990                    }
991                    field_id = Some(map.next_value()?);
992                }
993                "sync_setting" => {
994                    if field_sync_setting.is_some() {
995                        return Err(::serde::de::Error::duplicate_field("sync_setting"));
996                    }
997                    field_sync_setting = Some(map.next_value()?);
998                }
999                _ => {
1000                    // unknown field allowed and ignored
1001                    map.next_value::<::serde_json::Value>()?;
1002                }
1003            }
1004        }
1005        if optional && nothing {
1006            return Ok(None);
1007        }
1008        let result = ContentSyncSettingArg {
1009            id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
1010            sync_setting: field_sync_setting.ok_or_else(|| ::serde::de::Error::missing_field("sync_setting"))?,
1011        };
1012        Ok(Some(result))
1013    }
1014
1015    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1016        &self,
1017        s: &mut S::SerializeStruct,
1018    ) -> Result<(), S::Error> {
1019        use serde::ser::SerializeStruct;
1020        s.serialize_field("id", &self.id)?;
1021        s.serialize_field("sync_setting", &self.sync_setting)?;
1022        Ok(())
1023    }
1024}
1025
1026impl<'de> ::serde::de::Deserialize<'de> for ContentSyncSettingArg {
1027    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1028        // struct deserializer
1029        use serde::de::{MapAccess, Visitor};
1030        struct StructVisitor;
1031        impl<'de> Visitor<'de> for StructVisitor {
1032            type Value = ContentSyncSettingArg;
1033            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1034                f.write_str("a ContentSyncSettingArg struct")
1035            }
1036            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1037                ContentSyncSettingArg::internal_deserialize(map)
1038            }
1039        }
1040        deserializer.deserialize_struct("ContentSyncSettingArg", CONTENT_SYNC_SETTING_ARG_FIELDS, StructVisitor)
1041    }
1042}
1043
1044impl ::serde::ser::Serialize for ContentSyncSettingArg {
1045    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1046        // struct serializer
1047        use serde::ser::SerializeStruct;
1048        let mut s = serializer.serialize_struct("ContentSyncSettingArg", 2)?;
1049        self.internal_serialize::<S>(&mut s)?;
1050        s.end()
1051    }
1052}
1053
1054#[derive(Debug, Clone, PartialEq, Eq)]
1055#[non_exhaustive] // structs may have more fields added in the future.
1056pub struct CreateFolderArg {
1057    /// Path in the user's Dropbox to create.
1058    pub path: WritePath,
1059    /// If there's a conflict, have the Dropbox server try to autorename the folder to avoid the
1060    /// conflict.
1061    pub autorename: bool,
1062}
1063
1064impl CreateFolderArg {
1065    pub fn new(path: WritePath) -> Self {
1066        CreateFolderArg {
1067            path,
1068            autorename: false,
1069        }
1070    }
1071
1072    pub fn with_autorename(mut self, value: bool) -> Self {
1073        self.autorename = value;
1074        self
1075    }
1076}
1077
1078const CREATE_FOLDER_ARG_FIELDS: &[&str] = &["path",
1079                                            "autorename"];
1080impl CreateFolderArg {
1081    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1082        map: V,
1083    ) -> Result<CreateFolderArg, V::Error> {
1084        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1085    }
1086
1087    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1088        mut map: V,
1089        optional: bool,
1090    ) -> Result<Option<CreateFolderArg>, V::Error> {
1091        let mut field_path = None;
1092        let mut field_autorename = None;
1093        let mut nothing = true;
1094        while let Some(key) = map.next_key::<&str>()? {
1095            nothing = false;
1096            match key {
1097                "path" => {
1098                    if field_path.is_some() {
1099                        return Err(::serde::de::Error::duplicate_field("path"));
1100                    }
1101                    field_path = Some(map.next_value()?);
1102                }
1103                "autorename" => {
1104                    if field_autorename.is_some() {
1105                        return Err(::serde::de::Error::duplicate_field("autorename"));
1106                    }
1107                    field_autorename = Some(map.next_value()?);
1108                }
1109                _ => {
1110                    // unknown field allowed and ignored
1111                    map.next_value::<::serde_json::Value>()?;
1112                }
1113            }
1114        }
1115        if optional && nothing {
1116            return Ok(None);
1117        }
1118        let result = CreateFolderArg {
1119            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
1120            autorename: field_autorename.unwrap_or(false),
1121        };
1122        Ok(Some(result))
1123    }
1124
1125    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1126        &self,
1127        s: &mut S::SerializeStruct,
1128    ) -> Result<(), S::Error> {
1129        use serde::ser::SerializeStruct;
1130        s.serialize_field("path", &self.path)?;
1131        if self.autorename {
1132            s.serialize_field("autorename", &self.autorename)?;
1133        }
1134        Ok(())
1135    }
1136}
1137
1138impl<'de> ::serde::de::Deserialize<'de> for CreateFolderArg {
1139    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1140        // struct deserializer
1141        use serde::de::{MapAccess, Visitor};
1142        struct StructVisitor;
1143        impl<'de> Visitor<'de> for StructVisitor {
1144            type Value = CreateFolderArg;
1145            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1146                f.write_str("a CreateFolderArg struct")
1147            }
1148            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1149                CreateFolderArg::internal_deserialize(map)
1150            }
1151        }
1152        deserializer.deserialize_struct("CreateFolderArg", CREATE_FOLDER_ARG_FIELDS, StructVisitor)
1153    }
1154}
1155
1156impl ::serde::ser::Serialize for CreateFolderArg {
1157    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1158        // struct serializer
1159        use serde::ser::SerializeStruct;
1160        let mut s = serializer.serialize_struct("CreateFolderArg", 2)?;
1161        self.internal_serialize::<S>(&mut s)?;
1162        s.end()
1163    }
1164}
1165
1166#[derive(Debug, Clone, PartialEq, Eq)]
1167#[non_exhaustive] // structs may have more fields added in the future.
1168pub struct CreateFolderBatchArg {
1169    /// List of paths to be created in the user's Dropbox. Duplicate path arguments in the batch are
1170    /// considered only once.
1171    pub paths: Vec<WritePath>,
1172    /// If there's a conflict, have the Dropbox server try to autorename the folder to avoid the
1173    /// conflict.
1174    pub autorename: bool,
1175    /// Whether to force the create to happen asynchronously.
1176    pub force_async: bool,
1177}
1178
1179impl CreateFolderBatchArg {
1180    pub fn new(paths: Vec<WritePath>) -> Self {
1181        CreateFolderBatchArg {
1182            paths,
1183            autorename: false,
1184            force_async: false,
1185        }
1186    }
1187
1188    pub fn with_autorename(mut self, value: bool) -> Self {
1189        self.autorename = value;
1190        self
1191    }
1192
1193    pub fn with_force_async(mut self, value: bool) -> Self {
1194        self.force_async = value;
1195        self
1196    }
1197}
1198
1199const CREATE_FOLDER_BATCH_ARG_FIELDS: &[&str] = &["paths",
1200                                                  "autorename",
1201                                                  "force_async"];
1202impl CreateFolderBatchArg {
1203    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1204        map: V,
1205    ) -> Result<CreateFolderBatchArg, V::Error> {
1206        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1207    }
1208
1209    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1210        mut map: V,
1211        optional: bool,
1212    ) -> Result<Option<CreateFolderBatchArg>, V::Error> {
1213        let mut field_paths = None;
1214        let mut field_autorename = None;
1215        let mut field_force_async = None;
1216        let mut nothing = true;
1217        while let Some(key) = map.next_key::<&str>()? {
1218            nothing = false;
1219            match key {
1220                "paths" => {
1221                    if field_paths.is_some() {
1222                        return Err(::serde::de::Error::duplicate_field("paths"));
1223                    }
1224                    field_paths = Some(map.next_value()?);
1225                }
1226                "autorename" => {
1227                    if field_autorename.is_some() {
1228                        return Err(::serde::de::Error::duplicate_field("autorename"));
1229                    }
1230                    field_autorename = Some(map.next_value()?);
1231                }
1232                "force_async" => {
1233                    if field_force_async.is_some() {
1234                        return Err(::serde::de::Error::duplicate_field("force_async"));
1235                    }
1236                    field_force_async = Some(map.next_value()?);
1237                }
1238                _ => {
1239                    // unknown field allowed and ignored
1240                    map.next_value::<::serde_json::Value>()?;
1241                }
1242            }
1243        }
1244        if optional && nothing {
1245            return Ok(None);
1246        }
1247        let result = CreateFolderBatchArg {
1248            paths: field_paths.ok_or_else(|| ::serde::de::Error::missing_field("paths"))?,
1249            autorename: field_autorename.unwrap_or(false),
1250            force_async: field_force_async.unwrap_or(false),
1251        };
1252        Ok(Some(result))
1253    }
1254
1255    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1256        &self,
1257        s: &mut S::SerializeStruct,
1258    ) -> Result<(), S::Error> {
1259        use serde::ser::SerializeStruct;
1260        s.serialize_field("paths", &self.paths)?;
1261        if self.autorename {
1262            s.serialize_field("autorename", &self.autorename)?;
1263        }
1264        if self.force_async {
1265            s.serialize_field("force_async", &self.force_async)?;
1266        }
1267        Ok(())
1268    }
1269}
1270
1271impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchArg {
1272    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1273        // struct deserializer
1274        use serde::de::{MapAccess, Visitor};
1275        struct StructVisitor;
1276        impl<'de> Visitor<'de> for StructVisitor {
1277            type Value = CreateFolderBatchArg;
1278            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1279                f.write_str("a CreateFolderBatchArg struct")
1280            }
1281            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1282                CreateFolderBatchArg::internal_deserialize(map)
1283            }
1284        }
1285        deserializer.deserialize_struct("CreateFolderBatchArg", CREATE_FOLDER_BATCH_ARG_FIELDS, StructVisitor)
1286    }
1287}
1288
1289impl ::serde::ser::Serialize for CreateFolderBatchArg {
1290    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1291        // struct serializer
1292        use serde::ser::SerializeStruct;
1293        let mut s = serializer.serialize_struct("CreateFolderBatchArg", 3)?;
1294        self.internal_serialize::<S>(&mut s)?;
1295        s.end()
1296    }
1297}
1298
1299#[derive(Debug, Clone, PartialEq, Eq)]
1300#[non_exhaustive] // variants may be added in the future
1301pub enum CreateFolderBatchError {
1302    /// The operation would involve too many files or folders.
1303    TooManyFiles,
1304    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1305    /// typically indicates that this SDK version is out of date.
1306    Other,
1307}
1308
1309impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchError {
1310    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1311        // union deserializer
1312        use serde::de::{self, MapAccess, Visitor};
1313        struct EnumVisitor;
1314        impl<'de> Visitor<'de> for EnumVisitor {
1315            type Value = CreateFolderBatchError;
1316            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1317                f.write_str("a CreateFolderBatchError structure")
1318            }
1319            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1320                let tag: &str = match map.next_key()? {
1321                    Some(".tag") => map.next_value()?,
1322                    _ => return Err(de::Error::missing_field(".tag"))
1323                };
1324                let value = match tag {
1325                    "too_many_files" => CreateFolderBatchError::TooManyFiles,
1326                    _ => CreateFolderBatchError::Other,
1327                };
1328                crate::eat_json_fields(&mut map)?;
1329                Ok(value)
1330            }
1331        }
1332        const VARIANTS: &[&str] = &["too_many_files",
1333                                    "other"];
1334        deserializer.deserialize_struct("CreateFolderBatchError", VARIANTS, EnumVisitor)
1335    }
1336}
1337
1338impl ::serde::ser::Serialize for CreateFolderBatchError {
1339    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1340        // union serializer
1341        use serde::ser::SerializeStruct;
1342        match self {
1343            CreateFolderBatchError::TooManyFiles => {
1344                // unit
1345                let mut s = serializer.serialize_struct("CreateFolderBatchError", 1)?;
1346                s.serialize_field(".tag", "too_many_files")?;
1347                s.end()
1348            }
1349            CreateFolderBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1350        }
1351    }
1352}
1353
1354impl ::std::error::Error for CreateFolderBatchError {
1355}
1356
1357impl ::std::fmt::Display for CreateFolderBatchError {
1358    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1359        match self {
1360            CreateFolderBatchError::TooManyFiles => f.write_str("The operation would involve too many files or folders."),
1361            _ => write!(f, "{:?}", *self),
1362        }
1363    }
1364}
1365
1366#[derive(Debug, Clone, PartialEq, Eq)]
1367#[non_exhaustive] // variants may be added in the future
1368pub enum CreateFolderBatchJobStatus {
1369    /// The asynchronous job is still in progress.
1370    InProgress,
1371    /// The batch create folder has finished.
1372    Complete(CreateFolderBatchResult),
1373    /// The batch create folder has failed.
1374    Failed(CreateFolderBatchError),
1375    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1376    /// typically indicates that this SDK version is out of date.
1377    Other,
1378}
1379
1380impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchJobStatus {
1381    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1382        // union deserializer
1383        use serde::de::{self, MapAccess, Visitor};
1384        struct EnumVisitor;
1385        impl<'de> Visitor<'de> for EnumVisitor {
1386            type Value = CreateFolderBatchJobStatus;
1387            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1388                f.write_str("a CreateFolderBatchJobStatus structure")
1389            }
1390            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1391                let tag: &str = match map.next_key()? {
1392                    Some(".tag") => map.next_value()?,
1393                    _ => return Err(de::Error::missing_field(".tag"))
1394                };
1395                let value = match tag {
1396                    "in_progress" => CreateFolderBatchJobStatus::InProgress,
1397                    "complete" => CreateFolderBatchJobStatus::Complete(CreateFolderBatchResult::internal_deserialize(&mut map)?),
1398                    "failed" => {
1399                        match map.next_key()? {
1400                            Some("failed") => CreateFolderBatchJobStatus::Failed(map.next_value()?),
1401                            None => return Err(de::Error::missing_field("failed")),
1402                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1403                        }
1404                    }
1405                    _ => CreateFolderBatchJobStatus::Other,
1406                };
1407                crate::eat_json_fields(&mut map)?;
1408                Ok(value)
1409            }
1410        }
1411        const VARIANTS: &[&str] = &["in_progress",
1412                                    "complete",
1413                                    "failed",
1414                                    "other"];
1415        deserializer.deserialize_struct("CreateFolderBatchJobStatus", VARIANTS, EnumVisitor)
1416    }
1417}
1418
1419impl ::serde::ser::Serialize for CreateFolderBatchJobStatus {
1420    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1421        // union serializer
1422        use serde::ser::SerializeStruct;
1423        match self {
1424            CreateFolderBatchJobStatus::InProgress => {
1425                // unit
1426                let mut s = serializer.serialize_struct("CreateFolderBatchJobStatus", 1)?;
1427                s.serialize_field(".tag", "in_progress")?;
1428                s.end()
1429            }
1430            CreateFolderBatchJobStatus::Complete(x) => {
1431                // struct
1432                let mut s = serializer.serialize_struct("CreateFolderBatchJobStatus", 2)?;
1433                s.serialize_field(".tag", "complete")?;
1434                x.internal_serialize::<S>(&mut s)?;
1435                s.end()
1436            }
1437            CreateFolderBatchJobStatus::Failed(x) => {
1438                // union or polymporphic struct
1439                let mut s = serializer.serialize_struct("CreateFolderBatchJobStatus", 2)?;
1440                s.serialize_field(".tag", "failed")?;
1441                s.serialize_field("failed", x)?;
1442                s.end()
1443            }
1444            CreateFolderBatchJobStatus::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1445        }
1446    }
1447}
1448
1449// union extends crate::types::dbx_async::PollResultBase
1450impl From<crate::types::dbx_async::PollResultBase> for CreateFolderBatchJobStatus {
1451    fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
1452        match parent {
1453            crate::types::dbx_async::PollResultBase::InProgress => CreateFolderBatchJobStatus::InProgress,
1454        }
1455    }
1456}
1457/// Result returned by [`create_folder_batch()`](crate::files::create_folder_batch) that may either
1458/// launch an asynchronous job or complete synchronously.
1459#[derive(Debug, Clone, PartialEq, Eq)]
1460#[non_exhaustive] // variants may be added in the future
1461pub enum CreateFolderBatchLaunch {
1462    /// This response indicates that the processing is asynchronous. The string is an id that can be
1463    /// used to obtain the status of the asynchronous job.
1464    AsyncJobId(crate::types::dbx_async::AsyncJobId),
1465    Complete(CreateFolderBatchResult),
1466    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1467    /// typically indicates that this SDK version is out of date.
1468    Other,
1469}
1470
1471impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchLaunch {
1472    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1473        // union deserializer
1474        use serde::de::{self, MapAccess, Visitor};
1475        struct EnumVisitor;
1476        impl<'de> Visitor<'de> for EnumVisitor {
1477            type Value = CreateFolderBatchLaunch;
1478            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1479                f.write_str("a CreateFolderBatchLaunch structure")
1480            }
1481            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1482                let tag: &str = match map.next_key()? {
1483                    Some(".tag") => map.next_value()?,
1484                    _ => return Err(de::Error::missing_field(".tag"))
1485                };
1486                let value = match tag {
1487                    "async_job_id" => {
1488                        match map.next_key()? {
1489                            Some("async_job_id") => CreateFolderBatchLaunch::AsyncJobId(map.next_value()?),
1490                            None => return Err(de::Error::missing_field("async_job_id")),
1491                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1492                        }
1493                    }
1494                    "complete" => CreateFolderBatchLaunch::Complete(CreateFolderBatchResult::internal_deserialize(&mut map)?),
1495                    _ => CreateFolderBatchLaunch::Other,
1496                };
1497                crate::eat_json_fields(&mut map)?;
1498                Ok(value)
1499            }
1500        }
1501        const VARIANTS: &[&str] = &["async_job_id",
1502                                    "complete",
1503                                    "other"];
1504        deserializer.deserialize_struct("CreateFolderBatchLaunch", VARIANTS, EnumVisitor)
1505    }
1506}
1507
1508impl ::serde::ser::Serialize for CreateFolderBatchLaunch {
1509    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1510        // union serializer
1511        use serde::ser::SerializeStruct;
1512        match self {
1513            CreateFolderBatchLaunch::AsyncJobId(x) => {
1514                // primitive
1515                let mut s = serializer.serialize_struct("CreateFolderBatchLaunch", 2)?;
1516                s.serialize_field(".tag", "async_job_id")?;
1517                s.serialize_field("async_job_id", x)?;
1518                s.end()
1519            }
1520            CreateFolderBatchLaunch::Complete(x) => {
1521                // struct
1522                let mut s = serializer.serialize_struct("CreateFolderBatchLaunch", 2)?;
1523                s.serialize_field(".tag", "complete")?;
1524                x.internal_serialize::<S>(&mut s)?;
1525                s.end()
1526            }
1527            CreateFolderBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1528        }
1529    }
1530}
1531
1532// union extends crate::types::dbx_async::LaunchResultBase
1533impl From<crate::types::dbx_async::LaunchResultBase> for CreateFolderBatchLaunch {
1534    fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
1535        match parent {
1536            crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => CreateFolderBatchLaunch::AsyncJobId(x),
1537        }
1538    }
1539}
1540#[derive(Debug, Clone, PartialEq, Eq)]
1541#[non_exhaustive] // structs may have more fields added in the future.
1542pub struct CreateFolderBatchResult {
1543    /// Each entry in [`CreateFolderBatchArg::paths`](CreateFolderBatchArg) will appear at the same
1544    /// position inside [`CreateFolderBatchResult::entries`](CreateFolderBatchResult).
1545    pub entries: Vec<CreateFolderBatchResultEntry>,
1546}
1547
1548impl CreateFolderBatchResult {
1549    pub fn new(entries: Vec<CreateFolderBatchResultEntry>) -> Self {
1550        CreateFolderBatchResult {
1551            entries,
1552        }
1553    }
1554}
1555
1556const CREATE_FOLDER_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
1557impl CreateFolderBatchResult {
1558    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1559        map: V,
1560    ) -> Result<CreateFolderBatchResult, V::Error> {
1561        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1562    }
1563
1564    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1565        mut map: V,
1566        optional: bool,
1567    ) -> Result<Option<CreateFolderBatchResult>, V::Error> {
1568        let mut field_entries = None;
1569        let mut nothing = true;
1570        while let Some(key) = map.next_key::<&str>()? {
1571            nothing = false;
1572            match key {
1573                "entries" => {
1574                    if field_entries.is_some() {
1575                        return Err(::serde::de::Error::duplicate_field("entries"));
1576                    }
1577                    field_entries = Some(map.next_value()?);
1578                }
1579                _ => {
1580                    // unknown field allowed and ignored
1581                    map.next_value::<::serde_json::Value>()?;
1582                }
1583            }
1584        }
1585        if optional && nothing {
1586            return Ok(None);
1587        }
1588        let result = CreateFolderBatchResult {
1589            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
1590        };
1591        Ok(Some(result))
1592    }
1593
1594    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1595        &self,
1596        s: &mut S::SerializeStruct,
1597    ) -> Result<(), S::Error> {
1598        use serde::ser::SerializeStruct;
1599        s.serialize_field("entries", &self.entries)?;
1600        Ok(())
1601    }
1602}
1603
1604impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchResult {
1605    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1606        // struct deserializer
1607        use serde::de::{MapAccess, Visitor};
1608        struct StructVisitor;
1609        impl<'de> Visitor<'de> for StructVisitor {
1610            type Value = CreateFolderBatchResult;
1611            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1612                f.write_str("a CreateFolderBatchResult struct")
1613            }
1614            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1615                CreateFolderBatchResult::internal_deserialize(map)
1616            }
1617        }
1618        deserializer.deserialize_struct("CreateFolderBatchResult", CREATE_FOLDER_BATCH_RESULT_FIELDS, StructVisitor)
1619    }
1620}
1621
1622impl ::serde::ser::Serialize for CreateFolderBatchResult {
1623    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1624        // struct serializer
1625        use serde::ser::SerializeStruct;
1626        let mut s = serializer.serialize_struct("CreateFolderBatchResult", 1)?;
1627        self.internal_serialize::<S>(&mut s)?;
1628        s.end()
1629    }
1630}
1631
1632// struct extends FileOpsResult
1633impl From<CreateFolderBatchResult> for FileOpsResult {
1634    fn from(_: CreateFolderBatchResult) -> Self {
1635        Self {}
1636    }
1637}
1638#[derive(Debug, Clone, PartialEq, Eq)]
1639pub enum CreateFolderBatchResultEntry {
1640    Success(CreateFolderEntryResult),
1641    Failure(CreateFolderEntryError),
1642}
1643
1644impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchResultEntry {
1645    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1646        // union deserializer
1647        use serde::de::{self, MapAccess, Visitor};
1648        struct EnumVisitor;
1649        impl<'de> Visitor<'de> for EnumVisitor {
1650            type Value = CreateFolderBatchResultEntry;
1651            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1652                f.write_str("a CreateFolderBatchResultEntry structure")
1653            }
1654            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1655                let tag: &str = match map.next_key()? {
1656                    Some(".tag") => map.next_value()?,
1657                    _ => return Err(de::Error::missing_field(".tag"))
1658                };
1659                let value = match tag {
1660                    "success" => CreateFolderBatchResultEntry::Success(CreateFolderEntryResult::internal_deserialize(&mut map)?),
1661                    "failure" => {
1662                        match map.next_key()? {
1663                            Some("failure") => CreateFolderBatchResultEntry::Failure(map.next_value()?),
1664                            None => return Err(de::Error::missing_field("failure")),
1665                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1666                        }
1667                    }
1668                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
1669                };
1670                crate::eat_json_fields(&mut map)?;
1671                Ok(value)
1672            }
1673        }
1674        const VARIANTS: &[&str] = &["success",
1675                                    "failure"];
1676        deserializer.deserialize_struct("CreateFolderBatchResultEntry", VARIANTS, EnumVisitor)
1677    }
1678}
1679
1680impl ::serde::ser::Serialize for CreateFolderBatchResultEntry {
1681    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1682        // union serializer
1683        use serde::ser::SerializeStruct;
1684        match self {
1685            CreateFolderBatchResultEntry::Success(x) => {
1686                // struct
1687                let mut s = serializer.serialize_struct("CreateFolderBatchResultEntry", 2)?;
1688                s.serialize_field(".tag", "success")?;
1689                x.internal_serialize::<S>(&mut s)?;
1690                s.end()
1691            }
1692            CreateFolderBatchResultEntry::Failure(x) => {
1693                // union or polymporphic struct
1694                let mut s = serializer.serialize_struct("CreateFolderBatchResultEntry", 2)?;
1695                s.serialize_field(".tag", "failure")?;
1696                s.serialize_field("failure", x)?;
1697                s.end()
1698            }
1699        }
1700    }
1701}
1702
1703#[derive(Debug, Clone, PartialEq, Eq)]
1704#[non_exhaustive] // variants may be added in the future
1705pub enum CreateFolderEntryError {
1706    Path(WriteError),
1707    /// Catch-all used for unrecognized values returned from the server. Encountering this value
1708    /// typically indicates that this SDK version is out of date.
1709    Other,
1710}
1711
1712impl<'de> ::serde::de::Deserialize<'de> for CreateFolderEntryError {
1713    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1714        // union deserializer
1715        use serde::de::{self, MapAccess, Visitor};
1716        struct EnumVisitor;
1717        impl<'de> Visitor<'de> for EnumVisitor {
1718            type Value = CreateFolderEntryError;
1719            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1720                f.write_str("a CreateFolderEntryError structure")
1721            }
1722            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1723                let tag: &str = match map.next_key()? {
1724                    Some(".tag") => map.next_value()?,
1725                    _ => return Err(de::Error::missing_field(".tag"))
1726                };
1727                let value = match tag {
1728                    "path" => {
1729                        match map.next_key()? {
1730                            Some("path") => CreateFolderEntryError::Path(map.next_value()?),
1731                            None => return Err(de::Error::missing_field("path")),
1732                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1733                        }
1734                    }
1735                    _ => CreateFolderEntryError::Other,
1736                };
1737                crate::eat_json_fields(&mut map)?;
1738                Ok(value)
1739            }
1740        }
1741        const VARIANTS: &[&str] = &["path",
1742                                    "other"];
1743        deserializer.deserialize_struct("CreateFolderEntryError", VARIANTS, EnumVisitor)
1744    }
1745}
1746
1747impl ::serde::ser::Serialize for CreateFolderEntryError {
1748    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1749        // union serializer
1750        use serde::ser::SerializeStruct;
1751        match self {
1752            CreateFolderEntryError::Path(x) => {
1753                // union or polymporphic struct
1754                let mut s = serializer.serialize_struct("CreateFolderEntryError", 2)?;
1755                s.serialize_field(".tag", "path")?;
1756                s.serialize_field("path", x)?;
1757                s.end()
1758            }
1759            CreateFolderEntryError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1760        }
1761    }
1762}
1763
1764impl ::std::error::Error for CreateFolderEntryError {
1765    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
1766        match self {
1767            CreateFolderEntryError::Path(inner) => Some(inner),
1768            _ => None,
1769        }
1770    }
1771}
1772
1773impl ::std::fmt::Display for CreateFolderEntryError {
1774    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1775        match self {
1776            CreateFolderEntryError::Path(inner) => write!(f, "CreateFolderEntryError: {}", inner),
1777            _ => write!(f, "{:?}", *self),
1778        }
1779    }
1780}
1781
1782#[derive(Debug, Clone, PartialEq, Eq)]
1783#[non_exhaustive] // structs may have more fields added in the future.
1784pub struct CreateFolderEntryResult {
1785    /// Metadata of the created folder.
1786    pub metadata: FolderMetadata,
1787}
1788
1789impl CreateFolderEntryResult {
1790    pub fn new(metadata: FolderMetadata) -> Self {
1791        CreateFolderEntryResult {
1792            metadata,
1793        }
1794    }
1795}
1796
1797const CREATE_FOLDER_ENTRY_RESULT_FIELDS: &[&str] = &["metadata"];
1798impl CreateFolderEntryResult {
1799    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1800        map: V,
1801    ) -> Result<CreateFolderEntryResult, V::Error> {
1802        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1803    }
1804
1805    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1806        mut map: V,
1807        optional: bool,
1808    ) -> Result<Option<CreateFolderEntryResult>, V::Error> {
1809        let mut field_metadata = None;
1810        let mut nothing = true;
1811        while let Some(key) = map.next_key::<&str>()? {
1812            nothing = false;
1813            match key {
1814                "metadata" => {
1815                    if field_metadata.is_some() {
1816                        return Err(::serde::de::Error::duplicate_field("metadata"));
1817                    }
1818                    field_metadata = Some(map.next_value()?);
1819                }
1820                _ => {
1821                    // unknown field allowed and ignored
1822                    map.next_value::<::serde_json::Value>()?;
1823                }
1824            }
1825        }
1826        if optional && nothing {
1827            return Ok(None);
1828        }
1829        let result = CreateFolderEntryResult {
1830            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
1831        };
1832        Ok(Some(result))
1833    }
1834
1835    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1836        &self,
1837        s: &mut S::SerializeStruct,
1838    ) -> Result<(), S::Error> {
1839        use serde::ser::SerializeStruct;
1840        s.serialize_field("metadata", &self.metadata)?;
1841        Ok(())
1842    }
1843}
1844
1845impl<'de> ::serde::de::Deserialize<'de> for CreateFolderEntryResult {
1846    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1847        // struct deserializer
1848        use serde::de::{MapAccess, Visitor};
1849        struct StructVisitor;
1850        impl<'de> Visitor<'de> for StructVisitor {
1851            type Value = CreateFolderEntryResult;
1852            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1853                f.write_str("a CreateFolderEntryResult struct")
1854            }
1855            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1856                CreateFolderEntryResult::internal_deserialize(map)
1857            }
1858        }
1859        deserializer.deserialize_struct("CreateFolderEntryResult", CREATE_FOLDER_ENTRY_RESULT_FIELDS, StructVisitor)
1860    }
1861}
1862
1863impl ::serde::ser::Serialize for CreateFolderEntryResult {
1864    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1865        // struct serializer
1866        use serde::ser::SerializeStruct;
1867        let mut s = serializer.serialize_struct("CreateFolderEntryResult", 1)?;
1868        self.internal_serialize::<S>(&mut s)?;
1869        s.end()
1870    }
1871}
1872
1873#[derive(Debug, Clone, PartialEq, Eq)]
1874pub enum CreateFolderError {
1875    Path(WriteError),
1876}
1877
1878impl<'de> ::serde::de::Deserialize<'de> for CreateFolderError {
1879    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1880        // union deserializer
1881        use serde::de::{self, MapAccess, Visitor};
1882        struct EnumVisitor;
1883        impl<'de> Visitor<'de> for EnumVisitor {
1884            type Value = CreateFolderError;
1885            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1886                f.write_str("a CreateFolderError structure")
1887            }
1888            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1889                let tag: &str = match map.next_key()? {
1890                    Some(".tag") => map.next_value()?,
1891                    _ => return Err(de::Error::missing_field(".tag"))
1892                };
1893                let value = match tag {
1894                    "path" => {
1895                        match map.next_key()? {
1896                            Some("path") => CreateFolderError::Path(map.next_value()?),
1897                            None => return Err(de::Error::missing_field("path")),
1898                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1899                        }
1900                    }
1901                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
1902                };
1903                crate::eat_json_fields(&mut map)?;
1904                Ok(value)
1905            }
1906        }
1907        const VARIANTS: &[&str] = &["path"];
1908        deserializer.deserialize_struct("CreateFolderError", VARIANTS, EnumVisitor)
1909    }
1910}
1911
1912impl ::serde::ser::Serialize for CreateFolderError {
1913    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1914        // union serializer
1915        use serde::ser::SerializeStruct;
1916        match self {
1917            CreateFolderError::Path(x) => {
1918                // union or polymporphic struct
1919                let mut s = serializer.serialize_struct("CreateFolderError", 2)?;
1920                s.serialize_field(".tag", "path")?;
1921                s.serialize_field("path", x)?;
1922                s.end()
1923            }
1924        }
1925    }
1926}
1927
1928impl ::std::error::Error for CreateFolderError {
1929    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
1930        match self {
1931            CreateFolderError::Path(inner) => Some(inner),
1932        }
1933    }
1934}
1935
1936impl ::std::fmt::Display for CreateFolderError {
1937    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1938        match self {
1939            CreateFolderError::Path(inner) => write!(f, "CreateFolderError: {}", inner),
1940        }
1941    }
1942}
1943
1944#[derive(Debug, Clone, PartialEq, Eq)]
1945#[non_exhaustive] // structs may have more fields added in the future.
1946pub struct CreateFolderResult {
1947    /// Metadata of the created folder.
1948    pub metadata: FolderMetadata,
1949}
1950
1951impl CreateFolderResult {
1952    pub fn new(metadata: FolderMetadata) -> Self {
1953        CreateFolderResult {
1954            metadata,
1955        }
1956    }
1957}
1958
1959const CREATE_FOLDER_RESULT_FIELDS: &[&str] = &["metadata"];
1960impl CreateFolderResult {
1961    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1962        map: V,
1963    ) -> Result<CreateFolderResult, V::Error> {
1964        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1965    }
1966
1967    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1968        mut map: V,
1969        optional: bool,
1970    ) -> Result<Option<CreateFolderResult>, V::Error> {
1971        let mut field_metadata = None;
1972        let mut nothing = true;
1973        while let Some(key) = map.next_key::<&str>()? {
1974            nothing = false;
1975            match key {
1976                "metadata" => {
1977                    if field_metadata.is_some() {
1978                        return Err(::serde::de::Error::duplicate_field("metadata"));
1979                    }
1980                    field_metadata = Some(map.next_value()?);
1981                }
1982                _ => {
1983                    // unknown field allowed and ignored
1984                    map.next_value::<::serde_json::Value>()?;
1985                }
1986            }
1987        }
1988        if optional && nothing {
1989            return Ok(None);
1990        }
1991        let result = CreateFolderResult {
1992            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
1993        };
1994        Ok(Some(result))
1995    }
1996
1997    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1998        &self,
1999        s: &mut S::SerializeStruct,
2000    ) -> Result<(), S::Error> {
2001        use serde::ser::SerializeStruct;
2002        s.serialize_field("metadata", &self.metadata)?;
2003        Ok(())
2004    }
2005}
2006
2007impl<'de> ::serde::de::Deserialize<'de> for CreateFolderResult {
2008    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2009        // struct deserializer
2010        use serde::de::{MapAccess, Visitor};
2011        struct StructVisitor;
2012        impl<'de> Visitor<'de> for StructVisitor {
2013            type Value = CreateFolderResult;
2014            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2015                f.write_str("a CreateFolderResult struct")
2016            }
2017            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2018                CreateFolderResult::internal_deserialize(map)
2019            }
2020        }
2021        deserializer.deserialize_struct("CreateFolderResult", CREATE_FOLDER_RESULT_FIELDS, StructVisitor)
2022    }
2023}
2024
2025impl ::serde::ser::Serialize for CreateFolderResult {
2026    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2027        // struct serializer
2028        use serde::ser::SerializeStruct;
2029        let mut s = serializer.serialize_struct("CreateFolderResult", 1)?;
2030        self.internal_serialize::<S>(&mut s)?;
2031        s.end()
2032    }
2033}
2034
2035// struct extends FileOpsResult
2036impl From<CreateFolderResult> for FileOpsResult {
2037    fn from(_: CreateFolderResult) -> Self {
2038        Self {}
2039    }
2040}
2041#[derive(Debug, Clone, PartialEq, Eq)]
2042#[non_exhaustive] // structs may have more fields added in the future.
2043pub struct DeleteArg {
2044    /// Path in the user's Dropbox to delete.
2045    pub path: WritePathOrId,
2046    /// Perform delete if given "rev" matches the existing file's latest "rev". This field does not
2047    /// support deleting a folder.
2048    pub parent_rev: Option<Rev>,
2049}
2050
2051impl DeleteArg {
2052    pub fn new(path: WritePathOrId) -> Self {
2053        DeleteArg {
2054            path,
2055            parent_rev: None,
2056        }
2057    }
2058
2059    pub fn with_parent_rev(mut self, value: Rev) -> Self {
2060        self.parent_rev = Some(value);
2061        self
2062    }
2063}
2064
2065const DELETE_ARG_FIELDS: &[&str] = &["path",
2066                                     "parent_rev"];
2067impl DeleteArg {
2068    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2069        map: V,
2070    ) -> Result<DeleteArg, V::Error> {
2071        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2072    }
2073
2074    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2075        mut map: V,
2076        optional: bool,
2077    ) -> Result<Option<DeleteArg>, V::Error> {
2078        let mut field_path = None;
2079        let mut field_parent_rev = None;
2080        let mut nothing = true;
2081        while let Some(key) = map.next_key::<&str>()? {
2082            nothing = false;
2083            match key {
2084                "path" => {
2085                    if field_path.is_some() {
2086                        return Err(::serde::de::Error::duplicate_field("path"));
2087                    }
2088                    field_path = Some(map.next_value()?);
2089                }
2090                "parent_rev" => {
2091                    if field_parent_rev.is_some() {
2092                        return Err(::serde::de::Error::duplicate_field("parent_rev"));
2093                    }
2094                    field_parent_rev = Some(map.next_value()?);
2095                }
2096                _ => {
2097                    // unknown field allowed and ignored
2098                    map.next_value::<::serde_json::Value>()?;
2099                }
2100            }
2101        }
2102        if optional && nothing {
2103            return Ok(None);
2104        }
2105        let result = DeleteArg {
2106            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
2107            parent_rev: field_parent_rev.and_then(Option::flatten),
2108        };
2109        Ok(Some(result))
2110    }
2111
2112    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2113        &self,
2114        s: &mut S::SerializeStruct,
2115    ) -> Result<(), S::Error> {
2116        use serde::ser::SerializeStruct;
2117        s.serialize_field("path", &self.path)?;
2118        if let Some(val) = &self.parent_rev {
2119            s.serialize_field("parent_rev", val)?;
2120        }
2121        Ok(())
2122    }
2123}
2124
2125impl<'de> ::serde::de::Deserialize<'de> for DeleteArg {
2126    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2127        // struct deserializer
2128        use serde::de::{MapAccess, Visitor};
2129        struct StructVisitor;
2130        impl<'de> Visitor<'de> for StructVisitor {
2131            type Value = DeleteArg;
2132            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2133                f.write_str("a DeleteArg struct")
2134            }
2135            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2136                DeleteArg::internal_deserialize(map)
2137            }
2138        }
2139        deserializer.deserialize_struct("DeleteArg", DELETE_ARG_FIELDS, StructVisitor)
2140    }
2141}
2142
2143impl ::serde::ser::Serialize for DeleteArg {
2144    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2145        // struct serializer
2146        use serde::ser::SerializeStruct;
2147        let mut s = serializer.serialize_struct("DeleteArg", 2)?;
2148        self.internal_serialize::<S>(&mut s)?;
2149        s.end()
2150    }
2151}
2152
2153#[derive(Debug, Clone, PartialEq, Eq)]
2154#[non_exhaustive] // structs may have more fields added in the future.
2155pub struct DeleteBatchArg {
2156    pub entries: Vec<DeleteArg>,
2157}
2158
2159impl DeleteBatchArg {
2160    pub fn new(entries: Vec<DeleteArg>) -> Self {
2161        DeleteBatchArg {
2162            entries,
2163        }
2164    }
2165}
2166
2167const DELETE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
2168impl DeleteBatchArg {
2169    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2170        map: V,
2171    ) -> Result<DeleteBatchArg, V::Error> {
2172        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2173    }
2174
2175    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2176        mut map: V,
2177        optional: bool,
2178    ) -> Result<Option<DeleteBatchArg>, V::Error> {
2179        let mut field_entries = None;
2180        let mut nothing = true;
2181        while let Some(key) = map.next_key::<&str>()? {
2182            nothing = false;
2183            match key {
2184                "entries" => {
2185                    if field_entries.is_some() {
2186                        return Err(::serde::de::Error::duplicate_field("entries"));
2187                    }
2188                    field_entries = Some(map.next_value()?);
2189                }
2190                _ => {
2191                    // unknown field allowed and ignored
2192                    map.next_value::<::serde_json::Value>()?;
2193                }
2194            }
2195        }
2196        if optional && nothing {
2197            return Ok(None);
2198        }
2199        let result = DeleteBatchArg {
2200            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
2201        };
2202        Ok(Some(result))
2203    }
2204
2205    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2206        &self,
2207        s: &mut S::SerializeStruct,
2208    ) -> Result<(), S::Error> {
2209        use serde::ser::SerializeStruct;
2210        s.serialize_field("entries", &self.entries)?;
2211        Ok(())
2212    }
2213}
2214
2215impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchArg {
2216    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2217        // struct deserializer
2218        use serde::de::{MapAccess, Visitor};
2219        struct StructVisitor;
2220        impl<'de> Visitor<'de> for StructVisitor {
2221            type Value = DeleteBatchArg;
2222            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2223                f.write_str("a DeleteBatchArg struct")
2224            }
2225            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2226                DeleteBatchArg::internal_deserialize(map)
2227            }
2228        }
2229        deserializer.deserialize_struct("DeleteBatchArg", DELETE_BATCH_ARG_FIELDS, StructVisitor)
2230    }
2231}
2232
2233impl ::serde::ser::Serialize for DeleteBatchArg {
2234    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2235        // struct serializer
2236        use serde::ser::SerializeStruct;
2237        let mut s = serializer.serialize_struct("DeleteBatchArg", 1)?;
2238        self.internal_serialize::<S>(&mut s)?;
2239        s.end()
2240    }
2241}
2242
2243#[derive(Debug, Clone, PartialEq, Eq)]
2244#[non_exhaustive] // variants may be added in the future
2245pub enum DeleteBatchError {
2246    /// Use [`DeleteError::TooManyWriteOperations`]. [`delete_batch()`](crate::files::delete_batch)
2247    /// now provides smaller granularity about which entry has failed because of this.
2248    TooManyWriteOperations,
2249    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2250    /// typically indicates that this SDK version is out of date.
2251    Other,
2252}
2253
2254impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchError {
2255    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2256        // union deserializer
2257        use serde::de::{self, MapAccess, Visitor};
2258        struct EnumVisitor;
2259        impl<'de> Visitor<'de> for EnumVisitor {
2260            type Value = DeleteBatchError;
2261            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2262                f.write_str("a DeleteBatchError structure")
2263            }
2264            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2265                let tag: &str = match map.next_key()? {
2266                    Some(".tag") => map.next_value()?,
2267                    _ => return Err(de::Error::missing_field(".tag"))
2268                };
2269                let value = match tag {
2270                    "too_many_write_operations" => DeleteBatchError::TooManyWriteOperations,
2271                    _ => DeleteBatchError::Other,
2272                };
2273                crate::eat_json_fields(&mut map)?;
2274                Ok(value)
2275            }
2276        }
2277        const VARIANTS: &[&str] = &["too_many_write_operations",
2278                                    "other"];
2279        deserializer.deserialize_struct("DeleteBatchError", VARIANTS, EnumVisitor)
2280    }
2281}
2282
2283impl ::serde::ser::Serialize for DeleteBatchError {
2284    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2285        // union serializer
2286        use serde::ser::SerializeStruct;
2287        match self {
2288            DeleteBatchError::TooManyWriteOperations => {
2289                // unit
2290                let mut s = serializer.serialize_struct("DeleteBatchError", 1)?;
2291                s.serialize_field(".tag", "too_many_write_operations")?;
2292                s.end()
2293            }
2294            DeleteBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2295        }
2296    }
2297}
2298
2299impl ::std::error::Error for DeleteBatchError {
2300}
2301
2302impl ::std::fmt::Display for DeleteBatchError {
2303    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2304        write!(f, "{:?}", *self)
2305    }
2306}
2307
2308#[derive(Debug, Clone, PartialEq)]
2309#[non_exhaustive] // variants may be added in the future
2310pub enum DeleteBatchJobStatus {
2311    /// The asynchronous job is still in progress.
2312    InProgress,
2313    /// The batch delete has finished.
2314    Complete(DeleteBatchResult),
2315    /// The batch delete has failed.
2316    Failed(DeleteBatchError),
2317    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2318    /// typically indicates that this SDK version is out of date.
2319    Other,
2320}
2321
2322impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchJobStatus {
2323    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2324        // union deserializer
2325        use serde::de::{self, MapAccess, Visitor};
2326        struct EnumVisitor;
2327        impl<'de> Visitor<'de> for EnumVisitor {
2328            type Value = DeleteBatchJobStatus;
2329            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2330                f.write_str("a DeleteBatchJobStatus structure")
2331            }
2332            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2333                let tag: &str = match map.next_key()? {
2334                    Some(".tag") => map.next_value()?,
2335                    _ => return Err(de::Error::missing_field(".tag"))
2336                };
2337                let value = match tag {
2338                    "in_progress" => DeleteBatchJobStatus::InProgress,
2339                    "complete" => DeleteBatchJobStatus::Complete(DeleteBatchResult::internal_deserialize(&mut map)?),
2340                    "failed" => {
2341                        match map.next_key()? {
2342                            Some("failed") => DeleteBatchJobStatus::Failed(map.next_value()?),
2343                            None => return Err(de::Error::missing_field("failed")),
2344                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2345                        }
2346                    }
2347                    _ => DeleteBatchJobStatus::Other,
2348                };
2349                crate::eat_json_fields(&mut map)?;
2350                Ok(value)
2351            }
2352        }
2353        const VARIANTS: &[&str] = &["in_progress",
2354                                    "complete",
2355                                    "failed",
2356                                    "other"];
2357        deserializer.deserialize_struct("DeleteBatchJobStatus", VARIANTS, EnumVisitor)
2358    }
2359}
2360
2361impl ::serde::ser::Serialize for DeleteBatchJobStatus {
2362    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2363        // union serializer
2364        use serde::ser::SerializeStruct;
2365        match self {
2366            DeleteBatchJobStatus::InProgress => {
2367                // unit
2368                let mut s = serializer.serialize_struct("DeleteBatchJobStatus", 1)?;
2369                s.serialize_field(".tag", "in_progress")?;
2370                s.end()
2371            }
2372            DeleteBatchJobStatus::Complete(x) => {
2373                // struct
2374                let mut s = serializer.serialize_struct("DeleteBatchJobStatus", 2)?;
2375                s.serialize_field(".tag", "complete")?;
2376                x.internal_serialize::<S>(&mut s)?;
2377                s.end()
2378            }
2379            DeleteBatchJobStatus::Failed(x) => {
2380                // union or polymporphic struct
2381                let mut s = serializer.serialize_struct("DeleteBatchJobStatus", 2)?;
2382                s.serialize_field(".tag", "failed")?;
2383                s.serialize_field("failed", x)?;
2384                s.end()
2385            }
2386            DeleteBatchJobStatus::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2387        }
2388    }
2389}
2390
2391// union extends crate::types::dbx_async::PollResultBase
2392impl From<crate::types::dbx_async::PollResultBase> for DeleteBatchJobStatus {
2393    fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
2394        match parent {
2395            crate::types::dbx_async::PollResultBase::InProgress => DeleteBatchJobStatus::InProgress,
2396        }
2397    }
2398}
2399/// Result returned by [`delete_batch()`](crate::files::delete_batch) that may either launch an
2400/// asynchronous job or complete synchronously.
2401#[derive(Debug, Clone, PartialEq)]
2402#[non_exhaustive] // variants may be added in the future
2403pub enum DeleteBatchLaunch {
2404    /// This response indicates that the processing is asynchronous. The string is an id that can be
2405    /// used to obtain the status of the asynchronous job.
2406    AsyncJobId(crate::types::dbx_async::AsyncJobId),
2407    Complete(DeleteBatchResult),
2408    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2409    /// typically indicates that this SDK version is out of date.
2410    Other,
2411}
2412
2413impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchLaunch {
2414    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2415        // union deserializer
2416        use serde::de::{self, MapAccess, Visitor};
2417        struct EnumVisitor;
2418        impl<'de> Visitor<'de> for EnumVisitor {
2419            type Value = DeleteBatchLaunch;
2420            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2421                f.write_str("a DeleteBatchLaunch structure")
2422            }
2423            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2424                let tag: &str = match map.next_key()? {
2425                    Some(".tag") => map.next_value()?,
2426                    _ => return Err(de::Error::missing_field(".tag"))
2427                };
2428                let value = match tag {
2429                    "async_job_id" => {
2430                        match map.next_key()? {
2431                            Some("async_job_id") => DeleteBatchLaunch::AsyncJobId(map.next_value()?),
2432                            None => return Err(de::Error::missing_field("async_job_id")),
2433                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2434                        }
2435                    }
2436                    "complete" => DeleteBatchLaunch::Complete(DeleteBatchResult::internal_deserialize(&mut map)?),
2437                    _ => DeleteBatchLaunch::Other,
2438                };
2439                crate::eat_json_fields(&mut map)?;
2440                Ok(value)
2441            }
2442        }
2443        const VARIANTS: &[&str] = &["async_job_id",
2444                                    "complete",
2445                                    "other"];
2446        deserializer.deserialize_struct("DeleteBatchLaunch", VARIANTS, EnumVisitor)
2447    }
2448}
2449
2450impl ::serde::ser::Serialize for DeleteBatchLaunch {
2451    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2452        // union serializer
2453        use serde::ser::SerializeStruct;
2454        match self {
2455            DeleteBatchLaunch::AsyncJobId(x) => {
2456                // primitive
2457                let mut s = serializer.serialize_struct("DeleteBatchLaunch", 2)?;
2458                s.serialize_field(".tag", "async_job_id")?;
2459                s.serialize_field("async_job_id", x)?;
2460                s.end()
2461            }
2462            DeleteBatchLaunch::Complete(x) => {
2463                // struct
2464                let mut s = serializer.serialize_struct("DeleteBatchLaunch", 2)?;
2465                s.serialize_field(".tag", "complete")?;
2466                x.internal_serialize::<S>(&mut s)?;
2467                s.end()
2468            }
2469            DeleteBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2470        }
2471    }
2472}
2473
2474// union extends crate::types::dbx_async::LaunchResultBase
2475impl From<crate::types::dbx_async::LaunchResultBase> for DeleteBatchLaunch {
2476    fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
2477        match parent {
2478            crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => DeleteBatchLaunch::AsyncJobId(x),
2479        }
2480    }
2481}
2482#[derive(Debug, Clone, PartialEq)]
2483#[non_exhaustive] // structs may have more fields added in the future.
2484pub struct DeleteBatchResult {
2485    /// Each entry in [`DeleteBatchArg::entries`](DeleteBatchArg) will appear at the same position
2486    /// inside [`DeleteBatchResult::entries`](DeleteBatchResult).
2487    pub entries: Vec<DeleteBatchResultEntry>,
2488}
2489
2490impl DeleteBatchResult {
2491    pub fn new(entries: Vec<DeleteBatchResultEntry>) -> Self {
2492        DeleteBatchResult {
2493            entries,
2494        }
2495    }
2496}
2497
2498const DELETE_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
2499impl DeleteBatchResult {
2500    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2501        map: V,
2502    ) -> Result<DeleteBatchResult, V::Error> {
2503        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2504    }
2505
2506    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2507        mut map: V,
2508        optional: bool,
2509    ) -> Result<Option<DeleteBatchResult>, V::Error> {
2510        let mut field_entries = None;
2511        let mut nothing = true;
2512        while let Some(key) = map.next_key::<&str>()? {
2513            nothing = false;
2514            match key {
2515                "entries" => {
2516                    if field_entries.is_some() {
2517                        return Err(::serde::de::Error::duplicate_field("entries"));
2518                    }
2519                    field_entries = Some(map.next_value()?);
2520                }
2521                _ => {
2522                    // unknown field allowed and ignored
2523                    map.next_value::<::serde_json::Value>()?;
2524                }
2525            }
2526        }
2527        if optional && nothing {
2528            return Ok(None);
2529        }
2530        let result = DeleteBatchResult {
2531            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
2532        };
2533        Ok(Some(result))
2534    }
2535
2536    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2537        &self,
2538        s: &mut S::SerializeStruct,
2539    ) -> Result<(), S::Error> {
2540        use serde::ser::SerializeStruct;
2541        s.serialize_field("entries", &self.entries)?;
2542        Ok(())
2543    }
2544}
2545
2546impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchResult {
2547    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2548        // struct deserializer
2549        use serde::de::{MapAccess, Visitor};
2550        struct StructVisitor;
2551        impl<'de> Visitor<'de> for StructVisitor {
2552            type Value = DeleteBatchResult;
2553            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2554                f.write_str("a DeleteBatchResult struct")
2555            }
2556            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2557                DeleteBatchResult::internal_deserialize(map)
2558            }
2559        }
2560        deserializer.deserialize_struct("DeleteBatchResult", DELETE_BATCH_RESULT_FIELDS, StructVisitor)
2561    }
2562}
2563
2564impl ::serde::ser::Serialize for DeleteBatchResult {
2565    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2566        // struct serializer
2567        use serde::ser::SerializeStruct;
2568        let mut s = serializer.serialize_struct("DeleteBatchResult", 1)?;
2569        self.internal_serialize::<S>(&mut s)?;
2570        s.end()
2571    }
2572}
2573
2574// struct extends FileOpsResult
2575impl From<DeleteBatchResult> for FileOpsResult {
2576    fn from(_: DeleteBatchResult) -> Self {
2577        Self {}
2578    }
2579}
2580#[derive(Debug, Clone, PartialEq)]
2581#[non_exhaustive] // structs may have more fields added in the future.
2582pub struct DeleteBatchResultData {
2583    /// Metadata of the deleted object.
2584    pub metadata: Metadata,
2585}
2586
2587impl DeleteBatchResultData {
2588    pub fn new(metadata: Metadata) -> Self {
2589        DeleteBatchResultData {
2590            metadata,
2591        }
2592    }
2593}
2594
2595const DELETE_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata"];
2596impl DeleteBatchResultData {
2597    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2598        map: V,
2599    ) -> Result<DeleteBatchResultData, V::Error> {
2600        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2601    }
2602
2603    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2604        mut map: V,
2605        optional: bool,
2606    ) -> Result<Option<DeleteBatchResultData>, V::Error> {
2607        let mut field_metadata = None;
2608        let mut nothing = true;
2609        while let Some(key) = map.next_key::<&str>()? {
2610            nothing = false;
2611            match key {
2612                "metadata" => {
2613                    if field_metadata.is_some() {
2614                        return Err(::serde::de::Error::duplicate_field("metadata"));
2615                    }
2616                    field_metadata = Some(map.next_value()?);
2617                }
2618                _ => {
2619                    // unknown field allowed and ignored
2620                    map.next_value::<::serde_json::Value>()?;
2621                }
2622            }
2623        }
2624        if optional && nothing {
2625            return Ok(None);
2626        }
2627        let result = DeleteBatchResultData {
2628            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
2629        };
2630        Ok(Some(result))
2631    }
2632
2633    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2634        &self,
2635        s: &mut S::SerializeStruct,
2636    ) -> Result<(), S::Error> {
2637        use serde::ser::SerializeStruct;
2638        s.serialize_field("metadata", &self.metadata)?;
2639        Ok(())
2640    }
2641}
2642
2643impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchResultData {
2644    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2645        // struct deserializer
2646        use serde::de::{MapAccess, Visitor};
2647        struct StructVisitor;
2648        impl<'de> Visitor<'de> for StructVisitor {
2649            type Value = DeleteBatchResultData;
2650            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2651                f.write_str("a DeleteBatchResultData struct")
2652            }
2653            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2654                DeleteBatchResultData::internal_deserialize(map)
2655            }
2656        }
2657        deserializer.deserialize_struct("DeleteBatchResultData", DELETE_BATCH_RESULT_DATA_FIELDS, StructVisitor)
2658    }
2659}
2660
2661impl ::serde::ser::Serialize for DeleteBatchResultData {
2662    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2663        // struct serializer
2664        use serde::ser::SerializeStruct;
2665        let mut s = serializer.serialize_struct("DeleteBatchResultData", 1)?;
2666        self.internal_serialize::<S>(&mut s)?;
2667        s.end()
2668    }
2669}
2670
2671#[derive(Debug, Clone, PartialEq)]
2672pub enum DeleteBatchResultEntry {
2673    Success(DeleteBatchResultData),
2674    Failure(DeleteError),
2675}
2676
2677impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchResultEntry {
2678    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2679        // union deserializer
2680        use serde::de::{self, MapAccess, Visitor};
2681        struct EnumVisitor;
2682        impl<'de> Visitor<'de> for EnumVisitor {
2683            type Value = DeleteBatchResultEntry;
2684            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2685                f.write_str("a DeleteBatchResultEntry structure")
2686            }
2687            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2688                let tag: &str = match map.next_key()? {
2689                    Some(".tag") => map.next_value()?,
2690                    _ => return Err(de::Error::missing_field(".tag"))
2691                };
2692                let value = match tag {
2693                    "success" => DeleteBatchResultEntry::Success(DeleteBatchResultData::internal_deserialize(&mut map)?),
2694                    "failure" => {
2695                        match map.next_key()? {
2696                            Some("failure") => DeleteBatchResultEntry::Failure(map.next_value()?),
2697                            None => return Err(de::Error::missing_field("failure")),
2698                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2699                        }
2700                    }
2701                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
2702                };
2703                crate::eat_json_fields(&mut map)?;
2704                Ok(value)
2705            }
2706        }
2707        const VARIANTS: &[&str] = &["success",
2708                                    "failure"];
2709        deserializer.deserialize_struct("DeleteBatchResultEntry", VARIANTS, EnumVisitor)
2710    }
2711}
2712
2713impl ::serde::ser::Serialize for DeleteBatchResultEntry {
2714    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2715        // union serializer
2716        use serde::ser::SerializeStruct;
2717        match self {
2718            DeleteBatchResultEntry::Success(x) => {
2719                // struct
2720                let mut s = serializer.serialize_struct("DeleteBatchResultEntry", 2)?;
2721                s.serialize_field(".tag", "success")?;
2722                x.internal_serialize::<S>(&mut s)?;
2723                s.end()
2724            }
2725            DeleteBatchResultEntry::Failure(x) => {
2726                // union or polymporphic struct
2727                let mut s = serializer.serialize_struct("DeleteBatchResultEntry", 2)?;
2728                s.serialize_field(".tag", "failure")?;
2729                s.serialize_field("failure", x)?;
2730                s.end()
2731            }
2732        }
2733    }
2734}
2735
2736#[derive(Debug, Clone, PartialEq, Eq)]
2737#[non_exhaustive] // variants may be added in the future
2738pub enum DeleteError {
2739    PathLookup(LookupError),
2740    PathWrite(WriteError),
2741    /// There are too many write operations in user's Dropbox. Please retry this request.
2742    TooManyWriteOperations,
2743    /// There are too many files in one request. Please retry with fewer files.
2744    TooManyFiles,
2745    /// Catch-all used for unrecognized values returned from the server. Encountering this value
2746    /// typically indicates that this SDK version is out of date.
2747    Other,
2748}
2749
2750impl<'de> ::serde::de::Deserialize<'de> for DeleteError {
2751    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2752        // union deserializer
2753        use serde::de::{self, MapAccess, Visitor};
2754        struct EnumVisitor;
2755        impl<'de> Visitor<'de> for EnumVisitor {
2756            type Value = DeleteError;
2757            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2758                f.write_str("a DeleteError structure")
2759            }
2760            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2761                let tag: &str = match map.next_key()? {
2762                    Some(".tag") => map.next_value()?,
2763                    _ => return Err(de::Error::missing_field(".tag"))
2764                };
2765                let value = match tag {
2766                    "path_lookup" => {
2767                        match map.next_key()? {
2768                            Some("path_lookup") => DeleteError::PathLookup(map.next_value()?),
2769                            None => return Err(de::Error::missing_field("path_lookup")),
2770                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2771                        }
2772                    }
2773                    "path_write" => {
2774                        match map.next_key()? {
2775                            Some("path_write") => DeleteError::PathWrite(map.next_value()?),
2776                            None => return Err(de::Error::missing_field("path_write")),
2777                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2778                        }
2779                    }
2780                    "too_many_write_operations" => DeleteError::TooManyWriteOperations,
2781                    "too_many_files" => DeleteError::TooManyFiles,
2782                    _ => DeleteError::Other,
2783                };
2784                crate::eat_json_fields(&mut map)?;
2785                Ok(value)
2786            }
2787        }
2788        const VARIANTS: &[&str] = &["path_lookup",
2789                                    "path_write",
2790                                    "too_many_write_operations",
2791                                    "too_many_files",
2792                                    "other"];
2793        deserializer.deserialize_struct("DeleteError", VARIANTS, EnumVisitor)
2794    }
2795}
2796
2797impl ::serde::ser::Serialize for DeleteError {
2798    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2799        // union serializer
2800        use serde::ser::SerializeStruct;
2801        match self {
2802            DeleteError::PathLookup(x) => {
2803                // union or polymporphic struct
2804                let mut s = serializer.serialize_struct("DeleteError", 2)?;
2805                s.serialize_field(".tag", "path_lookup")?;
2806                s.serialize_field("path_lookup", x)?;
2807                s.end()
2808            }
2809            DeleteError::PathWrite(x) => {
2810                // union or polymporphic struct
2811                let mut s = serializer.serialize_struct("DeleteError", 2)?;
2812                s.serialize_field(".tag", "path_write")?;
2813                s.serialize_field("path_write", x)?;
2814                s.end()
2815            }
2816            DeleteError::TooManyWriteOperations => {
2817                // unit
2818                let mut s = serializer.serialize_struct("DeleteError", 1)?;
2819                s.serialize_field(".tag", "too_many_write_operations")?;
2820                s.end()
2821            }
2822            DeleteError::TooManyFiles => {
2823                // unit
2824                let mut s = serializer.serialize_struct("DeleteError", 1)?;
2825                s.serialize_field(".tag", "too_many_files")?;
2826                s.end()
2827            }
2828            DeleteError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2829        }
2830    }
2831}
2832
2833impl ::std::error::Error for DeleteError {
2834    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
2835        match self {
2836            DeleteError::PathLookup(inner) => Some(inner),
2837            DeleteError::PathWrite(inner) => Some(inner),
2838            _ => None,
2839        }
2840    }
2841}
2842
2843impl ::std::fmt::Display for DeleteError {
2844    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2845        match self {
2846            DeleteError::PathLookup(inner) => write!(f, "DeleteError: {}", inner),
2847            DeleteError::PathWrite(inner) => write!(f, "DeleteError: {}", inner),
2848            DeleteError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
2849            DeleteError::TooManyFiles => f.write_str("There are too many files in one request. Please retry with fewer files."),
2850            _ => write!(f, "{:?}", *self),
2851        }
2852    }
2853}
2854
2855#[derive(Debug, Clone, PartialEq)]
2856#[non_exhaustive] // structs may have more fields added in the future.
2857pub struct DeleteResult {
2858    /// Metadata of the deleted object.
2859    pub metadata: Metadata,
2860}
2861
2862impl DeleteResult {
2863    pub fn new(metadata: Metadata) -> Self {
2864        DeleteResult {
2865            metadata,
2866        }
2867    }
2868}
2869
2870const DELETE_RESULT_FIELDS: &[&str] = &["metadata"];
2871impl DeleteResult {
2872    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2873        map: V,
2874    ) -> Result<DeleteResult, V::Error> {
2875        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2876    }
2877
2878    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2879        mut map: V,
2880        optional: bool,
2881    ) -> Result<Option<DeleteResult>, V::Error> {
2882        let mut field_metadata = None;
2883        let mut nothing = true;
2884        while let Some(key) = map.next_key::<&str>()? {
2885            nothing = false;
2886            match key {
2887                "metadata" => {
2888                    if field_metadata.is_some() {
2889                        return Err(::serde::de::Error::duplicate_field("metadata"));
2890                    }
2891                    field_metadata = Some(map.next_value()?);
2892                }
2893                _ => {
2894                    // unknown field allowed and ignored
2895                    map.next_value::<::serde_json::Value>()?;
2896                }
2897            }
2898        }
2899        if optional && nothing {
2900            return Ok(None);
2901        }
2902        let result = DeleteResult {
2903            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
2904        };
2905        Ok(Some(result))
2906    }
2907
2908    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2909        &self,
2910        s: &mut S::SerializeStruct,
2911    ) -> Result<(), S::Error> {
2912        use serde::ser::SerializeStruct;
2913        s.serialize_field("metadata", &self.metadata)?;
2914        Ok(())
2915    }
2916}
2917
2918impl<'de> ::serde::de::Deserialize<'de> for DeleteResult {
2919    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2920        // struct deserializer
2921        use serde::de::{MapAccess, Visitor};
2922        struct StructVisitor;
2923        impl<'de> Visitor<'de> for StructVisitor {
2924            type Value = DeleteResult;
2925            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2926                f.write_str("a DeleteResult struct")
2927            }
2928            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2929                DeleteResult::internal_deserialize(map)
2930            }
2931        }
2932        deserializer.deserialize_struct("DeleteResult", DELETE_RESULT_FIELDS, StructVisitor)
2933    }
2934}
2935
2936impl ::serde::ser::Serialize for DeleteResult {
2937    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2938        // struct serializer
2939        use serde::ser::SerializeStruct;
2940        let mut s = serializer.serialize_struct("DeleteResult", 1)?;
2941        self.internal_serialize::<S>(&mut s)?;
2942        s.end()
2943    }
2944}
2945
2946// struct extends FileOpsResult
2947impl From<DeleteResult> for FileOpsResult {
2948    fn from(_: DeleteResult) -> Self {
2949        Self {}
2950    }
2951}
2952/// Indicates that there used to be a file or folder at this path, but it no longer exists.
2953#[derive(Debug, Clone, PartialEq, Eq)]
2954#[non_exhaustive] // structs may have more fields added in the future.
2955pub struct DeletedMetadata {
2956    /// The last component of the path (including extension). This never contains a slash.
2957    pub name: String,
2958    /// The lowercased full path in the user's Dropbox. This always starts with a slash. This field
2959    /// will be null if the file or folder is not mounted.
2960    pub path_lower: Option<String>,
2961    /// The cased path to be used for display purposes only. In rare instances the casing will not
2962    /// correctly match the user's filesystem, but this behavior will match the path provided in the
2963    /// Core API v1, and at least the last path component will have the correct casing. Changes to
2964    /// only the casing of paths won't be returned by
2965    /// [`list_folder_continue()`](crate::files::list_folder_continue). This field will be null if
2966    /// the file or folder is not mounted.
2967    pub path_display: Option<String>,
2968    /// Please use [`FileSharingInfo::parent_shared_folder_id`](FileSharingInfo) or
2969    /// [`FolderSharingInfo::parent_shared_folder_id`](FolderSharingInfo) instead.
2970    pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
2971    /// The preview URL of the file.
2972    pub preview_url: Option<String>,
2973}
2974
2975impl DeletedMetadata {
2976    pub fn new(name: String) -> Self {
2977        DeletedMetadata {
2978            name,
2979            path_lower: None,
2980            path_display: None,
2981            parent_shared_folder_id: None,
2982            preview_url: None,
2983        }
2984    }
2985
2986    pub fn with_path_lower(mut self, value: String) -> Self {
2987        self.path_lower = Some(value);
2988        self
2989    }
2990
2991    pub fn with_path_display(mut self, value: String) -> Self {
2992        self.path_display = Some(value);
2993        self
2994    }
2995
2996    pub fn with_parent_shared_folder_id(
2997        mut self,
2998        value: crate::types::common::SharedFolderId,
2999    ) -> Self {
3000        self.parent_shared_folder_id = Some(value);
3001        self
3002    }
3003
3004    pub fn with_preview_url(mut self, value: String) -> Self {
3005        self.preview_url = Some(value);
3006        self
3007    }
3008}
3009
3010const DELETED_METADATA_FIELDS: &[&str] = &["name",
3011                                           "path_lower",
3012                                           "path_display",
3013                                           "parent_shared_folder_id",
3014                                           "preview_url"];
3015impl DeletedMetadata {
3016    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3017        map: V,
3018    ) -> Result<DeletedMetadata, V::Error> {
3019        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3020    }
3021
3022    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3023        mut map: V,
3024        optional: bool,
3025    ) -> Result<Option<DeletedMetadata>, V::Error> {
3026        let mut field_name = None;
3027        let mut field_path_lower = None;
3028        let mut field_path_display = None;
3029        let mut field_parent_shared_folder_id = None;
3030        let mut field_preview_url = None;
3031        let mut nothing = true;
3032        while let Some(key) = map.next_key::<&str>()? {
3033            nothing = false;
3034            match key {
3035                "name" => {
3036                    if field_name.is_some() {
3037                        return Err(::serde::de::Error::duplicate_field("name"));
3038                    }
3039                    field_name = Some(map.next_value()?);
3040                }
3041                "path_lower" => {
3042                    if field_path_lower.is_some() {
3043                        return Err(::serde::de::Error::duplicate_field("path_lower"));
3044                    }
3045                    field_path_lower = Some(map.next_value()?);
3046                }
3047                "path_display" => {
3048                    if field_path_display.is_some() {
3049                        return Err(::serde::de::Error::duplicate_field("path_display"));
3050                    }
3051                    field_path_display = Some(map.next_value()?);
3052                }
3053                "parent_shared_folder_id" => {
3054                    if field_parent_shared_folder_id.is_some() {
3055                        return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
3056                    }
3057                    field_parent_shared_folder_id = Some(map.next_value()?);
3058                }
3059                "preview_url" => {
3060                    if field_preview_url.is_some() {
3061                        return Err(::serde::de::Error::duplicate_field("preview_url"));
3062                    }
3063                    field_preview_url = Some(map.next_value()?);
3064                }
3065                _ => {
3066                    // unknown field allowed and ignored
3067                    map.next_value::<::serde_json::Value>()?;
3068                }
3069            }
3070        }
3071        if optional && nothing {
3072            return Ok(None);
3073        }
3074        let result = DeletedMetadata {
3075            name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
3076            path_lower: field_path_lower.and_then(Option::flatten),
3077            path_display: field_path_display.and_then(Option::flatten),
3078            parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
3079            preview_url: field_preview_url.and_then(Option::flatten),
3080        };
3081        Ok(Some(result))
3082    }
3083
3084    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3085        &self,
3086        s: &mut S::SerializeStruct,
3087    ) -> Result<(), S::Error> {
3088        use serde::ser::SerializeStruct;
3089        s.serialize_field("name", &self.name)?;
3090        if let Some(val) = &self.path_lower {
3091            s.serialize_field("path_lower", val)?;
3092        }
3093        if let Some(val) = &self.path_display {
3094            s.serialize_field("path_display", val)?;
3095        }
3096        if let Some(val) = &self.parent_shared_folder_id {
3097            s.serialize_field("parent_shared_folder_id", val)?;
3098        }
3099        if let Some(val) = &self.preview_url {
3100            s.serialize_field("preview_url", val)?;
3101        }
3102        Ok(())
3103    }
3104}
3105
3106impl<'de> ::serde::de::Deserialize<'de> for DeletedMetadata {
3107    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3108        // struct deserializer
3109        use serde::de::{MapAccess, Visitor};
3110        struct StructVisitor;
3111        impl<'de> Visitor<'de> for StructVisitor {
3112            type Value = DeletedMetadata;
3113            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3114                f.write_str("a DeletedMetadata struct")
3115            }
3116            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3117                DeletedMetadata::internal_deserialize(map)
3118            }
3119        }
3120        deserializer.deserialize_struct("DeletedMetadata", DELETED_METADATA_FIELDS, StructVisitor)
3121    }
3122}
3123
3124impl ::serde::ser::Serialize for DeletedMetadata {
3125    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3126        // struct serializer
3127        use serde::ser::SerializeStruct;
3128        let mut s = serializer.serialize_struct("DeletedMetadata", 5)?;
3129        self.internal_serialize::<S>(&mut s)?;
3130        s.end()
3131    }
3132}
3133
3134// struct extends polymorphic struct Metadata
3135impl From<DeletedMetadata> for Metadata {
3136    fn from(subtype: DeletedMetadata) -> Self {
3137        Metadata::Deleted(subtype)
3138    }
3139}
3140/// Dimensions for a photo or video.
3141#[derive(Debug, Clone, PartialEq, Eq)]
3142#[non_exhaustive] // structs may have more fields added in the future.
3143pub struct Dimensions {
3144    /// Height of the photo/video.
3145    pub height: u64,
3146    /// Width of the photo/video.
3147    pub width: u64,
3148}
3149
3150impl Dimensions {
3151    pub fn new(height: u64, width: u64) -> Self {
3152        Dimensions {
3153            height,
3154            width,
3155        }
3156    }
3157}
3158
3159const DIMENSIONS_FIELDS: &[&str] = &["height",
3160                                     "width"];
3161impl Dimensions {
3162    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3163        map: V,
3164    ) -> Result<Dimensions, V::Error> {
3165        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3166    }
3167
3168    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3169        mut map: V,
3170        optional: bool,
3171    ) -> Result<Option<Dimensions>, V::Error> {
3172        let mut field_height = None;
3173        let mut field_width = None;
3174        let mut nothing = true;
3175        while let Some(key) = map.next_key::<&str>()? {
3176            nothing = false;
3177            match key {
3178                "height" => {
3179                    if field_height.is_some() {
3180                        return Err(::serde::de::Error::duplicate_field("height"));
3181                    }
3182                    field_height = Some(map.next_value()?);
3183                }
3184                "width" => {
3185                    if field_width.is_some() {
3186                        return Err(::serde::de::Error::duplicate_field("width"));
3187                    }
3188                    field_width = Some(map.next_value()?);
3189                }
3190                _ => {
3191                    // unknown field allowed and ignored
3192                    map.next_value::<::serde_json::Value>()?;
3193                }
3194            }
3195        }
3196        if optional && nothing {
3197            return Ok(None);
3198        }
3199        let result = Dimensions {
3200            height: field_height.ok_or_else(|| ::serde::de::Error::missing_field("height"))?,
3201            width: field_width.ok_or_else(|| ::serde::de::Error::missing_field("width"))?,
3202        };
3203        Ok(Some(result))
3204    }
3205
3206    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3207        &self,
3208        s: &mut S::SerializeStruct,
3209    ) -> Result<(), S::Error> {
3210        use serde::ser::SerializeStruct;
3211        s.serialize_field("height", &self.height)?;
3212        s.serialize_field("width", &self.width)?;
3213        Ok(())
3214    }
3215}
3216
3217impl<'de> ::serde::de::Deserialize<'de> for Dimensions {
3218    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3219        // struct deserializer
3220        use serde::de::{MapAccess, Visitor};
3221        struct StructVisitor;
3222        impl<'de> Visitor<'de> for StructVisitor {
3223            type Value = Dimensions;
3224            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3225                f.write_str("a Dimensions struct")
3226            }
3227            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3228                Dimensions::internal_deserialize(map)
3229            }
3230        }
3231        deserializer.deserialize_struct("Dimensions", DIMENSIONS_FIELDS, StructVisitor)
3232    }
3233}
3234
3235impl ::serde::ser::Serialize for Dimensions {
3236    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3237        // struct serializer
3238        use serde::ser::SerializeStruct;
3239        let mut s = serializer.serialize_struct("Dimensions", 2)?;
3240        self.internal_serialize::<S>(&mut s)?;
3241        s.end()
3242    }
3243}
3244
3245#[derive(Debug, Clone, PartialEq, Eq)]
3246#[non_exhaustive] // structs may have more fields added in the future.
3247pub struct DownloadArg {
3248    /// The path of the file to download.
3249    pub path: ReadPath,
3250    /// Please specify revision in `path` instead.
3251    pub rev: Option<Rev>,
3252}
3253
3254impl DownloadArg {
3255    pub fn new(path: ReadPath) -> Self {
3256        DownloadArg {
3257            path,
3258            rev: None,
3259        }
3260    }
3261
3262    pub fn with_rev(mut self, value: Rev) -> Self {
3263        self.rev = Some(value);
3264        self
3265    }
3266}
3267
3268const DOWNLOAD_ARG_FIELDS: &[&str] = &["path",
3269                                       "rev"];
3270impl DownloadArg {
3271    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3272        map: V,
3273    ) -> Result<DownloadArg, V::Error> {
3274        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3275    }
3276
3277    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3278        mut map: V,
3279        optional: bool,
3280    ) -> Result<Option<DownloadArg>, V::Error> {
3281        let mut field_path = None;
3282        let mut field_rev = None;
3283        let mut nothing = true;
3284        while let Some(key) = map.next_key::<&str>()? {
3285            nothing = false;
3286            match key {
3287                "path" => {
3288                    if field_path.is_some() {
3289                        return Err(::serde::de::Error::duplicate_field("path"));
3290                    }
3291                    field_path = Some(map.next_value()?);
3292                }
3293                "rev" => {
3294                    if field_rev.is_some() {
3295                        return Err(::serde::de::Error::duplicate_field("rev"));
3296                    }
3297                    field_rev = Some(map.next_value()?);
3298                }
3299                _ => {
3300                    // unknown field allowed and ignored
3301                    map.next_value::<::serde_json::Value>()?;
3302                }
3303            }
3304        }
3305        if optional && nothing {
3306            return Ok(None);
3307        }
3308        let result = DownloadArg {
3309            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
3310            rev: field_rev.and_then(Option::flatten),
3311        };
3312        Ok(Some(result))
3313    }
3314
3315    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3316        &self,
3317        s: &mut S::SerializeStruct,
3318    ) -> Result<(), S::Error> {
3319        use serde::ser::SerializeStruct;
3320        s.serialize_field("path", &self.path)?;
3321        if let Some(val) = &self.rev {
3322            s.serialize_field("rev", val)?;
3323        }
3324        Ok(())
3325    }
3326}
3327
3328impl<'de> ::serde::de::Deserialize<'de> for DownloadArg {
3329    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3330        // struct deserializer
3331        use serde::de::{MapAccess, Visitor};
3332        struct StructVisitor;
3333        impl<'de> Visitor<'de> for StructVisitor {
3334            type Value = DownloadArg;
3335            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3336                f.write_str("a DownloadArg struct")
3337            }
3338            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3339                DownloadArg::internal_deserialize(map)
3340            }
3341        }
3342        deserializer.deserialize_struct("DownloadArg", DOWNLOAD_ARG_FIELDS, StructVisitor)
3343    }
3344}
3345
3346impl ::serde::ser::Serialize for DownloadArg {
3347    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3348        // struct serializer
3349        use serde::ser::SerializeStruct;
3350        let mut s = serializer.serialize_struct("DownloadArg", 2)?;
3351        self.internal_serialize::<S>(&mut s)?;
3352        s.end()
3353    }
3354}
3355
3356#[derive(Debug, Clone, PartialEq, Eq)]
3357#[non_exhaustive] // variants may be added in the future
3358pub enum DownloadError {
3359    Path(LookupError),
3360    /// This file type cannot be downloaded directly; use [`export()`](crate::files::export)
3361    /// instead.
3362    UnsupportedFile,
3363    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3364    /// typically indicates that this SDK version is out of date.
3365    Other,
3366}
3367
3368impl<'de> ::serde::de::Deserialize<'de> for DownloadError {
3369    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3370        // union deserializer
3371        use serde::de::{self, MapAccess, Visitor};
3372        struct EnumVisitor;
3373        impl<'de> Visitor<'de> for EnumVisitor {
3374            type Value = DownloadError;
3375            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3376                f.write_str("a DownloadError structure")
3377            }
3378            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3379                let tag: &str = match map.next_key()? {
3380                    Some(".tag") => map.next_value()?,
3381                    _ => return Err(de::Error::missing_field(".tag"))
3382                };
3383                let value = match tag {
3384                    "path" => {
3385                        match map.next_key()? {
3386                            Some("path") => DownloadError::Path(map.next_value()?),
3387                            None => return Err(de::Error::missing_field("path")),
3388                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3389                        }
3390                    }
3391                    "unsupported_file" => DownloadError::UnsupportedFile,
3392                    _ => DownloadError::Other,
3393                };
3394                crate::eat_json_fields(&mut map)?;
3395                Ok(value)
3396            }
3397        }
3398        const VARIANTS: &[&str] = &["path",
3399                                    "unsupported_file",
3400                                    "other"];
3401        deserializer.deserialize_struct("DownloadError", VARIANTS, EnumVisitor)
3402    }
3403}
3404
3405impl ::serde::ser::Serialize for DownloadError {
3406    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3407        // union serializer
3408        use serde::ser::SerializeStruct;
3409        match self {
3410            DownloadError::Path(x) => {
3411                // union or polymporphic struct
3412                let mut s = serializer.serialize_struct("DownloadError", 2)?;
3413                s.serialize_field(".tag", "path")?;
3414                s.serialize_field("path", x)?;
3415                s.end()
3416            }
3417            DownloadError::UnsupportedFile => {
3418                // unit
3419                let mut s = serializer.serialize_struct("DownloadError", 1)?;
3420                s.serialize_field(".tag", "unsupported_file")?;
3421                s.end()
3422            }
3423            DownloadError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3424        }
3425    }
3426}
3427
3428impl ::std::error::Error for DownloadError {
3429    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
3430        match self {
3431            DownloadError::Path(inner) => Some(inner),
3432            _ => None,
3433        }
3434    }
3435}
3436
3437impl ::std::fmt::Display for DownloadError {
3438    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3439        match self {
3440            DownloadError::Path(inner) => write!(f, "DownloadError: {}", inner),
3441            _ => write!(f, "{:?}", *self),
3442        }
3443    }
3444}
3445
3446#[derive(Debug, Clone, PartialEq, Eq)]
3447#[non_exhaustive] // structs may have more fields added in the future.
3448pub struct DownloadZipArg {
3449    /// The path of the folder to download.
3450    pub path: ReadPath,
3451}
3452
3453impl DownloadZipArg {
3454    pub fn new(path: ReadPath) -> Self {
3455        DownloadZipArg {
3456            path,
3457        }
3458    }
3459}
3460
3461const DOWNLOAD_ZIP_ARG_FIELDS: &[&str] = &["path"];
3462impl DownloadZipArg {
3463    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3464        map: V,
3465    ) -> Result<DownloadZipArg, V::Error> {
3466        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3467    }
3468
3469    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3470        mut map: V,
3471        optional: bool,
3472    ) -> Result<Option<DownloadZipArg>, V::Error> {
3473        let mut field_path = None;
3474        let mut nothing = true;
3475        while let Some(key) = map.next_key::<&str>()? {
3476            nothing = false;
3477            match key {
3478                "path" => {
3479                    if field_path.is_some() {
3480                        return Err(::serde::de::Error::duplicate_field("path"));
3481                    }
3482                    field_path = Some(map.next_value()?);
3483                }
3484                _ => {
3485                    // unknown field allowed and ignored
3486                    map.next_value::<::serde_json::Value>()?;
3487                }
3488            }
3489        }
3490        if optional && nothing {
3491            return Ok(None);
3492        }
3493        let result = DownloadZipArg {
3494            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
3495        };
3496        Ok(Some(result))
3497    }
3498
3499    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3500        &self,
3501        s: &mut S::SerializeStruct,
3502    ) -> Result<(), S::Error> {
3503        use serde::ser::SerializeStruct;
3504        s.serialize_field("path", &self.path)?;
3505        Ok(())
3506    }
3507}
3508
3509impl<'de> ::serde::de::Deserialize<'de> for DownloadZipArg {
3510    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3511        // struct deserializer
3512        use serde::de::{MapAccess, Visitor};
3513        struct StructVisitor;
3514        impl<'de> Visitor<'de> for StructVisitor {
3515            type Value = DownloadZipArg;
3516            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3517                f.write_str("a DownloadZipArg struct")
3518            }
3519            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3520                DownloadZipArg::internal_deserialize(map)
3521            }
3522        }
3523        deserializer.deserialize_struct("DownloadZipArg", DOWNLOAD_ZIP_ARG_FIELDS, StructVisitor)
3524    }
3525}
3526
3527impl ::serde::ser::Serialize for DownloadZipArg {
3528    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3529        // struct serializer
3530        use serde::ser::SerializeStruct;
3531        let mut s = serializer.serialize_struct("DownloadZipArg", 1)?;
3532        self.internal_serialize::<S>(&mut s)?;
3533        s.end()
3534    }
3535}
3536
3537#[derive(Debug, Clone, PartialEq, Eq)]
3538#[non_exhaustive] // variants may be added in the future
3539pub enum DownloadZipError {
3540    Path(LookupError),
3541    /// The folder or a file is too large to download.
3542    TooLarge,
3543    /// The folder has too many files to download.
3544    TooManyFiles,
3545    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3546    /// typically indicates that this SDK version is out of date.
3547    Other,
3548}
3549
3550impl<'de> ::serde::de::Deserialize<'de> for DownloadZipError {
3551    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3552        // union deserializer
3553        use serde::de::{self, MapAccess, Visitor};
3554        struct EnumVisitor;
3555        impl<'de> Visitor<'de> for EnumVisitor {
3556            type Value = DownloadZipError;
3557            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3558                f.write_str("a DownloadZipError structure")
3559            }
3560            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3561                let tag: &str = match map.next_key()? {
3562                    Some(".tag") => map.next_value()?,
3563                    _ => return Err(de::Error::missing_field(".tag"))
3564                };
3565                let value = match tag {
3566                    "path" => {
3567                        match map.next_key()? {
3568                            Some("path") => DownloadZipError::Path(map.next_value()?),
3569                            None => return Err(de::Error::missing_field("path")),
3570                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3571                        }
3572                    }
3573                    "too_large" => DownloadZipError::TooLarge,
3574                    "too_many_files" => DownloadZipError::TooManyFiles,
3575                    _ => DownloadZipError::Other,
3576                };
3577                crate::eat_json_fields(&mut map)?;
3578                Ok(value)
3579            }
3580        }
3581        const VARIANTS: &[&str] = &["path",
3582                                    "too_large",
3583                                    "too_many_files",
3584                                    "other"];
3585        deserializer.deserialize_struct("DownloadZipError", VARIANTS, EnumVisitor)
3586    }
3587}
3588
3589impl ::serde::ser::Serialize for DownloadZipError {
3590    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3591        // union serializer
3592        use serde::ser::SerializeStruct;
3593        match self {
3594            DownloadZipError::Path(x) => {
3595                // union or polymporphic struct
3596                let mut s = serializer.serialize_struct("DownloadZipError", 2)?;
3597                s.serialize_field(".tag", "path")?;
3598                s.serialize_field("path", x)?;
3599                s.end()
3600            }
3601            DownloadZipError::TooLarge => {
3602                // unit
3603                let mut s = serializer.serialize_struct("DownloadZipError", 1)?;
3604                s.serialize_field(".tag", "too_large")?;
3605                s.end()
3606            }
3607            DownloadZipError::TooManyFiles => {
3608                // unit
3609                let mut s = serializer.serialize_struct("DownloadZipError", 1)?;
3610                s.serialize_field(".tag", "too_many_files")?;
3611                s.end()
3612            }
3613            DownloadZipError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3614        }
3615    }
3616}
3617
3618impl ::std::error::Error for DownloadZipError {
3619    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
3620        match self {
3621            DownloadZipError::Path(inner) => Some(inner),
3622            _ => None,
3623        }
3624    }
3625}
3626
3627impl ::std::fmt::Display for DownloadZipError {
3628    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3629        match self {
3630            DownloadZipError::Path(inner) => write!(f, "DownloadZipError: {}", inner),
3631            DownloadZipError::TooLarge => f.write_str("The folder or a file is too large to download."),
3632            DownloadZipError::TooManyFiles => f.write_str("The folder has too many files to download."),
3633            _ => write!(f, "{:?}", *self),
3634        }
3635    }
3636}
3637
3638#[derive(Debug, Clone, PartialEq, Eq)]
3639#[non_exhaustive] // structs may have more fields added in the future.
3640pub struct DownloadZipResult {
3641    pub metadata: FolderMetadata,
3642}
3643
3644impl DownloadZipResult {
3645    pub fn new(metadata: FolderMetadata) -> Self {
3646        DownloadZipResult {
3647            metadata,
3648        }
3649    }
3650}
3651
3652const DOWNLOAD_ZIP_RESULT_FIELDS: &[&str] = &["metadata"];
3653impl DownloadZipResult {
3654    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3655        map: V,
3656    ) -> Result<DownloadZipResult, V::Error> {
3657        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3658    }
3659
3660    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3661        mut map: V,
3662        optional: bool,
3663    ) -> Result<Option<DownloadZipResult>, V::Error> {
3664        let mut field_metadata = None;
3665        let mut nothing = true;
3666        while let Some(key) = map.next_key::<&str>()? {
3667            nothing = false;
3668            match key {
3669                "metadata" => {
3670                    if field_metadata.is_some() {
3671                        return Err(::serde::de::Error::duplicate_field("metadata"));
3672                    }
3673                    field_metadata = Some(map.next_value()?);
3674                }
3675                _ => {
3676                    // unknown field allowed and ignored
3677                    map.next_value::<::serde_json::Value>()?;
3678                }
3679            }
3680        }
3681        if optional && nothing {
3682            return Ok(None);
3683        }
3684        let result = DownloadZipResult {
3685            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
3686        };
3687        Ok(Some(result))
3688    }
3689
3690    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3691        &self,
3692        s: &mut S::SerializeStruct,
3693    ) -> Result<(), S::Error> {
3694        use serde::ser::SerializeStruct;
3695        s.serialize_field("metadata", &self.metadata)?;
3696        Ok(())
3697    }
3698}
3699
3700impl<'de> ::serde::de::Deserialize<'de> for DownloadZipResult {
3701    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3702        // struct deserializer
3703        use serde::de::{MapAccess, Visitor};
3704        struct StructVisitor;
3705        impl<'de> Visitor<'de> for StructVisitor {
3706            type Value = DownloadZipResult;
3707            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3708                f.write_str("a DownloadZipResult struct")
3709            }
3710            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3711                DownloadZipResult::internal_deserialize(map)
3712            }
3713        }
3714        deserializer.deserialize_struct("DownloadZipResult", DOWNLOAD_ZIP_RESULT_FIELDS, StructVisitor)
3715    }
3716}
3717
3718impl ::serde::ser::Serialize for DownloadZipResult {
3719    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3720        // struct serializer
3721        use serde::ser::SerializeStruct;
3722        let mut s = serializer.serialize_struct("DownloadZipResult", 1)?;
3723        self.internal_serialize::<S>(&mut s)?;
3724        s.end()
3725    }
3726}
3727
3728#[derive(Debug, Clone, PartialEq, Eq)]
3729#[non_exhaustive] // structs may have more fields added in the future.
3730pub struct ExportArg {
3731    /// The path of the file to be exported.
3732    pub path: ReadPath,
3733    /// The file format to which the file should be exported. This must be one of the formats listed
3734    /// in the file's export_options returned by [`get_metadata()`](crate::files::get_metadata). If
3735    /// none is specified, the default format (specified in export_as in file metadata) will be
3736    /// used.
3737    pub export_format: Option<String>,
3738}
3739
3740impl ExportArg {
3741    pub fn new(path: ReadPath) -> Self {
3742        ExportArg {
3743            path,
3744            export_format: None,
3745        }
3746    }
3747
3748    pub fn with_export_format(mut self, value: String) -> Self {
3749        self.export_format = Some(value);
3750        self
3751    }
3752}
3753
3754const EXPORT_ARG_FIELDS: &[&str] = &["path",
3755                                     "export_format"];
3756impl ExportArg {
3757    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3758        map: V,
3759    ) -> Result<ExportArg, V::Error> {
3760        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3761    }
3762
3763    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3764        mut map: V,
3765        optional: bool,
3766    ) -> Result<Option<ExportArg>, V::Error> {
3767        let mut field_path = None;
3768        let mut field_export_format = None;
3769        let mut nothing = true;
3770        while let Some(key) = map.next_key::<&str>()? {
3771            nothing = false;
3772            match key {
3773                "path" => {
3774                    if field_path.is_some() {
3775                        return Err(::serde::de::Error::duplicate_field("path"));
3776                    }
3777                    field_path = Some(map.next_value()?);
3778                }
3779                "export_format" => {
3780                    if field_export_format.is_some() {
3781                        return Err(::serde::de::Error::duplicate_field("export_format"));
3782                    }
3783                    field_export_format = Some(map.next_value()?);
3784                }
3785                _ => {
3786                    // unknown field allowed and ignored
3787                    map.next_value::<::serde_json::Value>()?;
3788                }
3789            }
3790        }
3791        if optional && nothing {
3792            return Ok(None);
3793        }
3794        let result = ExportArg {
3795            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
3796            export_format: field_export_format.and_then(Option::flatten),
3797        };
3798        Ok(Some(result))
3799    }
3800
3801    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3802        &self,
3803        s: &mut S::SerializeStruct,
3804    ) -> Result<(), S::Error> {
3805        use serde::ser::SerializeStruct;
3806        s.serialize_field("path", &self.path)?;
3807        if let Some(val) = &self.export_format {
3808            s.serialize_field("export_format", val)?;
3809        }
3810        Ok(())
3811    }
3812}
3813
3814impl<'de> ::serde::de::Deserialize<'de> for ExportArg {
3815    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3816        // struct deserializer
3817        use serde::de::{MapAccess, Visitor};
3818        struct StructVisitor;
3819        impl<'de> Visitor<'de> for StructVisitor {
3820            type Value = ExportArg;
3821            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3822                f.write_str("a ExportArg struct")
3823            }
3824            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3825                ExportArg::internal_deserialize(map)
3826            }
3827        }
3828        deserializer.deserialize_struct("ExportArg", EXPORT_ARG_FIELDS, StructVisitor)
3829    }
3830}
3831
3832impl ::serde::ser::Serialize for ExportArg {
3833    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3834        // struct serializer
3835        use serde::ser::SerializeStruct;
3836        let mut s = serializer.serialize_struct("ExportArg", 2)?;
3837        self.internal_serialize::<S>(&mut s)?;
3838        s.end()
3839    }
3840}
3841
3842#[derive(Debug, Clone, PartialEq, Eq)]
3843#[non_exhaustive] // variants may be added in the future
3844pub enum ExportError {
3845    Path(LookupError),
3846    /// This file type cannot be exported. Use [`download()`](crate::files::download) instead.
3847    NonExportable,
3848    /// The specified export format is not a valid option for this file type.
3849    InvalidExportFormat,
3850    /// The exportable content is not yet available. Please retry later.
3851    RetryError,
3852    /// Catch-all used for unrecognized values returned from the server. Encountering this value
3853    /// typically indicates that this SDK version is out of date.
3854    Other,
3855}
3856
3857impl<'de> ::serde::de::Deserialize<'de> for ExportError {
3858    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3859        // union deserializer
3860        use serde::de::{self, MapAccess, Visitor};
3861        struct EnumVisitor;
3862        impl<'de> Visitor<'de> for EnumVisitor {
3863            type Value = ExportError;
3864            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3865                f.write_str("a ExportError structure")
3866            }
3867            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3868                let tag: &str = match map.next_key()? {
3869                    Some(".tag") => map.next_value()?,
3870                    _ => return Err(de::Error::missing_field(".tag"))
3871                };
3872                let value = match tag {
3873                    "path" => {
3874                        match map.next_key()? {
3875                            Some("path") => ExportError::Path(map.next_value()?),
3876                            None => return Err(de::Error::missing_field("path")),
3877                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3878                        }
3879                    }
3880                    "non_exportable" => ExportError::NonExportable,
3881                    "invalid_export_format" => ExportError::InvalidExportFormat,
3882                    "retry_error" => ExportError::RetryError,
3883                    _ => ExportError::Other,
3884                };
3885                crate::eat_json_fields(&mut map)?;
3886                Ok(value)
3887            }
3888        }
3889        const VARIANTS: &[&str] = &["path",
3890                                    "non_exportable",
3891                                    "invalid_export_format",
3892                                    "retry_error",
3893                                    "other"];
3894        deserializer.deserialize_struct("ExportError", VARIANTS, EnumVisitor)
3895    }
3896}
3897
3898impl ::serde::ser::Serialize for ExportError {
3899    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3900        // union serializer
3901        use serde::ser::SerializeStruct;
3902        match self {
3903            ExportError::Path(x) => {
3904                // union or polymporphic struct
3905                let mut s = serializer.serialize_struct("ExportError", 2)?;
3906                s.serialize_field(".tag", "path")?;
3907                s.serialize_field("path", x)?;
3908                s.end()
3909            }
3910            ExportError::NonExportable => {
3911                // unit
3912                let mut s = serializer.serialize_struct("ExportError", 1)?;
3913                s.serialize_field(".tag", "non_exportable")?;
3914                s.end()
3915            }
3916            ExportError::InvalidExportFormat => {
3917                // unit
3918                let mut s = serializer.serialize_struct("ExportError", 1)?;
3919                s.serialize_field(".tag", "invalid_export_format")?;
3920                s.end()
3921            }
3922            ExportError::RetryError => {
3923                // unit
3924                let mut s = serializer.serialize_struct("ExportError", 1)?;
3925                s.serialize_field(".tag", "retry_error")?;
3926                s.end()
3927            }
3928            ExportError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3929        }
3930    }
3931}
3932
3933impl ::std::error::Error for ExportError {
3934    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
3935        match self {
3936            ExportError::Path(inner) => Some(inner),
3937            _ => None,
3938        }
3939    }
3940}
3941
3942impl ::std::fmt::Display for ExportError {
3943    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3944        match self {
3945            ExportError::Path(inner) => write!(f, "ExportError: {}", inner),
3946            ExportError::InvalidExportFormat => f.write_str("The specified export format is not a valid option for this file type."),
3947            ExportError::RetryError => f.write_str("The exportable content is not yet available. Please retry later."),
3948            _ => write!(f, "{:?}", *self),
3949        }
3950    }
3951}
3952
3953/// Export information for a file.
3954#[derive(Debug, Clone, PartialEq, Eq, Default)]
3955#[non_exhaustive] // structs may have more fields added in the future.
3956pub struct ExportInfo {
3957    /// Format to which the file can be exported to.
3958    pub export_as: Option<String>,
3959    /// Additional formats to which the file can be exported. These values can be specified as the
3960    /// export_format in /files/export.
3961    pub export_options: Option<Vec<String>>,
3962}
3963
3964impl ExportInfo {
3965    pub fn with_export_as(mut self, value: String) -> Self {
3966        self.export_as = Some(value);
3967        self
3968    }
3969
3970    pub fn with_export_options(mut self, value: Vec<String>) -> Self {
3971        self.export_options = Some(value);
3972        self
3973    }
3974}
3975
3976const EXPORT_INFO_FIELDS: &[&str] = &["export_as",
3977                                      "export_options"];
3978impl ExportInfo {
3979    // no _opt deserializer
3980    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3981        mut map: V,
3982    ) -> Result<ExportInfo, V::Error> {
3983        let mut field_export_as = None;
3984        let mut field_export_options = None;
3985        while let Some(key) = map.next_key::<&str>()? {
3986            match key {
3987                "export_as" => {
3988                    if field_export_as.is_some() {
3989                        return Err(::serde::de::Error::duplicate_field("export_as"));
3990                    }
3991                    field_export_as = Some(map.next_value()?);
3992                }
3993                "export_options" => {
3994                    if field_export_options.is_some() {
3995                        return Err(::serde::de::Error::duplicate_field("export_options"));
3996                    }
3997                    field_export_options = Some(map.next_value()?);
3998                }
3999                _ => {
4000                    // unknown field allowed and ignored
4001                    map.next_value::<::serde_json::Value>()?;
4002                }
4003            }
4004        }
4005        let result = ExportInfo {
4006            export_as: field_export_as.and_then(Option::flatten),
4007            export_options: field_export_options.and_then(Option::flatten),
4008        };
4009        Ok(result)
4010    }
4011
4012    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4013        &self,
4014        s: &mut S::SerializeStruct,
4015    ) -> Result<(), S::Error> {
4016        use serde::ser::SerializeStruct;
4017        if let Some(val) = &self.export_as {
4018            s.serialize_field("export_as", val)?;
4019        }
4020        if let Some(val) = &self.export_options {
4021            s.serialize_field("export_options", val)?;
4022        }
4023        Ok(())
4024    }
4025}
4026
4027impl<'de> ::serde::de::Deserialize<'de> for ExportInfo {
4028    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4029        // struct deserializer
4030        use serde::de::{MapAccess, Visitor};
4031        struct StructVisitor;
4032        impl<'de> Visitor<'de> for StructVisitor {
4033            type Value = ExportInfo;
4034            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4035                f.write_str("a ExportInfo struct")
4036            }
4037            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4038                ExportInfo::internal_deserialize(map)
4039            }
4040        }
4041        deserializer.deserialize_struct("ExportInfo", EXPORT_INFO_FIELDS, StructVisitor)
4042    }
4043}
4044
4045impl ::serde::ser::Serialize for ExportInfo {
4046    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4047        // struct serializer
4048        use serde::ser::SerializeStruct;
4049        let mut s = serializer.serialize_struct("ExportInfo", 2)?;
4050        self.internal_serialize::<S>(&mut s)?;
4051        s.end()
4052    }
4053}
4054
4055#[derive(Debug, Clone, PartialEq, Eq)]
4056#[non_exhaustive] // structs may have more fields added in the future.
4057pub struct ExportMetadata {
4058    /// The last component of the path (including extension). This never contains a slash.
4059    pub name: String,
4060    /// The file size in bytes.
4061    pub size: u64,
4062    /// A hash based on the exported file content. This field can be used to verify data integrity.
4063    /// Similar to content hash. For more information see our [Content
4064    /// hash](https://www.dropbox.com/developers/reference/content-hash) page.
4065    pub export_hash: Option<Sha256HexHash>,
4066    /// If the file is a Paper doc, this gives the latest doc revision which can be used in
4067    /// [`paper_update()`](crate::files::paper_update).
4068    pub paper_revision: Option<i64>,
4069}
4070
4071impl ExportMetadata {
4072    pub fn new(name: String, size: u64) -> Self {
4073        ExportMetadata {
4074            name,
4075            size,
4076            export_hash: None,
4077            paper_revision: None,
4078        }
4079    }
4080
4081    pub fn with_export_hash(mut self, value: Sha256HexHash) -> Self {
4082        self.export_hash = Some(value);
4083        self
4084    }
4085
4086    pub fn with_paper_revision(mut self, value: i64) -> Self {
4087        self.paper_revision = Some(value);
4088        self
4089    }
4090}
4091
4092const EXPORT_METADATA_FIELDS: &[&str] = &["name",
4093                                          "size",
4094                                          "export_hash",
4095                                          "paper_revision"];
4096impl ExportMetadata {
4097    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4098        map: V,
4099    ) -> Result<ExportMetadata, V::Error> {
4100        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4101    }
4102
4103    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4104        mut map: V,
4105        optional: bool,
4106    ) -> Result<Option<ExportMetadata>, V::Error> {
4107        let mut field_name = None;
4108        let mut field_size = None;
4109        let mut field_export_hash = None;
4110        let mut field_paper_revision = None;
4111        let mut nothing = true;
4112        while let Some(key) = map.next_key::<&str>()? {
4113            nothing = false;
4114            match key {
4115                "name" => {
4116                    if field_name.is_some() {
4117                        return Err(::serde::de::Error::duplicate_field("name"));
4118                    }
4119                    field_name = Some(map.next_value()?);
4120                }
4121                "size" => {
4122                    if field_size.is_some() {
4123                        return Err(::serde::de::Error::duplicate_field("size"));
4124                    }
4125                    field_size = Some(map.next_value()?);
4126                }
4127                "export_hash" => {
4128                    if field_export_hash.is_some() {
4129                        return Err(::serde::de::Error::duplicate_field("export_hash"));
4130                    }
4131                    field_export_hash = Some(map.next_value()?);
4132                }
4133                "paper_revision" => {
4134                    if field_paper_revision.is_some() {
4135                        return Err(::serde::de::Error::duplicate_field("paper_revision"));
4136                    }
4137                    field_paper_revision = Some(map.next_value()?);
4138                }
4139                _ => {
4140                    // unknown field allowed and ignored
4141                    map.next_value::<::serde_json::Value>()?;
4142                }
4143            }
4144        }
4145        if optional && nothing {
4146            return Ok(None);
4147        }
4148        let result = ExportMetadata {
4149            name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
4150            size: field_size.ok_or_else(|| ::serde::de::Error::missing_field("size"))?,
4151            export_hash: field_export_hash.and_then(Option::flatten),
4152            paper_revision: field_paper_revision.and_then(Option::flatten),
4153        };
4154        Ok(Some(result))
4155    }
4156
4157    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4158        &self,
4159        s: &mut S::SerializeStruct,
4160    ) -> Result<(), S::Error> {
4161        use serde::ser::SerializeStruct;
4162        s.serialize_field("name", &self.name)?;
4163        s.serialize_field("size", &self.size)?;
4164        if let Some(val) = &self.export_hash {
4165            s.serialize_field("export_hash", val)?;
4166        }
4167        if let Some(val) = &self.paper_revision {
4168            s.serialize_field("paper_revision", val)?;
4169        }
4170        Ok(())
4171    }
4172}
4173
4174impl<'de> ::serde::de::Deserialize<'de> for ExportMetadata {
4175    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4176        // struct deserializer
4177        use serde::de::{MapAccess, Visitor};
4178        struct StructVisitor;
4179        impl<'de> Visitor<'de> for StructVisitor {
4180            type Value = ExportMetadata;
4181            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4182                f.write_str("a ExportMetadata struct")
4183            }
4184            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4185                ExportMetadata::internal_deserialize(map)
4186            }
4187        }
4188        deserializer.deserialize_struct("ExportMetadata", EXPORT_METADATA_FIELDS, StructVisitor)
4189    }
4190}
4191
4192impl ::serde::ser::Serialize for ExportMetadata {
4193    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4194        // struct serializer
4195        use serde::ser::SerializeStruct;
4196        let mut s = serializer.serialize_struct("ExportMetadata", 4)?;
4197        self.internal_serialize::<S>(&mut s)?;
4198        s.end()
4199    }
4200}
4201
4202#[derive(Debug, Clone, PartialEq)]
4203#[non_exhaustive] // structs may have more fields added in the future.
4204pub struct ExportResult {
4205    /// Metadata for the exported version of the file.
4206    pub export_metadata: ExportMetadata,
4207    /// Metadata for the original file.
4208    pub file_metadata: FileMetadata,
4209}
4210
4211impl ExportResult {
4212    pub fn new(export_metadata: ExportMetadata, file_metadata: FileMetadata) -> Self {
4213        ExportResult {
4214            export_metadata,
4215            file_metadata,
4216        }
4217    }
4218}
4219
4220const EXPORT_RESULT_FIELDS: &[&str] = &["export_metadata",
4221                                        "file_metadata"];
4222impl ExportResult {
4223    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4224        map: V,
4225    ) -> Result<ExportResult, V::Error> {
4226        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4227    }
4228
4229    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4230        mut map: V,
4231        optional: bool,
4232    ) -> Result<Option<ExportResult>, V::Error> {
4233        let mut field_export_metadata = None;
4234        let mut field_file_metadata = None;
4235        let mut nothing = true;
4236        while let Some(key) = map.next_key::<&str>()? {
4237            nothing = false;
4238            match key {
4239                "export_metadata" => {
4240                    if field_export_metadata.is_some() {
4241                        return Err(::serde::de::Error::duplicate_field("export_metadata"));
4242                    }
4243                    field_export_metadata = Some(map.next_value()?);
4244                }
4245                "file_metadata" => {
4246                    if field_file_metadata.is_some() {
4247                        return Err(::serde::de::Error::duplicate_field("file_metadata"));
4248                    }
4249                    field_file_metadata = Some(map.next_value()?);
4250                }
4251                _ => {
4252                    // unknown field allowed and ignored
4253                    map.next_value::<::serde_json::Value>()?;
4254                }
4255            }
4256        }
4257        if optional && nothing {
4258            return Ok(None);
4259        }
4260        let result = ExportResult {
4261            export_metadata: field_export_metadata.ok_or_else(|| ::serde::de::Error::missing_field("export_metadata"))?,
4262            file_metadata: field_file_metadata.ok_or_else(|| ::serde::de::Error::missing_field("file_metadata"))?,
4263        };
4264        Ok(Some(result))
4265    }
4266
4267    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4268        &self,
4269        s: &mut S::SerializeStruct,
4270    ) -> Result<(), S::Error> {
4271        use serde::ser::SerializeStruct;
4272        s.serialize_field("export_metadata", &self.export_metadata)?;
4273        s.serialize_field("file_metadata", &self.file_metadata)?;
4274        Ok(())
4275    }
4276}
4277
4278impl<'de> ::serde::de::Deserialize<'de> for ExportResult {
4279    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4280        // struct deserializer
4281        use serde::de::{MapAccess, Visitor};
4282        struct StructVisitor;
4283        impl<'de> Visitor<'de> for StructVisitor {
4284            type Value = ExportResult;
4285            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4286                f.write_str("a ExportResult struct")
4287            }
4288            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4289                ExportResult::internal_deserialize(map)
4290            }
4291        }
4292        deserializer.deserialize_struct("ExportResult", EXPORT_RESULT_FIELDS, StructVisitor)
4293    }
4294}
4295
4296impl ::serde::ser::Serialize for ExportResult {
4297    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4298        // struct serializer
4299        use serde::ser::SerializeStruct;
4300        let mut s = serializer.serialize_struct("ExportResult", 2)?;
4301        self.internal_serialize::<S>(&mut s)?;
4302        s.end()
4303    }
4304}
4305
4306#[derive(Debug, Clone, PartialEq, Eq)]
4307#[non_exhaustive] // variants may be added in the future
4308pub enum FileCategory {
4309    /// jpg, png, gif, and more.
4310    Image,
4311    /// doc, docx, txt, and more.
4312    Document,
4313    /// pdf.
4314    Pdf,
4315    /// xlsx, xls, csv, and more.
4316    Spreadsheet,
4317    /// ppt, pptx, key, and more.
4318    Presentation,
4319    /// mp3, wav, mid, and more.
4320    Audio,
4321    /// mov, wmv, mp4, and more.
4322    Video,
4323    /// dropbox folder.
4324    Folder,
4325    /// dropbox paper doc.
4326    Paper,
4327    /// any file not in one of the categories above.
4328    Others,
4329    /// Catch-all used for unrecognized values returned from the server. Encountering this value
4330    /// typically indicates that this SDK version is out of date.
4331    Other,
4332}
4333
4334impl<'de> ::serde::de::Deserialize<'de> for FileCategory {
4335    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4336        // union deserializer
4337        use serde::de::{self, MapAccess, Visitor};
4338        struct EnumVisitor;
4339        impl<'de> Visitor<'de> for EnumVisitor {
4340            type Value = FileCategory;
4341            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4342                f.write_str("a FileCategory structure")
4343            }
4344            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
4345                let tag: &str = match map.next_key()? {
4346                    Some(".tag") => map.next_value()?,
4347                    _ => return Err(de::Error::missing_field(".tag"))
4348                };
4349                let value = match tag {
4350                    "image" => FileCategory::Image,
4351                    "document" => FileCategory::Document,
4352                    "pdf" => FileCategory::Pdf,
4353                    "spreadsheet" => FileCategory::Spreadsheet,
4354                    "presentation" => FileCategory::Presentation,
4355                    "audio" => FileCategory::Audio,
4356                    "video" => FileCategory::Video,
4357                    "folder" => FileCategory::Folder,
4358                    "paper" => FileCategory::Paper,
4359                    "others" => FileCategory::Others,
4360                    _ => FileCategory::Other,
4361                };
4362                crate::eat_json_fields(&mut map)?;
4363                Ok(value)
4364            }
4365        }
4366        const VARIANTS: &[&str] = &["image",
4367                                    "document",
4368                                    "pdf",
4369                                    "spreadsheet",
4370                                    "presentation",
4371                                    "audio",
4372                                    "video",
4373                                    "folder",
4374                                    "paper",
4375                                    "others",
4376                                    "other"];
4377        deserializer.deserialize_struct("FileCategory", VARIANTS, EnumVisitor)
4378    }
4379}
4380
4381impl ::serde::ser::Serialize for FileCategory {
4382    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4383        // union serializer
4384        use serde::ser::SerializeStruct;
4385        match self {
4386            FileCategory::Image => {
4387                // unit
4388                let mut s = serializer.serialize_struct("FileCategory", 1)?;
4389                s.serialize_field(".tag", "image")?;
4390                s.end()
4391            }
4392            FileCategory::Document => {
4393                // unit
4394                let mut s = serializer.serialize_struct("FileCategory", 1)?;
4395                s.serialize_field(".tag", "document")?;
4396                s.end()
4397            }
4398            FileCategory::Pdf => {
4399                // unit
4400                let mut s = serializer.serialize_struct("FileCategory", 1)?;
4401                s.serialize_field(".tag", "pdf")?;
4402                s.end()
4403            }
4404            FileCategory::Spreadsheet => {
4405                // unit
4406                let mut s = serializer.serialize_struct("FileCategory", 1)?;
4407                s.serialize_field(".tag", "spreadsheet")?;
4408                s.end()
4409            }
4410            FileCategory::Presentation => {
4411                // unit
4412                let mut s = serializer.serialize_struct("FileCategory", 1)?;
4413                s.serialize_field(".tag", "presentation")?;
4414                s.end()
4415            }
4416            FileCategory::Audio => {
4417                // unit
4418                let mut s = serializer.serialize_struct("FileCategory", 1)?;
4419                s.serialize_field(".tag", "audio")?;
4420                s.end()
4421            }
4422            FileCategory::Video => {
4423                // unit
4424                let mut s = serializer.serialize_struct("FileCategory", 1)?;
4425                s.serialize_field(".tag", "video")?;
4426                s.end()
4427            }
4428            FileCategory::Folder => {
4429                // unit
4430                let mut s = serializer.serialize_struct("FileCategory", 1)?;
4431                s.serialize_field(".tag", "folder")?;
4432                s.end()
4433            }
4434            FileCategory::Paper => {
4435                // unit
4436                let mut s = serializer.serialize_struct("FileCategory", 1)?;
4437                s.serialize_field(".tag", "paper")?;
4438                s.end()
4439            }
4440            FileCategory::Others => {
4441                // unit
4442                let mut s = serializer.serialize_struct("FileCategory", 1)?;
4443                s.serialize_field(".tag", "others")?;
4444                s.end()
4445            }
4446            FileCategory::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
4447        }
4448    }
4449}
4450
4451#[derive(Debug, Clone, PartialEq, Eq)]
4452#[non_exhaustive] // structs may have more fields added in the future.
4453pub struct FileLock {
4454    /// The lock description.
4455    pub content: FileLockContent,
4456}
4457
4458impl FileLock {
4459    pub fn new(content: FileLockContent) -> Self {
4460        FileLock {
4461            content,
4462        }
4463    }
4464}
4465
4466const FILE_LOCK_FIELDS: &[&str] = &["content"];
4467impl FileLock {
4468    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4469        map: V,
4470    ) -> Result<FileLock, V::Error> {
4471        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4472    }
4473
4474    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4475        mut map: V,
4476        optional: bool,
4477    ) -> Result<Option<FileLock>, V::Error> {
4478        let mut field_content = None;
4479        let mut nothing = true;
4480        while let Some(key) = map.next_key::<&str>()? {
4481            nothing = false;
4482            match key {
4483                "content" => {
4484                    if field_content.is_some() {
4485                        return Err(::serde::de::Error::duplicate_field("content"));
4486                    }
4487                    field_content = Some(map.next_value()?);
4488                }
4489                _ => {
4490                    // unknown field allowed and ignored
4491                    map.next_value::<::serde_json::Value>()?;
4492                }
4493            }
4494        }
4495        if optional && nothing {
4496            return Ok(None);
4497        }
4498        let result = FileLock {
4499            content: field_content.ok_or_else(|| ::serde::de::Error::missing_field("content"))?,
4500        };
4501        Ok(Some(result))
4502    }
4503
4504    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4505        &self,
4506        s: &mut S::SerializeStruct,
4507    ) -> Result<(), S::Error> {
4508        use serde::ser::SerializeStruct;
4509        s.serialize_field("content", &self.content)?;
4510        Ok(())
4511    }
4512}
4513
4514impl<'de> ::serde::de::Deserialize<'de> for FileLock {
4515    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4516        // struct deserializer
4517        use serde::de::{MapAccess, Visitor};
4518        struct StructVisitor;
4519        impl<'de> Visitor<'de> for StructVisitor {
4520            type Value = FileLock;
4521            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4522                f.write_str("a FileLock struct")
4523            }
4524            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4525                FileLock::internal_deserialize(map)
4526            }
4527        }
4528        deserializer.deserialize_struct("FileLock", FILE_LOCK_FIELDS, StructVisitor)
4529    }
4530}
4531
4532impl ::serde::ser::Serialize for FileLock {
4533    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4534        // struct serializer
4535        use serde::ser::SerializeStruct;
4536        let mut s = serializer.serialize_struct("FileLock", 1)?;
4537        self.internal_serialize::<S>(&mut s)?;
4538        s.end()
4539    }
4540}
4541
4542#[derive(Debug, Clone, PartialEq, Eq)]
4543#[non_exhaustive] // variants may be added in the future
4544pub enum FileLockContent {
4545    /// Empty type to indicate no lock.
4546    Unlocked,
4547    /// A lock held by a single user.
4548    SingleUser(SingleUserLock),
4549    /// Catch-all used for unrecognized values returned from the server. Encountering this value
4550    /// typically indicates that this SDK version is out of date.
4551    Other,
4552}
4553
4554impl<'de> ::serde::de::Deserialize<'de> for FileLockContent {
4555    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4556        // union deserializer
4557        use serde::de::{self, MapAccess, Visitor};
4558        struct EnumVisitor;
4559        impl<'de> Visitor<'de> for EnumVisitor {
4560            type Value = FileLockContent;
4561            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4562                f.write_str("a FileLockContent structure")
4563            }
4564            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
4565                let tag: &str = match map.next_key()? {
4566                    Some(".tag") => map.next_value()?,
4567                    _ => return Err(de::Error::missing_field(".tag"))
4568                };
4569                let value = match tag {
4570                    "unlocked" => FileLockContent::Unlocked,
4571                    "single_user" => FileLockContent::SingleUser(SingleUserLock::internal_deserialize(&mut map)?),
4572                    _ => FileLockContent::Other,
4573                };
4574                crate::eat_json_fields(&mut map)?;
4575                Ok(value)
4576            }
4577        }
4578        const VARIANTS: &[&str] = &["unlocked",
4579                                    "single_user",
4580                                    "other"];
4581        deserializer.deserialize_struct("FileLockContent", VARIANTS, EnumVisitor)
4582    }
4583}
4584
4585impl ::serde::ser::Serialize for FileLockContent {
4586    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4587        // union serializer
4588        use serde::ser::SerializeStruct;
4589        match self {
4590            FileLockContent::Unlocked => {
4591                // unit
4592                let mut s = serializer.serialize_struct("FileLockContent", 1)?;
4593                s.serialize_field(".tag", "unlocked")?;
4594                s.end()
4595            }
4596            FileLockContent::SingleUser(x) => {
4597                // struct
4598                let mut s = serializer.serialize_struct("FileLockContent", 4)?;
4599                s.serialize_field(".tag", "single_user")?;
4600                x.internal_serialize::<S>(&mut s)?;
4601                s.end()
4602            }
4603            FileLockContent::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
4604        }
4605    }
4606}
4607
4608#[derive(Debug, Clone, PartialEq, Eq, Default)]
4609#[non_exhaustive] // structs may have more fields added in the future.
4610pub struct FileLockMetadata {
4611    /// True if caller holds the file lock.
4612    pub is_lockholder: Option<bool>,
4613    /// The display name of the lock holder.
4614    pub lockholder_name: Option<String>,
4615    /// The account ID of the lock holder if known.
4616    pub lockholder_account_id: Option<crate::types::users_common::AccountId>,
4617    /// The timestamp of the lock was created.
4618    pub created: Option<crate::types::common::DropboxTimestamp>,
4619}
4620
4621impl FileLockMetadata {
4622    pub fn with_is_lockholder(mut self, value: bool) -> Self {
4623        self.is_lockholder = Some(value);
4624        self
4625    }
4626
4627    pub fn with_lockholder_name(mut self, value: String) -> Self {
4628        self.lockholder_name = Some(value);
4629        self
4630    }
4631
4632    pub fn with_lockholder_account_id(
4633        mut self,
4634        value: crate::types::users_common::AccountId,
4635    ) -> Self {
4636        self.lockholder_account_id = Some(value);
4637        self
4638    }
4639
4640    pub fn with_created(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
4641        self.created = Some(value);
4642        self
4643    }
4644}
4645
4646const FILE_LOCK_METADATA_FIELDS: &[&str] = &["is_lockholder",
4647                                             "lockholder_name",
4648                                             "lockholder_account_id",
4649                                             "created"];
4650impl FileLockMetadata {
4651    // no _opt deserializer
4652    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4653        mut map: V,
4654    ) -> Result<FileLockMetadata, V::Error> {
4655        let mut field_is_lockholder = None;
4656        let mut field_lockholder_name = None;
4657        let mut field_lockholder_account_id = None;
4658        let mut field_created = None;
4659        while let Some(key) = map.next_key::<&str>()? {
4660            match key {
4661                "is_lockholder" => {
4662                    if field_is_lockholder.is_some() {
4663                        return Err(::serde::de::Error::duplicate_field("is_lockholder"));
4664                    }
4665                    field_is_lockholder = Some(map.next_value()?);
4666                }
4667                "lockholder_name" => {
4668                    if field_lockholder_name.is_some() {
4669                        return Err(::serde::de::Error::duplicate_field("lockholder_name"));
4670                    }
4671                    field_lockholder_name = Some(map.next_value()?);
4672                }
4673                "lockholder_account_id" => {
4674                    if field_lockholder_account_id.is_some() {
4675                        return Err(::serde::de::Error::duplicate_field("lockholder_account_id"));
4676                    }
4677                    field_lockholder_account_id = Some(map.next_value()?);
4678                }
4679                "created" => {
4680                    if field_created.is_some() {
4681                        return Err(::serde::de::Error::duplicate_field("created"));
4682                    }
4683                    field_created = Some(map.next_value()?);
4684                }
4685                _ => {
4686                    // unknown field allowed and ignored
4687                    map.next_value::<::serde_json::Value>()?;
4688                }
4689            }
4690        }
4691        let result = FileLockMetadata {
4692            is_lockholder: field_is_lockholder.and_then(Option::flatten),
4693            lockholder_name: field_lockholder_name.and_then(Option::flatten),
4694            lockholder_account_id: field_lockholder_account_id.and_then(Option::flatten),
4695            created: field_created.and_then(Option::flatten),
4696        };
4697        Ok(result)
4698    }
4699
4700    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4701        &self,
4702        s: &mut S::SerializeStruct,
4703    ) -> Result<(), S::Error> {
4704        use serde::ser::SerializeStruct;
4705        if let Some(val) = &self.is_lockholder {
4706            s.serialize_field("is_lockholder", val)?;
4707        }
4708        if let Some(val) = &self.lockholder_name {
4709            s.serialize_field("lockholder_name", val)?;
4710        }
4711        if let Some(val) = &self.lockholder_account_id {
4712            s.serialize_field("lockholder_account_id", val)?;
4713        }
4714        if let Some(val) = &self.created {
4715            s.serialize_field("created", val)?;
4716        }
4717        Ok(())
4718    }
4719}
4720
4721impl<'de> ::serde::de::Deserialize<'de> for FileLockMetadata {
4722    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4723        // struct deserializer
4724        use serde::de::{MapAccess, Visitor};
4725        struct StructVisitor;
4726        impl<'de> Visitor<'de> for StructVisitor {
4727            type Value = FileLockMetadata;
4728            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4729                f.write_str("a FileLockMetadata struct")
4730            }
4731            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4732                FileLockMetadata::internal_deserialize(map)
4733            }
4734        }
4735        deserializer.deserialize_struct("FileLockMetadata", FILE_LOCK_METADATA_FIELDS, StructVisitor)
4736    }
4737}
4738
4739impl ::serde::ser::Serialize for FileLockMetadata {
4740    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4741        // struct serializer
4742        use serde::ser::SerializeStruct;
4743        let mut s = serializer.serialize_struct("FileLockMetadata", 4)?;
4744        self.internal_serialize::<S>(&mut s)?;
4745        s.end()
4746    }
4747}
4748
4749#[derive(Debug, Clone, PartialEq)]
4750#[non_exhaustive] // structs may have more fields added in the future.
4751pub struct FileMetadata {
4752    /// The last component of the path (including extension). This never contains a slash.
4753    pub name: String,
4754    /// A unique identifier for the file.
4755    pub id: Id,
4756    /// For files, this is the modification time set by the desktop client when the file was added
4757    /// to Dropbox. Since this time is not verified (the Dropbox server stores whatever the desktop
4758    /// client sends up), this should only be used for display purposes (such as sorting) and not,
4759    /// for example, to determine if a file has changed or not.
4760    pub client_modified: crate::types::common::DropboxTimestamp,
4761    /// The last time the file was modified on Dropbox.
4762    pub server_modified: crate::types::common::DropboxTimestamp,
4763    /// A unique identifier for the current revision of a file. This field is the same rev as
4764    /// elsewhere in the API and can be used to detect changes and avoid conflicts.
4765    pub rev: Rev,
4766    /// The file size in bytes.
4767    pub size: u64,
4768    /// The lowercased full path in the user's Dropbox. This always starts with a slash. This field
4769    /// will be null if the file or folder is not mounted.
4770    pub path_lower: Option<String>,
4771    /// The cased path to be used for display purposes only. In rare instances the casing will not
4772    /// correctly match the user's filesystem, but this behavior will match the path provided in the
4773    /// Core API v1, and at least the last path component will have the correct casing. Changes to
4774    /// only the casing of paths won't be returned by
4775    /// [`list_folder_continue()`](crate::files::list_folder_continue). This field will be null if
4776    /// the file or folder is not mounted.
4777    pub path_display: Option<String>,
4778    /// Please use [`FileSharingInfo::parent_shared_folder_id`](FileSharingInfo) or
4779    /// [`FolderSharingInfo::parent_shared_folder_id`](FolderSharingInfo) instead.
4780    pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
4781    /// The preview URL of the file.
4782    pub preview_url: Option<String>,
4783    /// Additional information if the file is a photo or video. This field will not be set on
4784    /// entries returned by [`list_folder()`](crate::files::list_folder),
4785    /// [`list_folder_continue()`](crate::files::list_folder_continue), or
4786    /// [`get_thumbnail_batch()`](crate::files::get_thumbnail_batch), starting December 2, 2019.
4787    pub media_info: Option<MediaInfo>,
4788    /// Set if this file is a symlink.
4789    pub symlink_info: Option<SymlinkInfo>,
4790    /// Set if this file is contained in a shared folder.
4791    pub sharing_info: Option<FileSharingInfo>,
4792    /// If true, file can be downloaded directly; else the file must be exported.
4793    pub is_downloadable: bool,
4794    /// Information about format this file can be exported to. This filed must be set if
4795    /// `is_downloadable` is set to false.
4796    pub export_info: Option<ExportInfo>,
4797    /// Additional information if the file has custom properties with the property template
4798    /// specified.
4799    pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
4800    /// This flag will only be present if include_has_explicit_shared_members  is true in
4801    /// [`list_folder()`](crate::files::list_folder) or
4802    /// [`get_metadata()`](crate::files::get_metadata). If this  flag is present, it will be true if
4803    /// this file has any explicit shared  members. This is different from sharing_info in that this
4804    /// could be true  in the case where a file has explicit members but is not contained within  a
4805    /// shared folder.
4806    pub has_explicit_shared_members: Option<bool>,
4807    /// A hash of the file content. This field can be used to verify data integrity. For more
4808    /// information see our [Content
4809    /// hash](https://www.dropbox.com/developers/reference/content-hash) page.
4810    pub content_hash: Option<Sha256HexHash>,
4811    /// If present, the metadata associated with the file's current lock.
4812    pub file_lock_info: Option<FileLockMetadata>,
4813}
4814
4815impl FileMetadata {
4816    pub fn new(
4817        name: String,
4818        id: Id,
4819        client_modified: crate::types::common::DropboxTimestamp,
4820        server_modified: crate::types::common::DropboxTimestamp,
4821        rev: Rev,
4822        size: u64,
4823    ) -> Self {
4824        FileMetadata {
4825            name,
4826            id,
4827            client_modified,
4828            server_modified,
4829            rev,
4830            size,
4831            path_lower: None,
4832            path_display: None,
4833            parent_shared_folder_id: None,
4834            preview_url: None,
4835            media_info: None,
4836            symlink_info: None,
4837            sharing_info: None,
4838            is_downloadable: true,
4839            export_info: None,
4840            property_groups: None,
4841            has_explicit_shared_members: None,
4842            content_hash: None,
4843            file_lock_info: None,
4844        }
4845    }
4846
4847    pub fn with_path_lower(mut self, value: String) -> Self {
4848        self.path_lower = Some(value);
4849        self
4850    }
4851
4852    pub fn with_path_display(mut self, value: String) -> Self {
4853        self.path_display = Some(value);
4854        self
4855    }
4856
4857    pub fn with_parent_shared_folder_id(
4858        mut self,
4859        value: crate::types::common::SharedFolderId,
4860    ) -> Self {
4861        self.parent_shared_folder_id = Some(value);
4862        self
4863    }
4864
4865    pub fn with_preview_url(mut self, value: String) -> Self {
4866        self.preview_url = Some(value);
4867        self
4868    }
4869
4870    pub fn with_media_info(mut self, value: MediaInfo) -> Self {
4871        self.media_info = Some(value);
4872        self
4873    }
4874
4875    pub fn with_symlink_info(mut self, value: SymlinkInfo) -> Self {
4876        self.symlink_info = Some(value);
4877        self
4878    }
4879
4880    pub fn with_sharing_info(mut self, value: FileSharingInfo) -> Self {
4881        self.sharing_info = Some(value);
4882        self
4883    }
4884
4885    pub fn with_is_downloadable(mut self, value: bool) -> Self {
4886        self.is_downloadable = value;
4887        self
4888    }
4889
4890    pub fn with_export_info(mut self, value: ExportInfo) -> Self {
4891        self.export_info = Some(value);
4892        self
4893    }
4894
4895    pub fn with_property_groups(
4896        mut self,
4897        value: Vec<crate::types::file_properties::PropertyGroup>,
4898    ) -> Self {
4899        self.property_groups = Some(value);
4900        self
4901    }
4902
4903    pub fn with_has_explicit_shared_members(mut self, value: bool) -> Self {
4904        self.has_explicit_shared_members = Some(value);
4905        self
4906    }
4907
4908    pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
4909        self.content_hash = Some(value);
4910        self
4911    }
4912
4913    pub fn with_file_lock_info(mut self, value: FileLockMetadata) -> Self {
4914        self.file_lock_info = Some(value);
4915        self
4916    }
4917}
4918
4919const FILE_METADATA_FIELDS: &[&str] = &["name",
4920                                        "id",
4921                                        "client_modified",
4922                                        "server_modified",
4923                                        "rev",
4924                                        "size",
4925                                        "path_lower",
4926                                        "path_display",
4927                                        "parent_shared_folder_id",
4928                                        "preview_url",
4929                                        "media_info",
4930                                        "symlink_info",
4931                                        "sharing_info",
4932                                        "is_downloadable",
4933                                        "export_info",
4934                                        "property_groups",
4935                                        "has_explicit_shared_members",
4936                                        "content_hash",
4937                                        "file_lock_info"];
4938impl FileMetadata {
4939    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4940        map: V,
4941    ) -> Result<FileMetadata, V::Error> {
4942        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4943    }
4944
4945    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4946        mut map: V,
4947        optional: bool,
4948    ) -> Result<Option<FileMetadata>, V::Error> {
4949        let mut field_name = None;
4950        let mut field_id = None;
4951        let mut field_client_modified = None;
4952        let mut field_server_modified = None;
4953        let mut field_rev = None;
4954        let mut field_size = None;
4955        let mut field_path_lower = None;
4956        let mut field_path_display = None;
4957        let mut field_parent_shared_folder_id = None;
4958        let mut field_preview_url = None;
4959        let mut field_media_info = None;
4960        let mut field_symlink_info = None;
4961        let mut field_sharing_info = None;
4962        let mut field_is_downloadable = None;
4963        let mut field_export_info = None;
4964        let mut field_property_groups = None;
4965        let mut field_has_explicit_shared_members = None;
4966        let mut field_content_hash = None;
4967        let mut field_file_lock_info = None;
4968        let mut nothing = true;
4969        while let Some(key) = map.next_key::<&str>()? {
4970            nothing = false;
4971            match key {
4972                "name" => {
4973                    if field_name.is_some() {
4974                        return Err(::serde::de::Error::duplicate_field("name"));
4975                    }
4976                    field_name = Some(map.next_value()?);
4977                }
4978                "id" => {
4979                    if field_id.is_some() {
4980                        return Err(::serde::de::Error::duplicate_field("id"));
4981                    }
4982                    field_id = Some(map.next_value()?);
4983                }
4984                "client_modified" => {
4985                    if field_client_modified.is_some() {
4986                        return Err(::serde::de::Error::duplicate_field("client_modified"));
4987                    }
4988                    field_client_modified = Some(map.next_value()?);
4989                }
4990                "server_modified" => {
4991                    if field_server_modified.is_some() {
4992                        return Err(::serde::de::Error::duplicate_field("server_modified"));
4993                    }
4994                    field_server_modified = Some(map.next_value()?);
4995                }
4996                "rev" => {
4997                    if field_rev.is_some() {
4998                        return Err(::serde::de::Error::duplicate_field("rev"));
4999                    }
5000                    field_rev = Some(map.next_value()?);
5001                }
5002                "size" => {
5003                    if field_size.is_some() {
5004                        return Err(::serde::de::Error::duplicate_field("size"));
5005                    }
5006                    field_size = Some(map.next_value()?);
5007                }
5008                "path_lower" => {
5009                    if field_path_lower.is_some() {
5010                        return Err(::serde::de::Error::duplicate_field("path_lower"));
5011                    }
5012                    field_path_lower = Some(map.next_value()?);
5013                }
5014                "path_display" => {
5015                    if field_path_display.is_some() {
5016                        return Err(::serde::de::Error::duplicate_field("path_display"));
5017                    }
5018                    field_path_display = Some(map.next_value()?);
5019                }
5020                "parent_shared_folder_id" => {
5021                    if field_parent_shared_folder_id.is_some() {
5022                        return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5023                    }
5024                    field_parent_shared_folder_id = Some(map.next_value()?);
5025                }
5026                "preview_url" => {
5027                    if field_preview_url.is_some() {
5028                        return Err(::serde::de::Error::duplicate_field("preview_url"));
5029                    }
5030                    field_preview_url = Some(map.next_value()?);
5031                }
5032                "media_info" => {
5033                    if field_media_info.is_some() {
5034                        return Err(::serde::de::Error::duplicate_field("media_info"));
5035                    }
5036                    field_media_info = Some(map.next_value()?);
5037                }
5038                "symlink_info" => {
5039                    if field_symlink_info.is_some() {
5040                        return Err(::serde::de::Error::duplicate_field("symlink_info"));
5041                    }
5042                    field_symlink_info = Some(map.next_value()?);
5043                }
5044                "sharing_info" => {
5045                    if field_sharing_info.is_some() {
5046                        return Err(::serde::de::Error::duplicate_field("sharing_info"));
5047                    }
5048                    field_sharing_info = Some(map.next_value()?);
5049                }
5050                "is_downloadable" => {
5051                    if field_is_downloadable.is_some() {
5052                        return Err(::serde::de::Error::duplicate_field("is_downloadable"));
5053                    }
5054                    field_is_downloadable = Some(map.next_value()?);
5055                }
5056                "export_info" => {
5057                    if field_export_info.is_some() {
5058                        return Err(::serde::de::Error::duplicate_field("export_info"));
5059                    }
5060                    field_export_info = Some(map.next_value()?);
5061                }
5062                "property_groups" => {
5063                    if field_property_groups.is_some() {
5064                        return Err(::serde::de::Error::duplicate_field("property_groups"));
5065                    }
5066                    field_property_groups = Some(map.next_value()?);
5067                }
5068                "has_explicit_shared_members" => {
5069                    if field_has_explicit_shared_members.is_some() {
5070                        return Err(::serde::de::Error::duplicate_field("has_explicit_shared_members"));
5071                    }
5072                    field_has_explicit_shared_members = Some(map.next_value()?);
5073                }
5074                "content_hash" => {
5075                    if field_content_hash.is_some() {
5076                        return Err(::serde::de::Error::duplicate_field("content_hash"));
5077                    }
5078                    field_content_hash = Some(map.next_value()?);
5079                }
5080                "file_lock_info" => {
5081                    if field_file_lock_info.is_some() {
5082                        return Err(::serde::de::Error::duplicate_field("file_lock_info"));
5083                    }
5084                    field_file_lock_info = Some(map.next_value()?);
5085                }
5086                _ => {
5087                    // unknown field allowed and ignored
5088                    map.next_value::<::serde_json::Value>()?;
5089                }
5090            }
5091        }
5092        if optional && nothing {
5093            return Ok(None);
5094        }
5095        let result = FileMetadata {
5096            name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
5097            id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
5098            client_modified: field_client_modified.ok_or_else(|| ::serde::de::Error::missing_field("client_modified"))?,
5099            server_modified: field_server_modified.ok_or_else(|| ::serde::de::Error::missing_field("server_modified"))?,
5100            rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
5101            size: field_size.ok_or_else(|| ::serde::de::Error::missing_field("size"))?,
5102            path_lower: field_path_lower.and_then(Option::flatten),
5103            path_display: field_path_display.and_then(Option::flatten),
5104            parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
5105            preview_url: field_preview_url.and_then(Option::flatten),
5106            media_info: field_media_info.and_then(Option::flatten),
5107            symlink_info: field_symlink_info.and_then(Option::flatten),
5108            sharing_info: field_sharing_info.and_then(Option::flatten),
5109            is_downloadable: field_is_downloadable.unwrap_or(true),
5110            export_info: field_export_info.and_then(Option::flatten),
5111            property_groups: field_property_groups.and_then(Option::flatten),
5112            has_explicit_shared_members: field_has_explicit_shared_members.and_then(Option::flatten),
5113            content_hash: field_content_hash.and_then(Option::flatten),
5114            file_lock_info: field_file_lock_info.and_then(Option::flatten),
5115        };
5116        Ok(Some(result))
5117    }
5118
5119    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5120        &self,
5121        s: &mut S::SerializeStruct,
5122    ) -> Result<(), S::Error> {
5123        use serde::ser::SerializeStruct;
5124        s.serialize_field("name", &self.name)?;
5125        s.serialize_field("id", &self.id)?;
5126        s.serialize_field("client_modified", &self.client_modified)?;
5127        s.serialize_field("server_modified", &self.server_modified)?;
5128        s.serialize_field("rev", &self.rev)?;
5129        s.serialize_field("size", &self.size)?;
5130        if let Some(val) = &self.path_lower {
5131            s.serialize_field("path_lower", val)?;
5132        }
5133        if let Some(val) = &self.path_display {
5134            s.serialize_field("path_display", val)?;
5135        }
5136        if let Some(val) = &self.parent_shared_folder_id {
5137            s.serialize_field("parent_shared_folder_id", val)?;
5138        }
5139        if let Some(val) = &self.preview_url {
5140            s.serialize_field("preview_url", val)?;
5141        }
5142        if let Some(val) = &self.media_info {
5143            s.serialize_field("media_info", val)?;
5144        }
5145        if let Some(val) = &self.symlink_info {
5146            s.serialize_field("symlink_info", val)?;
5147        }
5148        if let Some(val) = &self.sharing_info {
5149            s.serialize_field("sharing_info", val)?;
5150        }
5151        if !self.is_downloadable {
5152            s.serialize_field("is_downloadable", &self.is_downloadable)?;
5153        }
5154        if let Some(val) = &self.export_info {
5155            s.serialize_field("export_info", val)?;
5156        }
5157        if let Some(val) = &self.property_groups {
5158            s.serialize_field("property_groups", val)?;
5159        }
5160        if let Some(val) = &self.has_explicit_shared_members {
5161            s.serialize_field("has_explicit_shared_members", val)?;
5162        }
5163        if let Some(val) = &self.content_hash {
5164            s.serialize_field("content_hash", val)?;
5165        }
5166        if let Some(val) = &self.file_lock_info {
5167            s.serialize_field("file_lock_info", val)?;
5168        }
5169        Ok(())
5170    }
5171}
5172
5173impl<'de> ::serde::de::Deserialize<'de> for FileMetadata {
5174    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5175        // struct deserializer
5176        use serde::de::{MapAccess, Visitor};
5177        struct StructVisitor;
5178        impl<'de> Visitor<'de> for StructVisitor {
5179            type Value = FileMetadata;
5180            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5181                f.write_str("a FileMetadata struct")
5182            }
5183            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5184                FileMetadata::internal_deserialize(map)
5185            }
5186        }
5187        deserializer.deserialize_struct("FileMetadata", FILE_METADATA_FIELDS, StructVisitor)
5188    }
5189}
5190
5191impl ::serde::ser::Serialize for FileMetadata {
5192    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5193        // struct serializer
5194        use serde::ser::SerializeStruct;
5195        let mut s = serializer.serialize_struct("FileMetadata", 19)?;
5196        self.internal_serialize::<S>(&mut s)?;
5197        s.end()
5198    }
5199}
5200
5201// struct extends polymorphic struct Metadata
5202impl From<FileMetadata> for Metadata {
5203    fn from(subtype: FileMetadata) -> Self {
5204        Metadata::File(subtype)
5205    }
5206}
5207#[derive(Debug, Clone, PartialEq, Eq, Default)]
5208#[non_exhaustive] // structs may have more fields added in the future.
5209pub struct FileOpsResult {
5210}
5211
5212const FILE_OPS_RESULT_FIELDS: &[&str] = &[];
5213impl FileOpsResult {
5214    // no _opt deserializer
5215    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5216        mut map: V,
5217    ) -> Result<FileOpsResult, V::Error> {
5218        // ignore any fields found; none are presently recognized
5219        crate::eat_json_fields(&mut map)?;
5220        Ok(FileOpsResult {})
5221    }
5222}
5223
5224impl<'de> ::serde::de::Deserialize<'de> for FileOpsResult {
5225    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5226        // struct deserializer
5227        use serde::de::{MapAccess, Visitor};
5228        struct StructVisitor;
5229        impl<'de> Visitor<'de> for StructVisitor {
5230            type Value = FileOpsResult;
5231            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5232                f.write_str("a FileOpsResult struct")
5233            }
5234            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5235                FileOpsResult::internal_deserialize(map)
5236            }
5237        }
5238        deserializer.deserialize_struct("FileOpsResult", FILE_OPS_RESULT_FIELDS, StructVisitor)
5239    }
5240}
5241
5242impl ::serde::ser::Serialize for FileOpsResult {
5243    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5244        // struct serializer
5245        use serde::ser::SerializeStruct;
5246        serializer.serialize_struct("FileOpsResult", 0)?.end()
5247    }
5248}
5249
5250/// Sharing info for a file which is contained by a shared folder.
5251#[derive(Debug, Clone, PartialEq, Eq)]
5252#[non_exhaustive] // structs may have more fields added in the future.
5253pub struct FileSharingInfo {
5254    /// True if the file or folder is inside a read-only shared folder.
5255    pub read_only: bool,
5256    /// ID of shared folder that holds this file.
5257    pub parent_shared_folder_id: crate::types::common::SharedFolderId,
5258    /// The last user who modified the file. This field will be null if the user's account has been
5259    /// deleted.
5260    pub modified_by: Option<crate::types::users_common::AccountId>,
5261}
5262
5263impl FileSharingInfo {
5264    pub fn new(
5265        read_only: bool,
5266        parent_shared_folder_id: crate::types::common::SharedFolderId,
5267    ) -> Self {
5268        FileSharingInfo {
5269            read_only,
5270            parent_shared_folder_id,
5271            modified_by: None,
5272        }
5273    }
5274
5275    pub fn with_modified_by(mut self, value: crate::types::users_common::AccountId) -> Self {
5276        self.modified_by = Some(value);
5277        self
5278    }
5279}
5280
5281const FILE_SHARING_INFO_FIELDS: &[&str] = &["read_only",
5282                                            "parent_shared_folder_id",
5283                                            "modified_by"];
5284impl FileSharingInfo {
5285    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5286        map: V,
5287    ) -> Result<FileSharingInfo, V::Error> {
5288        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5289    }
5290
5291    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5292        mut map: V,
5293        optional: bool,
5294    ) -> Result<Option<FileSharingInfo>, V::Error> {
5295        let mut field_read_only = None;
5296        let mut field_parent_shared_folder_id = None;
5297        let mut field_modified_by = None;
5298        let mut nothing = true;
5299        while let Some(key) = map.next_key::<&str>()? {
5300            nothing = false;
5301            match key {
5302                "read_only" => {
5303                    if field_read_only.is_some() {
5304                        return Err(::serde::de::Error::duplicate_field("read_only"));
5305                    }
5306                    field_read_only = Some(map.next_value()?);
5307                }
5308                "parent_shared_folder_id" => {
5309                    if field_parent_shared_folder_id.is_some() {
5310                        return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5311                    }
5312                    field_parent_shared_folder_id = Some(map.next_value()?);
5313                }
5314                "modified_by" => {
5315                    if field_modified_by.is_some() {
5316                        return Err(::serde::de::Error::duplicate_field("modified_by"));
5317                    }
5318                    field_modified_by = Some(map.next_value()?);
5319                }
5320                _ => {
5321                    // unknown field allowed and ignored
5322                    map.next_value::<::serde_json::Value>()?;
5323                }
5324            }
5325        }
5326        if optional && nothing {
5327            return Ok(None);
5328        }
5329        let result = FileSharingInfo {
5330            read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
5331            parent_shared_folder_id: field_parent_shared_folder_id.ok_or_else(|| ::serde::de::Error::missing_field("parent_shared_folder_id"))?,
5332            modified_by: field_modified_by.and_then(Option::flatten),
5333        };
5334        Ok(Some(result))
5335    }
5336
5337    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5338        &self,
5339        s: &mut S::SerializeStruct,
5340    ) -> Result<(), S::Error> {
5341        use serde::ser::SerializeStruct;
5342        s.serialize_field("read_only", &self.read_only)?;
5343        s.serialize_field("parent_shared_folder_id", &self.parent_shared_folder_id)?;
5344        if let Some(val) = &self.modified_by {
5345            s.serialize_field("modified_by", val)?;
5346        }
5347        Ok(())
5348    }
5349}
5350
5351impl<'de> ::serde::de::Deserialize<'de> for FileSharingInfo {
5352    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5353        // struct deserializer
5354        use serde::de::{MapAccess, Visitor};
5355        struct StructVisitor;
5356        impl<'de> Visitor<'de> for StructVisitor {
5357            type Value = FileSharingInfo;
5358            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5359                f.write_str("a FileSharingInfo struct")
5360            }
5361            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5362                FileSharingInfo::internal_deserialize(map)
5363            }
5364        }
5365        deserializer.deserialize_struct("FileSharingInfo", FILE_SHARING_INFO_FIELDS, StructVisitor)
5366    }
5367}
5368
5369impl ::serde::ser::Serialize for FileSharingInfo {
5370    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5371        // struct serializer
5372        use serde::ser::SerializeStruct;
5373        let mut s = serializer.serialize_struct("FileSharingInfo", 3)?;
5374        self.internal_serialize::<S>(&mut s)?;
5375        s.end()
5376    }
5377}
5378
5379// struct extends SharingInfo
5380impl From<FileSharingInfo> for SharingInfo {
5381    fn from(subtype: FileSharingInfo) -> Self {
5382        Self {
5383            read_only: subtype.read_only,
5384        }
5385    }
5386}
5387#[derive(Debug, Clone, PartialEq, Eq)]
5388#[non_exhaustive] // variants may be added in the future
5389pub enum FileStatus {
5390    Active,
5391    Deleted,
5392    /// Catch-all used for unrecognized values returned from the server. Encountering this value
5393    /// typically indicates that this SDK version is out of date.
5394    Other,
5395}
5396
5397impl<'de> ::serde::de::Deserialize<'de> for FileStatus {
5398    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5399        // union deserializer
5400        use serde::de::{self, MapAccess, Visitor};
5401        struct EnumVisitor;
5402        impl<'de> Visitor<'de> for EnumVisitor {
5403            type Value = FileStatus;
5404            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5405                f.write_str("a FileStatus structure")
5406            }
5407            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
5408                let tag: &str = match map.next_key()? {
5409                    Some(".tag") => map.next_value()?,
5410                    _ => return Err(de::Error::missing_field(".tag"))
5411                };
5412                let value = match tag {
5413                    "active" => FileStatus::Active,
5414                    "deleted" => FileStatus::Deleted,
5415                    _ => FileStatus::Other,
5416                };
5417                crate::eat_json_fields(&mut map)?;
5418                Ok(value)
5419            }
5420        }
5421        const VARIANTS: &[&str] = &["active",
5422                                    "deleted",
5423                                    "other"];
5424        deserializer.deserialize_struct("FileStatus", VARIANTS, EnumVisitor)
5425    }
5426}
5427
5428impl ::serde::ser::Serialize for FileStatus {
5429    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5430        // union serializer
5431        use serde::ser::SerializeStruct;
5432        match self {
5433            FileStatus::Active => {
5434                // unit
5435                let mut s = serializer.serialize_struct("FileStatus", 1)?;
5436                s.serialize_field(".tag", "active")?;
5437                s.end()
5438            }
5439            FileStatus::Deleted => {
5440                // unit
5441                let mut s = serializer.serialize_struct("FileStatus", 1)?;
5442                s.serialize_field(".tag", "deleted")?;
5443                s.end()
5444            }
5445            FileStatus::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
5446        }
5447    }
5448}
5449
5450#[derive(Debug, Clone, PartialEq, Eq)]
5451#[non_exhaustive] // structs may have more fields added in the future.
5452pub struct FolderMetadata {
5453    /// The last component of the path (including extension). This never contains a slash.
5454    pub name: String,
5455    /// A unique identifier for the folder.
5456    pub id: Id,
5457    /// The lowercased full path in the user's Dropbox. This always starts with a slash. This field
5458    /// will be null if the file or folder is not mounted.
5459    pub path_lower: Option<String>,
5460    /// The cased path to be used for display purposes only. In rare instances the casing will not
5461    /// correctly match the user's filesystem, but this behavior will match the path provided in the
5462    /// Core API v1, and at least the last path component will have the correct casing. Changes to
5463    /// only the casing of paths won't be returned by
5464    /// [`list_folder_continue()`](crate::files::list_folder_continue). This field will be null if
5465    /// the file or folder is not mounted.
5466    pub path_display: Option<String>,
5467    /// Please use [`FileSharingInfo::parent_shared_folder_id`](FileSharingInfo) or
5468    /// [`FolderSharingInfo::parent_shared_folder_id`](FolderSharingInfo) instead.
5469    pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
5470    /// The preview URL of the file.
5471    pub preview_url: Option<String>,
5472    /// Please use `sharing_info` instead.
5473    pub shared_folder_id: Option<crate::types::common::SharedFolderId>,
5474    /// Set if the folder is contained in a shared folder or is a shared folder mount point.
5475    pub sharing_info: Option<FolderSharingInfo>,
5476    /// Additional information if the file has custom properties with the property template
5477    /// specified. Note that only properties associated with user-owned templates, not team-owned
5478    /// templates, can be attached to folders.
5479    pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
5480}
5481
5482impl FolderMetadata {
5483    pub fn new(name: String, id: Id) -> Self {
5484        FolderMetadata {
5485            name,
5486            id,
5487            path_lower: None,
5488            path_display: None,
5489            parent_shared_folder_id: None,
5490            preview_url: None,
5491            shared_folder_id: None,
5492            sharing_info: None,
5493            property_groups: None,
5494        }
5495    }
5496
5497    pub fn with_path_lower(mut self, value: String) -> Self {
5498        self.path_lower = Some(value);
5499        self
5500    }
5501
5502    pub fn with_path_display(mut self, value: String) -> Self {
5503        self.path_display = Some(value);
5504        self
5505    }
5506
5507    pub fn with_parent_shared_folder_id(
5508        mut self,
5509        value: crate::types::common::SharedFolderId,
5510    ) -> Self {
5511        self.parent_shared_folder_id = Some(value);
5512        self
5513    }
5514
5515    pub fn with_preview_url(mut self, value: String) -> Self {
5516        self.preview_url = Some(value);
5517        self
5518    }
5519
5520    pub fn with_shared_folder_id(mut self, value: crate::types::common::SharedFolderId) -> Self {
5521        self.shared_folder_id = Some(value);
5522        self
5523    }
5524
5525    pub fn with_sharing_info(mut self, value: FolderSharingInfo) -> Self {
5526        self.sharing_info = Some(value);
5527        self
5528    }
5529
5530    pub fn with_property_groups(
5531        mut self,
5532        value: Vec<crate::types::file_properties::PropertyGroup>,
5533    ) -> Self {
5534        self.property_groups = Some(value);
5535        self
5536    }
5537}
5538
5539const FOLDER_METADATA_FIELDS: &[&str] = &["name",
5540                                          "id",
5541                                          "path_lower",
5542                                          "path_display",
5543                                          "parent_shared_folder_id",
5544                                          "preview_url",
5545                                          "shared_folder_id",
5546                                          "sharing_info",
5547                                          "property_groups"];
5548impl FolderMetadata {
5549    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5550        map: V,
5551    ) -> Result<FolderMetadata, V::Error> {
5552        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5553    }
5554
5555    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5556        mut map: V,
5557        optional: bool,
5558    ) -> Result<Option<FolderMetadata>, V::Error> {
5559        let mut field_name = None;
5560        let mut field_id = None;
5561        let mut field_path_lower = None;
5562        let mut field_path_display = None;
5563        let mut field_parent_shared_folder_id = None;
5564        let mut field_preview_url = None;
5565        let mut field_shared_folder_id = None;
5566        let mut field_sharing_info = None;
5567        let mut field_property_groups = None;
5568        let mut nothing = true;
5569        while let Some(key) = map.next_key::<&str>()? {
5570            nothing = false;
5571            match key {
5572                "name" => {
5573                    if field_name.is_some() {
5574                        return Err(::serde::de::Error::duplicate_field("name"));
5575                    }
5576                    field_name = Some(map.next_value()?);
5577                }
5578                "id" => {
5579                    if field_id.is_some() {
5580                        return Err(::serde::de::Error::duplicate_field("id"));
5581                    }
5582                    field_id = Some(map.next_value()?);
5583                }
5584                "path_lower" => {
5585                    if field_path_lower.is_some() {
5586                        return Err(::serde::de::Error::duplicate_field("path_lower"));
5587                    }
5588                    field_path_lower = Some(map.next_value()?);
5589                }
5590                "path_display" => {
5591                    if field_path_display.is_some() {
5592                        return Err(::serde::de::Error::duplicate_field("path_display"));
5593                    }
5594                    field_path_display = Some(map.next_value()?);
5595                }
5596                "parent_shared_folder_id" => {
5597                    if field_parent_shared_folder_id.is_some() {
5598                        return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5599                    }
5600                    field_parent_shared_folder_id = Some(map.next_value()?);
5601                }
5602                "preview_url" => {
5603                    if field_preview_url.is_some() {
5604                        return Err(::serde::de::Error::duplicate_field("preview_url"));
5605                    }
5606                    field_preview_url = Some(map.next_value()?);
5607                }
5608                "shared_folder_id" => {
5609                    if field_shared_folder_id.is_some() {
5610                        return Err(::serde::de::Error::duplicate_field("shared_folder_id"));
5611                    }
5612                    field_shared_folder_id = Some(map.next_value()?);
5613                }
5614                "sharing_info" => {
5615                    if field_sharing_info.is_some() {
5616                        return Err(::serde::de::Error::duplicate_field("sharing_info"));
5617                    }
5618                    field_sharing_info = Some(map.next_value()?);
5619                }
5620                "property_groups" => {
5621                    if field_property_groups.is_some() {
5622                        return Err(::serde::de::Error::duplicate_field("property_groups"));
5623                    }
5624                    field_property_groups = Some(map.next_value()?);
5625                }
5626                _ => {
5627                    // unknown field allowed and ignored
5628                    map.next_value::<::serde_json::Value>()?;
5629                }
5630            }
5631        }
5632        if optional && nothing {
5633            return Ok(None);
5634        }
5635        let result = FolderMetadata {
5636            name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
5637            id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
5638            path_lower: field_path_lower.and_then(Option::flatten),
5639            path_display: field_path_display.and_then(Option::flatten),
5640            parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
5641            preview_url: field_preview_url.and_then(Option::flatten),
5642            shared_folder_id: field_shared_folder_id.and_then(Option::flatten),
5643            sharing_info: field_sharing_info.and_then(Option::flatten),
5644            property_groups: field_property_groups.and_then(Option::flatten),
5645        };
5646        Ok(Some(result))
5647    }
5648
5649    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5650        &self,
5651        s: &mut S::SerializeStruct,
5652    ) -> Result<(), S::Error> {
5653        use serde::ser::SerializeStruct;
5654        s.serialize_field("name", &self.name)?;
5655        s.serialize_field("id", &self.id)?;
5656        if let Some(val) = &self.path_lower {
5657            s.serialize_field("path_lower", val)?;
5658        }
5659        if let Some(val) = &self.path_display {
5660            s.serialize_field("path_display", val)?;
5661        }
5662        if let Some(val) = &self.parent_shared_folder_id {
5663            s.serialize_field("parent_shared_folder_id", val)?;
5664        }
5665        if let Some(val) = &self.preview_url {
5666            s.serialize_field("preview_url", val)?;
5667        }
5668        if let Some(val) = &self.shared_folder_id {
5669            s.serialize_field("shared_folder_id", val)?;
5670        }
5671        if let Some(val) = &self.sharing_info {
5672            s.serialize_field("sharing_info", val)?;
5673        }
5674        if let Some(val) = &self.property_groups {
5675            s.serialize_field("property_groups", val)?;
5676        }
5677        Ok(())
5678    }
5679}
5680
5681impl<'de> ::serde::de::Deserialize<'de> for FolderMetadata {
5682    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5683        // struct deserializer
5684        use serde::de::{MapAccess, Visitor};
5685        struct StructVisitor;
5686        impl<'de> Visitor<'de> for StructVisitor {
5687            type Value = FolderMetadata;
5688            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5689                f.write_str("a FolderMetadata struct")
5690            }
5691            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5692                FolderMetadata::internal_deserialize(map)
5693            }
5694        }
5695        deserializer.deserialize_struct("FolderMetadata", FOLDER_METADATA_FIELDS, StructVisitor)
5696    }
5697}
5698
5699impl ::serde::ser::Serialize for FolderMetadata {
5700    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5701        // struct serializer
5702        use serde::ser::SerializeStruct;
5703        let mut s = serializer.serialize_struct("FolderMetadata", 9)?;
5704        self.internal_serialize::<S>(&mut s)?;
5705        s.end()
5706    }
5707}
5708
5709// struct extends polymorphic struct Metadata
5710impl From<FolderMetadata> for Metadata {
5711    fn from(subtype: FolderMetadata) -> Self {
5712        Metadata::Folder(subtype)
5713    }
5714}
5715/// Sharing info for a folder which is contained in a shared folder or is a shared folder mount
5716/// point.
5717#[derive(Debug, Clone, PartialEq, Eq)]
5718#[non_exhaustive] // structs may have more fields added in the future.
5719pub struct FolderSharingInfo {
5720    /// True if the file or folder is inside a read-only shared folder.
5721    pub read_only: bool,
5722    /// Set if the folder is contained by a shared folder.
5723    pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
5724    /// If this folder is a shared folder mount point, the ID of the shared folder mounted at this
5725    /// location.
5726    pub shared_folder_id: Option<crate::types::common::SharedFolderId>,
5727    /// Specifies that the folder can only be traversed and the user can only see a limited subset
5728    /// of the contents of this folder because they don't have read access to this folder. They do,
5729    /// however, have access to some sub folder.
5730    pub traverse_only: bool,
5731    /// Specifies that the folder cannot be accessed by the user.
5732    pub no_access: bool,
5733}
5734
5735impl FolderSharingInfo {
5736    pub fn new(read_only: bool) -> Self {
5737        FolderSharingInfo {
5738            read_only,
5739            parent_shared_folder_id: None,
5740            shared_folder_id: None,
5741            traverse_only: false,
5742            no_access: false,
5743        }
5744    }
5745
5746    pub fn with_parent_shared_folder_id(
5747        mut self,
5748        value: crate::types::common::SharedFolderId,
5749    ) -> Self {
5750        self.parent_shared_folder_id = Some(value);
5751        self
5752    }
5753
5754    pub fn with_shared_folder_id(mut self, value: crate::types::common::SharedFolderId) -> Self {
5755        self.shared_folder_id = Some(value);
5756        self
5757    }
5758
5759    pub fn with_traverse_only(mut self, value: bool) -> Self {
5760        self.traverse_only = value;
5761        self
5762    }
5763
5764    pub fn with_no_access(mut self, value: bool) -> Self {
5765        self.no_access = value;
5766        self
5767    }
5768}
5769
5770const FOLDER_SHARING_INFO_FIELDS: &[&str] = &["read_only",
5771                                              "parent_shared_folder_id",
5772                                              "shared_folder_id",
5773                                              "traverse_only",
5774                                              "no_access"];
5775impl FolderSharingInfo {
5776    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5777        map: V,
5778    ) -> Result<FolderSharingInfo, V::Error> {
5779        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5780    }
5781
5782    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5783        mut map: V,
5784        optional: bool,
5785    ) -> Result<Option<FolderSharingInfo>, V::Error> {
5786        let mut field_read_only = None;
5787        let mut field_parent_shared_folder_id = None;
5788        let mut field_shared_folder_id = None;
5789        let mut field_traverse_only = None;
5790        let mut field_no_access = None;
5791        let mut nothing = true;
5792        while let Some(key) = map.next_key::<&str>()? {
5793            nothing = false;
5794            match key {
5795                "read_only" => {
5796                    if field_read_only.is_some() {
5797                        return Err(::serde::de::Error::duplicate_field("read_only"));
5798                    }
5799                    field_read_only = Some(map.next_value()?);
5800                }
5801                "parent_shared_folder_id" => {
5802                    if field_parent_shared_folder_id.is_some() {
5803                        return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5804                    }
5805                    field_parent_shared_folder_id = Some(map.next_value()?);
5806                }
5807                "shared_folder_id" => {
5808                    if field_shared_folder_id.is_some() {
5809                        return Err(::serde::de::Error::duplicate_field("shared_folder_id"));
5810                    }
5811                    field_shared_folder_id = Some(map.next_value()?);
5812                }
5813                "traverse_only" => {
5814                    if field_traverse_only.is_some() {
5815                        return Err(::serde::de::Error::duplicate_field("traverse_only"));
5816                    }
5817                    field_traverse_only = Some(map.next_value()?);
5818                }
5819                "no_access" => {
5820                    if field_no_access.is_some() {
5821                        return Err(::serde::de::Error::duplicate_field("no_access"));
5822                    }
5823                    field_no_access = Some(map.next_value()?);
5824                }
5825                _ => {
5826                    // unknown field allowed and ignored
5827                    map.next_value::<::serde_json::Value>()?;
5828                }
5829            }
5830        }
5831        if optional && nothing {
5832            return Ok(None);
5833        }
5834        let result = FolderSharingInfo {
5835            read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
5836            parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
5837            shared_folder_id: field_shared_folder_id.and_then(Option::flatten),
5838            traverse_only: field_traverse_only.unwrap_or(false),
5839            no_access: field_no_access.unwrap_or(false),
5840        };
5841        Ok(Some(result))
5842    }
5843
5844    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5845        &self,
5846        s: &mut S::SerializeStruct,
5847    ) -> Result<(), S::Error> {
5848        use serde::ser::SerializeStruct;
5849        s.serialize_field("read_only", &self.read_only)?;
5850        if let Some(val) = &self.parent_shared_folder_id {
5851            s.serialize_field("parent_shared_folder_id", val)?;
5852        }
5853        if let Some(val) = &self.shared_folder_id {
5854            s.serialize_field("shared_folder_id", val)?;
5855        }
5856        if self.traverse_only {
5857            s.serialize_field("traverse_only", &self.traverse_only)?;
5858        }
5859        if self.no_access {
5860            s.serialize_field("no_access", &self.no_access)?;
5861        }
5862        Ok(())
5863    }
5864}
5865
5866impl<'de> ::serde::de::Deserialize<'de> for FolderSharingInfo {
5867    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5868        // struct deserializer
5869        use serde::de::{MapAccess, Visitor};
5870        struct StructVisitor;
5871        impl<'de> Visitor<'de> for StructVisitor {
5872            type Value = FolderSharingInfo;
5873            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5874                f.write_str("a FolderSharingInfo struct")
5875            }
5876            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5877                FolderSharingInfo::internal_deserialize(map)
5878            }
5879        }
5880        deserializer.deserialize_struct("FolderSharingInfo", FOLDER_SHARING_INFO_FIELDS, StructVisitor)
5881    }
5882}
5883
5884impl ::serde::ser::Serialize for FolderSharingInfo {
5885    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5886        // struct serializer
5887        use serde::ser::SerializeStruct;
5888        let mut s = serializer.serialize_struct("FolderSharingInfo", 5)?;
5889        self.internal_serialize::<S>(&mut s)?;
5890        s.end()
5891    }
5892}
5893
5894// struct extends SharingInfo
5895impl From<FolderSharingInfo> for SharingInfo {
5896    fn from(subtype: FolderSharingInfo) -> Self {
5897        Self {
5898            read_only: subtype.read_only,
5899        }
5900    }
5901}
5902#[derive(Debug, Clone, PartialEq, Eq)]
5903#[non_exhaustive] // structs may have more fields added in the future.
5904pub struct GetCopyReferenceArg {
5905    /// The path to the file or folder you want to get a copy reference to.
5906    pub path: ReadPath,
5907}
5908
5909impl GetCopyReferenceArg {
5910    pub fn new(path: ReadPath) -> Self {
5911        GetCopyReferenceArg {
5912            path,
5913        }
5914    }
5915}
5916
5917const GET_COPY_REFERENCE_ARG_FIELDS: &[&str] = &["path"];
5918impl GetCopyReferenceArg {
5919    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5920        map: V,
5921    ) -> Result<GetCopyReferenceArg, V::Error> {
5922        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5923    }
5924
5925    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5926        mut map: V,
5927        optional: bool,
5928    ) -> Result<Option<GetCopyReferenceArg>, V::Error> {
5929        let mut field_path = None;
5930        let mut nothing = true;
5931        while let Some(key) = map.next_key::<&str>()? {
5932            nothing = false;
5933            match key {
5934                "path" => {
5935                    if field_path.is_some() {
5936                        return Err(::serde::de::Error::duplicate_field("path"));
5937                    }
5938                    field_path = Some(map.next_value()?);
5939                }
5940                _ => {
5941                    // unknown field allowed and ignored
5942                    map.next_value::<::serde_json::Value>()?;
5943                }
5944            }
5945        }
5946        if optional && nothing {
5947            return Ok(None);
5948        }
5949        let result = GetCopyReferenceArg {
5950            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
5951        };
5952        Ok(Some(result))
5953    }
5954
5955    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5956        &self,
5957        s: &mut S::SerializeStruct,
5958    ) -> Result<(), S::Error> {
5959        use serde::ser::SerializeStruct;
5960        s.serialize_field("path", &self.path)?;
5961        Ok(())
5962    }
5963}
5964
5965impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceArg {
5966    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5967        // struct deserializer
5968        use serde::de::{MapAccess, Visitor};
5969        struct StructVisitor;
5970        impl<'de> Visitor<'de> for StructVisitor {
5971            type Value = GetCopyReferenceArg;
5972            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5973                f.write_str("a GetCopyReferenceArg struct")
5974            }
5975            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5976                GetCopyReferenceArg::internal_deserialize(map)
5977            }
5978        }
5979        deserializer.deserialize_struct("GetCopyReferenceArg", GET_COPY_REFERENCE_ARG_FIELDS, StructVisitor)
5980    }
5981}
5982
5983impl ::serde::ser::Serialize for GetCopyReferenceArg {
5984    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5985        // struct serializer
5986        use serde::ser::SerializeStruct;
5987        let mut s = serializer.serialize_struct("GetCopyReferenceArg", 1)?;
5988        self.internal_serialize::<S>(&mut s)?;
5989        s.end()
5990    }
5991}
5992
5993#[derive(Debug, Clone, PartialEq, Eq)]
5994#[non_exhaustive] // variants may be added in the future
5995pub enum GetCopyReferenceError {
5996    Path(LookupError),
5997    /// Catch-all used for unrecognized values returned from the server. Encountering this value
5998    /// typically indicates that this SDK version is out of date.
5999    Other,
6000}
6001
6002impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceError {
6003    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6004        // union deserializer
6005        use serde::de::{self, MapAccess, Visitor};
6006        struct EnumVisitor;
6007        impl<'de> Visitor<'de> for EnumVisitor {
6008            type Value = GetCopyReferenceError;
6009            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6010                f.write_str("a GetCopyReferenceError structure")
6011            }
6012            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
6013                let tag: &str = match map.next_key()? {
6014                    Some(".tag") => map.next_value()?,
6015                    _ => return Err(de::Error::missing_field(".tag"))
6016                };
6017                let value = match tag {
6018                    "path" => {
6019                        match map.next_key()? {
6020                            Some("path") => GetCopyReferenceError::Path(map.next_value()?),
6021                            None => return Err(de::Error::missing_field("path")),
6022                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
6023                        }
6024                    }
6025                    _ => GetCopyReferenceError::Other,
6026                };
6027                crate::eat_json_fields(&mut map)?;
6028                Ok(value)
6029            }
6030        }
6031        const VARIANTS: &[&str] = &["path",
6032                                    "other"];
6033        deserializer.deserialize_struct("GetCopyReferenceError", VARIANTS, EnumVisitor)
6034    }
6035}
6036
6037impl ::serde::ser::Serialize for GetCopyReferenceError {
6038    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6039        // union serializer
6040        use serde::ser::SerializeStruct;
6041        match self {
6042            GetCopyReferenceError::Path(x) => {
6043                // union or polymporphic struct
6044                let mut s = serializer.serialize_struct("GetCopyReferenceError", 2)?;
6045                s.serialize_field(".tag", "path")?;
6046                s.serialize_field("path", x)?;
6047                s.end()
6048            }
6049            GetCopyReferenceError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
6050        }
6051    }
6052}
6053
6054impl ::std::error::Error for GetCopyReferenceError {
6055    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
6056        match self {
6057            GetCopyReferenceError::Path(inner) => Some(inner),
6058            _ => None,
6059        }
6060    }
6061}
6062
6063impl ::std::fmt::Display for GetCopyReferenceError {
6064    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6065        match self {
6066            GetCopyReferenceError::Path(inner) => write!(f, "GetCopyReferenceError: {}", inner),
6067            _ => write!(f, "{:?}", *self),
6068        }
6069    }
6070}
6071
6072#[derive(Debug, Clone, PartialEq)]
6073#[non_exhaustive] // structs may have more fields added in the future.
6074pub struct GetCopyReferenceResult {
6075    /// Metadata of the file or folder.
6076    pub metadata: Metadata,
6077    /// A copy reference to the file or folder.
6078    pub copy_reference: String,
6079    /// The expiration date of the copy reference. This value is currently set to be far enough in
6080    /// the future so that expiration is effectively not an issue.
6081    pub expires: crate::types::common::DropboxTimestamp,
6082}
6083
6084impl GetCopyReferenceResult {
6085    pub fn new(
6086        metadata: Metadata,
6087        copy_reference: String,
6088        expires: crate::types::common::DropboxTimestamp,
6089    ) -> Self {
6090        GetCopyReferenceResult {
6091            metadata,
6092            copy_reference,
6093            expires,
6094        }
6095    }
6096}
6097
6098const GET_COPY_REFERENCE_RESULT_FIELDS: &[&str] = &["metadata",
6099                                                    "copy_reference",
6100                                                    "expires"];
6101impl GetCopyReferenceResult {
6102    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6103        map: V,
6104    ) -> Result<GetCopyReferenceResult, V::Error> {
6105        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6106    }
6107
6108    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6109        mut map: V,
6110        optional: bool,
6111    ) -> Result<Option<GetCopyReferenceResult>, V::Error> {
6112        let mut field_metadata = None;
6113        let mut field_copy_reference = None;
6114        let mut field_expires = None;
6115        let mut nothing = true;
6116        while let Some(key) = map.next_key::<&str>()? {
6117            nothing = false;
6118            match key {
6119                "metadata" => {
6120                    if field_metadata.is_some() {
6121                        return Err(::serde::de::Error::duplicate_field("metadata"));
6122                    }
6123                    field_metadata = Some(map.next_value()?);
6124                }
6125                "copy_reference" => {
6126                    if field_copy_reference.is_some() {
6127                        return Err(::serde::de::Error::duplicate_field("copy_reference"));
6128                    }
6129                    field_copy_reference = Some(map.next_value()?);
6130                }
6131                "expires" => {
6132                    if field_expires.is_some() {
6133                        return Err(::serde::de::Error::duplicate_field("expires"));
6134                    }
6135                    field_expires = Some(map.next_value()?);
6136                }
6137                _ => {
6138                    // unknown field allowed and ignored
6139                    map.next_value::<::serde_json::Value>()?;
6140                }
6141            }
6142        }
6143        if optional && nothing {
6144            return Ok(None);
6145        }
6146        let result = GetCopyReferenceResult {
6147            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
6148            copy_reference: field_copy_reference.ok_or_else(|| ::serde::de::Error::missing_field("copy_reference"))?,
6149            expires: field_expires.ok_or_else(|| ::serde::de::Error::missing_field("expires"))?,
6150        };
6151        Ok(Some(result))
6152    }
6153
6154    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6155        &self,
6156        s: &mut S::SerializeStruct,
6157    ) -> Result<(), S::Error> {
6158        use serde::ser::SerializeStruct;
6159        s.serialize_field("metadata", &self.metadata)?;
6160        s.serialize_field("copy_reference", &self.copy_reference)?;
6161        s.serialize_field("expires", &self.expires)?;
6162        Ok(())
6163    }
6164}
6165
6166impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceResult {
6167    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6168        // struct deserializer
6169        use serde::de::{MapAccess, Visitor};
6170        struct StructVisitor;
6171        impl<'de> Visitor<'de> for StructVisitor {
6172            type Value = GetCopyReferenceResult;
6173            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6174                f.write_str("a GetCopyReferenceResult struct")
6175            }
6176            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6177                GetCopyReferenceResult::internal_deserialize(map)
6178            }
6179        }
6180        deserializer.deserialize_struct("GetCopyReferenceResult", GET_COPY_REFERENCE_RESULT_FIELDS, StructVisitor)
6181    }
6182}
6183
6184impl ::serde::ser::Serialize for GetCopyReferenceResult {
6185    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6186        // struct serializer
6187        use serde::ser::SerializeStruct;
6188        let mut s = serializer.serialize_struct("GetCopyReferenceResult", 3)?;
6189        self.internal_serialize::<S>(&mut s)?;
6190        s.end()
6191    }
6192}
6193
6194#[derive(Debug, Clone, PartialEq, Eq)]
6195#[non_exhaustive] // structs may have more fields added in the future.
6196pub struct GetMetadataArg {
6197    /// The path of a file or folder on Dropbox.
6198    pub path: ReadPath,
6199    /// If true, [`FileMetadata::media_info`](FileMetadata) is set for photo and video.
6200    pub include_media_info: bool,
6201    /// If true, [`DeletedMetadata`] will be returned for deleted file or folder, otherwise
6202    /// [`LookupError::NotFound`] will be returned.
6203    pub include_deleted: bool,
6204    /// If true, the results will include a flag for each file indicating whether or not  that file
6205    /// has any explicit members.
6206    pub include_has_explicit_shared_members: bool,
6207    /// If set to a valid list of template IDs, [`FileMetadata::property_groups`](FileMetadata) is
6208    /// set if there exists property data associated with the file and each of the listed templates.
6209    pub include_property_groups: Option<crate::types::file_properties::TemplateFilterBase>,
6210}
6211
6212impl GetMetadataArg {
6213    pub fn new(path: ReadPath) -> Self {
6214        GetMetadataArg {
6215            path,
6216            include_media_info: false,
6217            include_deleted: false,
6218            include_has_explicit_shared_members: false,
6219            include_property_groups: None,
6220        }
6221    }
6222
6223    pub fn with_include_media_info(mut self, value: bool) -> Self {
6224        self.include_media_info = value;
6225        self
6226    }
6227
6228    pub fn with_include_deleted(mut self, value: bool) -> Self {
6229        self.include_deleted = value;
6230        self
6231    }
6232
6233    pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
6234        self.include_has_explicit_shared_members = value;
6235        self
6236    }
6237
6238    pub fn with_include_property_groups(
6239        mut self,
6240        value: crate::types::file_properties::TemplateFilterBase,
6241    ) -> Self {
6242        self.include_property_groups = Some(value);
6243        self
6244    }
6245}
6246
6247const GET_METADATA_ARG_FIELDS: &[&str] = &["path",
6248                                           "include_media_info",
6249                                           "include_deleted",
6250                                           "include_has_explicit_shared_members",
6251                                           "include_property_groups"];
6252impl GetMetadataArg {
6253    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6254        map: V,
6255    ) -> Result<GetMetadataArg, V::Error> {
6256        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6257    }
6258
6259    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6260        mut map: V,
6261        optional: bool,
6262    ) -> Result<Option<GetMetadataArg>, V::Error> {
6263        let mut field_path = None;
6264        let mut field_include_media_info = None;
6265        let mut field_include_deleted = None;
6266        let mut field_include_has_explicit_shared_members = None;
6267        let mut field_include_property_groups = None;
6268        let mut nothing = true;
6269        while let Some(key) = map.next_key::<&str>()? {
6270            nothing = false;
6271            match key {
6272                "path" => {
6273                    if field_path.is_some() {
6274                        return Err(::serde::de::Error::duplicate_field("path"));
6275                    }
6276                    field_path = Some(map.next_value()?);
6277                }
6278                "include_media_info" => {
6279                    if field_include_media_info.is_some() {
6280                        return Err(::serde::de::Error::duplicate_field("include_media_info"));
6281                    }
6282                    field_include_media_info = Some(map.next_value()?);
6283                }
6284                "include_deleted" => {
6285                    if field_include_deleted.is_some() {
6286                        return Err(::serde::de::Error::duplicate_field("include_deleted"));
6287                    }
6288                    field_include_deleted = Some(map.next_value()?);
6289                }
6290                "include_has_explicit_shared_members" => {
6291                    if field_include_has_explicit_shared_members.is_some() {
6292                        return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
6293                    }
6294                    field_include_has_explicit_shared_members = Some(map.next_value()?);
6295                }
6296                "include_property_groups" => {
6297                    if field_include_property_groups.is_some() {
6298                        return Err(::serde::de::Error::duplicate_field("include_property_groups"));
6299                    }
6300                    field_include_property_groups = Some(map.next_value()?);
6301                }
6302                _ => {
6303                    // unknown field allowed and ignored
6304                    map.next_value::<::serde_json::Value>()?;
6305                }
6306            }
6307        }
6308        if optional && nothing {
6309            return Ok(None);
6310        }
6311        let result = GetMetadataArg {
6312            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
6313            include_media_info: field_include_media_info.unwrap_or(false),
6314            include_deleted: field_include_deleted.unwrap_or(false),
6315            include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
6316            include_property_groups: field_include_property_groups.and_then(Option::flatten),
6317        };
6318        Ok(Some(result))
6319    }
6320
6321    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6322        &self,
6323        s: &mut S::SerializeStruct,
6324    ) -> Result<(), S::Error> {
6325        use serde::ser::SerializeStruct;
6326        s.serialize_field("path", &self.path)?;
6327        if self.include_media_info {
6328            s.serialize_field("include_media_info", &self.include_media_info)?;
6329        }
6330        if self.include_deleted {
6331            s.serialize_field("include_deleted", &self.include_deleted)?;
6332        }
6333        if self.include_has_explicit_shared_members {
6334            s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
6335        }
6336        if let Some(val) = &self.include_property_groups {
6337            s.serialize_field("include_property_groups", val)?;
6338        }
6339        Ok(())
6340    }
6341}
6342
6343impl<'de> ::serde::de::Deserialize<'de> for GetMetadataArg {
6344    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6345        // struct deserializer
6346        use serde::de::{MapAccess, Visitor};
6347        struct StructVisitor;
6348        impl<'de> Visitor<'de> for StructVisitor {
6349            type Value = GetMetadataArg;
6350            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6351                f.write_str("a GetMetadataArg struct")
6352            }
6353            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6354                GetMetadataArg::internal_deserialize(map)
6355            }
6356        }
6357        deserializer.deserialize_struct("GetMetadataArg", GET_METADATA_ARG_FIELDS, StructVisitor)
6358    }
6359}
6360
6361impl ::serde::ser::Serialize for GetMetadataArg {
6362    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6363        // struct serializer
6364        use serde::ser::SerializeStruct;
6365        let mut s = serializer.serialize_struct("GetMetadataArg", 5)?;
6366        self.internal_serialize::<S>(&mut s)?;
6367        s.end()
6368    }
6369}
6370
6371#[derive(Debug, Clone, PartialEq, Eq)]
6372pub enum GetMetadataError {
6373    Path(LookupError),
6374}
6375
6376impl<'de> ::serde::de::Deserialize<'de> for GetMetadataError {
6377    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6378        // union deserializer
6379        use serde::de::{self, MapAccess, Visitor};
6380        struct EnumVisitor;
6381        impl<'de> Visitor<'de> for EnumVisitor {
6382            type Value = GetMetadataError;
6383            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6384                f.write_str("a GetMetadataError structure")
6385            }
6386            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
6387                let tag: &str = match map.next_key()? {
6388                    Some(".tag") => map.next_value()?,
6389                    _ => return Err(de::Error::missing_field(".tag"))
6390                };
6391                let value = match tag {
6392                    "path" => {
6393                        match map.next_key()? {
6394                            Some("path") => GetMetadataError::Path(map.next_value()?),
6395                            None => return Err(de::Error::missing_field("path")),
6396                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
6397                        }
6398                    }
6399                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
6400                };
6401                crate::eat_json_fields(&mut map)?;
6402                Ok(value)
6403            }
6404        }
6405        const VARIANTS: &[&str] = &["path"];
6406        deserializer.deserialize_struct("GetMetadataError", VARIANTS, EnumVisitor)
6407    }
6408}
6409
6410impl ::serde::ser::Serialize for GetMetadataError {
6411    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6412        // union serializer
6413        use serde::ser::SerializeStruct;
6414        match self {
6415            GetMetadataError::Path(x) => {
6416                // union or polymporphic struct
6417                let mut s = serializer.serialize_struct("GetMetadataError", 2)?;
6418                s.serialize_field(".tag", "path")?;
6419                s.serialize_field("path", x)?;
6420                s.end()
6421            }
6422        }
6423    }
6424}
6425
6426impl ::std::error::Error for GetMetadataError {
6427    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
6428        match self {
6429            GetMetadataError::Path(inner) => Some(inner),
6430        }
6431    }
6432}
6433
6434impl ::std::fmt::Display for GetMetadataError {
6435    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6436        match self {
6437            GetMetadataError::Path(inner) => write!(f, "GetMetadataError: {}", inner),
6438        }
6439    }
6440}
6441
6442#[derive(Debug, Clone, PartialEq, Eq)]
6443#[non_exhaustive] // structs may have more fields added in the future.
6444pub struct GetTagsArg {
6445    /// Path to the items.
6446    pub paths: Vec<Path>,
6447}
6448
6449impl GetTagsArg {
6450    pub fn new(paths: Vec<Path>) -> Self {
6451        GetTagsArg {
6452            paths,
6453        }
6454    }
6455}
6456
6457const GET_TAGS_ARG_FIELDS: &[&str] = &["paths"];
6458impl GetTagsArg {
6459    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6460        map: V,
6461    ) -> Result<GetTagsArg, V::Error> {
6462        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6463    }
6464
6465    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6466        mut map: V,
6467        optional: bool,
6468    ) -> Result<Option<GetTagsArg>, V::Error> {
6469        let mut field_paths = None;
6470        let mut nothing = true;
6471        while let Some(key) = map.next_key::<&str>()? {
6472            nothing = false;
6473            match key {
6474                "paths" => {
6475                    if field_paths.is_some() {
6476                        return Err(::serde::de::Error::duplicate_field("paths"));
6477                    }
6478                    field_paths = Some(map.next_value()?);
6479                }
6480                _ => {
6481                    // unknown field allowed and ignored
6482                    map.next_value::<::serde_json::Value>()?;
6483                }
6484            }
6485        }
6486        if optional && nothing {
6487            return Ok(None);
6488        }
6489        let result = GetTagsArg {
6490            paths: field_paths.ok_or_else(|| ::serde::de::Error::missing_field("paths"))?,
6491        };
6492        Ok(Some(result))
6493    }
6494
6495    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6496        &self,
6497        s: &mut S::SerializeStruct,
6498    ) -> Result<(), S::Error> {
6499        use serde::ser::SerializeStruct;
6500        s.serialize_field("paths", &self.paths)?;
6501        Ok(())
6502    }
6503}
6504
6505impl<'de> ::serde::de::Deserialize<'de> for GetTagsArg {
6506    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6507        // struct deserializer
6508        use serde::de::{MapAccess, Visitor};
6509        struct StructVisitor;
6510        impl<'de> Visitor<'de> for StructVisitor {
6511            type Value = GetTagsArg;
6512            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6513                f.write_str("a GetTagsArg struct")
6514            }
6515            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6516                GetTagsArg::internal_deserialize(map)
6517            }
6518        }
6519        deserializer.deserialize_struct("GetTagsArg", GET_TAGS_ARG_FIELDS, StructVisitor)
6520    }
6521}
6522
6523impl ::serde::ser::Serialize for GetTagsArg {
6524    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6525        // struct serializer
6526        use serde::ser::SerializeStruct;
6527        let mut s = serializer.serialize_struct("GetTagsArg", 1)?;
6528        self.internal_serialize::<S>(&mut s)?;
6529        s.end()
6530    }
6531}
6532
6533#[derive(Debug, Clone, PartialEq, Eq)]
6534#[non_exhaustive] // structs may have more fields added in the future.
6535pub struct GetTagsResult {
6536    /// List of paths and their corresponding tags.
6537    pub paths_to_tags: Vec<PathToTags>,
6538}
6539
6540impl GetTagsResult {
6541    pub fn new(paths_to_tags: Vec<PathToTags>) -> Self {
6542        GetTagsResult {
6543            paths_to_tags,
6544        }
6545    }
6546}
6547
6548const GET_TAGS_RESULT_FIELDS: &[&str] = &["paths_to_tags"];
6549impl GetTagsResult {
6550    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6551        map: V,
6552    ) -> Result<GetTagsResult, V::Error> {
6553        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6554    }
6555
6556    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6557        mut map: V,
6558        optional: bool,
6559    ) -> Result<Option<GetTagsResult>, V::Error> {
6560        let mut field_paths_to_tags = None;
6561        let mut nothing = true;
6562        while let Some(key) = map.next_key::<&str>()? {
6563            nothing = false;
6564            match key {
6565                "paths_to_tags" => {
6566                    if field_paths_to_tags.is_some() {
6567                        return Err(::serde::de::Error::duplicate_field("paths_to_tags"));
6568                    }
6569                    field_paths_to_tags = Some(map.next_value()?);
6570                }
6571                _ => {
6572                    // unknown field allowed and ignored
6573                    map.next_value::<::serde_json::Value>()?;
6574                }
6575            }
6576        }
6577        if optional && nothing {
6578            return Ok(None);
6579        }
6580        let result = GetTagsResult {
6581            paths_to_tags: field_paths_to_tags.ok_or_else(|| ::serde::de::Error::missing_field("paths_to_tags"))?,
6582        };
6583        Ok(Some(result))
6584    }
6585
6586    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6587        &self,
6588        s: &mut S::SerializeStruct,
6589    ) -> Result<(), S::Error> {
6590        use serde::ser::SerializeStruct;
6591        s.serialize_field("paths_to_tags", &self.paths_to_tags)?;
6592        Ok(())
6593    }
6594}
6595
6596impl<'de> ::serde::de::Deserialize<'de> for GetTagsResult {
6597    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6598        // struct deserializer
6599        use serde::de::{MapAccess, Visitor};
6600        struct StructVisitor;
6601        impl<'de> Visitor<'de> for StructVisitor {
6602            type Value = GetTagsResult;
6603            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6604                f.write_str("a GetTagsResult struct")
6605            }
6606            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6607                GetTagsResult::internal_deserialize(map)
6608            }
6609        }
6610        deserializer.deserialize_struct("GetTagsResult", GET_TAGS_RESULT_FIELDS, StructVisitor)
6611    }
6612}
6613
6614impl ::serde::ser::Serialize for GetTagsResult {
6615    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6616        // struct serializer
6617        use serde::ser::SerializeStruct;
6618        let mut s = serializer.serialize_struct("GetTagsResult", 1)?;
6619        self.internal_serialize::<S>(&mut s)?;
6620        s.end()
6621    }
6622}
6623
6624#[derive(Debug, Clone, PartialEq, Eq)]
6625#[non_exhaustive] // structs may have more fields added in the future.
6626pub struct GetTemporaryLinkArg {
6627    /// The path to the file you want a temporary link to.
6628    pub path: ReadPath,
6629}
6630
6631impl GetTemporaryLinkArg {
6632    pub fn new(path: ReadPath) -> Self {
6633        GetTemporaryLinkArg {
6634            path,
6635        }
6636    }
6637}
6638
6639const GET_TEMPORARY_LINK_ARG_FIELDS: &[&str] = &["path"];
6640impl GetTemporaryLinkArg {
6641    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6642        map: V,
6643    ) -> Result<GetTemporaryLinkArg, V::Error> {
6644        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6645    }
6646
6647    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6648        mut map: V,
6649        optional: bool,
6650    ) -> Result<Option<GetTemporaryLinkArg>, V::Error> {
6651        let mut field_path = None;
6652        let mut nothing = true;
6653        while let Some(key) = map.next_key::<&str>()? {
6654            nothing = false;
6655            match key {
6656                "path" => {
6657                    if field_path.is_some() {
6658                        return Err(::serde::de::Error::duplicate_field("path"));
6659                    }
6660                    field_path = Some(map.next_value()?);
6661                }
6662                _ => {
6663                    // unknown field allowed and ignored
6664                    map.next_value::<::serde_json::Value>()?;
6665                }
6666            }
6667        }
6668        if optional && nothing {
6669            return Ok(None);
6670        }
6671        let result = GetTemporaryLinkArg {
6672            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
6673        };
6674        Ok(Some(result))
6675    }
6676
6677    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6678        &self,
6679        s: &mut S::SerializeStruct,
6680    ) -> Result<(), S::Error> {
6681        use serde::ser::SerializeStruct;
6682        s.serialize_field("path", &self.path)?;
6683        Ok(())
6684    }
6685}
6686
6687impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkArg {
6688    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6689        // struct deserializer
6690        use serde::de::{MapAccess, Visitor};
6691        struct StructVisitor;
6692        impl<'de> Visitor<'de> for StructVisitor {
6693            type Value = GetTemporaryLinkArg;
6694            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6695                f.write_str("a GetTemporaryLinkArg struct")
6696            }
6697            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6698                GetTemporaryLinkArg::internal_deserialize(map)
6699            }
6700        }
6701        deserializer.deserialize_struct("GetTemporaryLinkArg", GET_TEMPORARY_LINK_ARG_FIELDS, StructVisitor)
6702    }
6703}
6704
6705impl ::serde::ser::Serialize for GetTemporaryLinkArg {
6706    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6707        // struct serializer
6708        use serde::ser::SerializeStruct;
6709        let mut s = serializer.serialize_struct("GetTemporaryLinkArg", 1)?;
6710        self.internal_serialize::<S>(&mut s)?;
6711        s.end()
6712    }
6713}
6714
6715#[derive(Debug, Clone, PartialEq, Eq)]
6716#[non_exhaustive] // variants may be added in the future
6717pub enum GetTemporaryLinkError {
6718    Path(LookupError),
6719    /// This user's email address is not verified. This functionality is only available on accounts
6720    /// with a verified email address. Users can verify their email address
6721    /// [here](https://www.dropbox.com/help/317).
6722    EmailNotVerified,
6723    /// Cannot get temporary link to this file type; use [`export()`](crate::files::export) instead.
6724    UnsupportedFile,
6725    /// The user is not allowed to request a temporary link to the specified file. For example, this
6726    /// can occur if the file is restricted or if the user's links are
6727    /// [banned](https://help.dropbox.com/files-folders/share/banned-links).
6728    NotAllowed,
6729    /// Catch-all used for unrecognized values returned from the server. Encountering this value
6730    /// typically indicates that this SDK version is out of date.
6731    Other,
6732}
6733
6734impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkError {
6735    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6736        // union deserializer
6737        use serde::de::{self, MapAccess, Visitor};
6738        struct EnumVisitor;
6739        impl<'de> Visitor<'de> for EnumVisitor {
6740            type Value = GetTemporaryLinkError;
6741            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6742                f.write_str("a GetTemporaryLinkError structure")
6743            }
6744            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
6745                let tag: &str = match map.next_key()? {
6746                    Some(".tag") => map.next_value()?,
6747                    _ => return Err(de::Error::missing_field(".tag"))
6748                };
6749                let value = match tag {
6750                    "path" => {
6751                        match map.next_key()? {
6752                            Some("path") => GetTemporaryLinkError::Path(map.next_value()?),
6753                            None => return Err(de::Error::missing_field("path")),
6754                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
6755                        }
6756                    }
6757                    "email_not_verified" => GetTemporaryLinkError::EmailNotVerified,
6758                    "unsupported_file" => GetTemporaryLinkError::UnsupportedFile,
6759                    "not_allowed" => GetTemporaryLinkError::NotAllowed,
6760                    _ => GetTemporaryLinkError::Other,
6761                };
6762                crate::eat_json_fields(&mut map)?;
6763                Ok(value)
6764            }
6765        }
6766        const VARIANTS: &[&str] = &["path",
6767                                    "email_not_verified",
6768                                    "unsupported_file",
6769                                    "not_allowed",
6770                                    "other"];
6771        deserializer.deserialize_struct("GetTemporaryLinkError", VARIANTS, EnumVisitor)
6772    }
6773}
6774
6775impl ::serde::ser::Serialize for GetTemporaryLinkError {
6776    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6777        // union serializer
6778        use serde::ser::SerializeStruct;
6779        match self {
6780            GetTemporaryLinkError::Path(x) => {
6781                // union or polymporphic struct
6782                let mut s = serializer.serialize_struct("GetTemporaryLinkError", 2)?;
6783                s.serialize_field(".tag", "path")?;
6784                s.serialize_field("path", x)?;
6785                s.end()
6786            }
6787            GetTemporaryLinkError::EmailNotVerified => {
6788                // unit
6789                let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
6790                s.serialize_field(".tag", "email_not_verified")?;
6791                s.end()
6792            }
6793            GetTemporaryLinkError::UnsupportedFile => {
6794                // unit
6795                let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
6796                s.serialize_field(".tag", "unsupported_file")?;
6797                s.end()
6798            }
6799            GetTemporaryLinkError::NotAllowed => {
6800                // unit
6801                let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
6802                s.serialize_field(".tag", "not_allowed")?;
6803                s.end()
6804            }
6805            GetTemporaryLinkError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
6806        }
6807    }
6808}
6809
6810impl ::std::error::Error for GetTemporaryLinkError {
6811    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
6812        match self {
6813            GetTemporaryLinkError::Path(inner) => Some(inner),
6814            _ => None,
6815        }
6816    }
6817}
6818
6819impl ::std::fmt::Display for GetTemporaryLinkError {
6820    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6821        match self {
6822            GetTemporaryLinkError::Path(inner) => write!(f, "GetTemporaryLinkError: {}", inner),
6823            _ => write!(f, "{:?}", *self),
6824        }
6825    }
6826}
6827
6828#[derive(Debug, Clone, PartialEq)]
6829#[non_exhaustive] // structs may have more fields added in the future.
6830pub struct GetTemporaryLinkResult {
6831    /// Metadata of the file.
6832    pub metadata: FileMetadata,
6833    /// The temporary link which can be used to stream content the file.
6834    pub link: String,
6835}
6836
6837impl GetTemporaryLinkResult {
6838    pub fn new(metadata: FileMetadata, link: String) -> Self {
6839        GetTemporaryLinkResult {
6840            metadata,
6841            link,
6842        }
6843    }
6844}
6845
6846const GET_TEMPORARY_LINK_RESULT_FIELDS: &[&str] = &["metadata",
6847                                                    "link"];
6848impl GetTemporaryLinkResult {
6849    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6850        map: V,
6851    ) -> Result<GetTemporaryLinkResult, V::Error> {
6852        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6853    }
6854
6855    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6856        mut map: V,
6857        optional: bool,
6858    ) -> Result<Option<GetTemporaryLinkResult>, V::Error> {
6859        let mut field_metadata = None;
6860        let mut field_link = None;
6861        let mut nothing = true;
6862        while let Some(key) = map.next_key::<&str>()? {
6863            nothing = false;
6864            match key {
6865                "metadata" => {
6866                    if field_metadata.is_some() {
6867                        return Err(::serde::de::Error::duplicate_field("metadata"));
6868                    }
6869                    field_metadata = Some(map.next_value()?);
6870                }
6871                "link" => {
6872                    if field_link.is_some() {
6873                        return Err(::serde::de::Error::duplicate_field("link"));
6874                    }
6875                    field_link = Some(map.next_value()?);
6876                }
6877                _ => {
6878                    // unknown field allowed and ignored
6879                    map.next_value::<::serde_json::Value>()?;
6880                }
6881            }
6882        }
6883        if optional && nothing {
6884            return Ok(None);
6885        }
6886        let result = GetTemporaryLinkResult {
6887            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
6888            link: field_link.ok_or_else(|| ::serde::de::Error::missing_field("link"))?,
6889        };
6890        Ok(Some(result))
6891    }
6892
6893    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6894        &self,
6895        s: &mut S::SerializeStruct,
6896    ) -> Result<(), S::Error> {
6897        use serde::ser::SerializeStruct;
6898        s.serialize_field("metadata", &self.metadata)?;
6899        s.serialize_field("link", &self.link)?;
6900        Ok(())
6901    }
6902}
6903
6904impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkResult {
6905    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6906        // struct deserializer
6907        use serde::de::{MapAccess, Visitor};
6908        struct StructVisitor;
6909        impl<'de> Visitor<'de> for StructVisitor {
6910            type Value = GetTemporaryLinkResult;
6911            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6912                f.write_str("a GetTemporaryLinkResult struct")
6913            }
6914            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6915                GetTemporaryLinkResult::internal_deserialize(map)
6916            }
6917        }
6918        deserializer.deserialize_struct("GetTemporaryLinkResult", GET_TEMPORARY_LINK_RESULT_FIELDS, StructVisitor)
6919    }
6920}
6921
6922impl ::serde::ser::Serialize for GetTemporaryLinkResult {
6923    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6924        // struct serializer
6925        use serde::ser::SerializeStruct;
6926        let mut s = serializer.serialize_struct("GetTemporaryLinkResult", 2)?;
6927        self.internal_serialize::<S>(&mut s)?;
6928        s.end()
6929    }
6930}
6931
6932#[derive(Debug, Clone, PartialEq)]
6933#[non_exhaustive] // structs may have more fields added in the future.
6934pub struct GetTemporaryUploadLinkArg {
6935    /// Contains the path and other optional modifiers for the future upload commit. Equivalent to
6936    /// the parameters provided to [`upload()`](crate::files::upload).
6937    pub commit_info: CommitInfo,
6938    /// How long before this link expires, in seconds.  Attempting to start an upload with this link
6939    /// longer than this period  of time after link creation will result in an error.
6940    pub duration: f64,
6941}
6942
6943impl GetTemporaryUploadLinkArg {
6944    pub fn new(commit_info: CommitInfo) -> Self {
6945        GetTemporaryUploadLinkArg {
6946            commit_info,
6947            duration: 14400.0,
6948        }
6949    }
6950
6951    pub fn with_duration(mut self, value: f64) -> Self {
6952        self.duration = value;
6953        self
6954    }
6955}
6956
6957const GET_TEMPORARY_UPLOAD_LINK_ARG_FIELDS: &[&str] = &["commit_info",
6958                                                        "duration"];
6959impl GetTemporaryUploadLinkArg {
6960    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6961        map: V,
6962    ) -> Result<GetTemporaryUploadLinkArg, V::Error> {
6963        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6964    }
6965
6966    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6967        mut map: V,
6968        optional: bool,
6969    ) -> Result<Option<GetTemporaryUploadLinkArg>, V::Error> {
6970        let mut field_commit_info = None;
6971        let mut field_duration = None;
6972        let mut nothing = true;
6973        while let Some(key) = map.next_key::<&str>()? {
6974            nothing = false;
6975            match key {
6976                "commit_info" => {
6977                    if field_commit_info.is_some() {
6978                        return Err(::serde::de::Error::duplicate_field("commit_info"));
6979                    }
6980                    field_commit_info = Some(map.next_value()?);
6981                }
6982                "duration" => {
6983                    if field_duration.is_some() {
6984                        return Err(::serde::de::Error::duplicate_field("duration"));
6985                    }
6986                    field_duration = Some(map.next_value()?);
6987                }
6988                _ => {
6989                    // unknown field allowed and ignored
6990                    map.next_value::<::serde_json::Value>()?;
6991                }
6992            }
6993        }
6994        if optional && nothing {
6995            return Ok(None);
6996        }
6997        let result = GetTemporaryUploadLinkArg {
6998            commit_info: field_commit_info.ok_or_else(|| ::serde::de::Error::missing_field("commit_info"))?,
6999            duration: field_duration.unwrap_or(14400.0),
7000        };
7001        Ok(Some(result))
7002    }
7003
7004    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7005        &self,
7006        s: &mut S::SerializeStruct,
7007    ) -> Result<(), S::Error> {
7008        use serde::ser::SerializeStruct;
7009        s.serialize_field("commit_info", &self.commit_info)?;
7010        if self.duration != 14400.0 {
7011            s.serialize_field("duration", &self.duration)?;
7012        }
7013        Ok(())
7014    }
7015}
7016
7017impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryUploadLinkArg {
7018    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7019        // struct deserializer
7020        use serde::de::{MapAccess, Visitor};
7021        struct StructVisitor;
7022        impl<'de> Visitor<'de> for StructVisitor {
7023            type Value = GetTemporaryUploadLinkArg;
7024            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7025                f.write_str("a GetTemporaryUploadLinkArg struct")
7026            }
7027            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7028                GetTemporaryUploadLinkArg::internal_deserialize(map)
7029            }
7030        }
7031        deserializer.deserialize_struct("GetTemporaryUploadLinkArg", GET_TEMPORARY_UPLOAD_LINK_ARG_FIELDS, StructVisitor)
7032    }
7033}
7034
7035impl ::serde::ser::Serialize for GetTemporaryUploadLinkArg {
7036    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7037        // struct serializer
7038        use serde::ser::SerializeStruct;
7039        let mut s = serializer.serialize_struct("GetTemporaryUploadLinkArg", 2)?;
7040        self.internal_serialize::<S>(&mut s)?;
7041        s.end()
7042    }
7043}
7044
7045#[derive(Debug, Clone, PartialEq, Eq)]
7046#[non_exhaustive] // structs may have more fields added in the future.
7047pub struct GetTemporaryUploadLinkResult {
7048    /// The temporary link which can be used to stream a file to a Dropbox location.
7049    pub link: String,
7050}
7051
7052impl GetTemporaryUploadLinkResult {
7053    pub fn new(link: String) -> Self {
7054        GetTemporaryUploadLinkResult {
7055            link,
7056        }
7057    }
7058}
7059
7060const GET_TEMPORARY_UPLOAD_LINK_RESULT_FIELDS: &[&str] = &["link"];
7061impl GetTemporaryUploadLinkResult {
7062    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7063        map: V,
7064    ) -> Result<GetTemporaryUploadLinkResult, V::Error> {
7065        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7066    }
7067
7068    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7069        mut map: V,
7070        optional: bool,
7071    ) -> Result<Option<GetTemporaryUploadLinkResult>, V::Error> {
7072        let mut field_link = None;
7073        let mut nothing = true;
7074        while let Some(key) = map.next_key::<&str>()? {
7075            nothing = false;
7076            match key {
7077                "link" => {
7078                    if field_link.is_some() {
7079                        return Err(::serde::de::Error::duplicate_field("link"));
7080                    }
7081                    field_link = Some(map.next_value()?);
7082                }
7083                _ => {
7084                    // unknown field allowed and ignored
7085                    map.next_value::<::serde_json::Value>()?;
7086                }
7087            }
7088        }
7089        if optional && nothing {
7090            return Ok(None);
7091        }
7092        let result = GetTemporaryUploadLinkResult {
7093            link: field_link.ok_or_else(|| ::serde::de::Error::missing_field("link"))?,
7094        };
7095        Ok(Some(result))
7096    }
7097
7098    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7099        &self,
7100        s: &mut S::SerializeStruct,
7101    ) -> Result<(), S::Error> {
7102        use serde::ser::SerializeStruct;
7103        s.serialize_field("link", &self.link)?;
7104        Ok(())
7105    }
7106}
7107
7108impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryUploadLinkResult {
7109    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7110        // struct deserializer
7111        use serde::de::{MapAccess, Visitor};
7112        struct StructVisitor;
7113        impl<'de> Visitor<'de> for StructVisitor {
7114            type Value = GetTemporaryUploadLinkResult;
7115            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7116                f.write_str("a GetTemporaryUploadLinkResult struct")
7117            }
7118            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7119                GetTemporaryUploadLinkResult::internal_deserialize(map)
7120            }
7121        }
7122        deserializer.deserialize_struct("GetTemporaryUploadLinkResult", GET_TEMPORARY_UPLOAD_LINK_RESULT_FIELDS, StructVisitor)
7123    }
7124}
7125
7126impl ::serde::ser::Serialize for GetTemporaryUploadLinkResult {
7127    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7128        // struct serializer
7129        use serde::ser::SerializeStruct;
7130        let mut s = serializer.serialize_struct("GetTemporaryUploadLinkResult", 1)?;
7131        self.internal_serialize::<S>(&mut s)?;
7132        s.end()
7133    }
7134}
7135
7136/// Arguments for [`get_thumbnail_batch()`](crate::files::get_thumbnail_batch).
7137#[derive(Debug, Clone, PartialEq, Eq)]
7138#[non_exhaustive] // structs may have more fields added in the future.
7139pub struct GetThumbnailBatchArg {
7140    /// List of files to get thumbnails.
7141    pub entries: Vec<ThumbnailArg>,
7142}
7143
7144impl GetThumbnailBatchArg {
7145    pub fn new(entries: Vec<ThumbnailArg>) -> Self {
7146        GetThumbnailBatchArg {
7147            entries,
7148        }
7149    }
7150}
7151
7152const GET_THUMBNAIL_BATCH_ARG_FIELDS: &[&str] = &["entries"];
7153impl GetThumbnailBatchArg {
7154    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7155        map: V,
7156    ) -> Result<GetThumbnailBatchArg, V::Error> {
7157        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7158    }
7159
7160    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7161        mut map: V,
7162        optional: bool,
7163    ) -> Result<Option<GetThumbnailBatchArg>, V::Error> {
7164        let mut field_entries = None;
7165        let mut nothing = true;
7166        while let Some(key) = map.next_key::<&str>()? {
7167            nothing = false;
7168            match key {
7169                "entries" => {
7170                    if field_entries.is_some() {
7171                        return Err(::serde::de::Error::duplicate_field("entries"));
7172                    }
7173                    field_entries = Some(map.next_value()?);
7174                }
7175                _ => {
7176                    // unknown field allowed and ignored
7177                    map.next_value::<::serde_json::Value>()?;
7178                }
7179            }
7180        }
7181        if optional && nothing {
7182            return Ok(None);
7183        }
7184        let result = GetThumbnailBatchArg {
7185            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
7186        };
7187        Ok(Some(result))
7188    }
7189
7190    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7191        &self,
7192        s: &mut S::SerializeStruct,
7193    ) -> Result<(), S::Error> {
7194        use serde::ser::SerializeStruct;
7195        s.serialize_field("entries", &self.entries)?;
7196        Ok(())
7197    }
7198}
7199
7200impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchArg {
7201    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7202        // struct deserializer
7203        use serde::de::{MapAccess, Visitor};
7204        struct StructVisitor;
7205        impl<'de> Visitor<'de> for StructVisitor {
7206            type Value = GetThumbnailBatchArg;
7207            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7208                f.write_str("a GetThumbnailBatchArg struct")
7209            }
7210            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7211                GetThumbnailBatchArg::internal_deserialize(map)
7212            }
7213        }
7214        deserializer.deserialize_struct("GetThumbnailBatchArg", GET_THUMBNAIL_BATCH_ARG_FIELDS, StructVisitor)
7215    }
7216}
7217
7218impl ::serde::ser::Serialize for GetThumbnailBatchArg {
7219    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7220        // struct serializer
7221        use serde::ser::SerializeStruct;
7222        let mut s = serializer.serialize_struct("GetThumbnailBatchArg", 1)?;
7223        self.internal_serialize::<S>(&mut s)?;
7224        s.end()
7225    }
7226}
7227
7228#[derive(Debug, Clone, PartialEq, Eq)]
7229#[non_exhaustive] // variants may be added in the future
7230pub enum GetThumbnailBatchError {
7231    /// The operation involves more than 25 files.
7232    TooManyFiles,
7233    /// Catch-all used for unrecognized values returned from the server. Encountering this value
7234    /// typically indicates that this SDK version is out of date.
7235    Other,
7236}
7237
7238impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchError {
7239    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7240        // union deserializer
7241        use serde::de::{self, MapAccess, Visitor};
7242        struct EnumVisitor;
7243        impl<'de> Visitor<'de> for EnumVisitor {
7244            type Value = GetThumbnailBatchError;
7245            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7246                f.write_str("a GetThumbnailBatchError structure")
7247            }
7248            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
7249                let tag: &str = match map.next_key()? {
7250                    Some(".tag") => map.next_value()?,
7251                    _ => return Err(de::Error::missing_field(".tag"))
7252                };
7253                let value = match tag {
7254                    "too_many_files" => GetThumbnailBatchError::TooManyFiles,
7255                    _ => GetThumbnailBatchError::Other,
7256                };
7257                crate::eat_json_fields(&mut map)?;
7258                Ok(value)
7259            }
7260        }
7261        const VARIANTS: &[&str] = &["too_many_files",
7262                                    "other"];
7263        deserializer.deserialize_struct("GetThumbnailBatchError", VARIANTS, EnumVisitor)
7264    }
7265}
7266
7267impl ::serde::ser::Serialize for GetThumbnailBatchError {
7268    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7269        // union serializer
7270        use serde::ser::SerializeStruct;
7271        match self {
7272            GetThumbnailBatchError::TooManyFiles => {
7273                // unit
7274                let mut s = serializer.serialize_struct("GetThumbnailBatchError", 1)?;
7275                s.serialize_field(".tag", "too_many_files")?;
7276                s.end()
7277            }
7278            GetThumbnailBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
7279        }
7280    }
7281}
7282
7283impl ::std::error::Error for GetThumbnailBatchError {
7284}
7285
7286impl ::std::fmt::Display for GetThumbnailBatchError {
7287    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7288        match self {
7289            GetThumbnailBatchError::TooManyFiles => f.write_str("The operation involves more than 25 files."),
7290            _ => write!(f, "{:?}", *self),
7291        }
7292    }
7293}
7294
7295#[derive(Debug, Clone, PartialEq)]
7296#[non_exhaustive] // structs may have more fields added in the future.
7297pub struct GetThumbnailBatchResult {
7298    /// List of files and their thumbnails.
7299    pub entries: Vec<GetThumbnailBatchResultEntry>,
7300}
7301
7302impl GetThumbnailBatchResult {
7303    pub fn new(entries: Vec<GetThumbnailBatchResultEntry>) -> Self {
7304        GetThumbnailBatchResult {
7305            entries,
7306        }
7307    }
7308}
7309
7310const GET_THUMBNAIL_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
7311impl GetThumbnailBatchResult {
7312    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7313        map: V,
7314    ) -> Result<GetThumbnailBatchResult, V::Error> {
7315        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7316    }
7317
7318    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7319        mut map: V,
7320        optional: bool,
7321    ) -> Result<Option<GetThumbnailBatchResult>, V::Error> {
7322        let mut field_entries = None;
7323        let mut nothing = true;
7324        while let Some(key) = map.next_key::<&str>()? {
7325            nothing = false;
7326            match key {
7327                "entries" => {
7328                    if field_entries.is_some() {
7329                        return Err(::serde::de::Error::duplicate_field("entries"));
7330                    }
7331                    field_entries = Some(map.next_value()?);
7332                }
7333                _ => {
7334                    // unknown field allowed and ignored
7335                    map.next_value::<::serde_json::Value>()?;
7336                }
7337            }
7338        }
7339        if optional && nothing {
7340            return Ok(None);
7341        }
7342        let result = GetThumbnailBatchResult {
7343            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
7344        };
7345        Ok(Some(result))
7346    }
7347
7348    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7349        &self,
7350        s: &mut S::SerializeStruct,
7351    ) -> Result<(), S::Error> {
7352        use serde::ser::SerializeStruct;
7353        s.serialize_field("entries", &self.entries)?;
7354        Ok(())
7355    }
7356}
7357
7358impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResult {
7359    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7360        // struct deserializer
7361        use serde::de::{MapAccess, Visitor};
7362        struct StructVisitor;
7363        impl<'de> Visitor<'de> for StructVisitor {
7364            type Value = GetThumbnailBatchResult;
7365            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7366                f.write_str("a GetThumbnailBatchResult struct")
7367            }
7368            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7369                GetThumbnailBatchResult::internal_deserialize(map)
7370            }
7371        }
7372        deserializer.deserialize_struct("GetThumbnailBatchResult", GET_THUMBNAIL_BATCH_RESULT_FIELDS, StructVisitor)
7373    }
7374}
7375
7376impl ::serde::ser::Serialize for GetThumbnailBatchResult {
7377    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7378        // struct serializer
7379        use serde::ser::SerializeStruct;
7380        let mut s = serializer.serialize_struct("GetThumbnailBatchResult", 1)?;
7381        self.internal_serialize::<S>(&mut s)?;
7382        s.end()
7383    }
7384}
7385
7386#[derive(Debug, Clone, PartialEq)]
7387#[non_exhaustive] // structs may have more fields added in the future.
7388pub struct GetThumbnailBatchResultData {
7389    pub metadata: FileMetadata,
7390    /// A string containing the base64-encoded thumbnail data for this file.
7391    pub thumbnail: String,
7392}
7393
7394impl GetThumbnailBatchResultData {
7395    pub fn new(metadata: FileMetadata, thumbnail: String) -> Self {
7396        GetThumbnailBatchResultData {
7397            metadata,
7398            thumbnail,
7399        }
7400    }
7401}
7402
7403const GET_THUMBNAIL_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata",
7404                                                          "thumbnail"];
7405impl GetThumbnailBatchResultData {
7406    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7407        map: V,
7408    ) -> Result<GetThumbnailBatchResultData, V::Error> {
7409        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7410    }
7411
7412    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7413        mut map: V,
7414        optional: bool,
7415    ) -> Result<Option<GetThumbnailBatchResultData>, V::Error> {
7416        let mut field_metadata = None;
7417        let mut field_thumbnail = None;
7418        let mut nothing = true;
7419        while let Some(key) = map.next_key::<&str>()? {
7420            nothing = false;
7421            match key {
7422                "metadata" => {
7423                    if field_metadata.is_some() {
7424                        return Err(::serde::de::Error::duplicate_field("metadata"));
7425                    }
7426                    field_metadata = Some(map.next_value()?);
7427                }
7428                "thumbnail" => {
7429                    if field_thumbnail.is_some() {
7430                        return Err(::serde::de::Error::duplicate_field("thumbnail"));
7431                    }
7432                    field_thumbnail = Some(map.next_value()?);
7433                }
7434                _ => {
7435                    // unknown field allowed and ignored
7436                    map.next_value::<::serde_json::Value>()?;
7437                }
7438            }
7439        }
7440        if optional && nothing {
7441            return Ok(None);
7442        }
7443        let result = GetThumbnailBatchResultData {
7444            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
7445            thumbnail: field_thumbnail.ok_or_else(|| ::serde::de::Error::missing_field("thumbnail"))?,
7446        };
7447        Ok(Some(result))
7448    }
7449
7450    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7451        &self,
7452        s: &mut S::SerializeStruct,
7453    ) -> Result<(), S::Error> {
7454        use serde::ser::SerializeStruct;
7455        s.serialize_field("metadata", &self.metadata)?;
7456        s.serialize_field("thumbnail", &self.thumbnail)?;
7457        Ok(())
7458    }
7459}
7460
7461impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResultData {
7462    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7463        // struct deserializer
7464        use serde::de::{MapAccess, Visitor};
7465        struct StructVisitor;
7466        impl<'de> Visitor<'de> for StructVisitor {
7467            type Value = GetThumbnailBatchResultData;
7468            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7469                f.write_str("a GetThumbnailBatchResultData struct")
7470            }
7471            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7472                GetThumbnailBatchResultData::internal_deserialize(map)
7473            }
7474        }
7475        deserializer.deserialize_struct("GetThumbnailBatchResultData", GET_THUMBNAIL_BATCH_RESULT_DATA_FIELDS, StructVisitor)
7476    }
7477}
7478
7479impl ::serde::ser::Serialize for GetThumbnailBatchResultData {
7480    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7481        // struct serializer
7482        use serde::ser::SerializeStruct;
7483        let mut s = serializer.serialize_struct("GetThumbnailBatchResultData", 2)?;
7484        self.internal_serialize::<S>(&mut s)?;
7485        s.end()
7486    }
7487}
7488
7489#[derive(Debug, Clone, PartialEq)]
7490#[non_exhaustive] // variants may be added in the future
7491pub enum GetThumbnailBatchResultEntry {
7492    Success(GetThumbnailBatchResultData),
7493    /// The result for this file if it was an error.
7494    Failure(ThumbnailError),
7495    /// Catch-all used for unrecognized values returned from the server. Encountering this value
7496    /// typically indicates that this SDK version is out of date.
7497    Other,
7498}
7499
7500impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResultEntry {
7501    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7502        // union deserializer
7503        use serde::de::{self, MapAccess, Visitor};
7504        struct EnumVisitor;
7505        impl<'de> Visitor<'de> for EnumVisitor {
7506            type Value = GetThumbnailBatchResultEntry;
7507            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7508                f.write_str("a GetThumbnailBatchResultEntry structure")
7509            }
7510            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
7511                let tag: &str = match map.next_key()? {
7512                    Some(".tag") => map.next_value()?,
7513                    _ => return Err(de::Error::missing_field(".tag"))
7514                };
7515                let value = match tag {
7516                    "success" => GetThumbnailBatchResultEntry::Success(GetThumbnailBatchResultData::internal_deserialize(&mut map)?),
7517                    "failure" => {
7518                        match map.next_key()? {
7519                            Some("failure") => GetThumbnailBatchResultEntry::Failure(map.next_value()?),
7520                            None => return Err(de::Error::missing_field("failure")),
7521                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
7522                        }
7523                    }
7524                    _ => GetThumbnailBatchResultEntry::Other,
7525                };
7526                crate::eat_json_fields(&mut map)?;
7527                Ok(value)
7528            }
7529        }
7530        const VARIANTS: &[&str] = &["success",
7531                                    "failure",
7532                                    "other"];
7533        deserializer.deserialize_struct("GetThumbnailBatchResultEntry", VARIANTS, EnumVisitor)
7534    }
7535}
7536
7537impl ::serde::ser::Serialize for GetThumbnailBatchResultEntry {
7538    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7539        // union serializer
7540        use serde::ser::SerializeStruct;
7541        match self {
7542            GetThumbnailBatchResultEntry::Success(x) => {
7543                // struct
7544                let mut s = serializer.serialize_struct("GetThumbnailBatchResultEntry", 3)?;
7545                s.serialize_field(".tag", "success")?;
7546                x.internal_serialize::<S>(&mut s)?;
7547                s.end()
7548            }
7549            GetThumbnailBatchResultEntry::Failure(x) => {
7550                // union or polymporphic struct
7551                let mut s = serializer.serialize_struct("GetThumbnailBatchResultEntry", 2)?;
7552                s.serialize_field(".tag", "failure")?;
7553                s.serialize_field("failure", x)?;
7554                s.end()
7555            }
7556            GetThumbnailBatchResultEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
7557        }
7558    }
7559}
7560
7561/// GPS coordinates for a photo or video.
7562#[derive(Debug, Clone, PartialEq)]
7563#[non_exhaustive] // structs may have more fields added in the future.
7564pub struct GpsCoordinates {
7565    /// Latitude of the GPS coordinates.
7566    pub latitude: f64,
7567    /// Longitude of the GPS coordinates.
7568    pub longitude: f64,
7569}
7570
7571impl GpsCoordinates {
7572    pub fn new(latitude: f64, longitude: f64) -> Self {
7573        GpsCoordinates {
7574            latitude,
7575            longitude,
7576        }
7577    }
7578}
7579
7580const GPS_COORDINATES_FIELDS: &[&str] = &["latitude",
7581                                          "longitude"];
7582impl GpsCoordinates {
7583    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7584        map: V,
7585    ) -> Result<GpsCoordinates, V::Error> {
7586        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7587    }
7588
7589    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7590        mut map: V,
7591        optional: bool,
7592    ) -> Result<Option<GpsCoordinates>, V::Error> {
7593        let mut field_latitude = None;
7594        let mut field_longitude = None;
7595        let mut nothing = true;
7596        while let Some(key) = map.next_key::<&str>()? {
7597            nothing = false;
7598            match key {
7599                "latitude" => {
7600                    if field_latitude.is_some() {
7601                        return Err(::serde::de::Error::duplicate_field("latitude"));
7602                    }
7603                    field_latitude = Some(map.next_value()?);
7604                }
7605                "longitude" => {
7606                    if field_longitude.is_some() {
7607                        return Err(::serde::de::Error::duplicate_field("longitude"));
7608                    }
7609                    field_longitude = Some(map.next_value()?);
7610                }
7611                _ => {
7612                    // unknown field allowed and ignored
7613                    map.next_value::<::serde_json::Value>()?;
7614                }
7615            }
7616        }
7617        if optional && nothing {
7618            return Ok(None);
7619        }
7620        let result = GpsCoordinates {
7621            latitude: field_latitude.ok_or_else(|| ::serde::de::Error::missing_field("latitude"))?,
7622            longitude: field_longitude.ok_or_else(|| ::serde::de::Error::missing_field("longitude"))?,
7623        };
7624        Ok(Some(result))
7625    }
7626
7627    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7628        &self,
7629        s: &mut S::SerializeStruct,
7630    ) -> Result<(), S::Error> {
7631        use serde::ser::SerializeStruct;
7632        s.serialize_field("latitude", &self.latitude)?;
7633        s.serialize_field("longitude", &self.longitude)?;
7634        Ok(())
7635    }
7636}
7637
7638impl<'de> ::serde::de::Deserialize<'de> for GpsCoordinates {
7639    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7640        // struct deserializer
7641        use serde::de::{MapAccess, Visitor};
7642        struct StructVisitor;
7643        impl<'de> Visitor<'de> for StructVisitor {
7644            type Value = GpsCoordinates;
7645            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7646                f.write_str("a GpsCoordinates struct")
7647            }
7648            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7649                GpsCoordinates::internal_deserialize(map)
7650            }
7651        }
7652        deserializer.deserialize_struct("GpsCoordinates", GPS_COORDINATES_FIELDS, StructVisitor)
7653    }
7654}
7655
7656impl ::serde::ser::Serialize for GpsCoordinates {
7657    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7658        // struct serializer
7659        use serde::ser::SerializeStruct;
7660        let mut s = serializer.serialize_struct("GpsCoordinates", 2)?;
7661        self.internal_serialize::<S>(&mut s)?;
7662        s.end()
7663    }
7664}
7665
7666#[derive(Debug, Clone, PartialEq, Eq)]
7667#[non_exhaustive] // structs may have more fields added in the future.
7668pub struct HighlightSpan {
7669    /// String to be determined whether it should be highlighted or not.
7670    pub highlight_str: String,
7671    /// The string should be highlighted or not.
7672    pub is_highlighted: bool,
7673}
7674
7675impl HighlightSpan {
7676    pub fn new(highlight_str: String, is_highlighted: bool) -> Self {
7677        HighlightSpan {
7678            highlight_str,
7679            is_highlighted,
7680        }
7681    }
7682}
7683
7684const HIGHLIGHT_SPAN_FIELDS: &[&str] = &["highlight_str",
7685                                         "is_highlighted"];
7686impl HighlightSpan {
7687    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7688        map: V,
7689    ) -> Result<HighlightSpan, V::Error> {
7690        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7691    }
7692
7693    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7694        mut map: V,
7695        optional: bool,
7696    ) -> Result<Option<HighlightSpan>, V::Error> {
7697        let mut field_highlight_str = None;
7698        let mut field_is_highlighted = None;
7699        let mut nothing = true;
7700        while let Some(key) = map.next_key::<&str>()? {
7701            nothing = false;
7702            match key {
7703                "highlight_str" => {
7704                    if field_highlight_str.is_some() {
7705                        return Err(::serde::de::Error::duplicate_field("highlight_str"));
7706                    }
7707                    field_highlight_str = Some(map.next_value()?);
7708                }
7709                "is_highlighted" => {
7710                    if field_is_highlighted.is_some() {
7711                        return Err(::serde::de::Error::duplicate_field("is_highlighted"));
7712                    }
7713                    field_is_highlighted = Some(map.next_value()?);
7714                }
7715                _ => {
7716                    // unknown field allowed and ignored
7717                    map.next_value::<::serde_json::Value>()?;
7718                }
7719            }
7720        }
7721        if optional && nothing {
7722            return Ok(None);
7723        }
7724        let result = HighlightSpan {
7725            highlight_str: field_highlight_str.ok_or_else(|| ::serde::de::Error::missing_field("highlight_str"))?,
7726            is_highlighted: field_is_highlighted.ok_or_else(|| ::serde::de::Error::missing_field("is_highlighted"))?,
7727        };
7728        Ok(Some(result))
7729    }
7730
7731    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7732        &self,
7733        s: &mut S::SerializeStruct,
7734    ) -> Result<(), S::Error> {
7735        use serde::ser::SerializeStruct;
7736        s.serialize_field("highlight_str", &self.highlight_str)?;
7737        s.serialize_field("is_highlighted", &self.is_highlighted)?;
7738        Ok(())
7739    }
7740}
7741
7742impl<'de> ::serde::de::Deserialize<'de> for HighlightSpan {
7743    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7744        // struct deserializer
7745        use serde::de::{MapAccess, Visitor};
7746        struct StructVisitor;
7747        impl<'de> Visitor<'de> for StructVisitor {
7748            type Value = HighlightSpan;
7749            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7750                f.write_str("a HighlightSpan struct")
7751            }
7752            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7753                HighlightSpan::internal_deserialize(map)
7754            }
7755        }
7756        deserializer.deserialize_struct("HighlightSpan", HIGHLIGHT_SPAN_FIELDS, StructVisitor)
7757    }
7758}
7759
7760impl ::serde::ser::Serialize for HighlightSpan {
7761    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7762        // struct serializer
7763        use serde::ser::SerializeStruct;
7764        let mut s = serializer.serialize_struct("HighlightSpan", 2)?;
7765        self.internal_serialize::<S>(&mut s)?;
7766        s.end()
7767    }
7768}
7769
7770/// The import format of the incoming Paper doc content.
7771#[derive(Debug, Clone, PartialEq, Eq)]
7772#[non_exhaustive] // variants may be added in the future
7773pub enum ImportFormat {
7774    /// The provided data is interpreted as standard HTML.
7775    Html,
7776    /// The provided data is interpreted as markdown.
7777    Markdown,
7778    /// The provided data is interpreted as plain text.
7779    PlainText,
7780    /// Catch-all used for unrecognized values returned from the server. Encountering this value
7781    /// typically indicates that this SDK version is out of date.
7782    Other,
7783}
7784
7785impl<'de> ::serde::de::Deserialize<'de> for ImportFormat {
7786    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7787        // union deserializer
7788        use serde::de::{self, MapAccess, Visitor};
7789        struct EnumVisitor;
7790        impl<'de> Visitor<'de> for EnumVisitor {
7791            type Value = ImportFormat;
7792            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7793                f.write_str("a ImportFormat structure")
7794            }
7795            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
7796                let tag: &str = match map.next_key()? {
7797                    Some(".tag") => map.next_value()?,
7798                    _ => return Err(de::Error::missing_field(".tag"))
7799                };
7800                let value = match tag {
7801                    "html" => ImportFormat::Html,
7802                    "markdown" => ImportFormat::Markdown,
7803                    "plain_text" => ImportFormat::PlainText,
7804                    _ => ImportFormat::Other,
7805                };
7806                crate::eat_json_fields(&mut map)?;
7807                Ok(value)
7808            }
7809        }
7810        const VARIANTS: &[&str] = &["html",
7811                                    "markdown",
7812                                    "plain_text",
7813                                    "other"];
7814        deserializer.deserialize_struct("ImportFormat", VARIANTS, EnumVisitor)
7815    }
7816}
7817
7818impl ::serde::ser::Serialize for ImportFormat {
7819    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7820        // union serializer
7821        use serde::ser::SerializeStruct;
7822        match self {
7823            ImportFormat::Html => {
7824                // unit
7825                let mut s = serializer.serialize_struct("ImportFormat", 1)?;
7826                s.serialize_field(".tag", "html")?;
7827                s.end()
7828            }
7829            ImportFormat::Markdown => {
7830                // unit
7831                let mut s = serializer.serialize_struct("ImportFormat", 1)?;
7832                s.serialize_field(".tag", "markdown")?;
7833                s.end()
7834            }
7835            ImportFormat::PlainText => {
7836                // unit
7837                let mut s = serializer.serialize_struct("ImportFormat", 1)?;
7838                s.serialize_field(".tag", "plain_text")?;
7839                s.end()
7840            }
7841            ImportFormat::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
7842        }
7843    }
7844}
7845
7846#[derive(Debug, Clone, PartialEq, Eq)]
7847#[non_exhaustive] // structs may have more fields added in the future.
7848pub struct ListFolderArg {
7849    /// A unique identifier for the file.
7850    pub path: PathROrId,
7851    /// If true, the list folder operation will be applied recursively to all subfolders and the
7852    /// response will contain contents of all subfolders.
7853    pub recursive: bool,
7854    /// If true, [`FileMetadata::media_info`](FileMetadata) is set for photo and video. This
7855    /// parameter will no longer have an effect starting December 2, 2019.
7856    pub include_media_info: bool,
7857    /// If true, the results will include entries for files and folders that used to exist but were
7858    /// deleted.
7859    pub include_deleted: bool,
7860    /// If true, the results will include a flag for each file indicating whether or not  that file
7861    /// has any explicit members.
7862    pub include_has_explicit_shared_members: bool,
7863    /// If true, the results will include entries under mounted folders which includes app folder,
7864    /// shared folder and team folder.
7865    pub include_mounted_folders: bool,
7866    /// The maximum number of results to return per request. Note: This is an approximate number and
7867    /// there can be slightly more entries returned in some cases.
7868    pub limit: Option<u32>,
7869    /// A shared link to list the contents of. If the link is password-protected, the password must
7870    /// be provided. If this field is present, [`ListFolderArg::path`](ListFolderArg) will be
7871    /// relative to root of the shared link. Only non-recursive mode is supported for shared link.
7872    pub shared_link: Option<SharedLink>,
7873    /// If set to a valid list of template IDs, [`FileMetadata::property_groups`](FileMetadata) is
7874    /// set if there exists property data associated with the file and each of the listed templates.
7875    pub include_property_groups: Option<crate::types::file_properties::TemplateFilterBase>,
7876    /// If true, include files that are not downloadable, i.e. Google Docs.
7877    pub include_non_downloadable_files: bool,
7878}
7879
7880impl ListFolderArg {
7881    pub fn new(path: PathROrId) -> Self {
7882        ListFolderArg {
7883            path,
7884            recursive: false,
7885            include_media_info: false,
7886            include_deleted: false,
7887            include_has_explicit_shared_members: false,
7888            include_mounted_folders: true,
7889            limit: None,
7890            shared_link: None,
7891            include_property_groups: None,
7892            include_non_downloadable_files: true,
7893        }
7894    }
7895
7896    pub fn with_recursive(mut self, value: bool) -> Self {
7897        self.recursive = value;
7898        self
7899    }
7900
7901    pub fn with_include_media_info(mut self, value: bool) -> Self {
7902        self.include_media_info = value;
7903        self
7904    }
7905
7906    pub fn with_include_deleted(mut self, value: bool) -> Self {
7907        self.include_deleted = value;
7908        self
7909    }
7910
7911    pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
7912        self.include_has_explicit_shared_members = value;
7913        self
7914    }
7915
7916    pub fn with_include_mounted_folders(mut self, value: bool) -> Self {
7917        self.include_mounted_folders = value;
7918        self
7919    }
7920
7921    pub fn with_limit(mut self, value: u32) -> Self {
7922        self.limit = Some(value);
7923        self
7924    }
7925
7926    pub fn with_shared_link(mut self, value: SharedLink) -> Self {
7927        self.shared_link = Some(value);
7928        self
7929    }
7930
7931    pub fn with_include_property_groups(
7932        mut self,
7933        value: crate::types::file_properties::TemplateFilterBase,
7934    ) -> Self {
7935        self.include_property_groups = Some(value);
7936        self
7937    }
7938
7939    pub fn with_include_non_downloadable_files(mut self, value: bool) -> Self {
7940        self.include_non_downloadable_files = value;
7941        self
7942    }
7943}
7944
7945const LIST_FOLDER_ARG_FIELDS: &[&str] = &["path",
7946                                          "recursive",
7947                                          "include_media_info",
7948                                          "include_deleted",
7949                                          "include_has_explicit_shared_members",
7950                                          "include_mounted_folders",
7951                                          "limit",
7952                                          "shared_link",
7953                                          "include_property_groups",
7954                                          "include_non_downloadable_files"];
7955impl ListFolderArg {
7956    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7957        map: V,
7958    ) -> Result<ListFolderArg, V::Error> {
7959        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7960    }
7961
7962    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7963        mut map: V,
7964        optional: bool,
7965    ) -> Result<Option<ListFolderArg>, V::Error> {
7966        let mut field_path = None;
7967        let mut field_recursive = None;
7968        let mut field_include_media_info = None;
7969        let mut field_include_deleted = None;
7970        let mut field_include_has_explicit_shared_members = None;
7971        let mut field_include_mounted_folders = None;
7972        let mut field_limit = None;
7973        let mut field_shared_link = None;
7974        let mut field_include_property_groups = None;
7975        let mut field_include_non_downloadable_files = None;
7976        let mut nothing = true;
7977        while let Some(key) = map.next_key::<&str>()? {
7978            nothing = false;
7979            match key {
7980                "path" => {
7981                    if field_path.is_some() {
7982                        return Err(::serde::de::Error::duplicate_field("path"));
7983                    }
7984                    field_path = Some(map.next_value()?);
7985                }
7986                "recursive" => {
7987                    if field_recursive.is_some() {
7988                        return Err(::serde::de::Error::duplicate_field("recursive"));
7989                    }
7990                    field_recursive = Some(map.next_value()?);
7991                }
7992                "include_media_info" => {
7993                    if field_include_media_info.is_some() {
7994                        return Err(::serde::de::Error::duplicate_field("include_media_info"));
7995                    }
7996                    field_include_media_info = Some(map.next_value()?);
7997                }
7998                "include_deleted" => {
7999                    if field_include_deleted.is_some() {
8000                        return Err(::serde::de::Error::duplicate_field("include_deleted"));
8001                    }
8002                    field_include_deleted = Some(map.next_value()?);
8003                }
8004                "include_has_explicit_shared_members" => {
8005                    if field_include_has_explicit_shared_members.is_some() {
8006                        return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
8007                    }
8008                    field_include_has_explicit_shared_members = Some(map.next_value()?);
8009                }
8010                "include_mounted_folders" => {
8011                    if field_include_mounted_folders.is_some() {
8012                        return Err(::serde::de::Error::duplicate_field("include_mounted_folders"));
8013                    }
8014                    field_include_mounted_folders = Some(map.next_value()?);
8015                }
8016                "limit" => {
8017                    if field_limit.is_some() {
8018                        return Err(::serde::de::Error::duplicate_field("limit"));
8019                    }
8020                    field_limit = Some(map.next_value()?);
8021                }
8022                "shared_link" => {
8023                    if field_shared_link.is_some() {
8024                        return Err(::serde::de::Error::duplicate_field("shared_link"));
8025                    }
8026                    field_shared_link = Some(map.next_value()?);
8027                }
8028                "include_property_groups" => {
8029                    if field_include_property_groups.is_some() {
8030                        return Err(::serde::de::Error::duplicate_field("include_property_groups"));
8031                    }
8032                    field_include_property_groups = Some(map.next_value()?);
8033                }
8034                "include_non_downloadable_files" => {
8035                    if field_include_non_downloadable_files.is_some() {
8036                        return Err(::serde::de::Error::duplicate_field("include_non_downloadable_files"));
8037                    }
8038                    field_include_non_downloadable_files = Some(map.next_value()?);
8039                }
8040                _ => {
8041                    // unknown field allowed and ignored
8042                    map.next_value::<::serde_json::Value>()?;
8043                }
8044            }
8045        }
8046        if optional && nothing {
8047            return Ok(None);
8048        }
8049        let result = ListFolderArg {
8050            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
8051            recursive: field_recursive.unwrap_or(false),
8052            include_media_info: field_include_media_info.unwrap_or(false),
8053            include_deleted: field_include_deleted.unwrap_or(false),
8054            include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
8055            include_mounted_folders: field_include_mounted_folders.unwrap_or(true),
8056            limit: field_limit.and_then(Option::flatten),
8057            shared_link: field_shared_link.and_then(Option::flatten),
8058            include_property_groups: field_include_property_groups.and_then(Option::flatten),
8059            include_non_downloadable_files: field_include_non_downloadable_files.unwrap_or(true),
8060        };
8061        Ok(Some(result))
8062    }
8063
8064    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8065        &self,
8066        s: &mut S::SerializeStruct,
8067    ) -> Result<(), S::Error> {
8068        use serde::ser::SerializeStruct;
8069        s.serialize_field("path", &self.path)?;
8070        if self.recursive {
8071            s.serialize_field("recursive", &self.recursive)?;
8072        }
8073        if self.include_media_info {
8074            s.serialize_field("include_media_info", &self.include_media_info)?;
8075        }
8076        if self.include_deleted {
8077            s.serialize_field("include_deleted", &self.include_deleted)?;
8078        }
8079        if self.include_has_explicit_shared_members {
8080            s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
8081        }
8082        if !self.include_mounted_folders {
8083            s.serialize_field("include_mounted_folders", &self.include_mounted_folders)?;
8084        }
8085        if let Some(val) = &self.limit {
8086            s.serialize_field("limit", val)?;
8087        }
8088        if let Some(val) = &self.shared_link {
8089            s.serialize_field("shared_link", val)?;
8090        }
8091        if let Some(val) = &self.include_property_groups {
8092            s.serialize_field("include_property_groups", val)?;
8093        }
8094        if !self.include_non_downloadable_files {
8095            s.serialize_field("include_non_downloadable_files", &self.include_non_downloadable_files)?;
8096        }
8097        Ok(())
8098    }
8099}
8100
8101impl<'de> ::serde::de::Deserialize<'de> for ListFolderArg {
8102    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8103        // struct deserializer
8104        use serde::de::{MapAccess, Visitor};
8105        struct StructVisitor;
8106        impl<'de> Visitor<'de> for StructVisitor {
8107            type Value = ListFolderArg;
8108            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8109                f.write_str("a ListFolderArg struct")
8110            }
8111            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8112                ListFolderArg::internal_deserialize(map)
8113            }
8114        }
8115        deserializer.deserialize_struct("ListFolderArg", LIST_FOLDER_ARG_FIELDS, StructVisitor)
8116    }
8117}
8118
8119impl ::serde::ser::Serialize for ListFolderArg {
8120    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8121        // struct serializer
8122        use serde::ser::SerializeStruct;
8123        let mut s = serializer.serialize_struct("ListFolderArg", 10)?;
8124        self.internal_serialize::<S>(&mut s)?;
8125        s.end()
8126    }
8127}
8128
8129#[derive(Debug, Clone, PartialEq, Eq)]
8130#[non_exhaustive] // structs may have more fields added in the future.
8131pub struct ListFolderContinueArg {
8132    /// The cursor returned by your last call to [`list_folder()`](crate::files::list_folder) or
8133    /// [`list_folder_continue()`](crate::files::list_folder_continue).
8134    pub cursor: ListFolderCursor,
8135}
8136
8137impl ListFolderContinueArg {
8138    pub fn new(cursor: ListFolderCursor) -> Self {
8139        ListFolderContinueArg {
8140            cursor,
8141        }
8142    }
8143}
8144
8145const LIST_FOLDER_CONTINUE_ARG_FIELDS: &[&str] = &["cursor"];
8146impl ListFolderContinueArg {
8147    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8148        map: V,
8149    ) -> Result<ListFolderContinueArg, V::Error> {
8150        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8151    }
8152
8153    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8154        mut map: V,
8155        optional: bool,
8156    ) -> Result<Option<ListFolderContinueArg>, V::Error> {
8157        let mut field_cursor = None;
8158        let mut nothing = true;
8159        while let Some(key) = map.next_key::<&str>()? {
8160            nothing = false;
8161            match key {
8162                "cursor" => {
8163                    if field_cursor.is_some() {
8164                        return Err(::serde::de::Error::duplicate_field("cursor"));
8165                    }
8166                    field_cursor = Some(map.next_value()?);
8167                }
8168                _ => {
8169                    // unknown field allowed and ignored
8170                    map.next_value::<::serde_json::Value>()?;
8171                }
8172            }
8173        }
8174        if optional && nothing {
8175            return Ok(None);
8176        }
8177        let result = ListFolderContinueArg {
8178            cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8179        };
8180        Ok(Some(result))
8181    }
8182
8183    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8184        &self,
8185        s: &mut S::SerializeStruct,
8186    ) -> Result<(), S::Error> {
8187        use serde::ser::SerializeStruct;
8188        s.serialize_field("cursor", &self.cursor)?;
8189        Ok(())
8190    }
8191}
8192
8193impl<'de> ::serde::de::Deserialize<'de> for ListFolderContinueArg {
8194    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8195        // struct deserializer
8196        use serde::de::{MapAccess, Visitor};
8197        struct StructVisitor;
8198        impl<'de> Visitor<'de> for StructVisitor {
8199            type Value = ListFolderContinueArg;
8200            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8201                f.write_str("a ListFolderContinueArg struct")
8202            }
8203            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8204                ListFolderContinueArg::internal_deserialize(map)
8205            }
8206        }
8207        deserializer.deserialize_struct("ListFolderContinueArg", LIST_FOLDER_CONTINUE_ARG_FIELDS, StructVisitor)
8208    }
8209}
8210
8211impl ::serde::ser::Serialize for ListFolderContinueArg {
8212    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8213        // struct serializer
8214        use serde::ser::SerializeStruct;
8215        let mut s = serializer.serialize_struct("ListFolderContinueArg", 1)?;
8216        self.internal_serialize::<S>(&mut s)?;
8217        s.end()
8218    }
8219}
8220
8221#[derive(Debug, Clone, PartialEq, Eq)]
8222#[non_exhaustive] // variants may be added in the future
8223pub enum ListFolderContinueError {
8224    Path(LookupError),
8225    /// Indicates that the cursor has been invalidated. Call
8226    /// [`list_folder()`](crate::files::list_folder) to obtain a new cursor.
8227    Reset,
8228    /// Catch-all used for unrecognized values returned from the server. Encountering this value
8229    /// typically indicates that this SDK version is out of date.
8230    Other,
8231}
8232
8233impl<'de> ::serde::de::Deserialize<'de> for ListFolderContinueError {
8234    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8235        // union deserializer
8236        use serde::de::{self, MapAccess, Visitor};
8237        struct EnumVisitor;
8238        impl<'de> Visitor<'de> for EnumVisitor {
8239            type Value = ListFolderContinueError;
8240            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8241                f.write_str("a ListFolderContinueError structure")
8242            }
8243            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
8244                let tag: &str = match map.next_key()? {
8245                    Some(".tag") => map.next_value()?,
8246                    _ => return Err(de::Error::missing_field(".tag"))
8247                };
8248                let value = match tag {
8249                    "path" => {
8250                        match map.next_key()? {
8251                            Some("path") => ListFolderContinueError::Path(map.next_value()?),
8252                            None => return Err(de::Error::missing_field("path")),
8253                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
8254                        }
8255                    }
8256                    "reset" => ListFolderContinueError::Reset,
8257                    _ => ListFolderContinueError::Other,
8258                };
8259                crate::eat_json_fields(&mut map)?;
8260                Ok(value)
8261            }
8262        }
8263        const VARIANTS: &[&str] = &["path",
8264                                    "reset",
8265                                    "other"];
8266        deserializer.deserialize_struct("ListFolderContinueError", VARIANTS, EnumVisitor)
8267    }
8268}
8269
8270impl ::serde::ser::Serialize for ListFolderContinueError {
8271    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8272        // union serializer
8273        use serde::ser::SerializeStruct;
8274        match self {
8275            ListFolderContinueError::Path(x) => {
8276                // union or polymporphic struct
8277                let mut s = serializer.serialize_struct("ListFolderContinueError", 2)?;
8278                s.serialize_field(".tag", "path")?;
8279                s.serialize_field("path", x)?;
8280                s.end()
8281            }
8282            ListFolderContinueError::Reset => {
8283                // unit
8284                let mut s = serializer.serialize_struct("ListFolderContinueError", 1)?;
8285                s.serialize_field(".tag", "reset")?;
8286                s.end()
8287            }
8288            ListFolderContinueError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
8289        }
8290    }
8291}
8292
8293impl ::std::error::Error for ListFolderContinueError {
8294    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
8295        match self {
8296            ListFolderContinueError::Path(inner) => Some(inner),
8297            _ => None,
8298        }
8299    }
8300}
8301
8302impl ::std::fmt::Display for ListFolderContinueError {
8303    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8304        match self {
8305            ListFolderContinueError::Path(inner) => write!(f, "ListFolderContinueError: {}", inner),
8306            _ => write!(f, "{:?}", *self),
8307        }
8308    }
8309}
8310
8311#[derive(Debug, Clone, PartialEq, Eq)]
8312#[non_exhaustive] // variants may be added in the future
8313pub enum ListFolderError {
8314    Path(LookupError),
8315    TemplateError(crate::types::file_properties::TemplateError),
8316    /// Catch-all used for unrecognized values returned from the server. Encountering this value
8317    /// typically indicates that this SDK version is out of date.
8318    Other,
8319}
8320
8321impl<'de> ::serde::de::Deserialize<'de> for ListFolderError {
8322    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8323        // union deserializer
8324        use serde::de::{self, MapAccess, Visitor};
8325        struct EnumVisitor;
8326        impl<'de> Visitor<'de> for EnumVisitor {
8327            type Value = ListFolderError;
8328            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8329                f.write_str("a ListFolderError structure")
8330            }
8331            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
8332                let tag: &str = match map.next_key()? {
8333                    Some(".tag") => map.next_value()?,
8334                    _ => return Err(de::Error::missing_field(".tag"))
8335                };
8336                let value = match tag {
8337                    "path" => {
8338                        match map.next_key()? {
8339                            Some("path") => ListFolderError::Path(map.next_value()?),
8340                            None => return Err(de::Error::missing_field("path")),
8341                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
8342                        }
8343                    }
8344                    "template_error" => {
8345                        match map.next_key()? {
8346                            Some("template_error") => ListFolderError::TemplateError(map.next_value()?),
8347                            None => return Err(de::Error::missing_field("template_error")),
8348                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
8349                        }
8350                    }
8351                    _ => ListFolderError::Other,
8352                };
8353                crate::eat_json_fields(&mut map)?;
8354                Ok(value)
8355            }
8356        }
8357        const VARIANTS: &[&str] = &["path",
8358                                    "template_error",
8359                                    "other"];
8360        deserializer.deserialize_struct("ListFolderError", VARIANTS, EnumVisitor)
8361    }
8362}
8363
8364impl ::serde::ser::Serialize for ListFolderError {
8365    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8366        // union serializer
8367        use serde::ser::SerializeStruct;
8368        match self {
8369            ListFolderError::Path(x) => {
8370                // union or polymporphic struct
8371                let mut s = serializer.serialize_struct("ListFolderError", 2)?;
8372                s.serialize_field(".tag", "path")?;
8373                s.serialize_field("path", x)?;
8374                s.end()
8375            }
8376            ListFolderError::TemplateError(x) => {
8377                // union or polymporphic struct
8378                let mut s = serializer.serialize_struct("ListFolderError", 2)?;
8379                s.serialize_field(".tag", "template_error")?;
8380                s.serialize_field("template_error", x)?;
8381                s.end()
8382            }
8383            ListFolderError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
8384        }
8385    }
8386}
8387
8388impl ::std::error::Error for ListFolderError {
8389    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
8390        match self {
8391            ListFolderError::Path(inner) => Some(inner),
8392            ListFolderError::TemplateError(inner) => Some(inner),
8393            _ => None,
8394        }
8395    }
8396}
8397
8398impl ::std::fmt::Display for ListFolderError {
8399    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8400        match self {
8401            ListFolderError::Path(inner) => write!(f, "ListFolderError: {}", inner),
8402            ListFolderError::TemplateError(inner) => write!(f, "ListFolderError: {}", inner),
8403            _ => write!(f, "{:?}", *self),
8404        }
8405    }
8406}
8407
8408#[derive(Debug, Clone, PartialEq, Eq)]
8409#[non_exhaustive] // structs may have more fields added in the future.
8410pub struct ListFolderGetLatestCursorResult {
8411    /// Pass the cursor into [`list_folder_continue()`](crate::files::list_folder_continue) to see
8412    /// what's changed in the folder since your previous query.
8413    pub cursor: ListFolderCursor,
8414}
8415
8416impl ListFolderGetLatestCursorResult {
8417    pub fn new(cursor: ListFolderCursor) -> Self {
8418        ListFolderGetLatestCursorResult {
8419            cursor,
8420        }
8421    }
8422}
8423
8424const LIST_FOLDER_GET_LATEST_CURSOR_RESULT_FIELDS: &[&str] = &["cursor"];
8425impl ListFolderGetLatestCursorResult {
8426    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8427        map: V,
8428    ) -> Result<ListFolderGetLatestCursorResult, V::Error> {
8429        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8430    }
8431
8432    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8433        mut map: V,
8434        optional: bool,
8435    ) -> Result<Option<ListFolderGetLatestCursorResult>, V::Error> {
8436        let mut field_cursor = None;
8437        let mut nothing = true;
8438        while let Some(key) = map.next_key::<&str>()? {
8439            nothing = false;
8440            match key {
8441                "cursor" => {
8442                    if field_cursor.is_some() {
8443                        return Err(::serde::de::Error::duplicate_field("cursor"));
8444                    }
8445                    field_cursor = Some(map.next_value()?);
8446                }
8447                _ => {
8448                    // unknown field allowed and ignored
8449                    map.next_value::<::serde_json::Value>()?;
8450                }
8451            }
8452        }
8453        if optional && nothing {
8454            return Ok(None);
8455        }
8456        let result = ListFolderGetLatestCursorResult {
8457            cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8458        };
8459        Ok(Some(result))
8460    }
8461
8462    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8463        &self,
8464        s: &mut S::SerializeStruct,
8465    ) -> Result<(), S::Error> {
8466        use serde::ser::SerializeStruct;
8467        s.serialize_field("cursor", &self.cursor)?;
8468        Ok(())
8469    }
8470}
8471
8472impl<'de> ::serde::de::Deserialize<'de> for ListFolderGetLatestCursorResult {
8473    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8474        // struct deserializer
8475        use serde::de::{MapAccess, Visitor};
8476        struct StructVisitor;
8477        impl<'de> Visitor<'de> for StructVisitor {
8478            type Value = ListFolderGetLatestCursorResult;
8479            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8480                f.write_str("a ListFolderGetLatestCursorResult struct")
8481            }
8482            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8483                ListFolderGetLatestCursorResult::internal_deserialize(map)
8484            }
8485        }
8486        deserializer.deserialize_struct("ListFolderGetLatestCursorResult", LIST_FOLDER_GET_LATEST_CURSOR_RESULT_FIELDS, StructVisitor)
8487    }
8488}
8489
8490impl ::serde::ser::Serialize for ListFolderGetLatestCursorResult {
8491    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8492        // struct serializer
8493        use serde::ser::SerializeStruct;
8494        let mut s = serializer.serialize_struct("ListFolderGetLatestCursorResult", 1)?;
8495        self.internal_serialize::<S>(&mut s)?;
8496        s.end()
8497    }
8498}
8499
8500#[derive(Debug, Clone, PartialEq, Eq)]
8501#[non_exhaustive] // structs may have more fields added in the future.
8502pub struct ListFolderLongpollArg {
8503    /// A cursor as returned by [`list_folder()`](crate::files::list_folder) or
8504    /// [`list_folder_continue()`](crate::files::list_folder_continue). Cursors retrieved by setting
8505    /// [`ListFolderArg::include_media_info`](ListFolderArg) to `true` are not supported.
8506    pub cursor: ListFolderCursor,
8507    /// A timeout in seconds. The request will block for at most this length of time, plus up to 90
8508    /// seconds of random jitter added to avoid the thundering herd problem. Care should be taken
8509    /// when using this parameter, as some network infrastructure does not support long timeouts.
8510    pub timeout: u64,
8511}
8512
8513impl ListFolderLongpollArg {
8514    pub fn new(cursor: ListFolderCursor) -> Self {
8515        ListFolderLongpollArg {
8516            cursor,
8517            timeout: 30,
8518        }
8519    }
8520
8521    pub fn with_timeout(mut self, value: u64) -> Self {
8522        self.timeout = value;
8523        self
8524    }
8525}
8526
8527const LIST_FOLDER_LONGPOLL_ARG_FIELDS: &[&str] = &["cursor",
8528                                                   "timeout"];
8529impl ListFolderLongpollArg {
8530    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8531        map: V,
8532    ) -> Result<ListFolderLongpollArg, V::Error> {
8533        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8534    }
8535
8536    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8537        mut map: V,
8538        optional: bool,
8539    ) -> Result<Option<ListFolderLongpollArg>, V::Error> {
8540        let mut field_cursor = None;
8541        let mut field_timeout = None;
8542        let mut nothing = true;
8543        while let Some(key) = map.next_key::<&str>()? {
8544            nothing = false;
8545            match key {
8546                "cursor" => {
8547                    if field_cursor.is_some() {
8548                        return Err(::serde::de::Error::duplicate_field("cursor"));
8549                    }
8550                    field_cursor = Some(map.next_value()?);
8551                }
8552                "timeout" => {
8553                    if field_timeout.is_some() {
8554                        return Err(::serde::de::Error::duplicate_field("timeout"));
8555                    }
8556                    field_timeout = Some(map.next_value()?);
8557                }
8558                _ => {
8559                    // unknown field allowed and ignored
8560                    map.next_value::<::serde_json::Value>()?;
8561                }
8562            }
8563        }
8564        if optional && nothing {
8565            return Ok(None);
8566        }
8567        let result = ListFolderLongpollArg {
8568            cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8569            timeout: field_timeout.unwrap_or(30),
8570        };
8571        Ok(Some(result))
8572    }
8573
8574    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8575        &self,
8576        s: &mut S::SerializeStruct,
8577    ) -> Result<(), S::Error> {
8578        use serde::ser::SerializeStruct;
8579        s.serialize_field("cursor", &self.cursor)?;
8580        if self.timeout != 30 {
8581            s.serialize_field("timeout", &self.timeout)?;
8582        }
8583        Ok(())
8584    }
8585}
8586
8587impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollArg {
8588    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8589        // struct deserializer
8590        use serde::de::{MapAccess, Visitor};
8591        struct StructVisitor;
8592        impl<'de> Visitor<'de> for StructVisitor {
8593            type Value = ListFolderLongpollArg;
8594            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8595                f.write_str("a ListFolderLongpollArg struct")
8596            }
8597            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8598                ListFolderLongpollArg::internal_deserialize(map)
8599            }
8600        }
8601        deserializer.deserialize_struct("ListFolderLongpollArg", LIST_FOLDER_LONGPOLL_ARG_FIELDS, StructVisitor)
8602    }
8603}
8604
8605impl ::serde::ser::Serialize for ListFolderLongpollArg {
8606    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8607        // struct serializer
8608        use serde::ser::SerializeStruct;
8609        let mut s = serializer.serialize_struct("ListFolderLongpollArg", 2)?;
8610        self.internal_serialize::<S>(&mut s)?;
8611        s.end()
8612    }
8613}
8614
8615#[derive(Debug, Clone, PartialEq, Eq)]
8616#[non_exhaustive] // variants may be added in the future
8617pub enum ListFolderLongpollError {
8618    /// Indicates that the cursor has been invalidated. Call
8619    /// [`list_folder()`](crate::files::list_folder) to obtain a new cursor.
8620    Reset,
8621    /// Catch-all used for unrecognized values returned from the server. Encountering this value
8622    /// typically indicates that this SDK version is out of date.
8623    Other,
8624}
8625
8626impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollError {
8627    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8628        // union deserializer
8629        use serde::de::{self, MapAccess, Visitor};
8630        struct EnumVisitor;
8631        impl<'de> Visitor<'de> for EnumVisitor {
8632            type Value = ListFolderLongpollError;
8633            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8634                f.write_str("a ListFolderLongpollError structure")
8635            }
8636            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
8637                let tag: &str = match map.next_key()? {
8638                    Some(".tag") => map.next_value()?,
8639                    _ => return Err(de::Error::missing_field(".tag"))
8640                };
8641                let value = match tag {
8642                    "reset" => ListFolderLongpollError::Reset,
8643                    _ => ListFolderLongpollError::Other,
8644                };
8645                crate::eat_json_fields(&mut map)?;
8646                Ok(value)
8647            }
8648        }
8649        const VARIANTS: &[&str] = &["reset",
8650                                    "other"];
8651        deserializer.deserialize_struct("ListFolderLongpollError", VARIANTS, EnumVisitor)
8652    }
8653}
8654
8655impl ::serde::ser::Serialize for ListFolderLongpollError {
8656    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8657        // union serializer
8658        use serde::ser::SerializeStruct;
8659        match self {
8660            ListFolderLongpollError::Reset => {
8661                // unit
8662                let mut s = serializer.serialize_struct("ListFolderLongpollError", 1)?;
8663                s.serialize_field(".tag", "reset")?;
8664                s.end()
8665            }
8666            ListFolderLongpollError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
8667        }
8668    }
8669}
8670
8671impl ::std::error::Error for ListFolderLongpollError {
8672}
8673
8674impl ::std::fmt::Display for ListFolderLongpollError {
8675    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8676        write!(f, "{:?}", *self)
8677    }
8678}
8679
8680#[derive(Debug, Clone, PartialEq, Eq)]
8681#[non_exhaustive] // structs may have more fields added in the future.
8682pub struct ListFolderLongpollResult {
8683    /// Indicates whether new changes are available. If true, call
8684    /// [`list_folder_continue()`](crate::files::list_folder_continue) to retrieve the changes.
8685    pub changes: bool,
8686    /// If present, backoff for at least this many seconds before calling
8687    /// [`list_folder_longpoll()`](crate::files::list_folder_longpoll) again.
8688    pub backoff: Option<u64>,
8689}
8690
8691impl ListFolderLongpollResult {
8692    pub fn new(changes: bool) -> Self {
8693        ListFolderLongpollResult {
8694            changes,
8695            backoff: None,
8696        }
8697    }
8698
8699    pub fn with_backoff(mut self, value: u64) -> Self {
8700        self.backoff = Some(value);
8701        self
8702    }
8703}
8704
8705const LIST_FOLDER_LONGPOLL_RESULT_FIELDS: &[&str] = &["changes",
8706                                                      "backoff"];
8707impl ListFolderLongpollResult {
8708    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8709        map: V,
8710    ) -> Result<ListFolderLongpollResult, V::Error> {
8711        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8712    }
8713
8714    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8715        mut map: V,
8716        optional: bool,
8717    ) -> Result<Option<ListFolderLongpollResult>, V::Error> {
8718        let mut field_changes = None;
8719        let mut field_backoff = None;
8720        let mut nothing = true;
8721        while let Some(key) = map.next_key::<&str>()? {
8722            nothing = false;
8723            match key {
8724                "changes" => {
8725                    if field_changes.is_some() {
8726                        return Err(::serde::de::Error::duplicate_field("changes"));
8727                    }
8728                    field_changes = Some(map.next_value()?);
8729                }
8730                "backoff" => {
8731                    if field_backoff.is_some() {
8732                        return Err(::serde::de::Error::duplicate_field("backoff"));
8733                    }
8734                    field_backoff = Some(map.next_value()?);
8735                }
8736                _ => {
8737                    // unknown field allowed and ignored
8738                    map.next_value::<::serde_json::Value>()?;
8739                }
8740            }
8741        }
8742        if optional && nothing {
8743            return Ok(None);
8744        }
8745        let result = ListFolderLongpollResult {
8746            changes: field_changes.ok_or_else(|| ::serde::de::Error::missing_field("changes"))?,
8747            backoff: field_backoff.and_then(Option::flatten),
8748        };
8749        Ok(Some(result))
8750    }
8751
8752    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8753        &self,
8754        s: &mut S::SerializeStruct,
8755    ) -> Result<(), S::Error> {
8756        use serde::ser::SerializeStruct;
8757        s.serialize_field("changes", &self.changes)?;
8758        if let Some(val) = &self.backoff {
8759            s.serialize_field("backoff", val)?;
8760        }
8761        Ok(())
8762    }
8763}
8764
8765impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollResult {
8766    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8767        // struct deserializer
8768        use serde::de::{MapAccess, Visitor};
8769        struct StructVisitor;
8770        impl<'de> Visitor<'de> for StructVisitor {
8771            type Value = ListFolderLongpollResult;
8772            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8773                f.write_str("a ListFolderLongpollResult struct")
8774            }
8775            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8776                ListFolderLongpollResult::internal_deserialize(map)
8777            }
8778        }
8779        deserializer.deserialize_struct("ListFolderLongpollResult", LIST_FOLDER_LONGPOLL_RESULT_FIELDS, StructVisitor)
8780    }
8781}
8782
8783impl ::serde::ser::Serialize for ListFolderLongpollResult {
8784    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8785        // struct serializer
8786        use serde::ser::SerializeStruct;
8787        let mut s = serializer.serialize_struct("ListFolderLongpollResult", 2)?;
8788        self.internal_serialize::<S>(&mut s)?;
8789        s.end()
8790    }
8791}
8792
8793#[derive(Debug, Clone, PartialEq)]
8794#[non_exhaustive] // structs may have more fields added in the future.
8795pub struct ListFolderResult {
8796    /// The files and (direct) subfolders in the folder.
8797    pub entries: Vec<Metadata>,
8798    /// Pass the cursor into [`list_folder_continue()`](crate::files::list_folder_continue) to see
8799    /// what's changed in the folder since your previous query.
8800    pub cursor: ListFolderCursor,
8801    /// If true, then there are more entries available. Pass the cursor to
8802    /// [`list_folder_continue()`](crate::files::list_folder_continue) to retrieve the rest.
8803    pub has_more: bool,
8804}
8805
8806impl ListFolderResult {
8807    pub fn new(entries: Vec<Metadata>, cursor: ListFolderCursor, has_more: bool) -> Self {
8808        ListFolderResult {
8809            entries,
8810            cursor,
8811            has_more,
8812        }
8813    }
8814}
8815
8816const LIST_FOLDER_RESULT_FIELDS: &[&str] = &["entries",
8817                                             "cursor",
8818                                             "has_more"];
8819impl ListFolderResult {
8820    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8821        map: V,
8822    ) -> Result<ListFolderResult, V::Error> {
8823        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8824    }
8825
8826    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8827        mut map: V,
8828        optional: bool,
8829    ) -> Result<Option<ListFolderResult>, V::Error> {
8830        let mut field_entries = None;
8831        let mut field_cursor = None;
8832        let mut field_has_more = None;
8833        let mut nothing = true;
8834        while let Some(key) = map.next_key::<&str>()? {
8835            nothing = false;
8836            match key {
8837                "entries" => {
8838                    if field_entries.is_some() {
8839                        return Err(::serde::de::Error::duplicate_field("entries"));
8840                    }
8841                    field_entries = Some(map.next_value()?);
8842                }
8843                "cursor" => {
8844                    if field_cursor.is_some() {
8845                        return Err(::serde::de::Error::duplicate_field("cursor"));
8846                    }
8847                    field_cursor = Some(map.next_value()?);
8848                }
8849                "has_more" => {
8850                    if field_has_more.is_some() {
8851                        return Err(::serde::de::Error::duplicate_field("has_more"));
8852                    }
8853                    field_has_more = Some(map.next_value()?);
8854                }
8855                _ => {
8856                    // unknown field allowed and ignored
8857                    map.next_value::<::serde_json::Value>()?;
8858                }
8859            }
8860        }
8861        if optional && nothing {
8862            return Ok(None);
8863        }
8864        let result = ListFolderResult {
8865            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
8866            cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8867            has_more: field_has_more.ok_or_else(|| ::serde::de::Error::missing_field("has_more"))?,
8868        };
8869        Ok(Some(result))
8870    }
8871
8872    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8873        &self,
8874        s: &mut S::SerializeStruct,
8875    ) -> Result<(), S::Error> {
8876        use serde::ser::SerializeStruct;
8877        s.serialize_field("entries", &self.entries)?;
8878        s.serialize_field("cursor", &self.cursor)?;
8879        s.serialize_field("has_more", &self.has_more)?;
8880        Ok(())
8881    }
8882}
8883
8884impl<'de> ::serde::de::Deserialize<'de> for ListFolderResult {
8885    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8886        // struct deserializer
8887        use serde::de::{MapAccess, Visitor};
8888        struct StructVisitor;
8889        impl<'de> Visitor<'de> for StructVisitor {
8890            type Value = ListFolderResult;
8891            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8892                f.write_str("a ListFolderResult struct")
8893            }
8894            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8895                ListFolderResult::internal_deserialize(map)
8896            }
8897        }
8898        deserializer.deserialize_struct("ListFolderResult", LIST_FOLDER_RESULT_FIELDS, StructVisitor)
8899    }
8900}
8901
8902impl ::serde::ser::Serialize for ListFolderResult {
8903    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8904        // struct serializer
8905        use serde::ser::SerializeStruct;
8906        let mut s = serializer.serialize_struct("ListFolderResult", 3)?;
8907        self.internal_serialize::<S>(&mut s)?;
8908        s.end()
8909    }
8910}
8911
8912#[derive(Debug, Clone, PartialEq, Eq)]
8913#[non_exhaustive] // structs may have more fields added in the future.
8914pub struct ListRevisionsArg {
8915    /// The path to the file you want to see the revisions of.
8916    pub path: PathOrId,
8917    /// Determines the behavior of the API in listing the revisions for a given file path or id.
8918    pub mode: ListRevisionsMode,
8919    /// The maximum number of revision entries returned.
8920    pub limit: u64,
8921}
8922
8923impl ListRevisionsArg {
8924    pub fn new(path: PathOrId) -> Self {
8925        ListRevisionsArg {
8926            path,
8927            mode: ListRevisionsMode::Path,
8928            limit: 10,
8929        }
8930    }
8931
8932    pub fn with_mode(mut self, value: ListRevisionsMode) -> Self {
8933        self.mode = value;
8934        self
8935    }
8936
8937    pub fn with_limit(mut self, value: u64) -> Self {
8938        self.limit = value;
8939        self
8940    }
8941}
8942
8943const LIST_REVISIONS_ARG_FIELDS: &[&str] = &["path",
8944                                             "mode",
8945                                             "limit"];
8946impl ListRevisionsArg {
8947    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8948        map: V,
8949    ) -> Result<ListRevisionsArg, V::Error> {
8950        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8951    }
8952
8953    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8954        mut map: V,
8955        optional: bool,
8956    ) -> Result<Option<ListRevisionsArg>, V::Error> {
8957        let mut field_path = None;
8958        let mut field_mode = None;
8959        let mut field_limit = None;
8960        let mut nothing = true;
8961        while let Some(key) = map.next_key::<&str>()? {
8962            nothing = false;
8963            match key {
8964                "path" => {
8965                    if field_path.is_some() {
8966                        return Err(::serde::de::Error::duplicate_field("path"));
8967                    }
8968                    field_path = Some(map.next_value()?);
8969                }
8970                "mode" => {
8971                    if field_mode.is_some() {
8972                        return Err(::serde::de::Error::duplicate_field("mode"));
8973                    }
8974                    field_mode = Some(map.next_value()?);
8975                }
8976                "limit" => {
8977                    if field_limit.is_some() {
8978                        return Err(::serde::de::Error::duplicate_field("limit"));
8979                    }
8980                    field_limit = Some(map.next_value()?);
8981                }
8982                _ => {
8983                    // unknown field allowed and ignored
8984                    map.next_value::<::serde_json::Value>()?;
8985                }
8986            }
8987        }
8988        if optional && nothing {
8989            return Ok(None);
8990        }
8991        let result = ListRevisionsArg {
8992            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
8993            mode: field_mode.unwrap_or(ListRevisionsMode::Path),
8994            limit: field_limit.unwrap_or(10),
8995        };
8996        Ok(Some(result))
8997    }
8998
8999    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9000        &self,
9001        s: &mut S::SerializeStruct,
9002    ) -> Result<(), S::Error> {
9003        use serde::ser::SerializeStruct;
9004        s.serialize_field("path", &self.path)?;
9005        if self.mode != ListRevisionsMode::Path {
9006            s.serialize_field("mode", &self.mode)?;
9007        }
9008        if self.limit != 10 {
9009            s.serialize_field("limit", &self.limit)?;
9010        }
9011        Ok(())
9012    }
9013}
9014
9015impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsArg {
9016    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9017        // struct deserializer
9018        use serde::de::{MapAccess, Visitor};
9019        struct StructVisitor;
9020        impl<'de> Visitor<'de> for StructVisitor {
9021            type Value = ListRevisionsArg;
9022            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9023                f.write_str("a ListRevisionsArg struct")
9024            }
9025            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9026                ListRevisionsArg::internal_deserialize(map)
9027            }
9028        }
9029        deserializer.deserialize_struct("ListRevisionsArg", LIST_REVISIONS_ARG_FIELDS, StructVisitor)
9030    }
9031}
9032
9033impl ::serde::ser::Serialize for ListRevisionsArg {
9034    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9035        // struct serializer
9036        use serde::ser::SerializeStruct;
9037        let mut s = serializer.serialize_struct("ListRevisionsArg", 3)?;
9038        self.internal_serialize::<S>(&mut s)?;
9039        s.end()
9040    }
9041}
9042
9043#[derive(Debug, Clone, PartialEq, Eq)]
9044#[non_exhaustive] // variants may be added in the future
9045pub enum ListRevisionsError {
9046    Path(LookupError),
9047    /// Catch-all used for unrecognized values returned from the server. Encountering this value
9048    /// typically indicates that this SDK version is out of date.
9049    Other,
9050}
9051
9052impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsError {
9053    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9054        // union deserializer
9055        use serde::de::{self, MapAccess, Visitor};
9056        struct EnumVisitor;
9057        impl<'de> Visitor<'de> for EnumVisitor {
9058            type Value = ListRevisionsError;
9059            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9060                f.write_str("a ListRevisionsError structure")
9061            }
9062            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
9063                let tag: &str = match map.next_key()? {
9064                    Some(".tag") => map.next_value()?,
9065                    _ => return Err(de::Error::missing_field(".tag"))
9066                };
9067                let value = match tag {
9068                    "path" => {
9069                        match map.next_key()? {
9070                            Some("path") => ListRevisionsError::Path(map.next_value()?),
9071                            None => return Err(de::Error::missing_field("path")),
9072                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
9073                        }
9074                    }
9075                    _ => ListRevisionsError::Other,
9076                };
9077                crate::eat_json_fields(&mut map)?;
9078                Ok(value)
9079            }
9080        }
9081        const VARIANTS: &[&str] = &["path",
9082                                    "other"];
9083        deserializer.deserialize_struct("ListRevisionsError", VARIANTS, EnumVisitor)
9084    }
9085}
9086
9087impl ::serde::ser::Serialize for ListRevisionsError {
9088    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9089        // union serializer
9090        use serde::ser::SerializeStruct;
9091        match self {
9092            ListRevisionsError::Path(x) => {
9093                // union or polymporphic struct
9094                let mut s = serializer.serialize_struct("ListRevisionsError", 2)?;
9095                s.serialize_field(".tag", "path")?;
9096                s.serialize_field("path", x)?;
9097                s.end()
9098            }
9099            ListRevisionsError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
9100        }
9101    }
9102}
9103
9104impl ::std::error::Error for ListRevisionsError {
9105    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
9106        match self {
9107            ListRevisionsError::Path(inner) => Some(inner),
9108            _ => None,
9109        }
9110    }
9111}
9112
9113impl ::std::fmt::Display for ListRevisionsError {
9114    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9115        match self {
9116            ListRevisionsError::Path(inner) => write!(f, "ListRevisionsError: {}", inner),
9117            _ => write!(f, "{:?}", *self),
9118        }
9119    }
9120}
9121
9122#[derive(Debug, Clone, PartialEq, Eq)]
9123#[non_exhaustive] // variants may be added in the future
9124pub enum ListRevisionsMode {
9125    /// Returns revisions with the same file path as identified by the latest file entry at the
9126    /// given file path or id.
9127    Path,
9128    /// Returns revisions with the same file id as identified by the latest file entry at the given
9129    /// file path or id.
9130    Id,
9131    /// Catch-all used for unrecognized values returned from the server. Encountering this value
9132    /// typically indicates that this SDK version is out of date.
9133    Other,
9134}
9135
9136impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsMode {
9137    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9138        // union deserializer
9139        use serde::de::{self, MapAccess, Visitor};
9140        struct EnumVisitor;
9141        impl<'de> Visitor<'de> for EnumVisitor {
9142            type Value = ListRevisionsMode;
9143            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9144                f.write_str("a ListRevisionsMode structure")
9145            }
9146            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
9147                let tag: &str = match map.next_key()? {
9148                    Some(".tag") => map.next_value()?,
9149                    _ => return Err(de::Error::missing_field(".tag"))
9150                };
9151                let value = match tag {
9152                    "path" => ListRevisionsMode::Path,
9153                    "id" => ListRevisionsMode::Id,
9154                    _ => ListRevisionsMode::Other,
9155                };
9156                crate::eat_json_fields(&mut map)?;
9157                Ok(value)
9158            }
9159        }
9160        const VARIANTS: &[&str] = &["path",
9161                                    "id",
9162                                    "other"];
9163        deserializer.deserialize_struct("ListRevisionsMode", VARIANTS, EnumVisitor)
9164    }
9165}
9166
9167impl ::serde::ser::Serialize for ListRevisionsMode {
9168    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9169        // union serializer
9170        use serde::ser::SerializeStruct;
9171        match self {
9172            ListRevisionsMode::Path => {
9173                // unit
9174                let mut s = serializer.serialize_struct("ListRevisionsMode", 1)?;
9175                s.serialize_field(".tag", "path")?;
9176                s.end()
9177            }
9178            ListRevisionsMode::Id => {
9179                // unit
9180                let mut s = serializer.serialize_struct("ListRevisionsMode", 1)?;
9181                s.serialize_field(".tag", "id")?;
9182                s.end()
9183            }
9184            ListRevisionsMode::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
9185        }
9186    }
9187}
9188
9189#[derive(Debug, Clone, PartialEq)]
9190#[non_exhaustive] // structs may have more fields added in the future.
9191pub struct ListRevisionsResult {
9192    /// If the file identified by the latest revision in the response is either deleted or moved.
9193    pub is_deleted: bool,
9194    /// The revisions for the file. Only revisions that are not deleted will show up here.
9195    pub entries: Vec<FileMetadata>,
9196    /// The time of deletion if the file was deleted.
9197    pub server_deleted: Option<crate::types::common::DropboxTimestamp>,
9198}
9199
9200impl ListRevisionsResult {
9201    pub fn new(is_deleted: bool, entries: Vec<FileMetadata>) -> Self {
9202        ListRevisionsResult {
9203            is_deleted,
9204            entries,
9205            server_deleted: None,
9206        }
9207    }
9208
9209    pub fn with_server_deleted(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
9210        self.server_deleted = Some(value);
9211        self
9212    }
9213}
9214
9215const LIST_REVISIONS_RESULT_FIELDS: &[&str] = &["is_deleted",
9216                                                "entries",
9217                                                "server_deleted"];
9218impl ListRevisionsResult {
9219    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9220        map: V,
9221    ) -> Result<ListRevisionsResult, V::Error> {
9222        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9223    }
9224
9225    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9226        mut map: V,
9227        optional: bool,
9228    ) -> Result<Option<ListRevisionsResult>, V::Error> {
9229        let mut field_is_deleted = None;
9230        let mut field_entries = None;
9231        let mut field_server_deleted = None;
9232        let mut nothing = true;
9233        while let Some(key) = map.next_key::<&str>()? {
9234            nothing = false;
9235            match key {
9236                "is_deleted" => {
9237                    if field_is_deleted.is_some() {
9238                        return Err(::serde::de::Error::duplicate_field("is_deleted"));
9239                    }
9240                    field_is_deleted = Some(map.next_value()?);
9241                }
9242                "entries" => {
9243                    if field_entries.is_some() {
9244                        return Err(::serde::de::Error::duplicate_field("entries"));
9245                    }
9246                    field_entries = Some(map.next_value()?);
9247                }
9248                "server_deleted" => {
9249                    if field_server_deleted.is_some() {
9250                        return Err(::serde::de::Error::duplicate_field("server_deleted"));
9251                    }
9252                    field_server_deleted = Some(map.next_value()?);
9253                }
9254                _ => {
9255                    // unknown field allowed and ignored
9256                    map.next_value::<::serde_json::Value>()?;
9257                }
9258            }
9259        }
9260        if optional && nothing {
9261            return Ok(None);
9262        }
9263        let result = ListRevisionsResult {
9264            is_deleted: field_is_deleted.ok_or_else(|| ::serde::de::Error::missing_field("is_deleted"))?,
9265            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
9266            server_deleted: field_server_deleted.and_then(Option::flatten),
9267        };
9268        Ok(Some(result))
9269    }
9270
9271    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9272        &self,
9273        s: &mut S::SerializeStruct,
9274    ) -> Result<(), S::Error> {
9275        use serde::ser::SerializeStruct;
9276        s.serialize_field("is_deleted", &self.is_deleted)?;
9277        s.serialize_field("entries", &self.entries)?;
9278        if let Some(val) = &self.server_deleted {
9279            s.serialize_field("server_deleted", val)?;
9280        }
9281        Ok(())
9282    }
9283}
9284
9285impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsResult {
9286    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9287        // struct deserializer
9288        use serde::de::{MapAccess, Visitor};
9289        struct StructVisitor;
9290        impl<'de> Visitor<'de> for StructVisitor {
9291            type Value = ListRevisionsResult;
9292            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9293                f.write_str("a ListRevisionsResult struct")
9294            }
9295            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9296                ListRevisionsResult::internal_deserialize(map)
9297            }
9298        }
9299        deserializer.deserialize_struct("ListRevisionsResult", LIST_REVISIONS_RESULT_FIELDS, StructVisitor)
9300    }
9301}
9302
9303impl ::serde::ser::Serialize for ListRevisionsResult {
9304    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9305        // struct serializer
9306        use serde::ser::SerializeStruct;
9307        let mut s = serializer.serialize_struct("ListRevisionsResult", 3)?;
9308        self.internal_serialize::<S>(&mut s)?;
9309        s.end()
9310    }
9311}
9312
9313#[derive(Debug, Clone, PartialEq, Eq)]
9314#[non_exhaustive] // structs may have more fields added in the future.
9315pub struct LockConflictError {
9316    /// The lock that caused the conflict.
9317    pub lock: FileLock,
9318}
9319
9320impl LockConflictError {
9321    pub fn new(lock: FileLock) -> Self {
9322        LockConflictError {
9323            lock,
9324        }
9325    }
9326}
9327
9328const LOCK_CONFLICT_ERROR_FIELDS: &[&str] = &["lock"];
9329impl LockConflictError {
9330    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9331        map: V,
9332    ) -> Result<LockConflictError, V::Error> {
9333        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9334    }
9335
9336    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9337        mut map: V,
9338        optional: bool,
9339    ) -> Result<Option<LockConflictError>, V::Error> {
9340        let mut field_lock = None;
9341        let mut nothing = true;
9342        while let Some(key) = map.next_key::<&str>()? {
9343            nothing = false;
9344            match key {
9345                "lock" => {
9346                    if field_lock.is_some() {
9347                        return Err(::serde::de::Error::duplicate_field("lock"));
9348                    }
9349                    field_lock = Some(map.next_value()?);
9350                }
9351                _ => {
9352                    // unknown field allowed and ignored
9353                    map.next_value::<::serde_json::Value>()?;
9354                }
9355            }
9356        }
9357        if optional && nothing {
9358            return Ok(None);
9359        }
9360        let result = LockConflictError {
9361            lock: field_lock.ok_or_else(|| ::serde::de::Error::missing_field("lock"))?,
9362        };
9363        Ok(Some(result))
9364    }
9365
9366    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9367        &self,
9368        s: &mut S::SerializeStruct,
9369    ) -> Result<(), S::Error> {
9370        use serde::ser::SerializeStruct;
9371        s.serialize_field("lock", &self.lock)?;
9372        Ok(())
9373    }
9374}
9375
9376impl<'de> ::serde::de::Deserialize<'de> for LockConflictError {
9377    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9378        // struct deserializer
9379        use serde::de::{MapAccess, Visitor};
9380        struct StructVisitor;
9381        impl<'de> Visitor<'de> for StructVisitor {
9382            type Value = LockConflictError;
9383            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9384                f.write_str("a LockConflictError struct")
9385            }
9386            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9387                LockConflictError::internal_deserialize(map)
9388            }
9389        }
9390        deserializer.deserialize_struct("LockConflictError", LOCK_CONFLICT_ERROR_FIELDS, StructVisitor)
9391    }
9392}
9393
9394impl ::serde::ser::Serialize for LockConflictError {
9395    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9396        // struct serializer
9397        use serde::ser::SerializeStruct;
9398        let mut s = serializer.serialize_struct("LockConflictError", 1)?;
9399        self.internal_serialize::<S>(&mut s)?;
9400        s.end()
9401    }
9402}
9403
9404#[derive(Debug, Clone, PartialEq, Eq)]
9405#[non_exhaustive] // structs may have more fields added in the future.
9406pub struct LockFileArg {
9407    /// Path in the user's Dropbox to a file.
9408    pub path: WritePathOrId,
9409}
9410
9411impl LockFileArg {
9412    pub fn new(path: WritePathOrId) -> Self {
9413        LockFileArg {
9414            path,
9415        }
9416    }
9417}
9418
9419const LOCK_FILE_ARG_FIELDS: &[&str] = &["path"];
9420impl LockFileArg {
9421    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9422        map: V,
9423    ) -> Result<LockFileArg, V::Error> {
9424        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9425    }
9426
9427    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9428        mut map: V,
9429        optional: bool,
9430    ) -> Result<Option<LockFileArg>, V::Error> {
9431        let mut field_path = None;
9432        let mut nothing = true;
9433        while let Some(key) = map.next_key::<&str>()? {
9434            nothing = false;
9435            match key {
9436                "path" => {
9437                    if field_path.is_some() {
9438                        return Err(::serde::de::Error::duplicate_field("path"));
9439                    }
9440                    field_path = Some(map.next_value()?);
9441                }
9442                _ => {
9443                    // unknown field allowed and ignored
9444                    map.next_value::<::serde_json::Value>()?;
9445                }
9446            }
9447        }
9448        if optional && nothing {
9449            return Ok(None);
9450        }
9451        let result = LockFileArg {
9452            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
9453        };
9454        Ok(Some(result))
9455    }
9456
9457    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9458        &self,
9459        s: &mut S::SerializeStruct,
9460    ) -> Result<(), S::Error> {
9461        use serde::ser::SerializeStruct;
9462        s.serialize_field("path", &self.path)?;
9463        Ok(())
9464    }
9465}
9466
9467impl<'de> ::serde::de::Deserialize<'de> for LockFileArg {
9468    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9469        // struct deserializer
9470        use serde::de::{MapAccess, Visitor};
9471        struct StructVisitor;
9472        impl<'de> Visitor<'de> for StructVisitor {
9473            type Value = LockFileArg;
9474            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9475                f.write_str("a LockFileArg struct")
9476            }
9477            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9478                LockFileArg::internal_deserialize(map)
9479            }
9480        }
9481        deserializer.deserialize_struct("LockFileArg", LOCK_FILE_ARG_FIELDS, StructVisitor)
9482    }
9483}
9484
9485impl ::serde::ser::Serialize for LockFileArg {
9486    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9487        // struct serializer
9488        use serde::ser::SerializeStruct;
9489        let mut s = serializer.serialize_struct("LockFileArg", 1)?;
9490        self.internal_serialize::<S>(&mut s)?;
9491        s.end()
9492    }
9493}
9494
9495#[derive(Debug, Clone, PartialEq, Eq)]
9496#[non_exhaustive] // structs may have more fields added in the future.
9497pub struct LockFileBatchArg {
9498    /// List of 'entries'. Each 'entry' contains a path of the file which will be locked or queried.
9499    /// Duplicate path arguments in the batch are considered only once.
9500    pub entries: Vec<LockFileArg>,
9501}
9502
9503impl LockFileBatchArg {
9504    pub fn new(entries: Vec<LockFileArg>) -> Self {
9505        LockFileBatchArg {
9506            entries,
9507        }
9508    }
9509}
9510
9511const LOCK_FILE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
9512impl LockFileBatchArg {
9513    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9514        map: V,
9515    ) -> Result<LockFileBatchArg, V::Error> {
9516        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9517    }
9518
9519    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9520        mut map: V,
9521        optional: bool,
9522    ) -> Result<Option<LockFileBatchArg>, V::Error> {
9523        let mut field_entries = None;
9524        let mut nothing = true;
9525        while let Some(key) = map.next_key::<&str>()? {
9526            nothing = false;
9527            match key {
9528                "entries" => {
9529                    if field_entries.is_some() {
9530                        return Err(::serde::de::Error::duplicate_field("entries"));
9531                    }
9532                    field_entries = Some(map.next_value()?);
9533                }
9534                _ => {
9535                    // unknown field allowed and ignored
9536                    map.next_value::<::serde_json::Value>()?;
9537                }
9538            }
9539        }
9540        if optional && nothing {
9541            return Ok(None);
9542        }
9543        let result = LockFileBatchArg {
9544            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
9545        };
9546        Ok(Some(result))
9547    }
9548
9549    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9550        &self,
9551        s: &mut S::SerializeStruct,
9552    ) -> Result<(), S::Error> {
9553        use serde::ser::SerializeStruct;
9554        s.serialize_field("entries", &self.entries)?;
9555        Ok(())
9556    }
9557}
9558
9559impl<'de> ::serde::de::Deserialize<'de> for LockFileBatchArg {
9560    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9561        // struct deserializer
9562        use serde::de::{MapAccess, Visitor};
9563        struct StructVisitor;
9564        impl<'de> Visitor<'de> for StructVisitor {
9565            type Value = LockFileBatchArg;
9566            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9567                f.write_str("a LockFileBatchArg struct")
9568            }
9569            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9570                LockFileBatchArg::internal_deserialize(map)
9571            }
9572        }
9573        deserializer.deserialize_struct("LockFileBatchArg", LOCK_FILE_BATCH_ARG_FIELDS, StructVisitor)
9574    }
9575}
9576
9577impl ::serde::ser::Serialize for LockFileBatchArg {
9578    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9579        // struct serializer
9580        use serde::ser::SerializeStruct;
9581        let mut s = serializer.serialize_struct("LockFileBatchArg", 1)?;
9582        self.internal_serialize::<S>(&mut s)?;
9583        s.end()
9584    }
9585}
9586
9587#[derive(Debug, Clone, PartialEq)]
9588#[non_exhaustive] // structs may have more fields added in the future.
9589pub struct LockFileBatchResult {
9590    /// Each Entry in the 'entries' will have '.tag' with the operation status (e.g. success), the
9591    /// metadata for the file and the lock state after the operation.
9592    pub entries: Vec<LockFileResultEntry>,
9593}
9594
9595impl LockFileBatchResult {
9596    pub fn new(entries: Vec<LockFileResultEntry>) -> Self {
9597        LockFileBatchResult {
9598            entries,
9599        }
9600    }
9601}
9602
9603const LOCK_FILE_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
9604impl LockFileBatchResult {
9605    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9606        map: V,
9607    ) -> Result<LockFileBatchResult, V::Error> {
9608        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9609    }
9610
9611    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9612        mut map: V,
9613        optional: bool,
9614    ) -> Result<Option<LockFileBatchResult>, V::Error> {
9615        let mut field_entries = None;
9616        let mut nothing = true;
9617        while let Some(key) = map.next_key::<&str>()? {
9618            nothing = false;
9619            match key {
9620                "entries" => {
9621                    if field_entries.is_some() {
9622                        return Err(::serde::de::Error::duplicate_field("entries"));
9623                    }
9624                    field_entries = Some(map.next_value()?);
9625                }
9626                _ => {
9627                    // unknown field allowed and ignored
9628                    map.next_value::<::serde_json::Value>()?;
9629                }
9630            }
9631        }
9632        if optional && nothing {
9633            return Ok(None);
9634        }
9635        let result = LockFileBatchResult {
9636            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
9637        };
9638        Ok(Some(result))
9639    }
9640
9641    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9642        &self,
9643        s: &mut S::SerializeStruct,
9644    ) -> Result<(), S::Error> {
9645        use serde::ser::SerializeStruct;
9646        s.serialize_field("entries", &self.entries)?;
9647        Ok(())
9648    }
9649}
9650
9651impl<'de> ::serde::de::Deserialize<'de> for LockFileBatchResult {
9652    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9653        // struct deserializer
9654        use serde::de::{MapAccess, Visitor};
9655        struct StructVisitor;
9656        impl<'de> Visitor<'de> for StructVisitor {
9657            type Value = LockFileBatchResult;
9658            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9659                f.write_str("a LockFileBatchResult struct")
9660            }
9661            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9662                LockFileBatchResult::internal_deserialize(map)
9663            }
9664        }
9665        deserializer.deserialize_struct("LockFileBatchResult", LOCK_FILE_BATCH_RESULT_FIELDS, StructVisitor)
9666    }
9667}
9668
9669impl ::serde::ser::Serialize for LockFileBatchResult {
9670    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9671        // struct serializer
9672        use serde::ser::SerializeStruct;
9673        let mut s = serializer.serialize_struct("LockFileBatchResult", 1)?;
9674        self.internal_serialize::<S>(&mut s)?;
9675        s.end()
9676    }
9677}
9678
9679// struct extends FileOpsResult
9680impl From<LockFileBatchResult> for FileOpsResult {
9681    fn from(_: LockFileBatchResult) -> Self {
9682        Self {}
9683    }
9684}
9685#[derive(Debug, Clone, PartialEq, Eq)]
9686#[non_exhaustive] // variants may be added in the future
9687pub enum LockFileError {
9688    /// Could not find the specified resource.
9689    PathLookup(LookupError),
9690    /// There are too many write operations in user's Dropbox. Please retry this request.
9691    TooManyWriteOperations,
9692    /// There are too many files in one request. Please retry with fewer files.
9693    TooManyFiles,
9694    /// The user does not have permissions to change the lock state or access the file.
9695    NoWritePermission,
9696    /// Item is a type that cannot be locked.
9697    CannotBeLocked,
9698    /// Requested file is not currently shared.
9699    FileNotShared,
9700    /// The user action conflicts with an existing lock on the file.
9701    LockConflict(LockConflictError),
9702    /// Something went wrong with the job on Dropbox's end. You'll need to verify that the action
9703    /// you were taking succeeded, and if not, try again. This should happen very rarely.
9704    InternalError,
9705    /// Catch-all used for unrecognized values returned from the server. Encountering this value
9706    /// typically indicates that this SDK version is out of date.
9707    Other,
9708}
9709
9710impl<'de> ::serde::de::Deserialize<'de> for LockFileError {
9711    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9712        // union deserializer
9713        use serde::de::{self, MapAccess, Visitor};
9714        struct EnumVisitor;
9715        impl<'de> Visitor<'de> for EnumVisitor {
9716            type Value = LockFileError;
9717            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9718                f.write_str("a LockFileError structure")
9719            }
9720            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
9721                let tag: &str = match map.next_key()? {
9722                    Some(".tag") => map.next_value()?,
9723                    _ => return Err(de::Error::missing_field(".tag"))
9724                };
9725                let value = match tag {
9726                    "path_lookup" => {
9727                        match map.next_key()? {
9728                            Some("path_lookup") => LockFileError::PathLookup(map.next_value()?),
9729                            None => return Err(de::Error::missing_field("path_lookup")),
9730                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
9731                        }
9732                    }
9733                    "too_many_write_operations" => LockFileError::TooManyWriteOperations,
9734                    "too_many_files" => LockFileError::TooManyFiles,
9735                    "no_write_permission" => LockFileError::NoWritePermission,
9736                    "cannot_be_locked" => LockFileError::CannotBeLocked,
9737                    "file_not_shared" => LockFileError::FileNotShared,
9738                    "lock_conflict" => LockFileError::LockConflict(LockConflictError::internal_deserialize(&mut map)?),
9739                    "internal_error" => LockFileError::InternalError,
9740                    _ => LockFileError::Other,
9741                };
9742                crate::eat_json_fields(&mut map)?;
9743                Ok(value)
9744            }
9745        }
9746        const VARIANTS: &[&str] = &["path_lookup",
9747                                    "too_many_write_operations",
9748                                    "too_many_files",
9749                                    "no_write_permission",
9750                                    "cannot_be_locked",
9751                                    "file_not_shared",
9752                                    "lock_conflict",
9753                                    "internal_error",
9754                                    "other"];
9755        deserializer.deserialize_struct("LockFileError", VARIANTS, EnumVisitor)
9756    }
9757}
9758
9759impl ::serde::ser::Serialize for LockFileError {
9760    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9761        // union serializer
9762        use serde::ser::SerializeStruct;
9763        match self {
9764            LockFileError::PathLookup(x) => {
9765                // union or polymporphic struct
9766                let mut s = serializer.serialize_struct("LockFileError", 2)?;
9767                s.serialize_field(".tag", "path_lookup")?;
9768                s.serialize_field("path_lookup", x)?;
9769                s.end()
9770            }
9771            LockFileError::TooManyWriteOperations => {
9772                // unit
9773                let mut s = serializer.serialize_struct("LockFileError", 1)?;
9774                s.serialize_field(".tag", "too_many_write_operations")?;
9775                s.end()
9776            }
9777            LockFileError::TooManyFiles => {
9778                // unit
9779                let mut s = serializer.serialize_struct("LockFileError", 1)?;
9780                s.serialize_field(".tag", "too_many_files")?;
9781                s.end()
9782            }
9783            LockFileError::NoWritePermission => {
9784                // unit
9785                let mut s = serializer.serialize_struct("LockFileError", 1)?;
9786                s.serialize_field(".tag", "no_write_permission")?;
9787                s.end()
9788            }
9789            LockFileError::CannotBeLocked => {
9790                // unit
9791                let mut s = serializer.serialize_struct("LockFileError", 1)?;
9792                s.serialize_field(".tag", "cannot_be_locked")?;
9793                s.end()
9794            }
9795            LockFileError::FileNotShared => {
9796                // unit
9797                let mut s = serializer.serialize_struct("LockFileError", 1)?;
9798                s.serialize_field(".tag", "file_not_shared")?;
9799                s.end()
9800            }
9801            LockFileError::LockConflict(x) => {
9802                // struct
9803                let mut s = serializer.serialize_struct("LockFileError", 2)?;
9804                s.serialize_field(".tag", "lock_conflict")?;
9805                x.internal_serialize::<S>(&mut s)?;
9806                s.end()
9807            }
9808            LockFileError::InternalError => {
9809                // unit
9810                let mut s = serializer.serialize_struct("LockFileError", 1)?;
9811                s.serialize_field(".tag", "internal_error")?;
9812                s.end()
9813            }
9814            LockFileError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
9815        }
9816    }
9817}
9818
9819impl ::std::error::Error for LockFileError {
9820    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
9821        match self {
9822            LockFileError::PathLookup(inner) => Some(inner),
9823            _ => None,
9824        }
9825    }
9826}
9827
9828impl ::std::fmt::Display for LockFileError {
9829    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9830        match self {
9831            LockFileError::PathLookup(inner) => write!(f, "Could not find the specified resource: {}", inner),
9832            LockFileError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
9833            LockFileError::TooManyFiles => f.write_str("There are too many files in one request. Please retry with fewer files."),
9834            LockFileError::NoWritePermission => f.write_str("The user does not have permissions to change the lock state or access the file."),
9835            LockFileError::CannotBeLocked => f.write_str("Item is a type that cannot be locked."),
9836            LockFileError::FileNotShared => f.write_str("Requested file is not currently shared."),
9837            LockFileError::LockConflict(inner) => write!(f, "The user action conflicts with an existing lock on the file: {:?}", inner),
9838            LockFileError::InternalError => f.write_str("Something went wrong with the job on Dropbox's end. You'll need to verify that the action you were taking succeeded, and if not, try again. This should happen very rarely."),
9839            _ => write!(f, "{:?}", *self),
9840        }
9841    }
9842}
9843
9844#[derive(Debug, Clone, PartialEq)]
9845#[non_exhaustive] // structs may have more fields added in the future.
9846pub struct LockFileResult {
9847    /// Metadata of the file.
9848    pub metadata: Metadata,
9849    /// The file lock state after the operation.
9850    pub lock: FileLock,
9851}
9852
9853impl LockFileResult {
9854    pub fn new(metadata: Metadata, lock: FileLock) -> Self {
9855        LockFileResult {
9856            metadata,
9857            lock,
9858        }
9859    }
9860}
9861
9862const LOCK_FILE_RESULT_FIELDS: &[&str] = &["metadata",
9863                                           "lock"];
9864impl LockFileResult {
9865    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9866        map: V,
9867    ) -> Result<LockFileResult, V::Error> {
9868        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9869    }
9870
9871    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9872        mut map: V,
9873        optional: bool,
9874    ) -> Result<Option<LockFileResult>, V::Error> {
9875        let mut field_metadata = None;
9876        let mut field_lock = None;
9877        let mut nothing = true;
9878        while let Some(key) = map.next_key::<&str>()? {
9879            nothing = false;
9880            match key {
9881                "metadata" => {
9882                    if field_metadata.is_some() {
9883                        return Err(::serde::de::Error::duplicate_field("metadata"));
9884                    }
9885                    field_metadata = Some(map.next_value()?);
9886                }
9887                "lock" => {
9888                    if field_lock.is_some() {
9889                        return Err(::serde::de::Error::duplicate_field("lock"));
9890                    }
9891                    field_lock = Some(map.next_value()?);
9892                }
9893                _ => {
9894                    // unknown field allowed and ignored
9895                    map.next_value::<::serde_json::Value>()?;
9896                }
9897            }
9898        }
9899        if optional && nothing {
9900            return Ok(None);
9901        }
9902        let result = LockFileResult {
9903            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
9904            lock: field_lock.ok_or_else(|| ::serde::de::Error::missing_field("lock"))?,
9905        };
9906        Ok(Some(result))
9907    }
9908
9909    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9910        &self,
9911        s: &mut S::SerializeStruct,
9912    ) -> Result<(), S::Error> {
9913        use serde::ser::SerializeStruct;
9914        s.serialize_field("metadata", &self.metadata)?;
9915        s.serialize_field("lock", &self.lock)?;
9916        Ok(())
9917    }
9918}
9919
9920impl<'de> ::serde::de::Deserialize<'de> for LockFileResult {
9921    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9922        // struct deserializer
9923        use serde::de::{MapAccess, Visitor};
9924        struct StructVisitor;
9925        impl<'de> Visitor<'de> for StructVisitor {
9926            type Value = LockFileResult;
9927            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9928                f.write_str("a LockFileResult struct")
9929            }
9930            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9931                LockFileResult::internal_deserialize(map)
9932            }
9933        }
9934        deserializer.deserialize_struct("LockFileResult", LOCK_FILE_RESULT_FIELDS, StructVisitor)
9935    }
9936}
9937
9938impl ::serde::ser::Serialize for LockFileResult {
9939    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9940        // struct serializer
9941        use serde::ser::SerializeStruct;
9942        let mut s = serializer.serialize_struct("LockFileResult", 2)?;
9943        self.internal_serialize::<S>(&mut s)?;
9944        s.end()
9945    }
9946}
9947
9948#[derive(Debug, Clone, PartialEq)]
9949pub enum LockFileResultEntry {
9950    Success(LockFileResult),
9951    Failure(LockFileError),
9952}
9953
9954impl<'de> ::serde::de::Deserialize<'de> for LockFileResultEntry {
9955    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9956        // union deserializer
9957        use serde::de::{self, MapAccess, Visitor};
9958        struct EnumVisitor;
9959        impl<'de> Visitor<'de> for EnumVisitor {
9960            type Value = LockFileResultEntry;
9961            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9962                f.write_str("a LockFileResultEntry structure")
9963            }
9964            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
9965                let tag: &str = match map.next_key()? {
9966                    Some(".tag") => map.next_value()?,
9967                    _ => return Err(de::Error::missing_field(".tag"))
9968                };
9969                let value = match tag {
9970                    "success" => LockFileResultEntry::Success(LockFileResult::internal_deserialize(&mut map)?),
9971                    "failure" => {
9972                        match map.next_key()? {
9973                            Some("failure") => LockFileResultEntry::Failure(map.next_value()?),
9974                            None => return Err(de::Error::missing_field("failure")),
9975                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
9976                        }
9977                    }
9978                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
9979                };
9980                crate::eat_json_fields(&mut map)?;
9981                Ok(value)
9982            }
9983        }
9984        const VARIANTS: &[&str] = &["success",
9985                                    "failure"];
9986        deserializer.deserialize_struct("LockFileResultEntry", VARIANTS, EnumVisitor)
9987    }
9988}
9989
9990impl ::serde::ser::Serialize for LockFileResultEntry {
9991    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9992        // union serializer
9993        use serde::ser::SerializeStruct;
9994        match self {
9995            LockFileResultEntry::Success(x) => {
9996                // struct
9997                let mut s = serializer.serialize_struct("LockFileResultEntry", 3)?;
9998                s.serialize_field(".tag", "success")?;
9999                x.internal_serialize::<S>(&mut s)?;
10000                s.end()
10001            }
10002            LockFileResultEntry::Failure(x) => {
10003                // union or polymporphic struct
10004                let mut s = serializer.serialize_struct("LockFileResultEntry", 2)?;
10005                s.serialize_field(".tag", "failure")?;
10006                s.serialize_field("failure", x)?;
10007                s.end()
10008            }
10009        }
10010    }
10011}
10012
10013#[derive(Debug, Clone, PartialEq, Eq)]
10014#[non_exhaustive] // variants may be added in the future
10015pub enum LookupError {
10016    /// The given path does not satisfy the required path format. Please refer to the [Path formats
10017    /// documentation](https://www.dropbox.com/developers/documentation/http/documentation#path-formats)
10018    /// for more information.
10019    MalformedPath(MalformedPathError),
10020    /// There is nothing at the given path.
10021    NotFound,
10022    /// We were expecting a file, but the given path refers to something that isn't a file.
10023    NotFile,
10024    /// We were expecting a folder, but the given path refers to something that isn't a folder.
10025    NotFolder,
10026    /// The file cannot be transferred because the content is restricted. For example, we might
10027    /// restrict a file due to legal requirements.
10028    RestrictedContent,
10029    /// This operation is not supported for this content type.
10030    UnsupportedContentType,
10031    /// The given path is locked.
10032    Locked,
10033    /// Catch-all used for unrecognized values returned from the server. Encountering this value
10034    /// typically indicates that this SDK version is out of date.
10035    Other,
10036}
10037
10038impl<'de> ::serde::de::Deserialize<'de> for LookupError {
10039    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10040        // union deserializer
10041        use serde::de::{self, MapAccess, Visitor};
10042        struct EnumVisitor;
10043        impl<'de> Visitor<'de> for EnumVisitor {
10044            type Value = LookupError;
10045            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10046                f.write_str("a LookupError structure")
10047            }
10048            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10049                let tag: &str = match map.next_key()? {
10050                    Some(".tag") => map.next_value()?,
10051                    _ => return Err(de::Error::missing_field(".tag"))
10052                };
10053                let value = match tag {
10054                    "malformed_path" => {
10055                        match map.next_key()? {
10056                            Some("malformed_path") => LookupError::MalformedPath(map.next_value()?),
10057                            None => LookupError::MalformedPath(None),
10058                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10059                        }
10060                    }
10061                    "not_found" => LookupError::NotFound,
10062                    "not_file" => LookupError::NotFile,
10063                    "not_folder" => LookupError::NotFolder,
10064                    "restricted_content" => LookupError::RestrictedContent,
10065                    "unsupported_content_type" => LookupError::UnsupportedContentType,
10066                    "locked" => LookupError::Locked,
10067                    _ => LookupError::Other,
10068                };
10069                crate::eat_json_fields(&mut map)?;
10070                Ok(value)
10071            }
10072        }
10073        const VARIANTS: &[&str] = &["malformed_path",
10074                                    "not_found",
10075                                    "not_file",
10076                                    "not_folder",
10077                                    "restricted_content",
10078                                    "unsupported_content_type",
10079                                    "locked",
10080                                    "other"];
10081        deserializer.deserialize_struct("LookupError", VARIANTS, EnumVisitor)
10082    }
10083}
10084
10085impl ::serde::ser::Serialize for LookupError {
10086    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10087        // union serializer
10088        use serde::ser::SerializeStruct;
10089        match self {
10090            LookupError::MalformedPath(x) => {
10091                // nullable (struct or primitive)
10092                let n = if x.is_some() { 2 } else { 1 };
10093                let mut s = serializer.serialize_struct("LookupError", n)?;
10094                s.serialize_field(".tag", "malformed_path")?;
10095                if let Some(x) = x {
10096                    s.serialize_field("malformed_path", &x)?;
10097                }
10098                s.end()
10099            }
10100            LookupError::NotFound => {
10101                // unit
10102                let mut s = serializer.serialize_struct("LookupError", 1)?;
10103                s.serialize_field(".tag", "not_found")?;
10104                s.end()
10105            }
10106            LookupError::NotFile => {
10107                // unit
10108                let mut s = serializer.serialize_struct("LookupError", 1)?;
10109                s.serialize_field(".tag", "not_file")?;
10110                s.end()
10111            }
10112            LookupError::NotFolder => {
10113                // unit
10114                let mut s = serializer.serialize_struct("LookupError", 1)?;
10115                s.serialize_field(".tag", "not_folder")?;
10116                s.end()
10117            }
10118            LookupError::RestrictedContent => {
10119                // unit
10120                let mut s = serializer.serialize_struct("LookupError", 1)?;
10121                s.serialize_field(".tag", "restricted_content")?;
10122                s.end()
10123            }
10124            LookupError::UnsupportedContentType => {
10125                // unit
10126                let mut s = serializer.serialize_struct("LookupError", 1)?;
10127                s.serialize_field(".tag", "unsupported_content_type")?;
10128                s.end()
10129            }
10130            LookupError::Locked => {
10131                // unit
10132                let mut s = serializer.serialize_struct("LookupError", 1)?;
10133                s.serialize_field(".tag", "locked")?;
10134                s.end()
10135            }
10136            LookupError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10137        }
10138    }
10139}
10140
10141impl ::std::error::Error for LookupError {
10142}
10143
10144impl ::std::fmt::Display for LookupError {
10145    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10146        match self {
10147            LookupError::MalformedPath(inner) => write!(f, "malformed_path: {:?}", inner),
10148            LookupError::NotFound => f.write_str("There is nothing at the given path."),
10149            LookupError::NotFile => f.write_str("We were expecting a file, but the given path refers to something that isn't a file."),
10150            LookupError::NotFolder => f.write_str("We were expecting a folder, but the given path refers to something that isn't a folder."),
10151            LookupError::RestrictedContent => f.write_str("The file cannot be transferred because the content is restricted. For example, we might restrict a file due to legal requirements."),
10152            LookupError::UnsupportedContentType => f.write_str("This operation is not supported for this content type."),
10153            LookupError::Locked => f.write_str("The given path is locked."),
10154            _ => write!(f, "{:?}", *self),
10155        }
10156    }
10157}
10158
10159#[derive(Debug, Clone, PartialEq)]
10160pub enum MediaInfo {
10161    /// Indicate the photo/video is still under processing and metadata is not available yet.
10162    Pending,
10163    /// The metadata for the photo/video.
10164    Metadata(MediaMetadata),
10165}
10166
10167impl<'de> ::serde::de::Deserialize<'de> for MediaInfo {
10168    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10169        // union deserializer
10170        use serde::de::{self, MapAccess, Visitor};
10171        struct EnumVisitor;
10172        impl<'de> Visitor<'de> for EnumVisitor {
10173            type Value = MediaInfo;
10174            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10175                f.write_str("a MediaInfo structure")
10176            }
10177            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10178                let tag: &str = match map.next_key()? {
10179                    Some(".tag") => map.next_value()?,
10180                    _ => return Err(de::Error::missing_field(".tag"))
10181                };
10182                let value = match tag {
10183                    "pending" => MediaInfo::Pending,
10184                    "metadata" => {
10185                        match map.next_key()? {
10186                            Some("metadata") => MediaInfo::Metadata(map.next_value()?),
10187                            None => return Err(de::Error::missing_field("metadata")),
10188                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10189                        }
10190                    }
10191                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
10192                };
10193                crate::eat_json_fields(&mut map)?;
10194                Ok(value)
10195            }
10196        }
10197        const VARIANTS: &[&str] = &["pending",
10198                                    "metadata"];
10199        deserializer.deserialize_struct("MediaInfo", VARIANTS, EnumVisitor)
10200    }
10201}
10202
10203impl ::serde::ser::Serialize for MediaInfo {
10204    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10205        // union serializer
10206        use serde::ser::SerializeStruct;
10207        match self {
10208            MediaInfo::Pending => {
10209                // unit
10210                let mut s = serializer.serialize_struct("MediaInfo", 1)?;
10211                s.serialize_field(".tag", "pending")?;
10212                s.end()
10213            }
10214            MediaInfo::Metadata(x) => {
10215                // union or polymporphic struct
10216                let mut s = serializer.serialize_struct("MediaInfo", 2)?;
10217                s.serialize_field(".tag", "metadata")?;
10218                s.serialize_field("metadata", x)?;
10219                s.end()
10220            }
10221        }
10222    }
10223}
10224
10225/// Metadata for a photo or video.
10226#[derive(Debug, Clone, PartialEq)]
10227pub enum MediaMetadata {
10228    Photo(PhotoMetadata),
10229    Video(VideoMetadata),
10230}
10231
10232impl<'de> ::serde::de::Deserialize<'de> for MediaMetadata {
10233    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10234        // polymorphic struct deserializer
10235        use serde::de::{self, MapAccess, Visitor};
10236        struct EnumVisitor;
10237        impl<'de> Visitor<'de> for EnumVisitor {
10238            type Value = MediaMetadata;
10239            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10240                f.write_str("a MediaMetadata structure")
10241            }
10242            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10243                let tag = match map.next_key()? {
10244                    Some(".tag") => map.next_value()?,
10245                    _ => return Err(de::Error::missing_field(".tag"))
10246                };
10247                match tag {
10248                    "photo" => Ok(MediaMetadata::Photo(PhotoMetadata::internal_deserialize(map)?)),
10249                    "video" => Ok(MediaMetadata::Video(VideoMetadata::internal_deserialize(map)?)),
10250                    _ => Err(de::Error::unknown_variant(tag, VARIANTS))
10251                }
10252            }
10253        }
10254        const VARIANTS: &[&str] = &["photo",
10255                                    "video"];
10256        deserializer.deserialize_struct("MediaMetadata", VARIANTS, EnumVisitor)
10257    }
10258}
10259
10260impl ::serde::ser::Serialize for MediaMetadata {
10261    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10262        // polymorphic struct serializer
10263        use serde::ser::SerializeStruct;
10264        match self {
10265            MediaMetadata::Photo(x) => {
10266                let mut s = serializer.serialize_struct("MediaMetadata", 4)?;
10267                s.serialize_field(".tag", "photo")?;
10268                x.internal_serialize::<S>(&mut s)?;
10269                s.end()
10270            }
10271            MediaMetadata::Video(x) => {
10272                let mut s = serializer.serialize_struct("MediaMetadata", 5)?;
10273                s.serialize_field(".tag", "video")?;
10274                x.internal_serialize::<S>(&mut s)?;
10275                s.end()
10276            }
10277        }
10278    }
10279}
10280
10281/// Metadata for a file or folder.
10282#[derive(Debug, Clone, PartialEq)]
10283pub enum Metadata {
10284    File(FileMetadata),
10285    Folder(FolderMetadata),
10286    Deleted(DeletedMetadata),
10287}
10288
10289impl<'de> ::serde::de::Deserialize<'de> for Metadata {
10290    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10291        // polymorphic struct deserializer
10292        use serde::de::{self, MapAccess, Visitor};
10293        struct EnumVisitor;
10294        impl<'de> Visitor<'de> for EnumVisitor {
10295            type Value = Metadata;
10296            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10297                f.write_str("a Metadata structure")
10298            }
10299            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10300                let tag = match map.next_key()? {
10301                    Some(".tag") => map.next_value()?,
10302                    _ => return Err(de::Error::missing_field(".tag"))
10303                };
10304                match tag {
10305                    "file" => Ok(Metadata::File(FileMetadata::internal_deserialize(map)?)),
10306                    "folder" => Ok(Metadata::Folder(FolderMetadata::internal_deserialize(map)?)),
10307                    "deleted" => Ok(Metadata::Deleted(DeletedMetadata::internal_deserialize(map)?)),
10308                    _ => Err(de::Error::unknown_variant(tag, VARIANTS))
10309                }
10310            }
10311        }
10312        const VARIANTS: &[&str] = &["file",
10313                                    "folder",
10314                                    "deleted"];
10315        deserializer.deserialize_struct("Metadata", VARIANTS, EnumVisitor)
10316    }
10317}
10318
10319impl ::serde::ser::Serialize for Metadata {
10320    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10321        // polymorphic struct serializer
10322        use serde::ser::SerializeStruct;
10323        match self {
10324            Metadata::File(x) => {
10325                let mut s = serializer.serialize_struct("Metadata", 20)?;
10326                s.serialize_field(".tag", "file")?;
10327                x.internal_serialize::<S>(&mut s)?;
10328                s.end()
10329            }
10330            Metadata::Folder(x) => {
10331                let mut s = serializer.serialize_struct("Metadata", 10)?;
10332                s.serialize_field(".tag", "folder")?;
10333                x.internal_serialize::<S>(&mut s)?;
10334                s.end()
10335            }
10336            Metadata::Deleted(x) => {
10337                let mut s = serializer.serialize_struct("Metadata", 6)?;
10338                s.serialize_field(".tag", "deleted")?;
10339                x.internal_serialize::<S>(&mut s)?;
10340                s.end()
10341            }
10342        }
10343    }
10344}
10345
10346/// Metadata for a file, folder or other resource types.
10347#[derive(Debug, Clone, PartialEq)]
10348#[non_exhaustive] // variants may be added in the future
10349pub enum MetadataV2 {
10350    Metadata(Metadata),
10351    /// Catch-all used for unrecognized values returned from the server. Encountering this value
10352    /// typically indicates that this SDK version is out of date.
10353    Other,
10354}
10355
10356impl<'de> ::serde::de::Deserialize<'de> for MetadataV2 {
10357    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10358        // union deserializer
10359        use serde::de::{self, MapAccess, Visitor};
10360        struct EnumVisitor;
10361        impl<'de> Visitor<'de> for EnumVisitor {
10362            type Value = MetadataV2;
10363            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10364                f.write_str("a MetadataV2 structure")
10365            }
10366            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10367                let tag: &str = match map.next_key()? {
10368                    Some(".tag") => map.next_value()?,
10369                    _ => return Err(de::Error::missing_field(".tag"))
10370                };
10371                let value = match tag {
10372                    "metadata" => {
10373                        match map.next_key()? {
10374                            Some("metadata") => MetadataV2::Metadata(map.next_value()?),
10375                            None => return Err(de::Error::missing_field("metadata")),
10376                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10377                        }
10378                    }
10379                    _ => MetadataV2::Other,
10380                };
10381                crate::eat_json_fields(&mut map)?;
10382                Ok(value)
10383            }
10384        }
10385        const VARIANTS: &[&str] = &["metadata",
10386                                    "other"];
10387        deserializer.deserialize_struct("MetadataV2", VARIANTS, EnumVisitor)
10388    }
10389}
10390
10391impl ::serde::ser::Serialize for MetadataV2 {
10392    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10393        // union serializer
10394        use serde::ser::SerializeStruct;
10395        match self {
10396            MetadataV2::Metadata(x) => {
10397                // union or polymporphic struct
10398                let mut s = serializer.serialize_struct("MetadataV2", 2)?;
10399                s.serialize_field(".tag", "metadata")?;
10400                s.serialize_field("metadata", x)?;
10401                s.end()
10402            }
10403            MetadataV2::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10404        }
10405    }
10406}
10407
10408#[derive(Debug, Clone, PartialEq, Eq)]
10409#[non_exhaustive] // structs may have more fields added in the future.
10410pub struct MinimalFileLinkMetadata {
10411    /// URL of the shared link.
10412    pub url: String,
10413    /// A unique identifier for the current revision of a file. This field is the same rev as
10414    /// elsewhere in the API and can be used to detect changes and avoid conflicts.
10415    pub rev: Rev,
10416    /// Unique identifier for the linked file.
10417    pub id: Option<Id>,
10418    /// Full path in the user's Dropbox. This always starts with a slash. This field will only be
10419    /// present only if the linked file is in the authenticated user's Dropbox.
10420    pub path: Option<String>,
10421}
10422
10423impl MinimalFileLinkMetadata {
10424    pub fn new(url: String, rev: Rev) -> Self {
10425        MinimalFileLinkMetadata {
10426            url,
10427            rev,
10428            id: None,
10429            path: None,
10430        }
10431    }
10432
10433    pub fn with_id(mut self, value: Id) -> Self {
10434        self.id = Some(value);
10435        self
10436    }
10437
10438    pub fn with_path(mut self, value: String) -> Self {
10439        self.path = Some(value);
10440        self
10441    }
10442}
10443
10444const MINIMAL_FILE_LINK_METADATA_FIELDS: &[&str] = &["url",
10445                                                     "rev",
10446                                                     "id",
10447                                                     "path"];
10448impl MinimalFileLinkMetadata {
10449    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
10450        map: V,
10451    ) -> Result<MinimalFileLinkMetadata, V::Error> {
10452        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
10453    }
10454
10455    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
10456        mut map: V,
10457        optional: bool,
10458    ) -> Result<Option<MinimalFileLinkMetadata>, V::Error> {
10459        let mut field_url = None;
10460        let mut field_rev = None;
10461        let mut field_id = None;
10462        let mut field_path = None;
10463        let mut nothing = true;
10464        while let Some(key) = map.next_key::<&str>()? {
10465            nothing = false;
10466            match key {
10467                "url" => {
10468                    if field_url.is_some() {
10469                        return Err(::serde::de::Error::duplicate_field("url"));
10470                    }
10471                    field_url = Some(map.next_value()?);
10472                }
10473                "rev" => {
10474                    if field_rev.is_some() {
10475                        return Err(::serde::de::Error::duplicate_field("rev"));
10476                    }
10477                    field_rev = Some(map.next_value()?);
10478                }
10479                "id" => {
10480                    if field_id.is_some() {
10481                        return Err(::serde::de::Error::duplicate_field("id"));
10482                    }
10483                    field_id = Some(map.next_value()?);
10484                }
10485                "path" => {
10486                    if field_path.is_some() {
10487                        return Err(::serde::de::Error::duplicate_field("path"));
10488                    }
10489                    field_path = Some(map.next_value()?);
10490                }
10491                _ => {
10492                    // unknown field allowed and ignored
10493                    map.next_value::<::serde_json::Value>()?;
10494                }
10495            }
10496        }
10497        if optional && nothing {
10498            return Ok(None);
10499        }
10500        let result = MinimalFileLinkMetadata {
10501            url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
10502            rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
10503            id: field_id.and_then(Option::flatten),
10504            path: field_path.and_then(Option::flatten),
10505        };
10506        Ok(Some(result))
10507    }
10508
10509    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
10510        &self,
10511        s: &mut S::SerializeStruct,
10512    ) -> Result<(), S::Error> {
10513        use serde::ser::SerializeStruct;
10514        s.serialize_field("url", &self.url)?;
10515        s.serialize_field("rev", &self.rev)?;
10516        if let Some(val) = &self.id {
10517            s.serialize_field("id", val)?;
10518        }
10519        if let Some(val) = &self.path {
10520            s.serialize_field("path", val)?;
10521        }
10522        Ok(())
10523    }
10524}
10525
10526impl<'de> ::serde::de::Deserialize<'de> for MinimalFileLinkMetadata {
10527    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10528        // struct deserializer
10529        use serde::de::{MapAccess, Visitor};
10530        struct StructVisitor;
10531        impl<'de> Visitor<'de> for StructVisitor {
10532            type Value = MinimalFileLinkMetadata;
10533            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10534                f.write_str("a MinimalFileLinkMetadata struct")
10535            }
10536            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
10537                MinimalFileLinkMetadata::internal_deserialize(map)
10538            }
10539        }
10540        deserializer.deserialize_struct("MinimalFileLinkMetadata", MINIMAL_FILE_LINK_METADATA_FIELDS, StructVisitor)
10541    }
10542}
10543
10544impl ::serde::ser::Serialize for MinimalFileLinkMetadata {
10545    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10546        // struct serializer
10547        use serde::ser::SerializeStruct;
10548        let mut s = serializer.serialize_struct("MinimalFileLinkMetadata", 4)?;
10549        self.internal_serialize::<S>(&mut s)?;
10550        s.end()
10551    }
10552}
10553
10554#[derive(Debug, Clone, PartialEq, Eq)]
10555#[non_exhaustive] // structs may have more fields added in the future.
10556pub struct MoveBatchArg {
10557    /// List of entries to be moved or copied. Each entry is [`RelocationPath`].
10558    pub entries: Vec<RelocationPath>,
10559    /// If there's a conflict with any file, have the Dropbox server try to autorename that file to
10560    /// avoid the conflict.
10561    pub autorename: bool,
10562    /// Allow moves by owner even if it would result in an ownership transfer for the content being
10563    /// moved. This does not apply to copies.
10564    pub allow_ownership_transfer: bool,
10565}
10566
10567impl MoveBatchArg {
10568    pub fn new(entries: Vec<RelocationPath>) -> Self {
10569        MoveBatchArg {
10570            entries,
10571            autorename: false,
10572            allow_ownership_transfer: false,
10573        }
10574    }
10575
10576    pub fn with_autorename(mut self, value: bool) -> Self {
10577        self.autorename = value;
10578        self
10579    }
10580
10581    pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
10582        self.allow_ownership_transfer = value;
10583        self
10584    }
10585}
10586
10587const MOVE_BATCH_ARG_FIELDS: &[&str] = &["entries",
10588                                         "autorename",
10589                                         "allow_ownership_transfer"];
10590impl MoveBatchArg {
10591    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
10592        map: V,
10593    ) -> Result<MoveBatchArg, V::Error> {
10594        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
10595    }
10596
10597    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
10598        mut map: V,
10599        optional: bool,
10600    ) -> Result<Option<MoveBatchArg>, V::Error> {
10601        let mut field_entries = None;
10602        let mut field_autorename = None;
10603        let mut field_allow_ownership_transfer = None;
10604        let mut nothing = true;
10605        while let Some(key) = map.next_key::<&str>()? {
10606            nothing = false;
10607            match key {
10608                "entries" => {
10609                    if field_entries.is_some() {
10610                        return Err(::serde::de::Error::duplicate_field("entries"));
10611                    }
10612                    field_entries = Some(map.next_value()?);
10613                }
10614                "autorename" => {
10615                    if field_autorename.is_some() {
10616                        return Err(::serde::de::Error::duplicate_field("autorename"));
10617                    }
10618                    field_autorename = Some(map.next_value()?);
10619                }
10620                "allow_ownership_transfer" => {
10621                    if field_allow_ownership_transfer.is_some() {
10622                        return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
10623                    }
10624                    field_allow_ownership_transfer = Some(map.next_value()?);
10625                }
10626                _ => {
10627                    // unknown field allowed and ignored
10628                    map.next_value::<::serde_json::Value>()?;
10629                }
10630            }
10631        }
10632        if optional && nothing {
10633            return Ok(None);
10634        }
10635        let result = MoveBatchArg {
10636            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
10637            autorename: field_autorename.unwrap_or(false),
10638            allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
10639        };
10640        Ok(Some(result))
10641    }
10642
10643    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
10644        &self,
10645        s: &mut S::SerializeStruct,
10646    ) -> Result<(), S::Error> {
10647        use serde::ser::SerializeStruct;
10648        s.serialize_field("entries", &self.entries)?;
10649        if self.autorename {
10650            s.serialize_field("autorename", &self.autorename)?;
10651        }
10652        if self.allow_ownership_transfer {
10653            s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
10654        }
10655        Ok(())
10656    }
10657}
10658
10659impl<'de> ::serde::de::Deserialize<'de> for MoveBatchArg {
10660    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10661        // struct deserializer
10662        use serde::de::{MapAccess, Visitor};
10663        struct StructVisitor;
10664        impl<'de> Visitor<'de> for StructVisitor {
10665            type Value = MoveBatchArg;
10666            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10667                f.write_str("a MoveBatchArg struct")
10668            }
10669            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
10670                MoveBatchArg::internal_deserialize(map)
10671            }
10672        }
10673        deserializer.deserialize_struct("MoveBatchArg", MOVE_BATCH_ARG_FIELDS, StructVisitor)
10674    }
10675}
10676
10677impl ::serde::ser::Serialize for MoveBatchArg {
10678    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10679        // struct serializer
10680        use serde::ser::SerializeStruct;
10681        let mut s = serializer.serialize_struct("MoveBatchArg", 3)?;
10682        self.internal_serialize::<S>(&mut s)?;
10683        s.end()
10684    }
10685}
10686
10687// struct extends RelocationBatchArgBase
10688impl From<MoveBatchArg> for RelocationBatchArgBase {
10689    fn from(subtype: MoveBatchArg) -> Self {
10690        Self {
10691            entries: subtype.entries,
10692            autorename: subtype.autorename,
10693        }
10694    }
10695}
10696#[derive(Debug, Clone, PartialEq, Eq)]
10697#[non_exhaustive] // variants may be added in the future
10698pub enum MoveIntoFamilyError {
10699    /// Moving shared folder into Family Room folder is not allowed.
10700    IsSharedFolder,
10701    /// Catch-all used for unrecognized values returned from the server. Encountering this value
10702    /// typically indicates that this SDK version is out of date.
10703    Other,
10704}
10705
10706impl<'de> ::serde::de::Deserialize<'de> for MoveIntoFamilyError {
10707    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10708        // union deserializer
10709        use serde::de::{self, MapAccess, Visitor};
10710        struct EnumVisitor;
10711        impl<'de> Visitor<'de> for EnumVisitor {
10712            type Value = MoveIntoFamilyError;
10713            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10714                f.write_str("a MoveIntoFamilyError structure")
10715            }
10716            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10717                let tag: &str = match map.next_key()? {
10718                    Some(".tag") => map.next_value()?,
10719                    _ => return Err(de::Error::missing_field(".tag"))
10720                };
10721                let value = match tag {
10722                    "is_shared_folder" => MoveIntoFamilyError::IsSharedFolder,
10723                    _ => MoveIntoFamilyError::Other,
10724                };
10725                crate::eat_json_fields(&mut map)?;
10726                Ok(value)
10727            }
10728        }
10729        const VARIANTS: &[&str] = &["is_shared_folder",
10730                                    "other"];
10731        deserializer.deserialize_struct("MoveIntoFamilyError", VARIANTS, EnumVisitor)
10732    }
10733}
10734
10735impl ::serde::ser::Serialize for MoveIntoFamilyError {
10736    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10737        // union serializer
10738        use serde::ser::SerializeStruct;
10739        match self {
10740            MoveIntoFamilyError::IsSharedFolder => {
10741                // unit
10742                let mut s = serializer.serialize_struct("MoveIntoFamilyError", 1)?;
10743                s.serialize_field(".tag", "is_shared_folder")?;
10744                s.end()
10745            }
10746            MoveIntoFamilyError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10747        }
10748    }
10749}
10750
10751impl ::std::error::Error for MoveIntoFamilyError {
10752}
10753
10754impl ::std::fmt::Display for MoveIntoFamilyError {
10755    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10756        match self {
10757            MoveIntoFamilyError::IsSharedFolder => f.write_str("Moving shared folder into Family Room folder is not allowed."),
10758            _ => write!(f, "{:?}", *self),
10759        }
10760    }
10761}
10762
10763#[derive(Debug, Clone, PartialEq, Eq)]
10764#[non_exhaustive] // variants may be added in the future
10765pub enum MoveIntoVaultError {
10766    /// Moving shared folder into Vault is not allowed.
10767    IsSharedFolder,
10768    /// Catch-all used for unrecognized values returned from the server. Encountering this value
10769    /// typically indicates that this SDK version is out of date.
10770    Other,
10771}
10772
10773impl<'de> ::serde::de::Deserialize<'de> for MoveIntoVaultError {
10774    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10775        // union deserializer
10776        use serde::de::{self, MapAccess, Visitor};
10777        struct EnumVisitor;
10778        impl<'de> Visitor<'de> for EnumVisitor {
10779            type Value = MoveIntoVaultError;
10780            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10781                f.write_str("a MoveIntoVaultError structure")
10782            }
10783            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10784                let tag: &str = match map.next_key()? {
10785                    Some(".tag") => map.next_value()?,
10786                    _ => return Err(de::Error::missing_field(".tag"))
10787                };
10788                let value = match tag {
10789                    "is_shared_folder" => MoveIntoVaultError::IsSharedFolder,
10790                    _ => MoveIntoVaultError::Other,
10791                };
10792                crate::eat_json_fields(&mut map)?;
10793                Ok(value)
10794            }
10795        }
10796        const VARIANTS: &[&str] = &["is_shared_folder",
10797                                    "other"];
10798        deserializer.deserialize_struct("MoveIntoVaultError", VARIANTS, EnumVisitor)
10799    }
10800}
10801
10802impl ::serde::ser::Serialize for MoveIntoVaultError {
10803    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10804        // union serializer
10805        use serde::ser::SerializeStruct;
10806        match self {
10807            MoveIntoVaultError::IsSharedFolder => {
10808                // unit
10809                let mut s = serializer.serialize_struct("MoveIntoVaultError", 1)?;
10810                s.serialize_field(".tag", "is_shared_folder")?;
10811                s.end()
10812            }
10813            MoveIntoVaultError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10814        }
10815    }
10816}
10817
10818impl ::std::error::Error for MoveIntoVaultError {
10819}
10820
10821impl ::std::fmt::Display for MoveIntoVaultError {
10822    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10823        match self {
10824            MoveIntoVaultError::IsSharedFolder => f.write_str("Moving shared folder into Vault is not allowed."),
10825            _ => write!(f, "{:?}", *self),
10826        }
10827    }
10828}
10829
10830#[derive(Debug, Clone, PartialEq, Eq)]
10831#[non_exhaustive] // variants may be added in the future
10832pub enum PaperContentError {
10833    /// Your account does not have permissions to edit Paper docs.
10834    InsufficientPermissions,
10835    /// The provided content was malformed and cannot be imported to Paper.
10836    ContentMalformed,
10837    /// The Paper doc would be too large, split the content into multiple docs.
10838    DocLengthExceeded,
10839    /// The imported document contains an image that is too large. The current limit is 1MB. This
10840    /// only applies to HTML with data URI.
10841    ImageSizeExceeded,
10842    /// Catch-all used for unrecognized values returned from the server. Encountering this value
10843    /// typically indicates that this SDK version is out of date.
10844    Other,
10845}
10846
10847impl<'de> ::serde::de::Deserialize<'de> for PaperContentError {
10848    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10849        // union deserializer
10850        use serde::de::{self, MapAccess, Visitor};
10851        struct EnumVisitor;
10852        impl<'de> Visitor<'de> for EnumVisitor {
10853            type Value = PaperContentError;
10854            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10855                f.write_str("a PaperContentError structure")
10856            }
10857            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10858                let tag: &str = match map.next_key()? {
10859                    Some(".tag") => map.next_value()?,
10860                    _ => return Err(de::Error::missing_field(".tag"))
10861                };
10862                let value = match tag {
10863                    "insufficient_permissions" => PaperContentError::InsufficientPermissions,
10864                    "content_malformed" => PaperContentError::ContentMalformed,
10865                    "doc_length_exceeded" => PaperContentError::DocLengthExceeded,
10866                    "image_size_exceeded" => PaperContentError::ImageSizeExceeded,
10867                    _ => PaperContentError::Other,
10868                };
10869                crate::eat_json_fields(&mut map)?;
10870                Ok(value)
10871            }
10872        }
10873        const VARIANTS: &[&str] = &["insufficient_permissions",
10874                                    "content_malformed",
10875                                    "doc_length_exceeded",
10876                                    "image_size_exceeded",
10877                                    "other"];
10878        deserializer.deserialize_struct("PaperContentError", VARIANTS, EnumVisitor)
10879    }
10880}
10881
10882impl ::serde::ser::Serialize for PaperContentError {
10883    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10884        // union serializer
10885        use serde::ser::SerializeStruct;
10886        match self {
10887            PaperContentError::InsufficientPermissions => {
10888                // unit
10889                let mut s = serializer.serialize_struct("PaperContentError", 1)?;
10890                s.serialize_field(".tag", "insufficient_permissions")?;
10891                s.end()
10892            }
10893            PaperContentError::ContentMalformed => {
10894                // unit
10895                let mut s = serializer.serialize_struct("PaperContentError", 1)?;
10896                s.serialize_field(".tag", "content_malformed")?;
10897                s.end()
10898            }
10899            PaperContentError::DocLengthExceeded => {
10900                // unit
10901                let mut s = serializer.serialize_struct("PaperContentError", 1)?;
10902                s.serialize_field(".tag", "doc_length_exceeded")?;
10903                s.end()
10904            }
10905            PaperContentError::ImageSizeExceeded => {
10906                // unit
10907                let mut s = serializer.serialize_struct("PaperContentError", 1)?;
10908                s.serialize_field(".tag", "image_size_exceeded")?;
10909                s.end()
10910            }
10911            PaperContentError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10912        }
10913    }
10914}
10915
10916impl ::std::error::Error for PaperContentError {
10917}
10918
10919impl ::std::fmt::Display for PaperContentError {
10920    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10921        match self {
10922            PaperContentError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
10923            PaperContentError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
10924            PaperContentError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
10925            PaperContentError::ImageSizeExceeded => f.write_str("The imported document contains an image that is too large. The current limit is 1MB. This only applies to HTML with data URI."),
10926            _ => write!(f, "{:?}", *self),
10927        }
10928    }
10929}
10930
10931#[derive(Debug, Clone, PartialEq, Eq)]
10932#[non_exhaustive] // structs may have more fields added in the future.
10933pub struct PaperCreateArg {
10934    /// The fully qualified path to the location in the user's Dropbox where the Paper Doc should be
10935    /// created. This should include the document's title and end with .paper.
10936    pub path: Path,
10937    /// The format of the provided data.
10938    pub import_format: ImportFormat,
10939}
10940
10941impl PaperCreateArg {
10942    pub fn new(path: Path, import_format: ImportFormat) -> Self {
10943        PaperCreateArg {
10944            path,
10945            import_format,
10946        }
10947    }
10948}
10949
10950const PAPER_CREATE_ARG_FIELDS: &[&str] = &["path",
10951                                           "import_format"];
10952impl PaperCreateArg {
10953    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
10954        map: V,
10955    ) -> Result<PaperCreateArg, V::Error> {
10956        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
10957    }
10958
10959    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
10960        mut map: V,
10961        optional: bool,
10962    ) -> Result<Option<PaperCreateArg>, V::Error> {
10963        let mut field_path = None;
10964        let mut field_import_format = None;
10965        let mut nothing = true;
10966        while let Some(key) = map.next_key::<&str>()? {
10967            nothing = false;
10968            match key {
10969                "path" => {
10970                    if field_path.is_some() {
10971                        return Err(::serde::de::Error::duplicate_field("path"));
10972                    }
10973                    field_path = Some(map.next_value()?);
10974                }
10975                "import_format" => {
10976                    if field_import_format.is_some() {
10977                        return Err(::serde::de::Error::duplicate_field("import_format"));
10978                    }
10979                    field_import_format = Some(map.next_value()?);
10980                }
10981                _ => {
10982                    // unknown field allowed and ignored
10983                    map.next_value::<::serde_json::Value>()?;
10984                }
10985            }
10986        }
10987        if optional && nothing {
10988            return Ok(None);
10989        }
10990        let result = PaperCreateArg {
10991            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
10992            import_format: field_import_format.ok_or_else(|| ::serde::de::Error::missing_field("import_format"))?,
10993        };
10994        Ok(Some(result))
10995    }
10996
10997    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
10998        &self,
10999        s: &mut S::SerializeStruct,
11000    ) -> Result<(), S::Error> {
11001        use serde::ser::SerializeStruct;
11002        s.serialize_field("path", &self.path)?;
11003        s.serialize_field("import_format", &self.import_format)?;
11004        Ok(())
11005    }
11006}
11007
11008impl<'de> ::serde::de::Deserialize<'de> for PaperCreateArg {
11009    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11010        // struct deserializer
11011        use serde::de::{MapAccess, Visitor};
11012        struct StructVisitor;
11013        impl<'de> Visitor<'de> for StructVisitor {
11014            type Value = PaperCreateArg;
11015            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11016                f.write_str("a PaperCreateArg struct")
11017            }
11018            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11019                PaperCreateArg::internal_deserialize(map)
11020            }
11021        }
11022        deserializer.deserialize_struct("PaperCreateArg", PAPER_CREATE_ARG_FIELDS, StructVisitor)
11023    }
11024}
11025
11026impl ::serde::ser::Serialize for PaperCreateArg {
11027    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11028        // struct serializer
11029        use serde::ser::SerializeStruct;
11030        let mut s = serializer.serialize_struct("PaperCreateArg", 2)?;
11031        self.internal_serialize::<S>(&mut s)?;
11032        s.end()
11033    }
11034}
11035
11036#[derive(Debug, Clone, PartialEq, Eq)]
11037#[non_exhaustive] // variants may be added in the future
11038pub enum PaperCreateError {
11039    /// Your account does not have permissions to edit Paper docs.
11040    InsufficientPermissions,
11041    /// The provided content was malformed and cannot be imported to Paper.
11042    ContentMalformed,
11043    /// The Paper doc would be too large, split the content into multiple docs.
11044    DocLengthExceeded,
11045    /// The imported document contains an image that is too large. The current limit is 1MB. This
11046    /// only applies to HTML with data URI.
11047    ImageSizeExceeded,
11048    /// The file could not be saved to the specified location.
11049    InvalidPath,
11050    /// The user's email must be verified to create Paper docs.
11051    EmailUnverified,
11052    /// The file path must end in .paper.
11053    InvalidFileExtension,
11054    /// Paper is disabled for your team.
11055    PaperDisabled,
11056    /// Catch-all used for unrecognized values returned from the server. Encountering this value
11057    /// typically indicates that this SDK version is out of date.
11058    Other,
11059}
11060
11061impl<'de> ::serde::de::Deserialize<'de> for PaperCreateError {
11062    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11063        // union deserializer
11064        use serde::de::{self, MapAccess, Visitor};
11065        struct EnumVisitor;
11066        impl<'de> Visitor<'de> for EnumVisitor {
11067            type Value = PaperCreateError;
11068            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11069                f.write_str("a PaperCreateError structure")
11070            }
11071            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11072                let tag: &str = match map.next_key()? {
11073                    Some(".tag") => map.next_value()?,
11074                    _ => return Err(de::Error::missing_field(".tag"))
11075                };
11076                let value = match tag {
11077                    "insufficient_permissions" => PaperCreateError::InsufficientPermissions,
11078                    "content_malformed" => PaperCreateError::ContentMalformed,
11079                    "doc_length_exceeded" => PaperCreateError::DocLengthExceeded,
11080                    "image_size_exceeded" => PaperCreateError::ImageSizeExceeded,
11081                    "invalid_path" => PaperCreateError::InvalidPath,
11082                    "email_unverified" => PaperCreateError::EmailUnverified,
11083                    "invalid_file_extension" => PaperCreateError::InvalidFileExtension,
11084                    "paper_disabled" => PaperCreateError::PaperDisabled,
11085                    _ => PaperCreateError::Other,
11086                };
11087                crate::eat_json_fields(&mut map)?;
11088                Ok(value)
11089            }
11090        }
11091        const VARIANTS: &[&str] = &["insufficient_permissions",
11092                                    "content_malformed",
11093                                    "doc_length_exceeded",
11094                                    "image_size_exceeded",
11095                                    "other",
11096                                    "invalid_path",
11097                                    "email_unverified",
11098                                    "invalid_file_extension",
11099                                    "paper_disabled"];
11100        deserializer.deserialize_struct("PaperCreateError", VARIANTS, EnumVisitor)
11101    }
11102}
11103
11104impl ::serde::ser::Serialize for PaperCreateError {
11105    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11106        // union serializer
11107        use serde::ser::SerializeStruct;
11108        match self {
11109            PaperCreateError::InsufficientPermissions => {
11110                // unit
11111                let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11112                s.serialize_field(".tag", "insufficient_permissions")?;
11113                s.end()
11114            }
11115            PaperCreateError::ContentMalformed => {
11116                // unit
11117                let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11118                s.serialize_field(".tag", "content_malformed")?;
11119                s.end()
11120            }
11121            PaperCreateError::DocLengthExceeded => {
11122                // unit
11123                let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11124                s.serialize_field(".tag", "doc_length_exceeded")?;
11125                s.end()
11126            }
11127            PaperCreateError::ImageSizeExceeded => {
11128                // unit
11129                let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11130                s.serialize_field(".tag", "image_size_exceeded")?;
11131                s.end()
11132            }
11133            PaperCreateError::InvalidPath => {
11134                // unit
11135                let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11136                s.serialize_field(".tag", "invalid_path")?;
11137                s.end()
11138            }
11139            PaperCreateError::EmailUnverified => {
11140                // unit
11141                let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11142                s.serialize_field(".tag", "email_unverified")?;
11143                s.end()
11144            }
11145            PaperCreateError::InvalidFileExtension => {
11146                // unit
11147                let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11148                s.serialize_field(".tag", "invalid_file_extension")?;
11149                s.end()
11150            }
11151            PaperCreateError::PaperDisabled => {
11152                // unit
11153                let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11154                s.serialize_field(".tag", "paper_disabled")?;
11155                s.end()
11156            }
11157            PaperCreateError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11158        }
11159    }
11160}
11161
11162impl ::std::error::Error for PaperCreateError {
11163}
11164
11165impl ::std::fmt::Display for PaperCreateError {
11166    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11167        match self {
11168            PaperCreateError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
11169            PaperCreateError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
11170            PaperCreateError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
11171            PaperCreateError::ImageSizeExceeded => f.write_str("The imported document contains an image that is too large. The current limit is 1MB. This only applies to HTML with data URI."),
11172            PaperCreateError::InvalidPath => f.write_str("The file could not be saved to the specified location."),
11173            PaperCreateError::EmailUnverified => f.write_str("The user's email must be verified to create Paper docs."),
11174            PaperCreateError::InvalidFileExtension => f.write_str("The file path must end in .paper."),
11175            PaperCreateError::PaperDisabled => f.write_str("Paper is disabled for your team."),
11176            _ => write!(f, "{:?}", *self),
11177        }
11178    }
11179}
11180
11181// union extends PaperContentError
11182impl From<PaperContentError> for PaperCreateError {
11183    fn from(parent: PaperContentError) -> Self {
11184        match parent {
11185            PaperContentError::InsufficientPermissions => PaperCreateError::InsufficientPermissions,
11186            PaperContentError::ContentMalformed => PaperCreateError::ContentMalformed,
11187            PaperContentError::DocLengthExceeded => PaperCreateError::DocLengthExceeded,
11188            PaperContentError::ImageSizeExceeded => PaperCreateError::ImageSizeExceeded,
11189            PaperContentError::Other => PaperCreateError::Other,
11190        }
11191    }
11192}
11193#[derive(Debug, Clone, PartialEq, Eq)]
11194#[non_exhaustive] // structs may have more fields added in the future.
11195pub struct PaperCreateResult {
11196    /// URL to open the Paper Doc.
11197    pub url: String,
11198    /// The fully qualified path the Paper Doc was actually created at.
11199    pub result_path: String,
11200    /// The id to use in Dropbox APIs when referencing the Paper Doc.
11201    pub file_id: FileId,
11202    /// The current doc revision.
11203    pub paper_revision: i64,
11204}
11205
11206impl PaperCreateResult {
11207    pub fn new(url: String, result_path: String, file_id: FileId, paper_revision: i64) -> Self {
11208        PaperCreateResult {
11209            url,
11210            result_path,
11211            file_id,
11212            paper_revision,
11213        }
11214    }
11215}
11216
11217const PAPER_CREATE_RESULT_FIELDS: &[&str] = &["url",
11218                                              "result_path",
11219                                              "file_id",
11220                                              "paper_revision"];
11221impl PaperCreateResult {
11222    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11223        map: V,
11224    ) -> Result<PaperCreateResult, V::Error> {
11225        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11226    }
11227
11228    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11229        mut map: V,
11230        optional: bool,
11231    ) -> Result<Option<PaperCreateResult>, V::Error> {
11232        let mut field_url = None;
11233        let mut field_result_path = None;
11234        let mut field_file_id = None;
11235        let mut field_paper_revision = None;
11236        let mut nothing = true;
11237        while let Some(key) = map.next_key::<&str>()? {
11238            nothing = false;
11239            match key {
11240                "url" => {
11241                    if field_url.is_some() {
11242                        return Err(::serde::de::Error::duplicate_field("url"));
11243                    }
11244                    field_url = Some(map.next_value()?);
11245                }
11246                "result_path" => {
11247                    if field_result_path.is_some() {
11248                        return Err(::serde::de::Error::duplicate_field("result_path"));
11249                    }
11250                    field_result_path = Some(map.next_value()?);
11251                }
11252                "file_id" => {
11253                    if field_file_id.is_some() {
11254                        return Err(::serde::de::Error::duplicate_field("file_id"));
11255                    }
11256                    field_file_id = Some(map.next_value()?);
11257                }
11258                "paper_revision" => {
11259                    if field_paper_revision.is_some() {
11260                        return Err(::serde::de::Error::duplicate_field("paper_revision"));
11261                    }
11262                    field_paper_revision = Some(map.next_value()?);
11263                }
11264                _ => {
11265                    // unknown field allowed and ignored
11266                    map.next_value::<::serde_json::Value>()?;
11267                }
11268            }
11269        }
11270        if optional && nothing {
11271            return Ok(None);
11272        }
11273        let result = PaperCreateResult {
11274            url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
11275            result_path: field_result_path.ok_or_else(|| ::serde::de::Error::missing_field("result_path"))?,
11276            file_id: field_file_id.ok_or_else(|| ::serde::de::Error::missing_field("file_id"))?,
11277            paper_revision: field_paper_revision.ok_or_else(|| ::serde::de::Error::missing_field("paper_revision"))?,
11278        };
11279        Ok(Some(result))
11280    }
11281
11282    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11283        &self,
11284        s: &mut S::SerializeStruct,
11285    ) -> Result<(), S::Error> {
11286        use serde::ser::SerializeStruct;
11287        s.serialize_field("url", &self.url)?;
11288        s.serialize_field("result_path", &self.result_path)?;
11289        s.serialize_field("file_id", &self.file_id)?;
11290        s.serialize_field("paper_revision", &self.paper_revision)?;
11291        Ok(())
11292    }
11293}
11294
11295impl<'de> ::serde::de::Deserialize<'de> for PaperCreateResult {
11296    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11297        // struct deserializer
11298        use serde::de::{MapAccess, Visitor};
11299        struct StructVisitor;
11300        impl<'de> Visitor<'de> for StructVisitor {
11301            type Value = PaperCreateResult;
11302            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11303                f.write_str("a PaperCreateResult struct")
11304            }
11305            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11306                PaperCreateResult::internal_deserialize(map)
11307            }
11308        }
11309        deserializer.deserialize_struct("PaperCreateResult", PAPER_CREATE_RESULT_FIELDS, StructVisitor)
11310    }
11311}
11312
11313impl ::serde::ser::Serialize for PaperCreateResult {
11314    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11315        // struct serializer
11316        use serde::ser::SerializeStruct;
11317        let mut s = serializer.serialize_struct("PaperCreateResult", 4)?;
11318        self.internal_serialize::<S>(&mut s)?;
11319        s.end()
11320    }
11321}
11322
11323#[derive(Debug, Clone, PartialEq, Eq)]
11324#[non_exhaustive] // variants may be added in the future
11325pub enum PaperDocUpdatePolicy {
11326    /// Sets the doc content to the provided content if the provided paper_revision matches the
11327    /// latest doc revision. Otherwise, returns an error.
11328    Update,
11329    /// Sets the doc content to the provided content without checking paper_revision.
11330    Overwrite,
11331    /// Adds the provided content to the beginning of the doc without checking paper_revision.
11332    Prepend,
11333    /// Adds the provided content to the end of the doc without checking paper_revision.
11334    Append,
11335    /// Catch-all used for unrecognized values returned from the server. Encountering this value
11336    /// typically indicates that this SDK version is out of date.
11337    Other,
11338}
11339
11340impl<'de> ::serde::de::Deserialize<'de> for PaperDocUpdatePolicy {
11341    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11342        // union deserializer
11343        use serde::de::{self, MapAccess, Visitor};
11344        struct EnumVisitor;
11345        impl<'de> Visitor<'de> for EnumVisitor {
11346            type Value = PaperDocUpdatePolicy;
11347            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11348                f.write_str("a PaperDocUpdatePolicy structure")
11349            }
11350            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11351                let tag: &str = match map.next_key()? {
11352                    Some(".tag") => map.next_value()?,
11353                    _ => return Err(de::Error::missing_field(".tag"))
11354                };
11355                let value = match tag {
11356                    "update" => PaperDocUpdatePolicy::Update,
11357                    "overwrite" => PaperDocUpdatePolicy::Overwrite,
11358                    "prepend" => PaperDocUpdatePolicy::Prepend,
11359                    "append" => PaperDocUpdatePolicy::Append,
11360                    _ => PaperDocUpdatePolicy::Other,
11361                };
11362                crate::eat_json_fields(&mut map)?;
11363                Ok(value)
11364            }
11365        }
11366        const VARIANTS: &[&str] = &["update",
11367                                    "overwrite",
11368                                    "prepend",
11369                                    "append",
11370                                    "other"];
11371        deserializer.deserialize_struct("PaperDocUpdatePolicy", VARIANTS, EnumVisitor)
11372    }
11373}
11374
11375impl ::serde::ser::Serialize for PaperDocUpdatePolicy {
11376    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11377        // union serializer
11378        use serde::ser::SerializeStruct;
11379        match self {
11380            PaperDocUpdatePolicy::Update => {
11381                // unit
11382                let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11383                s.serialize_field(".tag", "update")?;
11384                s.end()
11385            }
11386            PaperDocUpdatePolicy::Overwrite => {
11387                // unit
11388                let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11389                s.serialize_field(".tag", "overwrite")?;
11390                s.end()
11391            }
11392            PaperDocUpdatePolicy::Prepend => {
11393                // unit
11394                let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11395                s.serialize_field(".tag", "prepend")?;
11396                s.end()
11397            }
11398            PaperDocUpdatePolicy::Append => {
11399                // unit
11400                let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11401                s.serialize_field(".tag", "append")?;
11402                s.end()
11403            }
11404            PaperDocUpdatePolicy::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11405        }
11406    }
11407}
11408
11409#[derive(Debug, Clone, PartialEq, Eq)]
11410#[non_exhaustive] // structs may have more fields added in the future.
11411pub struct PaperUpdateArg {
11412    /// Path in the user's Dropbox to update. The path must correspond to a Paper doc or an error
11413    /// will be returned.
11414    pub path: WritePathOrId,
11415    /// The format of the provided data.
11416    pub import_format: ImportFormat,
11417    /// How the provided content should be applied to the doc.
11418    pub doc_update_policy: PaperDocUpdatePolicy,
11419    /// The latest doc revision. Required when doc_update_policy is update. This value must match
11420    /// the current revision of the doc or error revision_mismatch will be returned.
11421    pub paper_revision: Option<i64>,
11422}
11423
11424impl PaperUpdateArg {
11425    pub fn new(
11426        path: WritePathOrId,
11427        import_format: ImportFormat,
11428        doc_update_policy: PaperDocUpdatePolicy,
11429    ) -> Self {
11430        PaperUpdateArg {
11431            path,
11432            import_format,
11433            doc_update_policy,
11434            paper_revision: None,
11435        }
11436    }
11437
11438    pub fn with_paper_revision(mut self, value: i64) -> Self {
11439        self.paper_revision = Some(value);
11440        self
11441    }
11442}
11443
11444const PAPER_UPDATE_ARG_FIELDS: &[&str] = &["path",
11445                                           "import_format",
11446                                           "doc_update_policy",
11447                                           "paper_revision"];
11448impl PaperUpdateArg {
11449    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11450        map: V,
11451    ) -> Result<PaperUpdateArg, V::Error> {
11452        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11453    }
11454
11455    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11456        mut map: V,
11457        optional: bool,
11458    ) -> Result<Option<PaperUpdateArg>, V::Error> {
11459        let mut field_path = None;
11460        let mut field_import_format = None;
11461        let mut field_doc_update_policy = None;
11462        let mut field_paper_revision = None;
11463        let mut nothing = true;
11464        while let Some(key) = map.next_key::<&str>()? {
11465            nothing = false;
11466            match key {
11467                "path" => {
11468                    if field_path.is_some() {
11469                        return Err(::serde::de::Error::duplicate_field("path"));
11470                    }
11471                    field_path = Some(map.next_value()?);
11472                }
11473                "import_format" => {
11474                    if field_import_format.is_some() {
11475                        return Err(::serde::de::Error::duplicate_field("import_format"));
11476                    }
11477                    field_import_format = Some(map.next_value()?);
11478                }
11479                "doc_update_policy" => {
11480                    if field_doc_update_policy.is_some() {
11481                        return Err(::serde::de::Error::duplicate_field("doc_update_policy"));
11482                    }
11483                    field_doc_update_policy = Some(map.next_value()?);
11484                }
11485                "paper_revision" => {
11486                    if field_paper_revision.is_some() {
11487                        return Err(::serde::de::Error::duplicate_field("paper_revision"));
11488                    }
11489                    field_paper_revision = Some(map.next_value()?);
11490                }
11491                _ => {
11492                    // unknown field allowed and ignored
11493                    map.next_value::<::serde_json::Value>()?;
11494                }
11495            }
11496        }
11497        if optional && nothing {
11498            return Ok(None);
11499        }
11500        let result = PaperUpdateArg {
11501            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
11502            import_format: field_import_format.ok_or_else(|| ::serde::de::Error::missing_field("import_format"))?,
11503            doc_update_policy: field_doc_update_policy.ok_or_else(|| ::serde::de::Error::missing_field("doc_update_policy"))?,
11504            paper_revision: field_paper_revision.and_then(Option::flatten),
11505        };
11506        Ok(Some(result))
11507    }
11508
11509    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11510        &self,
11511        s: &mut S::SerializeStruct,
11512    ) -> Result<(), S::Error> {
11513        use serde::ser::SerializeStruct;
11514        s.serialize_field("path", &self.path)?;
11515        s.serialize_field("import_format", &self.import_format)?;
11516        s.serialize_field("doc_update_policy", &self.doc_update_policy)?;
11517        if let Some(val) = &self.paper_revision {
11518            s.serialize_field("paper_revision", val)?;
11519        }
11520        Ok(())
11521    }
11522}
11523
11524impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateArg {
11525    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11526        // struct deserializer
11527        use serde::de::{MapAccess, Visitor};
11528        struct StructVisitor;
11529        impl<'de> Visitor<'de> for StructVisitor {
11530            type Value = PaperUpdateArg;
11531            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11532                f.write_str("a PaperUpdateArg struct")
11533            }
11534            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11535                PaperUpdateArg::internal_deserialize(map)
11536            }
11537        }
11538        deserializer.deserialize_struct("PaperUpdateArg", PAPER_UPDATE_ARG_FIELDS, StructVisitor)
11539    }
11540}
11541
11542impl ::serde::ser::Serialize for PaperUpdateArg {
11543    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11544        // struct serializer
11545        use serde::ser::SerializeStruct;
11546        let mut s = serializer.serialize_struct("PaperUpdateArg", 4)?;
11547        self.internal_serialize::<S>(&mut s)?;
11548        s.end()
11549    }
11550}
11551
11552#[derive(Debug, Clone, PartialEq, Eq)]
11553#[non_exhaustive] // variants may be added in the future
11554pub enum PaperUpdateError {
11555    /// Your account does not have permissions to edit Paper docs.
11556    InsufficientPermissions,
11557    /// The provided content was malformed and cannot be imported to Paper.
11558    ContentMalformed,
11559    /// The Paper doc would be too large, split the content into multiple docs.
11560    DocLengthExceeded,
11561    /// The imported document contains an image that is too large. The current limit is 1MB. This
11562    /// only applies to HTML with data URI.
11563    ImageSizeExceeded,
11564    Path(LookupError),
11565    /// The provided revision does not match the document head.
11566    RevisionMismatch,
11567    /// This operation is not allowed on archived Paper docs.
11568    DocArchived,
11569    /// This operation is not allowed on deleted Paper docs.
11570    DocDeleted,
11571    /// Catch-all used for unrecognized values returned from the server. Encountering this value
11572    /// typically indicates that this SDK version is out of date.
11573    Other,
11574}
11575
11576impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateError {
11577    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11578        // union deserializer
11579        use serde::de::{self, MapAccess, Visitor};
11580        struct EnumVisitor;
11581        impl<'de> Visitor<'de> for EnumVisitor {
11582            type Value = PaperUpdateError;
11583            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11584                f.write_str("a PaperUpdateError structure")
11585            }
11586            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11587                let tag: &str = match map.next_key()? {
11588                    Some(".tag") => map.next_value()?,
11589                    _ => return Err(de::Error::missing_field(".tag"))
11590                };
11591                let value = match tag {
11592                    "insufficient_permissions" => PaperUpdateError::InsufficientPermissions,
11593                    "content_malformed" => PaperUpdateError::ContentMalformed,
11594                    "doc_length_exceeded" => PaperUpdateError::DocLengthExceeded,
11595                    "image_size_exceeded" => PaperUpdateError::ImageSizeExceeded,
11596                    "path" => {
11597                        match map.next_key()? {
11598                            Some("path") => PaperUpdateError::Path(map.next_value()?),
11599                            None => return Err(de::Error::missing_field("path")),
11600                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
11601                        }
11602                    }
11603                    "revision_mismatch" => PaperUpdateError::RevisionMismatch,
11604                    "doc_archived" => PaperUpdateError::DocArchived,
11605                    "doc_deleted" => PaperUpdateError::DocDeleted,
11606                    _ => PaperUpdateError::Other,
11607                };
11608                crate::eat_json_fields(&mut map)?;
11609                Ok(value)
11610            }
11611        }
11612        const VARIANTS: &[&str] = &["insufficient_permissions",
11613                                    "content_malformed",
11614                                    "doc_length_exceeded",
11615                                    "image_size_exceeded",
11616                                    "other",
11617                                    "path",
11618                                    "revision_mismatch",
11619                                    "doc_archived",
11620                                    "doc_deleted"];
11621        deserializer.deserialize_struct("PaperUpdateError", VARIANTS, EnumVisitor)
11622    }
11623}
11624
11625impl ::serde::ser::Serialize for PaperUpdateError {
11626    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11627        // union serializer
11628        use serde::ser::SerializeStruct;
11629        match self {
11630            PaperUpdateError::InsufficientPermissions => {
11631                // unit
11632                let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11633                s.serialize_field(".tag", "insufficient_permissions")?;
11634                s.end()
11635            }
11636            PaperUpdateError::ContentMalformed => {
11637                // unit
11638                let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11639                s.serialize_field(".tag", "content_malformed")?;
11640                s.end()
11641            }
11642            PaperUpdateError::DocLengthExceeded => {
11643                // unit
11644                let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11645                s.serialize_field(".tag", "doc_length_exceeded")?;
11646                s.end()
11647            }
11648            PaperUpdateError::ImageSizeExceeded => {
11649                // unit
11650                let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11651                s.serialize_field(".tag", "image_size_exceeded")?;
11652                s.end()
11653            }
11654            PaperUpdateError::Path(x) => {
11655                // union or polymporphic struct
11656                let mut s = serializer.serialize_struct("PaperUpdateError", 2)?;
11657                s.serialize_field(".tag", "path")?;
11658                s.serialize_field("path", x)?;
11659                s.end()
11660            }
11661            PaperUpdateError::RevisionMismatch => {
11662                // unit
11663                let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11664                s.serialize_field(".tag", "revision_mismatch")?;
11665                s.end()
11666            }
11667            PaperUpdateError::DocArchived => {
11668                // unit
11669                let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11670                s.serialize_field(".tag", "doc_archived")?;
11671                s.end()
11672            }
11673            PaperUpdateError::DocDeleted => {
11674                // unit
11675                let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11676                s.serialize_field(".tag", "doc_deleted")?;
11677                s.end()
11678            }
11679            PaperUpdateError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11680        }
11681    }
11682}
11683
11684impl ::std::error::Error for PaperUpdateError {
11685    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
11686        match self {
11687            PaperUpdateError::Path(inner) => Some(inner),
11688            _ => None,
11689        }
11690    }
11691}
11692
11693impl ::std::fmt::Display for PaperUpdateError {
11694    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11695        match self {
11696            PaperUpdateError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
11697            PaperUpdateError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
11698            PaperUpdateError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
11699            PaperUpdateError::ImageSizeExceeded => f.write_str("The imported document contains an image that is too large. The current limit is 1MB. This only applies to HTML with data URI."),
11700            PaperUpdateError::Path(inner) => write!(f, "PaperUpdateError: {}", inner),
11701            PaperUpdateError::RevisionMismatch => f.write_str("The provided revision does not match the document head."),
11702            PaperUpdateError::DocArchived => f.write_str("This operation is not allowed on archived Paper docs."),
11703            PaperUpdateError::DocDeleted => f.write_str("This operation is not allowed on deleted Paper docs."),
11704            _ => write!(f, "{:?}", *self),
11705        }
11706    }
11707}
11708
11709// union extends PaperContentError
11710impl From<PaperContentError> for PaperUpdateError {
11711    fn from(parent: PaperContentError) -> Self {
11712        match parent {
11713            PaperContentError::InsufficientPermissions => PaperUpdateError::InsufficientPermissions,
11714            PaperContentError::ContentMalformed => PaperUpdateError::ContentMalformed,
11715            PaperContentError::DocLengthExceeded => PaperUpdateError::DocLengthExceeded,
11716            PaperContentError::ImageSizeExceeded => PaperUpdateError::ImageSizeExceeded,
11717            PaperContentError::Other => PaperUpdateError::Other,
11718        }
11719    }
11720}
11721#[derive(Debug, Clone, PartialEq, Eq)]
11722#[non_exhaustive] // structs may have more fields added in the future.
11723pub struct PaperUpdateResult {
11724    /// The current doc revision.
11725    pub paper_revision: i64,
11726}
11727
11728impl PaperUpdateResult {
11729    pub fn new(paper_revision: i64) -> Self {
11730        PaperUpdateResult {
11731            paper_revision,
11732        }
11733    }
11734}
11735
11736const PAPER_UPDATE_RESULT_FIELDS: &[&str] = &["paper_revision"];
11737impl PaperUpdateResult {
11738    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11739        map: V,
11740    ) -> Result<PaperUpdateResult, V::Error> {
11741        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11742    }
11743
11744    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11745        mut map: V,
11746        optional: bool,
11747    ) -> Result<Option<PaperUpdateResult>, V::Error> {
11748        let mut field_paper_revision = None;
11749        let mut nothing = true;
11750        while let Some(key) = map.next_key::<&str>()? {
11751            nothing = false;
11752            match key {
11753                "paper_revision" => {
11754                    if field_paper_revision.is_some() {
11755                        return Err(::serde::de::Error::duplicate_field("paper_revision"));
11756                    }
11757                    field_paper_revision = Some(map.next_value()?);
11758                }
11759                _ => {
11760                    // unknown field allowed and ignored
11761                    map.next_value::<::serde_json::Value>()?;
11762                }
11763            }
11764        }
11765        if optional && nothing {
11766            return Ok(None);
11767        }
11768        let result = PaperUpdateResult {
11769            paper_revision: field_paper_revision.ok_or_else(|| ::serde::de::Error::missing_field("paper_revision"))?,
11770        };
11771        Ok(Some(result))
11772    }
11773
11774    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11775        &self,
11776        s: &mut S::SerializeStruct,
11777    ) -> Result<(), S::Error> {
11778        use serde::ser::SerializeStruct;
11779        s.serialize_field("paper_revision", &self.paper_revision)?;
11780        Ok(())
11781    }
11782}
11783
11784impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateResult {
11785    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11786        // struct deserializer
11787        use serde::de::{MapAccess, Visitor};
11788        struct StructVisitor;
11789        impl<'de> Visitor<'de> for StructVisitor {
11790            type Value = PaperUpdateResult;
11791            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11792                f.write_str("a PaperUpdateResult struct")
11793            }
11794            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11795                PaperUpdateResult::internal_deserialize(map)
11796            }
11797        }
11798        deserializer.deserialize_struct("PaperUpdateResult", PAPER_UPDATE_RESULT_FIELDS, StructVisitor)
11799    }
11800}
11801
11802impl ::serde::ser::Serialize for PaperUpdateResult {
11803    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11804        // struct serializer
11805        use serde::ser::SerializeStruct;
11806        let mut s = serializer.serialize_struct("PaperUpdateResult", 1)?;
11807        self.internal_serialize::<S>(&mut s)?;
11808        s.end()
11809    }
11810}
11811
11812#[derive(Debug, Clone, PartialEq, Eq)]
11813#[non_exhaustive] // variants may be added in the future
11814pub enum PathOrLink {
11815    Path(ReadPath),
11816    Link(SharedLinkFileInfo),
11817    /// Catch-all used for unrecognized values returned from the server. Encountering this value
11818    /// typically indicates that this SDK version is out of date.
11819    Other,
11820}
11821
11822impl<'de> ::serde::de::Deserialize<'de> for PathOrLink {
11823    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11824        // union deserializer
11825        use serde::de::{self, MapAccess, Visitor};
11826        struct EnumVisitor;
11827        impl<'de> Visitor<'de> for EnumVisitor {
11828            type Value = PathOrLink;
11829            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11830                f.write_str("a PathOrLink structure")
11831            }
11832            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11833                let tag: &str = match map.next_key()? {
11834                    Some(".tag") => map.next_value()?,
11835                    _ => return Err(de::Error::missing_field(".tag"))
11836                };
11837                let value = match tag {
11838                    "path" => {
11839                        match map.next_key()? {
11840                            Some("path") => PathOrLink::Path(map.next_value()?),
11841                            None => return Err(de::Error::missing_field("path")),
11842                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
11843                        }
11844                    }
11845                    "link" => PathOrLink::Link(SharedLinkFileInfo::internal_deserialize(&mut map)?),
11846                    _ => PathOrLink::Other,
11847                };
11848                crate::eat_json_fields(&mut map)?;
11849                Ok(value)
11850            }
11851        }
11852        const VARIANTS: &[&str] = &["path",
11853                                    "link",
11854                                    "other"];
11855        deserializer.deserialize_struct("PathOrLink", VARIANTS, EnumVisitor)
11856    }
11857}
11858
11859impl ::serde::ser::Serialize for PathOrLink {
11860    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11861        // union serializer
11862        use serde::ser::SerializeStruct;
11863        match self {
11864            PathOrLink::Path(x) => {
11865                // primitive
11866                let mut s = serializer.serialize_struct("PathOrLink", 2)?;
11867                s.serialize_field(".tag", "path")?;
11868                s.serialize_field("path", x)?;
11869                s.end()
11870            }
11871            PathOrLink::Link(x) => {
11872                // struct
11873                let mut s = serializer.serialize_struct("PathOrLink", 4)?;
11874                s.serialize_field(".tag", "link")?;
11875                x.internal_serialize::<S>(&mut s)?;
11876                s.end()
11877            }
11878            PathOrLink::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11879        }
11880    }
11881}
11882
11883#[derive(Debug, Clone, PartialEq, Eq)]
11884#[non_exhaustive] // structs may have more fields added in the future.
11885pub struct PathToTags {
11886    /// Path of the item.
11887    pub path: Path,
11888    /// Tags assigned to this item.
11889    pub tags: Vec<Tag>,
11890}
11891
11892impl PathToTags {
11893    pub fn new(path: Path, tags: Vec<Tag>) -> Self {
11894        PathToTags {
11895            path,
11896            tags,
11897        }
11898    }
11899}
11900
11901const PATH_TO_TAGS_FIELDS: &[&str] = &["path",
11902                                       "tags"];
11903impl PathToTags {
11904    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11905        map: V,
11906    ) -> Result<PathToTags, V::Error> {
11907        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11908    }
11909
11910    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11911        mut map: V,
11912        optional: bool,
11913    ) -> Result<Option<PathToTags>, V::Error> {
11914        let mut field_path = None;
11915        let mut field_tags = None;
11916        let mut nothing = true;
11917        while let Some(key) = map.next_key::<&str>()? {
11918            nothing = false;
11919            match key {
11920                "path" => {
11921                    if field_path.is_some() {
11922                        return Err(::serde::de::Error::duplicate_field("path"));
11923                    }
11924                    field_path = Some(map.next_value()?);
11925                }
11926                "tags" => {
11927                    if field_tags.is_some() {
11928                        return Err(::serde::de::Error::duplicate_field("tags"));
11929                    }
11930                    field_tags = Some(map.next_value()?);
11931                }
11932                _ => {
11933                    // unknown field allowed and ignored
11934                    map.next_value::<::serde_json::Value>()?;
11935                }
11936            }
11937        }
11938        if optional && nothing {
11939            return Ok(None);
11940        }
11941        let result = PathToTags {
11942            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
11943            tags: field_tags.ok_or_else(|| ::serde::de::Error::missing_field("tags"))?,
11944        };
11945        Ok(Some(result))
11946    }
11947
11948    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11949        &self,
11950        s: &mut S::SerializeStruct,
11951    ) -> Result<(), S::Error> {
11952        use serde::ser::SerializeStruct;
11953        s.serialize_field("path", &self.path)?;
11954        s.serialize_field("tags", &self.tags)?;
11955        Ok(())
11956    }
11957}
11958
11959impl<'de> ::serde::de::Deserialize<'de> for PathToTags {
11960    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11961        // struct deserializer
11962        use serde::de::{MapAccess, Visitor};
11963        struct StructVisitor;
11964        impl<'de> Visitor<'de> for StructVisitor {
11965            type Value = PathToTags;
11966            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11967                f.write_str("a PathToTags struct")
11968            }
11969            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11970                PathToTags::internal_deserialize(map)
11971            }
11972        }
11973        deserializer.deserialize_struct("PathToTags", PATH_TO_TAGS_FIELDS, StructVisitor)
11974    }
11975}
11976
11977impl ::serde::ser::Serialize for PathToTags {
11978    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11979        // struct serializer
11980        use serde::ser::SerializeStruct;
11981        let mut s = serializer.serialize_struct("PathToTags", 2)?;
11982        self.internal_serialize::<S>(&mut s)?;
11983        s.end()
11984    }
11985}
11986
11987/// Metadata for a photo.
11988#[derive(Debug, Clone, PartialEq, Default)]
11989#[non_exhaustive] // structs may have more fields added in the future.
11990pub struct PhotoMetadata {
11991    /// Dimension of the photo/video.
11992    pub dimensions: Option<Dimensions>,
11993    /// The GPS coordinate of the photo/video.
11994    pub location: Option<GpsCoordinates>,
11995    /// The timestamp when the photo/video is taken.
11996    pub time_taken: Option<crate::types::common::DropboxTimestamp>,
11997}
11998
11999impl PhotoMetadata {
12000    pub fn with_dimensions(mut self, value: Dimensions) -> Self {
12001        self.dimensions = Some(value);
12002        self
12003    }
12004
12005    pub fn with_location(mut self, value: GpsCoordinates) -> Self {
12006        self.location = Some(value);
12007        self
12008    }
12009
12010    pub fn with_time_taken(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
12011        self.time_taken = Some(value);
12012        self
12013    }
12014}
12015
12016const PHOTO_METADATA_FIELDS: &[&str] = &["dimensions",
12017                                         "location",
12018                                         "time_taken"];
12019impl PhotoMetadata {
12020    // no _opt deserializer
12021    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12022        mut map: V,
12023    ) -> Result<PhotoMetadata, V::Error> {
12024        let mut field_dimensions = None;
12025        let mut field_location = None;
12026        let mut field_time_taken = None;
12027        while let Some(key) = map.next_key::<&str>()? {
12028            match key {
12029                "dimensions" => {
12030                    if field_dimensions.is_some() {
12031                        return Err(::serde::de::Error::duplicate_field("dimensions"));
12032                    }
12033                    field_dimensions = Some(map.next_value()?);
12034                }
12035                "location" => {
12036                    if field_location.is_some() {
12037                        return Err(::serde::de::Error::duplicate_field("location"));
12038                    }
12039                    field_location = Some(map.next_value()?);
12040                }
12041                "time_taken" => {
12042                    if field_time_taken.is_some() {
12043                        return Err(::serde::de::Error::duplicate_field("time_taken"));
12044                    }
12045                    field_time_taken = Some(map.next_value()?);
12046                }
12047                _ => {
12048                    // unknown field allowed and ignored
12049                    map.next_value::<::serde_json::Value>()?;
12050                }
12051            }
12052        }
12053        let result = PhotoMetadata {
12054            dimensions: field_dimensions.and_then(Option::flatten),
12055            location: field_location.and_then(Option::flatten),
12056            time_taken: field_time_taken.and_then(Option::flatten),
12057        };
12058        Ok(result)
12059    }
12060
12061    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12062        &self,
12063        s: &mut S::SerializeStruct,
12064    ) -> Result<(), S::Error> {
12065        use serde::ser::SerializeStruct;
12066        if let Some(val) = &self.dimensions {
12067            s.serialize_field("dimensions", val)?;
12068        }
12069        if let Some(val) = &self.location {
12070            s.serialize_field("location", val)?;
12071        }
12072        if let Some(val) = &self.time_taken {
12073            s.serialize_field("time_taken", val)?;
12074        }
12075        Ok(())
12076    }
12077}
12078
12079impl<'de> ::serde::de::Deserialize<'de> for PhotoMetadata {
12080    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12081        // struct deserializer
12082        use serde::de::{MapAccess, Visitor};
12083        struct StructVisitor;
12084        impl<'de> Visitor<'de> for StructVisitor {
12085            type Value = PhotoMetadata;
12086            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12087                f.write_str("a PhotoMetadata struct")
12088            }
12089            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12090                PhotoMetadata::internal_deserialize(map)
12091            }
12092        }
12093        deserializer.deserialize_struct("PhotoMetadata", PHOTO_METADATA_FIELDS, StructVisitor)
12094    }
12095}
12096
12097impl ::serde::ser::Serialize for PhotoMetadata {
12098    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12099        // struct serializer
12100        use serde::ser::SerializeStruct;
12101        let mut s = serializer.serialize_struct("PhotoMetadata", 3)?;
12102        self.internal_serialize::<S>(&mut s)?;
12103        s.end()
12104    }
12105}
12106
12107// struct extends polymorphic struct MediaMetadata
12108impl From<PhotoMetadata> for MediaMetadata {
12109    fn from(subtype: PhotoMetadata) -> Self {
12110        MediaMetadata::Photo(subtype)
12111    }
12112}
12113#[derive(Debug, Clone, PartialEq, Eq)]
12114#[non_exhaustive] // structs may have more fields added in the future.
12115pub struct PreviewArg {
12116    /// The path of the file to preview.
12117    pub path: ReadPath,
12118    /// Please specify revision in `path` instead.
12119    pub rev: Option<Rev>,
12120}
12121
12122impl PreviewArg {
12123    pub fn new(path: ReadPath) -> Self {
12124        PreviewArg {
12125            path,
12126            rev: None,
12127        }
12128    }
12129
12130    pub fn with_rev(mut self, value: Rev) -> Self {
12131        self.rev = Some(value);
12132        self
12133    }
12134}
12135
12136const PREVIEW_ARG_FIELDS: &[&str] = &["path",
12137                                      "rev"];
12138impl PreviewArg {
12139    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12140        map: V,
12141    ) -> Result<PreviewArg, V::Error> {
12142        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12143    }
12144
12145    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12146        mut map: V,
12147        optional: bool,
12148    ) -> Result<Option<PreviewArg>, V::Error> {
12149        let mut field_path = None;
12150        let mut field_rev = None;
12151        let mut nothing = true;
12152        while let Some(key) = map.next_key::<&str>()? {
12153            nothing = false;
12154            match key {
12155                "path" => {
12156                    if field_path.is_some() {
12157                        return Err(::serde::de::Error::duplicate_field("path"));
12158                    }
12159                    field_path = Some(map.next_value()?);
12160                }
12161                "rev" => {
12162                    if field_rev.is_some() {
12163                        return Err(::serde::de::Error::duplicate_field("rev"));
12164                    }
12165                    field_rev = Some(map.next_value()?);
12166                }
12167                _ => {
12168                    // unknown field allowed and ignored
12169                    map.next_value::<::serde_json::Value>()?;
12170                }
12171            }
12172        }
12173        if optional && nothing {
12174            return Ok(None);
12175        }
12176        let result = PreviewArg {
12177            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
12178            rev: field_rev.and_then(Option::flatten),
12179        };
12180        Ok(Some(result))
12181    }
12182
12183    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12184        &self,
12185        s: &mut S::SerializeStruct,
12186    ) -> Result<(), S::Error> {
12187        use serde::ser::SerializeStruct;
12188        s.serialize_field("path", &self.path)?;
12189        if let Some(val) = &self.rev {
12190            s.serialize_field("rev", val)?;
12191        }
12192        Ok(())
12193    }
12194}
12195
12196impl<'de> ::serde::de::Deserialize<'de> for PreviewArg {
12197    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12198        // struct deserializer
12199        use serde::de::{MapAccess, Visitor};
12200        struct StructVisitor;
12201        impl<'de> Visitor<'de> for StructVisitor {
12202            type Value = PreviewArg;
12203            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12204                f.write_str("a PreviewArg struct")
12205            }
12206            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12207                PreviewArg::internal_deserialize(map)
12208            }
12209        }
12210        deserializer.deserialize_struct("PreviewArg", PREVIEW_ARG_FIELDS, StructVisitor)
12211    }
12212}
12213
12214impl ::serde::ser::Serialize for PreviewArg {
12215    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12216        // struct serializer
12217        use serde::ser::SerializeStruct;
12218        let mut s = serializer.serialize_struct("PreviewArg", 2)?;
12219        self.internal_serialize::<S>(&mut s)?;
12220        s.end()
12221    }
12222}
12223
12224#[derive(Debug, Clone, PartialEq, Eq)]
12225pub enum PreviewError {
12226    /// An error occurs when downloading metadata for the file.
12227    Path(LookupError),
12228    /// This preview generation is still in progress and the file is not ready  for preview yet.
12229    InProgress,
12230    /// The file extension is not supported preview generation.
12231    UnsupportedExtension,
12232    /// The file content is not supported for preview generation.
12233    UnsupportedContent,
12234}
12235
12236impl<'de> ::serde::de::Deserialize<'de> for PreviewError {
12237    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12238        // union deserializer
12239        use serde::de::{self, MapAccess, Visitor};
12240        struct EnumVisitor;
12241        impl<'de> Visitor<'de> for EnumVisitor {
12242            type Value = PreviewError;
12243            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12244                f.write_str("a PreviewError structure")
12245            }
12246            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
12247                let tag: &str = match map.next_key()? {
12248                    Some(".tag") => map.next_value()?,
12249                    _ => return Err(de::Error::missing_field(".tag"))
12250                };
12251                let value = match tag {
12252                    "path" => {
12253                        match map.next_key()? {
12254                            Some("path") => PreviewError::Path(map.next_value()?),
12255                            None => return Err(de::Error::missing_field("path")),
12256                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
12257                        }
12258                    }
12259                    "in_progress" => PreviewError::InProgress,
12260                    "unsupported_extension" => PreviewError::UnsupportedExtension,
12261                    "unsupported_content" => PreviewError::UnsupportedContent,
12262                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
12263                };
12264                crate::eat_json_fields(&mut map)?;
12265                Ok(value)
12266            }
12267        }
12268        const VARIANTS: &[&str] = &["path",
12269                                    "in_progress",
12270                                    "unsupported_extension",
12271                                    "unsupported_content"];
12272        deserializer.deserialize_struct("PreviewError", VARIANTS, EnumVisitor)
12273    }
12274}
12275
12276impl ::serde::ser::Serialize for PreviewError {
12277    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12278        // union serializer
12279        use serde::ser::SerializeStruct;
12280        match self {
12281            PreviewError::Path(x) => {
12282                // union or polymporphic struct
12283                let mut s = serializer.serialize_struct("PreviewError", 2)?;
12284                s.serialize_field(".tag", "path")?;
12285                s.serialize_field("path", x)?;
12286                s.end()
12287            }
12288            PreviewError::InProgress => {
12289                // unit
12290                let mut s = serializer.serialize_struct("PreviewError", 1)?;
12291                s.serialize_field(".tag", "in_progress")?;
12292                s.end()
12293            }
12294            PreviewError::UnsupportedExtension => {
12295                // unit
12296                let mut s = serializer.serialize_struct("PreviewError", 1)?;
12297                s.serialize_field(".tag", "unsupported_extension")?;
12298                s.end()
12299            }
12300            PreviewError::UnsupportedContent => {
12301                // unit
12302                let mut s = serializer.serialize_struct("PreviewError", 1)?;
12303                s.serialize_field(".tag", "unsupported_content")?;
12304                s.end()
12305            }
12306        }
12307    }
12308}
12309
12310impl ::std::error::Error for PreviewError {
12311    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
12312        match self {
12313            PreviewError::Path(inner) => Some(inner),
12314            _ => None,
12315        }
12316    }
12317}
12318
12319impl ::std::fmt::Display for PreviewError {
12320    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12321        match self {
12322            PreviewError::Path(inner) => write!(f, "An error occurs when downloading metadata for the file: {}", inner),
12323            PreviewError::InProgress => f.write_str("This preview generation is still in progress and the file is not ready  for preview yet."),
12324            PreviewError::UnsupportedExtension => f.write_str("The file extension is not supported preview generation."),
12325            PreviewError::UnsupportedContent => f.write_str("The file content is not supported for preview generation."),
12326        }
12327    }
12328}
12329
12330#[derive(Debug, Clone, PartialEq, Default)]
12331#[non_exhaustive] // structs may have more fields added in the future.
12332pub struct PreviewResult {
12333    /// Metadata corresponding to the file received as an argument. Will be populated if the
12334    /// endpoint is called with a path (ReadPath).
12335    pub file_metadata: Option<FileMetadata>,
12336    /// Minimal metadata corresponding to the file received as an argument. Will be populated if the
12337    /// endpoint is called using a shared link (SharedLinkFileInfo).
12338    pub link_metadata: Option<MinimalFileLinkMetadata>,
12339}
12340
12341impl PreviewResult {
12342    pub fn with_file_metadata(mut self, value: FileMetadata) -> Self {
12343        self.file_metadata = Some(value);
12344        self
12345    }
12346
12347    pub fn with_link_metadata(mut self, value: MinimalFileLinkMetadata) -> Self {
12348        self.link_metadata = Some(value);
12349        self
12350    }
12351}
12352
12353const PREVIEW_RESULT_FIELDS: &[&str] = &["file_metadata",
12354                                         "link_metadata"];
12355impl PreviewResult {
12356    // no _opt deserializer
12357    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12358        mut map: V,
12359    ) -> Result<PreviewResult, V::Error> {
12360        let mut field_file_metadata = None;
12361        let mut field_link_metadata = None;
12362        while let Some(key) = map.next_key::<&str>()? {
12363            match key {
12364                "file_metadata" => {
12365                    if field_file_metadata.is_some() {
12366                        return Err(::serde::de::Error::duplicate_field("file_metadata"));
12367                    }
12368                    field_file_metadata = Some(map.next_value()?);
12369                }
12370                "link_metadata" => {
12371                    if field_link_metadata.is_some() {
12372                        return Err(::serde::de::Error::duplicate_field("link_metadata"));
12373                    }
12374                    field_link_metadata = Some(map.next_value()?);
12375                }
12376                _ => {
12377                    // unknown field allowed and ignored
12378                    map.next_value::<::serde_json::Value>()?;
12379                }
12380            }
12381        }
12382        let result = PreviewResult {
12383            file_metadata: field_file_metadata.and_then(Option::flatten),
12384            link_metadata: field_link_metadata.and_then(Option::flatten),
12385        };
12386        Ok(result)
12387    }
12388
12389    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12390        &self,
12391        s: &mut S::SerializeStruct,
12392    ) -> Result<(), S::Error> {
12393        use serde::ser::SerializeStruct;
12394        if let Some(val) = &self.file_metadata {
12395            s.serialize_field("file_metadata", val)?;
12396        }
12397        if let Some(val) = &self.link_metadata {
12398            s.serialize_field("link_metadata", val)?;
12399        }
12400        Ok(())
12401    }
12402}
12403
12404impl<'de> ::serde::de::Deserialize<'de> for PreviewResult {
12405    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12406        // struct deserializer
12407        use serde::de::{MapAccess, Visitor};
12408        struct StructVisitor;
12409        impl<'de> Visitor<'de> for StructVisitor {
12410            type Value = PreviewResult;
12411            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12412                f.write_str("a PreviewResult struct")
12413            }
12414            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12415                PreviewResult::internal_deserialize(map)
12416            }
12417        }
12418        deserializer.deserialize_struct("PreviewResult", PREVIEW_RESULT_FIELDS, StructVisitor)
12419    }
12420}
12421
12422impl ::serde::ser::Serialize for PreviewResult {
12423    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12424        // struct serializer
12425        use serde::ser::SerializeStruct;
12426        let mut s = serializer.serialize_struct("PreviewResult", 2)?;
12427        self.internal_serialize::<S>(&mut s)?;
12428        s.end()
12429    }
12430}
12431
12432#[derive(Debug, Clone, PartialEq, Eq)]
12433#[non_exhaustive] // structs may have more fields added in the future.
12434pub struct RelocationArg {
12435    /// Path in the user's Dropbox to be copied or moved.
12436    pub from_path: WritePathOrId,
12437    /// Path in the user's Dropbox that is the destination.
12438    pub to_path: WritePathOrId,
12439    /// This flag has no effect.
12440    pub allow_shared_folder: bool,
12441    /// If there's a conflict, have the Dropbox server try to autorename the file to avoid the
12442    /// conflict.
12443    pub autorename: bool,
12444    /// Allow moves by owner even if it would result in an ownership transfer for the content being
12445    /// moved. This does not apply to copies.
12446    pub allow_ownership_transfer: bool,
12447}
12448
12449impl RelocationArg {
12450    pub fn new(from_path: WritePathOrId, to_path: WritePathOrId) -> Self {
12451        RelocationArg {
12452            from_path,
12453            to_path,
12454            allow_shared_folder: false,
12455            autorename: false,
12456            allow_ownership_transfer: false,
12457        }
12458    }
12459
12460    pub fn with_allow_shared_folder(mut self, value: bool) -> Self {
12461        self.allow_shared_folder = value;
12462        self
12463    }
12464
12465    pub fn with_autorename(mut self, value: bool) -> Self {
12466        self.autorename = value;
12467        self
12468    }
12469
12470    pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
12471        self.allow_ownership_transfer = value;
12472        self
12473    }
12474}
12475
12476const RELOCATION_ARG_FIELDS: &[&str] = &["from_path",
12477                                         "to_path",
12478                                         "allow_shared_folder",
12479                                         "autorename",
12480                                         "allow_ownership_transfer"];
12481impl RelocationArg {
12482    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12483        map: V,
12484    ) -> Result<RelocationArg, V::Error> {
12485        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12486    }
12487
12488    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12489        mut map: V,
12490        optional: bool,
12491    ) -> Result<Option<RelocationArg>, V::Error> {
12492        let mut field_from_path = None;
12493        let mut field_to_path = None;
12494        let mut field_allow_shared_folder = None;
12495        let mut field_autorename = None;
12496        let mut field_allow_ownership_transfer = None;
12497        let mut nothing = true;
12498        while let Some(key) = map.next_key::<&str>()? {
12499            nothing = false;
12500            match key {
12501                "from_path" => {
12502                    if field_from_path.is_some() {
12503                        return Err(::serde::de::Error::duplicate_field("from_path"));
12504                    }
12505                    field_from_path = Some(map.next_value()?);
12506                }
12507                "to_path" => {
12508                    if field_to_path.is_some() {
12509                        return Err(::serde::de::Error::duplicate_field("to_path"));
12510                    }
12511                    field_to_path = Some(map.next_value()?);
12512                }
12513                "allow_shared_folder" => {
12514                    if field_allow_shared_folder.is_some() {
12515                        return Err(::serde::de::Error::duplicate_field("allow_shared_folder"));
12516                    }
12517                    field_allow_shared_folder = Some(map.next_value()?);
12518                }
12519                "autorename" => {
12520                    if field_autorename.is_some() {
12521                        return Err(::serde::de::Error::duplicate_field("autorename"));
12522                    }
12523                    field_autorename = Some(map.next_value()?);
12524                }
12525                "allow_ownership_transfer" => {
12526                    if field_allow_ownership_transfer.is_some() {
12527                        return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
12528                    }
12529                    field_allow_ownership_transfer = Some(map.next_value()?);
12530                }
12531                _ => {
12532                    // unknown field allowed and ignored
12533                    map.next_value::<::serde_json::Value>()?;
12534                }
12535            }
12536        }
12537        if optional && nothing {
12538            return Ok(None);
12539        }
12540        let result = RelocationArg {
12541            from_path: field_from_path.ok_or_else(|| ::serde::de::Error::missing_field("from_path"))?,
12542            to_path: field_to_path.ok_or_else(|| ::serde::de::Error::missing_field("to_path"))?,
12543            allow_shared_folder: field_allow_shared_folder.unwrap_or(false),
12544            autorename: field_autorename.unwrap_or(false),
12545            allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
12546        };
12547        Ok(Some(result))
12548    }
12549
12550    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12551        &self,
12552        s: &mut S::SerializeStruct,
12553    ) -> Result<(), S::Error> {
12554        use serde::ser::SerializeStruct;
12555        s.serialize_field("from_path", &self.from_path)?;
12556        s.serialize_field("to_path", &self.to_path)?;
12557        if self.allow_shared_folder {
12558            s.serialize_field("allow_shared_folder", &self.allow_shared_folder)?;
12559        }
12560        if self.autorename {
12561            s.serialize_field("autorename", &self.autorename)?;
12562        }
12563        if self.allow_ownership_transfer {
12564            s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
12565        }
12566        Ok(())
12567    }
12568}
12569
12570impl<'de> ::serde::de::Deserialize<'de> for RelocationArg {
12571    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12572        // struct deserializer
12573        use serde::de::{MapAccess, Visitor};
12574        struct StructVisitor;
12575        impl<'de> Visitor<'de> for StructVisitor {
12576            type Value = RelocationArg;
12577            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12578                f.write_str("a RelocationArg struct")
12579            }
12580            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12581                RelocationArg::internal_deserialize(map)
12582            }
12583        }
12584        deserializer.deserialize_struct("RelocationArg", RELOCATION_ARG_FIELDS, StructVisitor)
12585    }
12586}
12587
12588impl ::serde::ser::Serialize for RelocationArg {
12589    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12590        // struct serializer
12591        use serde::ser::SerializeStruct;
12592        let mut s = serializer.serialize_struct("RelocationArg", 5)?;
12593        self.internal_serialize::<S>(&mut s)?;
12594        s.end()
12595    }
12596}
12597
12598// struct extends RelocationPath
12599impl From<RelocationArg> for RelocationPath {
12600    fn from(subtype: RelocationArg) -> Self {
12601        Self {
12602            from_path: subtype.from_path,
12603            to_path: subtype.to_path,
12604        }
12605    }
12606}
12607#[derive(Debug, Clone, PartialEq, Eq)]
12608#[non_exhaustive] // structs may have more fields added in the future.
12609pub struct RelocationBatchArg {
12610    /// List of entries to be moved or copied. Each entry is [`RelocationPath`].
12611    pub entries: Vec<RelocationPath>,
12612    /// If there's a conflict with any file, have the Dropbox server try to autorename that file to
12613    /// avoid the conflict.
12614    pub autorename: bool,
12615    /// This flag has no effect.
12616    pub allow_shared_folder: bool,
12617    /// Allow moves by owner even if it would result in an ownership transfer for the content being
12618    /// moved. This does not apply to copies.
12619    pub allow_ownership_transfer: bool,
12620}
12621
12622impl RelocationBatchArg {
12623    pub fn new(entries: Vec<RelocationPath>) -> Self {
12624        RelocationBatchArg {
12625            entries,
12626            autorename: false,
12627            allow_shared_folder: false,
12628            allow_ownership_transfer: false,
12629        }
12630    }
12631
12632    pub fn with_autorename(mut self, value: bool) -> Self {
12633        self.autorename = value;
12634        self
12635    }
12636
12637    pub fn with_allow_shared_folder(mut self, value: bool) -> Self {
12638        self.allow_shared_folder = value;
12639        self
12640    }
12641
12642    pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
12643        self.allow_ownership_transfer = value;
12644        self
12645    }
12646}
12647
12648const RELOCATION_BATCH_ARG_FIELDS: &[&str] = &["entries",
12649                                               "autorename",
12650                                               "allow_shared_folder",
12651                                               "allow_ownership_transfer"];
12652impl RelocationBatchArg {
12653    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12654        map: V,
12655    ) -> Result<RelocationBatchArg, V::Error> {
12656        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12657    }
12658
12659    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12660        mut map: V,
12661        optional: bool,
12662    ) -> Result<Option<RelocationBatchArg>, V::Error> {
12663        let mut field_entries = None;
12664        let mut field_autorename = None;
12665        let mut field_allow_shared_folder = None;
12666        let mut field_allow_ownership_transfer = None;
12667        let mut nothing = true;
12668        while let Some(key) = map.next_key::<&str>()? {
12669            nothing = false;
12670            match key {
12671                "entries" => {
12672                    if field_entries.is_some() {
12673                        return Err(::serde::de::Error::duplicate_field("entries"));
12674                    }
12675                    field_entries = Some(map.next_value()?);
12676                }
12677                "autorename" => {
12678                    if field_autorename.is_some() {
12679                        return Err(::serde::de::Error::duplicate_field("autorename"));
12680                    }
12681                    field_autorename = Some(map.next_value()?);
12682                }
12683                "allow_shared_folder" => {
12684                    if field_allow_shared_folder.is_some() {
12685                        return Err(::serde::de::Error::duplicate_field("allow_shared_folder"));
12686                    }
12687                    field_allow_shared_folder = Some(map.next_value()?);
12688                }
12689                "allow_ownership_transfer" => {
12690                    if field_allow_ownership_transfer.is_some() {
12691                        return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
12692                    }
12693                    field_allow_ownership_transfer = Some(map.next_value()?);
12694                }
12695                _ => {
12696                    // unknown field allowed and ignored
12697                    map.next_value::<::serde_json::Value>()?;
12698                }
12699            }
12700        }
12701        if optional && nothing {
12702            return Ok(None);
12703        }
12704        let result = RelocationBatchArg {
12705            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
12706            autorename: field_autorename.unwrap_or(false),
12707            allow_shared_folder: field_allow_shared_folder.unwrap_or(false),
12708            allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
12709        };
12710        Ok(Some(result))
12711    }
12712
12713    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12714        &self,
12715        s: &mut S::SerializeStruct,
12716    ) -> Result<(), S::Error> {
12717        use serde::ser::SerializeStruct;
12718        s.serialize_field("entries", &self.entries)?;
12719        if self.autorename {
12720            s.serialize_field("autorename", &self.autorename)?;
12721        }
12722        if self.allow_shared_folder {
12723            s.serialize_field("allow_shared_folder", &self.allow_shared_folder)?;
12724        }
12725        if self.allow_ownership_transfer {
12726            s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
12727        }
12728        Ok(())
12729    }
12730}
12731
12732impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchArg {
12733    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12734        // struct deserializer
12735        use serde::de::{MapAccess, Visitor};
12736        struct StructVisitor;
12737        impl<'de> Visitor<'de> for StructVisitor {
12738            type Value = RelocationBatchArg;
12739            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12740                f.write_str("a RelocationBatchArg struct")
12741            }
12742            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12743                RelocationBatchArg::internal_deserialize(map)
12744            }
12745        }
12746        deserializer.deserialize_struct("RelocationBatchArg", RELOCATION_BATCH_ARG_FIELDS, StructVisitor)
12747    }
12748}
12749
12750impl ::serde::ser::Serialize for RelocationBatchArg {
12751    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12752        // struct serializer
12753        use serde::ser::SerializeStruct;
12754        let mut s = serializer.serialize_struct("RelocationBatchArg", 4)?;
12755        self.internal_serialize::<S>(&mut s)?;
12756        s.end()
12757    }
12758}
12759
12760// struct extends RelocationBatchArgBase
12761impl From<RelocationBatchArg> for RelocationBatchArgBase {
12762    fn from(subtype: RelocationBatchArg) -> Self {
12763        Self {
12764            entries: subtype.entries,
12765            autorename: subtype.autorename,
12766        }
12767    }
12768}
12769#[derive(Debug, Clone, PartialEq, Eq)]
12770#[non_exhaustive] // structs may have more fields added in the future.
12771pub struct RelocationBatchArgBase {
12772    /// List of entries to be moved or copied. Each entry is [`RelocationPath`].
12773    pub entries: Vec<RelocationPath>,
12774    /// If there's a conflict with any file, have the Dropbox server try to autorename that file to
12775    /// avoid the conflict.
12776    pub autorename: bool,
12777}
12778
12779impl RelocationBatchArgBase {
12780    pub fn new(entries: Vec<RelocationPath>) -> Self {
12781        RelocationBatchArgBase {
12782            entries,
12783            autorename: false,
12784        }
12785    }
12786
12787    pub fn with_autorename(mut self, value: bool) -> Self {
12788        self.autorename = value;
12789        self
12790    }
12791}
12792
12793const RELOCATION_BATCH_ARG_BASE_FIELDS: &[&str] = &["entries",
12794                                                    "autorename"];
12795impl RelocationBatchArgBase {
12796    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12797        map: V,
12798    ) -> Result<RelocationBatchArgBase, V::Error> {
12799        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12800    }
12801
12802    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12803        mut map: V,
12804        optional: bool,
12805    ) -> Result<Option<RelocationBatchArgBase>, V::Error> {
12806        let mut field_entries = None;
12807        let mut field_autorename = None;
12808        let mut nothing = true;
12809        while let Some(key) = map.next_key::<&str>()? {
12810            nothing = false;
12811            match key {
12812                "entries" => {
12813                    if field_entries.is_some() {
12814                        return Err(::serde::de::Error::duplicate_field("entries"));
12815                    }
12816                    field_entries = Some(map.next_value()?);
12817                }
12818                "autorename" => {
12819                    if field_autorename.is_some() {
12820                        return Err(::serde::de::Error::duplicate_field("autorename"));
12821                    }
12822                    field_autorename = Some(map.next_value()?);
12823                }
12824                _ => {
12825                    // unknown field allowed and ignored
12826                    map.next_value::<::serde_json::Value>()?;
12827                }
12828            }
12829        }
12830        if optional && nothing {
12831            return Ok(None);
12832        }
12833        let result = RelocationBatchArgBase {
12834            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
12835            autorename: field_autorename.unwrap_or(false),
12836        };
12837        Ok(Some(result))
12838    }
12839
12840    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12841        &self,
12842        s: &mut S::SerializeStruct,
12843    ) -> Result<(), S::Error> {
12844        use serde::ser::SerializeStruct;
12845        s.serialize_field("entries", &self.entries)?;
12846        if self.autorename {
12847            s.serialize_field("autorename", &self.autorename)?;
12848        }
12849        Ok(())
12850    }
12851}
12852
12853impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchArgBase {
12854    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12855        // struct deserializer
12856        use serde::de::{MapAccess, Visitor};
12857        struct StructVisitor;
12858        impl<'de> Visitor<'de> for StructVisitor {
12859            type Value = RelocationBatchArgBase;
12860            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12861                f.write_str("a RelocationBatchArgBase struct")
12862            }
12863            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12864                RelocationBatchArgBase::internal_deserialize(map)
12865            }
12866        }
12867        deserializer.deserialize_struct("RelocationBatchArgBase", RELOCATION_BATCH_ARG_BASE_FIELDS, StructVisitor)
12868    }
12869}
12870
12871impl ::serde::ser::Serialize for RelocationBatchArgBase {
12872    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12873        // struct serializer
12874        use serde::ser::SerializeStruct;
12875        let mut s = serializer.serialize_struct("RelocationBatchArgBase", 2)?;
12876        self.internal_serialize::<S>(&mut s)?;
12877        s.end()
12878    }
12879}
12880
12881#[derive(Debug, Clone, PartialEq, Eq)]
12882#[non_exhaustive] // variants may be added in the future
12883pub enum RelocationBatchError {
12884    FromLookup(LookupError),
12885    FromWrite(WriteError),
12886    To(WriteError),
12887    /// Shared folders can't be copied.
12888    CantCopySharedFolder,
12889    /// Your move operation would result in nested shared folders.  This is not allowed.
12890    CantNestSharedFolder,
12891    /// You cannot move a folder into itself.
12892    CantMoveFolderIntoItself,
12893    /// The operation would involve more than 10,000 files and folders.
12894    TooManyFiles,
12895    /// There are duplicated/nested paths among [`RelocationArg::from_path`](RelocationArg) and
12896    /// [`RelocationArg::to_path`](RelocationArg).
12897    DuplicatedOrNestedPaths,
12898    /// Your move operation would result in an ownership transfer. You may reissue the request with
12899    /// the field [`RelocationArg::allow_ownership_transfer`](RelocationArg) to true.
12900    CantTransferOwnership,
12901    /// The current user does not have enough space to move or copy the files.
12902    InsufficientQuota,
12903    /// Something went wrong with the job on Dropbox's end. You'll need to verify that the action
12904    /// you were taking succeeded, and if not, try again. This should happen very rarely.
12905    InternalError,
12906    /// Can't move the shared folder to the given destination.
12907    CantMoveSharedFolder,
12908    /// Some content cannot be moved into Vault under certain circumstances, see detailed error.
12909    CantMoveIntoVault(MoveIntoVaultError),
12910    /// Some content cannot be moved into the Family Room folder under certain circumstances, see
12911    /// detailed error.
12912    CantMoveIntoFamily(MoveIntoFamilyError),
12913    /// There are too many write operations in user's Dropbox. Please retry this request.
12914    TooManyWriteOperations,
12915    /// Catch-all used for unrecognized values returned from the server. Encountering this value
12916    /// typically indicates that this SDK version is out of date.
12917    Other,
12918}
12919
12920impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchError {
12921    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12922        // union deserializer
12923        use serde::de::{self, MapAccess, Visitor};
12924        struct EnumVisitor;
12925        impl<'de> Visitor<'de> for EnumVisitor {
12926            type Value = RelocationBatchError;
12927            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12928                f.write_str("a RelocationBatchError structure")
12929            }
12930            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
12931                let tag: &str = match map.next_key()? {
12932                    Some(".tag") => map.next_value()?,
12933                    _ => return Err(de::Error::missing_field(".tag"))
12934                };
12935                let value = match tag {
12936                    "from_lookup" => {
12937                        match map.next_key()? {
12938                            Some("from_lookup") => RelocationBatchError::FromLookup(map.next_value()?),
12939                            None => return Err(de::Error::missing_field("from_lookup")),
12940                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
12941                        }
12942                    }
12943                    "from_write" => {
12944                        match map.next_key()? {
12945                            Some("from_write") => RelocationBatchError::FromWrite(map.next_value()?),
12946                            None => return Err(de::Error::missing_field("from_write")),
12947                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
12948                        }
12949                    }
12950                    "to" => {
12951                        match map.next_key()? {
12952                            Some("to") => RelocationBatchError::To(map.next_value()?),
12953                            None => return Err(de::Error::missing_field("to")),
12954                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
12955                        }
12956                    }
12957                    "cant_copy_shared_folder" => RelocationBatchError::CantCopySharedFolder,
12958                    "cant_nest_shared_folder" => RelocationBatchError::CantNestSharedFolder,
12959                    "cant_move_folder_into_itself" => RelocationBatchError::CantMoveFolderIntoItself,
12960                    "too_many_files" => RelocationBatchError::TooManyFiles,
12961                    "duplicated_or_nested_paths" => RelocationBatchError::DuplicatedOrNestedPaths,
12962                    "cant_transfer_ownership" => RelocationBatchError::CantTransferOwnership,
12963                    "insufficient_quota" => RelocationBatchError::InsufficientQuota,
12964                    "internal_error" => RelocationBatchError::InternalError,
12965                    "cant_move_shared_folder" => RelocationBatchError::CantMoveSharedFolder,
12966                    "cant_move_into_vault" => {
12967                        match map.next_key()? {
12968                            Some("cant_move_into_vault") => RelocationBatchError::CantMoveIntoVault(map.next_value()?),
12969                            None => return Err(de::Error::missing_field("cant_move_into_vault")),
12970                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
12971                        }
12972                    }
12973                    "cant_move_into_family" => {
12974                        match map.next_key()? {
12975                            Some("cant_move_into_family") => RelocationBatchError::CantMoveIntoFamily(map.next_value()?),
12976                            None => return Err(de::Error::missing_field("cant_move_into_family")),
12977                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
12978                        }
12979                    }
12980                    "too_many_write_operations" => RelocationBatchError::TooManyWriteOperations,
12981                    _ => RelocationBatchError::Other,
12982                };
12983                crate::eat_json_fields(&mut map)?;
12984                Ok(value)
12985            }
12986        }
12987        const VARIANTS: &[&str] = &["from_lookup",
12988                                    "from_write",
12989                                    "to",
12990                                    "cant_copy_shared_folder",
12991                                    "cant_nest_shared_folder",
12992                                    "cant_move_folder_into_itself",
12993                                    "too_many_files",
12994                                    "duplicated_or_nested_paths",
12995                                    "cant_transfer_ownership",
12996                                    "insufficient_quota",
12997                                    "internal_error",
12998                                    "cant_move_shared_folder",
12999                                    "cant_move_into_vault",
13000                                    "cant_move_into_family",
13001                                    "other",
13002                                    "too_many_write_operations"];
13003        deserializer.deserialize_struct("RelocationBatchError", VARIANTS, EnumVisitor)
13004    }
13005}
13006
13007impl ::serde::ser::Serialize for RelocationBatchError {
13008    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13009        // union serializer
13010        use serde::ser::SerializeStruct;
13011        match self {
13012            RelocationBatchError::FromLookup(x) => {
13013                // union or polymporphic struct
13014                let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13015                s.serialize_field(".tag", "from_lookup")?;
13016                s.serialize_field("from_lookup", x)?;
13017                s.end()
13018            }
13019            RelocationBatchError::FromWrite(x) => {
13020                // union or polymporphic struct
13021                let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13022                s.serialize_field(".tag", "from_write")?;
13023                s.serialize_field("from_write", x)?;
13024                s.end()
13025            }
13026            RelocationBatchError::To(x) => {
13027                // union or polymporphic struct
13028                let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13029                s.serialize_field(".tag", "to")?;
13030                s.serialize_field("to", x)?;
13031                s.end()
13032            }
13033            RelocationBatchError::CantCopySharedFolder => {
13034                // unit
13035                let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13036                s.serialize_field(".tag", "cant_copy_shared_folder")?;
13037                s.end()
13038            }
13039            RelocationBatchError::CantNestSharedFolder => {
13040                // unit
13041                let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13042                s.serialize_field(".tag", "cant_nest_shared_folder")?;
13043                s.end()
13044            }
13045            RelocationBatchError::CantMoveFolderIntoItself => {
13046                // unit
13047                let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13048                s.serialize_field(".tag", "cant_move_folder_into_itself")?;
13049                s.end()
13050            }
13051            RelocationBatchError::TooManyFiles => {
13052                // unit
13053                let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13054                s.serialize_field(".tag", "too_many_files")?;
13055                s.end()
13056            }
13057            RelocationBatchError::DuplicatedOrNestedPaths => {
13058                // unit
13059                let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13060                s.serialize_field(".tag", "duplicated_or_nested_paths")?;
13061                s.end()
13062            }
13063            RelocationBatchError::CantTransferOwnership => {
13064                // unit
13065                let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13066                s.serialize_field(".tag", "cant_transfer_ownership")?;
13067                s.end()
13068            }
13069            RelocationBatchError::InsufficientQuota => {
13070                // unit
13071                let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13072                s.serialize_field(".tag", "insufficient_quota")?;
13073                s.end()
13074            }
13075            RelocationBatchError::InternalError => {
13076                // unit
13077                let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13078                s.serialize_field(".tag", "internal_error")?;
13079                s.end()
13080            }
13081            RelocationBatchError::CantMoveSharedFolder => {
13082                // unit
13083                let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13084                s.serialize_field(".tag", "cant_move_shared_folder")?;
13085                s.end()
13086            }
13087            RelocationBatchError::CantMoveIntoVault(x) => {
13088                // union or polymporphic struct
13089                let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13090                s.serialize_field(".tag", "cant_move_into_vault")?;
13091                s.serialize_field("cant_move_into_vault", x)?;
13092                s.end()
13093            }
13094            RelocationBatchError::CantMoveIntoFamily(x) => {
13095                // union or polymporphic struct
13096                let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13097                s.serialize_field(".tag", "cant_move_into_family")?;
13098                s.serialize_field("cant_move_into_family", x)?;
13099                s.end()
13100            }
13101            RelocationBatchError::TooManyWriteOperations => {
13102                // unit
13103                let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13104                s.serialize_field(".tag", "too_many_write_operations")?;
13105                s.end()
13106            }
13107            RelocationBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13108        }
13109    }
13110}
13111
13112impl ::std::error::Error for RelocationBatchError {
13113    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
13114        match self {
13115            RelocationBatchError::FromLookup(inner) => Some(inner),
13116            RelocationBatchError::FromWrite(inner) => Some(inner),
13117            RelocationBatchError::To(inner) => Some(inner),
13118            RelocationBatchError::CantMoveIntoVault(inner) => Some(inner),
13119            RelocationBatchError::CantMoveIntoFamily(inner) => Some(inner),
13120            _ => None,
13121        }
13122    }
13123}
13124
13125impl ::std::fmt::Display for RelocationBatchError {
13126    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13127        match self {
13128            RelocationBatchError::FromLookup(inner) => write!(f, "RelocationBatchError: {}", inner),
13129            RelocationBatchError::FromWrite(inner) => write!(f, "RelocationBatchError: {}", inner),
13130            RelocationBatchError::To(inner) => write!(f, "RelocationBatchError: {}", inner),
13131            RelocationBatchError::CantCopySharedFolder => f.write_str("Shared folders can't be copied."),
13132            RelocationBatchError::CantNestSharedFolder => f.write_str("Your move operation would result in nested shared folders.  This is not allowed."),
13133            RelocationBatchError::CantMoveFolderIntoItself => f.write_str("You cannot move a folder into itself."),
13134            RelocationBatchError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
13135            RelocationBatchError::InsufficientQuota => f.write_str("The current user does not have enough space to move or copy the files."),
13136            RelocationBatchError::InternalError => f.write_str("Something went wrong with the job on Dropbox's end. You'll need to verify that the action you were taking succeeded, and if not, try again. This should happen very rarely."),
13137            RelocationBatchError::CantMoveSharedFolder => f.write_str("Can't move the shared folder to the given destination."),
13138            RelocationBatchError::CantMoveIntoVault(inner) => write!(f, "Some content cannot be moved into Vault under certain circumstances, see detailed error: {}", inner),
13139            RelocationBatchError::CantMoveIntoFamily(inner) => write!(f, "Some content cannot be moved into the Family Room folder under certain circumstances, see detailed error: {}", inner),
13140            RelocationBatchError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
13141            _ => write!(f, "{:?}", *self),
13142        }
13143    }
13144}
13145
13146// union extends RelocationError
13147impl From<RelocationError> for RelocationBatchError {
13148    fn from(parent: RelocationError) -> Self {
13149        match parent {
13150            RelocationError::FromLookup(x) => RelocationBatchError::FromLookup(x),
13151            RelocationError::FromWrite(x) => RelocationBatchError::FromWrite(x),
13152            RelocationError::To(x) => RelocationBatchError::To(x),
13153            RelocationError::CantCopySharedFolder => RelocationBatchError::CantCopySharedFolder,
13154            RelocationError::CantNestSharedFolder => RelocationBatchError::CantNestSharedFolder,
13155            RelocationError::CantMoveFolderIntoItself => RelocationBatchError::CantMoveFolderIntoItself,
13156            RelocationError::TooManyFiles => RelocationBatchError::TooManyFiles,
13157            RelocationError::DuplicatedOrNestedPaths => RelocationBatchError::DuplicatedOrNestedPaths,
13158            RelocationError::CantTransferOwnership => RelocationBatchError::CantTransferOwnership,
13159            RelocationError::InsufficientQuota => RelocationBatchError::InsufficientQuota,
13160            RelocationError::InternalError => RelocationBatchError::InternalError,
13161            RelocationError::CantMoveSharedFolder => RelocationBatchError::CantMoveSharedFolder,
13162            RelocationError::CantMoveIntoVault(x) => RelocationBatchError::CantMoveIntoVault(x),
13163            RelocationError::CantMoveIntoFamily(x) => RelocationBatchError::CantMoveIntoFamily(x),
13164            RelocationError::Other => RelocationBatchError::Other,
13165        }
13166    }
13167}
13168#[derive(Debug, Clone, PartialEq, Eq)]
13169#[non_exhaustive] // variants may be added in the future
13170pub enum RelocationBatchErrorEntry {
13171    /// User errors that retry won't help.
13172    RelocationError(RelocationError),
13173    /// Something went wrong with the job on Dropbox's end. You'll need to verify that the action
13174    /// you were taking succeeded, and if not, try again. This should happen very rarely.
13175    InternalError,
13176    /// There are too many write operations in user's Dropbox. Please retry this request.
13177    TooManyWriteOperations,
13178    /// Catch-all used for unrecognized values returned from the server. Encountering this value
13179    /// typically indicates that this SDK version is out of date.
13180    Other,
13181}
13182
13183impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchErrorEntry {
13184    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13185        // union deserializer
13186        use serde::de::{self, MapAccess, Visitor};
13187        struct EnumVisitor;
13188        impl<'de> Visitor<'de> for EnumVisitor {
13189            type Value = RelocationBatchErrorEntry;
13190            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13191                f.write_str("a RelocationBatchErrorEntry structure")
13192            }
13193            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13194                let tag: &str = match map.next_key()? {
13195                    Some(".tag") => map.next_value()?,
13196                    _ => return Err(de::Error::missing_field(".tag"))
13197                };
13198                let value = match tag {
13199                    "relocation_error" => {
13200                        match map.next_key()? {
13201                            Some("relocation_error") => RelocationBatchErrorEntry::RelocationError(map.next_value()?),
13202                            None => return Err(de::Error::missing_field("relocation_error")),
13203                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13204                        }
13205                    }
13206                    "internal_error" => RelocationBatchErrorEntry::InternalError,
13207                    "too_many_write_operations" => RelocationBatchErrorEntry::TooManyWriteOperations,
13208                    _ => RelocationBatchErrorEntry::Other,
13209                };
13210                crate::eat_json_fields(&mut map)?;
13211                Ok(value)
13212            }
13213        }
13214        const VARIANTS: &[&str] = &["relocation_error",
13215                                    "internal_error",
13216                                    "too_many_write_operations",
13217                                    "other"];
13218        deserializer.deserialize_struct("RelocationBatchErrorEntry", VARIANTS, EnumVisitor)
13219    }
13220}
13221
13222impl ::serde::ser::Serialize for RelocationBatchErrorEntry {
13223    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13224        // union serializer
13225        use serde::ser::SerializeStruct;
13226        match self {
13227            RelocationBatchErrorEntry::RelocationError(x) => {
13228                // union or polymporphic struct
13229                let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 2)?;
13230                s.serialize_field(".tag", "relocation_error")?;
13231                s.serialize_field("relocation_error", x)?;
13232                s.end()
13233            }
13234            RelocationBatchErrorEntry::InternalError => {
13235                // unit
13236                let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 1)?;
13237                s.serialize_field(".tag", "internal_error")?;
13238                s.end()
13239            }
13240            RelocationBatchErrorEntry::TooManyWriteOperations => {
13241                // unit
13242                let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 1)?;
13243                s.serialize_field(".tag", "too_many_write_operations")?;
13244                s.end()
13245            }
13246            RelocationBatchErrorEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13247        }
13248    }
13249}
13250
13251#[derive(Debug, Clone, PartialEq)]
13252pub enum RelocationBatchJobStatus {
13253    /// The asynchronous job is still in progress.
13254    InProgress,
13255    /// The copy or move batch job has finished.
13256    Complete(RelocationBatchResult),
13257    /// The copy or move batch job has failed with exception.
13258    Failed(RelocationBatchError),
13259}
13260
13261impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchJobStatus {
13262    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13263        // union deserializer
13264        use serde::de::{self, MapAccess, Visitor};
13265        struct EnumVisitor;
13266        impl<'de> Visitor<'de> for EnumVisitor {
13267            type Value = RelocationBatchJobStatus;
13268            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13269                f.write_str("a RelocationBatchJobStatus structure")
13270            }
13271            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13272                let tag: &str = match map.next_key()? {
13273                    Some(".tag") => map.next_value()?,
13274                    _ => return Err(de::Error::missing_field(".tag"))
13275                };
13276                let value = match tag {
13277                    "in_progress" => RelocationBatchJobStatus::InProgress,
13278                    "complete" => RelocationBatchJobStatus::Complete(RelocationBatchResult::internal_deserialize(&mut map)?),
13279                    "failed" => {
13280                        match map.next_key()? {
13281                            Some("failed") => RelocationBatchJobStatus::Failed(map.next_value()?),
13282                            None => return Err(de::Error::missing_field("failed")),
13283                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13284                        }
13285                    }
13286                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
13287                };
13288                crate::eat_json_fields(&mut map)?;
13289                Ok(value)
13290            }
13291        }
13292        const VARIANTS: &[&str] = &["in_progress",
13293                                    "complete",
13294                                    "failed"];
13295        deserializer.deserialize_struct("RelocationBatchJobStatus", VARIANTS, EnumVisitor)
13296    }
13297}
13298
13299impl ::serde::ser::Serialize for RelocationBatchJobStatus {
13300    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13301        // union serializer
13302        use serde::ser::SerializeStruct;
13303        match self {
13304            RelocationBatchJobStatus::InProgress => {
13305                // unit
13306                let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 1)?;
13307                s.serialize_field(".tag", "in_progress")?;
13308                s.end()
13309            }
13310            RelocationBatchJobStatus::Complete(x) => {
13311                // struct
13312                let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 2)?;
13313                s.serialize_field(".tag", "complete")?;
13314                x.internal_serialize::<S>(&mut s)?;
13315                s.end()
13316            }
13317            RelocationBatchJobStatus::Failed(x) => {
13318                // union or polymporphic struct
13319                let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 2)?;
13320                s.serialize_field(".tag", "failed")?;
13321                s.serialize_field("failed", x)?;
13322                s.end()
13323            }
13324        }
13325    }
13326}
13327
13328// union extends crate::types::dbx_async::PollResultBase
13329impl From<crate::types::dbx_async::PollResultBase> for RelocationBatchJobStatus {
13330    fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
13331        match parent {
13332            crate::types::dbx_async::PollResultBase::InProgress => RelocationBatchJobStatus::InProgress,
13333        }
13334    }
13335}
13336/// Result returned by [`copy_batch()`](crate::files::copy_batch) or
13337/// [`move_batch()`](crate::files::move_batch) that may either launch an asynchronous job or
13338/// complete synchronously.
13339#[derive(Debug, Clone, PartialEq)]
13340#[non_exhaustive] // variants may be added in the future
13341pub enum RelocationBatchLaunch {
13342    /// This response indicates that the processing is asynchronous. The string is an id that can be
13343    /// used to obtain the status of the asynchronous job.
13344    AsyncJobId(crate::types::dbx_async::AsyncJobId),
13345    Complete(RelocationBatchResult),
13346    /// Catch-all used for unrecognized values returned from the server. Encountering this value
13347    /// typically indicates that this SDK version is out of date.
13348    Other,
13349}
13350
13351impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchLaunch {
13352    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13353        // union deserializer
13354        use serde::de::{self, MapAccess, Visitor};
13355        struct EnumVisitor;
13356        impl<'de> Visitor<'de> for EnumVisitor {
13357            type Value = RelocationBatchLaunch;
13358            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13359                f.write_str("a RelocationBatchLaunch structure")
13360            }
13361            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13362                let tag: &str = match map.next_key()? {
13363                    Some(".tag") => map.next_value()?,
13364                    _ => return Err(de::Error::missing_field(".tag"))
13365                };
13366                let value = match tag {
13367                    "async_job_id" => {
13368                        match map.next_key()? {
13369                            Some("async_job_id") => RelocationBatchLaunch::AsyncJobId(map.next_value()?),
13370                            None => return Err(de::Error::missing_field("async_job_id")),
13371                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13372                        }
13373                    }
13374                    "complete" => RelocationBatchLaunch::Complete(RelocationBatchResult::internal_deserialize(&mut map)?),
13375                    _ => RelocationBatchLaunch::Other,
13376                };
13377                crate::eat_json_fields(&mut map)?;
13378                Ok(value)
13379            }
13380        }
13381        const VARIANTS: &[&str] = &["async_job_id",
13382                                    "complete",
13383                                    "other"];
13384        deserializer.deserialize_struct("RelocationBatchLaunch", VARIANTS, EnumVisitor)
13385    }
13386}
13387
13388impl ::serde::ser::Serialize for RelocationBatchLaunch {
13389    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13390        // union serializer
13391        use serde::ser::SerializeStruct;
13392        match self {
13393            RelocationBatchLaunch::AsyncJobId(x) => {
13394                // primitive
13395                let mut s = serializer.serialize_struct("RelocationBatchLaunch", 2)?;
13396                s.serialize_field(".tag", "async_job_id")?;
13397                s.serialize_field("async_job_id", x)?;
13398                s.end()
13399            }
13400            RelocationBatchLaunch::Complete(x) => {
13401                // struct
13402                let mut s = serializer.serialize_struct("RelocationBatchLaunch", 2)?;
13403                s.serialize_field(".tag", "complete")?;
13404                x.internal_serialize::<S>(&mut s)?;
13405                s.end()
13406            }
13407            RelocationBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13408        }
13409    }
13410}
13411
13412// union extends crate::types::dbx_async::LaunchResultBase
13413impl From<crate::types::dbx_async::LaunchResultBase> for RelocationBatchLaunch {
13414    fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
13415        match parent {
13416            crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => RelocationBatchLaunch::AsyncJobId(x),
13417        }
13418    }
13419}
13420#[derive(Debug, Clone, PartialEq)]
13421#[non_exhaustive] // structs may have more fields added in the future.
13422pub struct RelocationBatchResult {
13423    pub entries: Vec<RelocationBatchResultData>,
13424}
13425
13426impl RelocationBatchResult {
13427    pub fn new(entries: Vec<RelocationBatchResultData>) -> Self {
13428        RelocationBatchResult {
13429            entries,
13430        }
13431    }
13432}
13433
13434const RELOCATION_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
13435impl RelocationBatchResult {
13436    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
13437        map: V,
13438    ) -> Result<RelocationBatchResult, V::Error> {
13439        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
13440    }
13441
13442    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
13443        mut map: V,
13444        optional: bool,
13445    ) -> Result<Option<RelocationBatchResult>, V::Error> {
13446        let mut field_entries = None;
13447        let mut nothing = true;
13448        while let Some(key) = map.next_key::<&str>()? {
13449            nothing = false;
13450            match key {
13451                "entries" => {
13452                    if field_entries.is_some() {
13453                        return Err(::serde::de::Error::duplicate_field("entries"));
13454                    }
13455                    field_entries = Some(map.next_value()?);
13456                }
13457                _ => {
13458                    // unknown field allowed and ignored
13459                    map.next_value::<::serde_json::Value>()?;
13460                }
13461            }
13462        }
13463        if optional && nothing {
13464            return Ok(None);
13465        }
13466        let result = RelocationBatchResult {
13467            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
13468        };
13469        Ok(Some(result))
13470    }
13471
13472    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
13473        &self,
13474        s: &mut S::SerializeStruct,
13475    ) -> Result<(), S::Error> {
13476        use serde::ser::SerializeStruct;
13477        s.serialize_field("entries", &self.entries)?;
13478        Ok(())
13479    }
13480}
13481
13482impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResult {
13483    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13484        // struct deserializer
13485        use serde::de::{MapAccess, Visitor};
13486        struct StructVisitor;
13487        impl<'de> Visitor<'de> for StructVisitor {
13488            type Value = RelocationBatchResult;
13489            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13490                f.write_str("a RelocationBatchResult struct")
13491            }
13492            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
13493                RelocationBatchResult::internal_deserialize(map)
13494            }
13495        }
13496        deserializer.deserialize_struct("RelocationBatchResult", RELOCATION_BATCH_RESULT_FIELDS, StructVisitor)
13497    }
13498}
13499
13500impl ::serde::ser::Serialize for RelocationBatchResult {
13501    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13502        // struct serializer
13503        use serde::ser::SerializeStruct;
13504        let mut s = serializer.serialize_struct("RelocationBatchResult", 1)?;
13505        self.internal_serialize::<S>(&mut s)?;
13506        s.end()
13507    }
13508}
13509
13510// struct extends FileOpsResult
13511impl From<RelocationBatchResult> for FileOpsResult {
13512    fn from(_: RelocationBatchResult) -> Self {
13513        Self {}
13514    }
13515}
13516#[derive(Debug, Clone, PartialEq)]
13517#[non_exhaustive] // structs may have more fields added in the future.
13518pub struct RelocationBatchResultData {
13519    /// Metadata of the relocated object.
13520    pub metadata: Metadata,
13521}
13522
13523impl RelocationBatchResultData {
13524    pub fn new(metadata: Metadata) -> Self {
13525        RelocationBatchResultData {
13526            metadata,
13527        }
13528    }
13529}
13530
13531const RELOCATION_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata"];
13532impl RelocationBatchResultData {
13533    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
13534        map: V,
13535    ) -> Result<RelocationBatchResultData, V::Error> {
13536        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
13537    }
13538
13539    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
13540        mut map: V,
13541        optional: bool,
13542    ) -> Result<Option<RelocationBatchResultData>, V::Error> {
13543        let mut field_metadata = None;
13544        let mut nothing = true;
13545        while let Some(key) = map.next_key::<&str>()? {
13546            nothing = false;
13547            match key {
13548                "metadata" => {
13549                    if field_metadata.is_some() {
13550                        return Err(::serde::de::Error::duplicate_field("metadata"));
13551                    }
13552                    field_metadata = Some(map.next_value()?);
13553                }
13554                _ => {
13555                    // unknown field allowed and ignored
13556                    map.next_value::<::serde_json::Value>()?;
13557                }
13558            }
13559        }
13560        if optional && nothing {
13561            return Ok(None);
13562        }
13563        let result = RelocationBatchResultData {
13564            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
13565        };
13566        Ok(Some(result))
13567    }
13568
13569    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
13570        &self,
13571        s: &mut S::SerializeStruct,
13572    ) -> Result<(), S::Error> {
13573        use serde::ser::SerializeStruct;
13574        s.serialize_field("metadata", &self.metadata)?;
13575        Ok(())
13576    }
13577}
13578
13579impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResultData {
13580    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13581        // struct deserializer
13582        use serde::de::{MapAccess, Visitor};
13583        struct StructVisitor;
13584        impl<'de> Visitor<'de> for StructVisitor {
13585            type Value = RelocationBatchResultData;
13586            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13587                f.write_str("a RelocationBatchResultData struct")
13588            }
13589            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
13590                RelocationBatchResultData::internal_deserialize(map)
13591            }
13592        }
13593        deserializer.deserialize_struct("RelocationBatchResultData", RELOCATION_BATCH_RESULT_DATA_FIELDS, StructVisitor)
13594    }
13595}
13596
13597impl ::serde::ser::Serialize for RelocationBatchResultData {
13598    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13599        // struct serializer
13600        use serde::ser::SerializeStruct;
13601        let mut s = serializer.serialize_struct("RelocationBatchResultData", 1)?;
13602        self.internal_serialize::<S>(&mut s)?;
13603        s.end()
13604    }
13605}
13606
13607#[derive(Debug, Clone, PartialEq)]
13608#[non_exhaustive] // variants may be added in the future
13609pub enum RelocationBatchResultEntry {
13610    Success(Metadata),
13611    Failure(RelocationBatchErrorEntry),
13612    /// Catch-all used for unrecognized values returned from the server. Encountering this value
13613    /// typically indicates that this SDK version is out of date.
13614    Other,
13615}
13616
13617impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResultEntry {
13618    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13619        // union deserializer
13620        use serde::de::{self, MapAccess, Visitor};
13621        struct EnumVisitor;
13622        impl<'de> Visitor<'de> for EnumVisitor {
13623            type Value = RelocationBatchResultEntry;
13624            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13625                f.write_str("a RelocationBatchResultEntry structure")
13626            }
13627            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13628                let tag: &str = match map.next_key()? {
13629                    Some(".tag") => map.next_value()?,
13630                    _ => return Err(de::Error::missing_field(".tag"))
13631                };
13632                let value = match tag {
13633                    "success" => {
13634                        match map.next_key()? {
13635                            Some("success") => RelocationBatchResultEntry::Success(map.next_value()?),
13636                            None => return Err(de::Error::missing_field("success")),
13637                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13638                        }
13639                    }
13640                    "failure" => {
13641                        match map.next_key()? {
13642                            Some("failure") => RelocationBatchResultEntry::Failure(map.next_value()?),
13643                            None => return Err(de::Error::missing_field("failure")),
13644                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13645                        }
13646                    }
13647                    _ => RelocationBatchResultEntry::Other,
13648                };
13649                crate::eat_json_fields(&mut map)?;
13650                Ok(value)
13651            }
13652        }
13653        const VARIANTS: &[&str] = &["success",
13654                                    "failure",
13655                                    "other"];
13656        deserializer.deserialize_struct("RelocationBatchResultEntry", VARIANTS, EnumVisitor)
13657    }
13658}
13659
13660impl ::serde::ser::Serialize for RelocationBatchResultEntry {
13661    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13662        // union serializer
13663        use serde::ser::SerializeStruct;
13664        match self {
13665            RelocationBatchResultEntry::Success(x) => {
13666                // union or polymporphic struct
13667                let mut s = serializer.serialize_struct("RelocationBatchResultEntry", 2)?;
13668                s.serialize_field(".tag", "success")?;
13669                s.serialize_field("success", x)?;
13670                s.end()
13671            }
13672            RelocationBatchResultEntry::Failure(x) => {
13673                // union or polymporphic struct
13674                let mut s = serializer.serialize_struct("RelocationBatchResultEntry", 2)?;
13675                s.serialize_field(".tag", "failure")?;
13676                s.serialize_field("failure", x)?;
13677                s.end()
13678            }
13679            RelocationBatchResultEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13680        }
13681    }
13682}
13683
13684/// Result returned by [`copy_batch_check_v2()`](crate::files::copy_batch_check_v2) or
13685/// [`move_batch_check_v2()`](crate::files::move_batch_check_v2) that may either be in progress or
13686/// completed with result for each entry.
13687#[derive(Debug, Clone, PartialEq)]
13688pub enum RelocationBatchV2JobStatus {
13689    /// The asynchronous job is still in progress.
13690    InProgress,
13691    /// The copy or move batch job has finished.
13692    Complete(RelocationBatchV2Result),
13693}
13694
13695impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2JobStatus {
13696    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13697        // union deserializer
13698        use serde::de::{self, MapAccess, Visitor};
13699        struct EnumVisitor;
13700        impl<'de> Visitor<'de> for EnumVisitor {
13701            type Value = RelocationBatchV2JobStatus;
13702            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13703                f.write_str("a RelocationBatchV2JobStatus structure")
13704            }
13705            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13706                let tag: &str = match map.next_key()? {
13707                    Some(".tag") => map.next_value()?,
13708                    _ => return Err(de::Error::missing_field(".tag"))
13709                };
13710                let value = match tag {
13711                    "in_progress" => RelocationBatchV2JobStatus::InProgress,
13712                    "complete" => RelocationBatchV2JobStatus::Complete(RelocationBatchV2Result::internal_deserialize(&mut map)?),
13713                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
13714                };
13715                crate::eat_json_fields(&mut map)?;
13716                Ok(value)
13717            }
13718        }
13719        const VARIANTS: &[&str] = &["in_progress",
13720                                    "complete"];
13721        deserializer.deserialize_struct("RelocationBatchV2JobStatus", VARIANTS, EnumVisitor)
13722    }
13723}
13724
13725impl ::serde::ser::Serialize for RelocationBatchV2JobStatus {
13726    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13727        // union serializer
13728        use serde::ser::SerializeStruct;
13729        match self {
13730            RelocationBatchV2JobStatus::InProgress => {
13731                // unit
13732                let mut s = serializer.serialize_struct("RelocationBatchV2JobStatus", 1)?;
13733                s.serialize_field(".tag", "in_progress")?;
13734                s.end()
13735            }
13736            RelocationBatchV2JobStatus::Complete(x) => {
13737                // struct
13738                let mut s = serializer.serialize_struct("RelocationBatchV2JobStatus", 2)?;
13739                s.serialize_field(".tag", "complete")?;
13740                x.internal_serialize::<S>(&mut s)?;
13741                s.end()
13742            }
13743        }
13744    }
13745}
13746
13747// union extends crate::types::dbx_async::PollResultBase
13748impl From<crate::types::dbx_async::PollResultBase> for RelocationBatchV2JobStatus {
13749    fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
13750        match parent {
13751            crate::types::dbx_async::PollResultBase::InProgress => RelocationBatchV2JobStatus::InProgress,
13752        }
13753    }
13754}
13755/// Result returned by [`copy_batch_v2()`](crate::files::copy_batch_v2) or
13756/// [`move_batch_v2()`](crate::files::move_batch_v2) that may either launch an asynchronous job or
13757/// complete synchronously.
13758#[derive(Debug, Clone, PartialEq)]
13759pub enum RelocationBatchV2Launch {
13760    /// This response indicates that the processing is asynchronous. The string is an id that can be
13761    /// used to obtain the status of the asynchronous job.
13762    AsyncJobId(crate::types::dbx_async::AsyncJobId),
13763    Complete(RelocationBatchV2Result),
13764}
13765
13766impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2Launch {
13767    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13768        // union deserializer
13769        use serde::de::{self, MapAccess, Visitor};
13770        struct EnumVisitor;
13771        impl<'de> Visitor<'de> for EnumVisitor {
13772            type Value = RelocationBatchV2Launch;
13773            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13774                f.write_str("a RelocationBatchV2Launch structure")
13775            }
13776            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13777                let tag: &str = match map.next_key()? {
13778                    Some(".tag") => map.next_value()?,
13779                    _ => return Err(de::Error::missing_field(".tag"))
13780                };
13781                let value = match tag {
13782                    "async_job_id" => {
13783                        match map.next_key()? {
13784                            Some("async_job_id") => RelocationBatchV2Launch::AsyncJobId(map.next_value()?),
13785                            None => return Err(de::Error::missing_field("async_job_id")),
13786                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13787                        }
13788                    }
13789                    "complete" => RelocationBatchV2Launch::Complete(RelocationBatchV2Result::internal_deserialize(&mut map)?),
13790                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
13791                };
13792                crate::eat_json_fields(&mut map)?;
13793                Ok(value)
13794            }
13795        }
13796        const VARIANTS: &[&str] = &["async_job_id",
13797                                    "complete"];
13798        deserializer.deserialize_struct("RelocationBatchV2Launch", VARIANTS, EnumVisitor)
13799    }
13800}
13801
13802impl ::serde::ser::Serialize for RelocationBatchV2Launch {
13803    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13804        // union serializer
13805        use serde::ser::SerializeStruct;
13806        match self {
13807            RelocationBatchV2Launch::AsyncJobId(x) => {
13808                // primitive
13809                let mut s = serializer.serialize_struct("RelocationBatchV2Launch", 2)?;
13810                s.serialize_field(".tag", "async_job_id")?;
13811                s.serialize_field("async_job_id", x)?;
13812                s.end()
13813            }
13814            RelocationBatchV2Launch::Complete(x) => {
13815                // struct
13816                let mut s = serializer.serialize_struct("RelocationBatchV2Launch", 2)?;
13817                s.serialize_field(".tag", "complete")?;
13818                x.internal_serialize::<S>(&mut s)?;
13819                s.end()
13820            }
13821        }
13822    }
13823}
13824
13825// union extends crate::types::dbx_async::LaunchResultBase
13826impl From<crate::types::dbx_async::LaunchResultBase> for RelocationBatchV2Launch {
13827    fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
13828        match parent {
13829            crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => RelocationBatchV2Launch::AsyncJobId(x),
13830        }
13831    }
13832}
13833#[derive(Debug, Clone, PartialEq)]
13834#[non_exhaustive] // structs may have more fields added in the future.
13835pub struct RelocationBatchV2Result {
13836    /// Each entry in CopyBatchArg.entries or [`MoveBatchArg::entries`](MoveBatchArg) will appear at
13837    /// the same position inside [`RelocationBatchV2Result::entries`](RelocationBatchV2Result).
13838    pub entries: Vec<RelocationBatchResultEntry>,
13839}
13840
13841impl RelocationBatchV2Result {
13842    pub fn new(entries: Vec<RelocationBatchResultEntry>) -> Self {
13843        RelocationBatchV2Result {
13844            entries,
13845        }
13846    }
13847}
13848
13849const RELOCATION_BATCH_V2_RESULT_FIELDS: &[&str] = &["entries"];
13850impl RelocationBatchV2Result {
13851    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
13852        map: V,
13853    ) -> Result<RelocationBatchV2Result, V::Error> {
13854        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
13855    }
13856
13857    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
13858        mut map: V,
13859        optional: bool,
13860    ) -> Result<Option<RelocationBatchV2Result>, V::Error> {
13861        let mut field_entries = None;
13862        let mut nothing = true;
13863        while let Some(key) = map.next_key::<&str>()? {
13864            nothing = false;
13865            match key {
13866                "entries" => {
13867                    if field_entries.is_some() {
13868                        return Err(::serde::de::Error::duplicate_field("entries"));
13869                    }
13870                    field_entries = Some(map.next_value()?);
13871                }
13872                _ => {
13873                    // unknown field allowed and ignored
13874                    map.next_value::<::serde_json::Value>()?;
13875                }
13876            }
13877        }
13878        if optional && nothing {
13879            return Ok(None);
13880        }
13881        let result = RelocationBatchV2Result {
13882            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
13883        };
13884        Ok(Some(result))
13885    }
13886
13887    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
13888        &self,
13889        s: &mut S::SerializeStruct,
13890    ) -> Result<(), S::Error> {
13891        use serde::ser::SerializeStruct;
13892        s.serialize_field("entries", &self.entries)?;
13893        Ok(())
13894    }
13895}
13896
13897impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2Result {
13898    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13899        // struct deserializer
13900        use serde::de::{MapAccess, Visitor};
13901        struct StructVisitor;
13902        impl<'de> Visitor<'de> for StructVisitor {
13903            type Value = RelocationBatchV2Result;
13904            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13905                f.write_str("a RelocationBatchV2Result struct")
13906            }
13907            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
13908                RelocationBatchV2Result::internal_deserialize(map)
13909            }
13910        }
13911        deserializer.deserialize_struct("RelocationBatchV2Result", RELOCATION_BATCH_V2_RESULT_FIELDS, StructVisitor)
13912    }
13913}
13914
13915impl ::serde::ser::Serialize for RelocationBatchV2Result {
13916    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13917        // struct serializer
13918        use serde::ser::SerializeStruct;
13919        let mut s = serializer.serialize_struct("RelocationBatchV2Result", 1)?;
13920        self.internal_serialize::<S>(&mut s)?;
13921        s.end()
13922    }
13923}
13924
13925// struct extends FileOpsResult
13926impl From<RelocationBatchV2Result> for FileOpsResult {
13927    fn from(_: RelocationBatchV2Result) -> Self {
13928        Self {}
13929    }
13930}
13931#[derive(Debug, Clone, PartialEq, Eq)]
13932#[non_exhaustive] // variants may be added in the future
13933pub enum RelocationError {
13934    FromLookup(LookupError),
13935    FromWrite(WriteError),
13936    To(WriteError),
13937    /// Shared folders can't be copied.
13938    CantCopySharedFolder,
13939    /// Your move operation would result in nested shared folders.  This is not allowed.
13940    CantNestSharedFolder,
13941    /// You cannot move a folder into itself.
13942    CantMoveFolderIntoItself,
13943    /// The operation would involve more than 10,000 files and folders.
13944    TooManyFiles,
13945    /// There are duplicated/nested paths among [`RelocationArg::from_path`](RelocationArg) and
13946    /// [`RelocationArg::to_path`](RelocationArg).
13947    DuplicatedOrNestedPaths,
13948    /// Your move operation would result in an ownership transfer. You may reissue the request with
13949    /// the field [`RelocationArg::allow_ownership_transfer`](RelocationArg) to true.
13950    CantTransferOwnership,
13951    /// The current user does not have enough space to move or copy the files.
13952    InsufficientQuota,
13953    /// Something went wrong with the job on Dropbox's end. You'll need to verify that the action
13954    /// you were taking succeeded, and if not, try again. This should happen very rarely.
13955    InternalError,
13956    /// Can't move the shared folder to the given destination.
13957    CantMoveSharedFolder,
13958    /// Some content cannot be moved into Vault under certain circumstances, see detailed error.
13959    CantMoveIntoVault(MoveIntoVaultError),
13960    /// Some content cannot be moved into the Family Room folder under certain circumstances, see
13961    /// detailed error.
13962    CantMoveIntoFamily(MoveIntoFamilyError),
13963    /// Catch-all used for unrecognized values returned from the server. Encountering this value
13964    /// typically indicates that this SDK version is out of date.
13965    Other,
13966}
13967
13968impl<'de> ::serde::de::Deserialize<'de> for RelocationError {
13969    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13970        // union deserializer
13971        use serde::de::{self, MapAccess, Visitor};
13972        struct EnumVisitor;
13973        impl<'de> Visitor<'de> for EnumVisitor {
13974            type Value = RelocationError;
13975            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13976                f.write_str("a RelocationError structure")
13977            }
13978            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13979                let tag: &str = match map.next_key()? {
13980                    Some(".tag") => map.next_value()?,
13981                    _ => return Err(de::Error::missing_field(".tag"))
13982                };
13983                let value = match tag {
13984                    "from_lookup" => {
13985                        match map.next_key()? {
13986                            Some("from_lookup") => RelocationError::FromLookup(map.next_value()?),
13987                            None => return Err(de::Error::missing_field("from_lookup")),
13988                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13989                        }
13990                    }
13991                    "from_write" => {
13992                        match map.next_key()? {
13993                            Some("from_write") => RelocationError::FromWrite(map.next_value()?),
13994                            None => return Err(de::Error::missing_field("from_write")),
13995                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13996                        }
13997                    }
13998                    "to" => {
13999                        match map.next_key()? {
14000                            Some("to") => RelocationError::To(map.next_value()?),
14001                            None => return Err(de::Error::missing_field("to")),
14002                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14003                        }
14004                    }
14005                    "cant_copy_shared_folder" => RelocationError::CantCopySharedFolder,
14006                    "cant_nest_shared_folder" => RelocationError::CantNestSharedFolder,
14007                    "cant_move_folder_into_itself" => RelocationError::CantMoveFolderIntoItself,
14008                    "too_many_files" => RelocationError::TooManyFiles,
14009                    "duplicated_or_nested_paths" => RelocationError::DuplicatedOrNestedPaths,
14010                    "cant_transfer_ownership" => RelocationError::CantTransferOwnership,
14011                    "insufficient_quota" => RelocationError::InsufficientQuota,
14012                    "internal_error" => RelocationError::InternalError,
14013                    "cant_move_shared_folder" => RelocationError::CantMoveSharedFolder,
14014                    "cant_move_into_vault" => {
14015                        match map.next_key()? {
14016                            Some("cant_move_into_vault") => RelocationError::CantMoveIntoVault(map.next_value()?),
14017                            None => return Err(de::Error::missing_field("cant_move_into_vault")),
14018                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14019                        }
14020                    }
14021                    "cant_move_into_family" => {
14022                        match map.next_key()? {
14023                            Some("cant_move_into_family") => RelocationError::CantMoveIntoFamily(map.next_value()?),
14024                            None => return Err(de::Error::missing_field("cant_move_into_family")),
14025                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14026                        }
14027                    }
14028                    _ => RelocationError::Other,
14029                };
14030                crate::eat_json_fields(&mut map)?;
14031                Ok(value)
14032            }
14033        }
14034        const VARIANTS: &[&str] = &["from_lookup",
14035                                    "from_write",
14036                                    "to",
14037                                    "cant_copy_shared_folder",
14038                                    "cant_nest_shared_folder",
14039                                    "cant_move_folder_into_itself",
14040                                    "too_many_files",
14041                                    "duplicated_or_nested_paths",
14042                                    "cant_transfer_ownership",
14043                                    "insufficient_quota",
14044                                    "internal_error",
14045                                    "cant_move_shared_folder",
14046                                    "cant_move_into_vault",
14047                                    "cant_move_into_family",
14048                                    "other"];
14049        deserializer.deserialize_struct("RelocationError", VARIANTS, EnumVisitor)
14050    }
14051}
14052
14053impl ::serde::ser::Serialize for RelocationError {
14054    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14055        // union serializer
14056        use serde::ser::SerializeStruct;
14057        match self {
14058            RelocationError::FromLookup(x) => {
14059                // union or polymporphic struct
14060                let mut s = serializer.serialize_struct("RelocationError", 2)?;
14061                s.serialize_field(".tag", "from_lookup")?;
14062                s.serialize_field("from_lookup", x)?;
14063                s.end()
14064            }
14065            RelocationError::FromWrite(x) => {
14066                // union or polymporphic struct
14067                let mut s = serializer.serialize_struct("RelocationError", 2)?;
14068                s.serialize_field(".tag", "from_write")?;
14069                s.serialize_field("from_write", x)?;
14070                s.end()
14071            }
14072            RelocationError::To(x) => {
14073                // union or polymporphic struct
14074                let mut s = serializer.serialize_struct("RelocationError", 2)?;
14075                s.serialize_field(".tag", "to")?;
14076                s.serialize_field("to", x)?;
14077                s.end()
14078            }
14079            RelocationError::CantCopySharedFolder => {
14080                // unit
14081                let mut s = serializer.serialize_struct("RelocationError", 1)?;
14082                s.serialize_field(".tag", "cant_copy_shared_folder")?;
14083                s.end()
14084            }
14085            RelocationError::CantNestSharedFolder => {
14086                // unit
14087                let mut s = serializer.serialize_struct("RelocationError", 1)?;
14088                s.serialize_field(".tag", "cant_nest_shared_folder")?;
14089                s.end()
14090            }
14091            RelocationError::CantMoveFolderIntoItself => {
14092                // unit
14093                let mut s = serializer.serialize_struct("RelocationError", 1)?;
14094                s.serialize_field(".tag", "cant_move_folder_into_itself")?;
14095                s.end()
14096            }
14097            RelocationError::TooManyFiles => {
14098                // unit
14099                let mut s = serializer.serialize_struct("RelocationError", 1)?;
14100                s.serialize_field(".tag", "too_many_files")?;
14101                s.end()
14102            }
14103            RelocationError::DuplicatedOrNestedPaths => {
14104                // unit
14105                let mut s = serializer.serialize_struct("RelocationError", 1)?;
14106                s.serialize_field(".tag", "duplicated_or_nested_paths")?;
14107                s.end()
14108            }
14109            RelocationError::CantTransferOwnership => {
14110                // unit
14111                let mut s = serializer.serialize_struct("RelocationError", 1)?;
14112                s.serialize_field(".tag", "cant_transfer_ownership")?;
14113                s.end()
14114            }
14115            RelocationError::InsufficientQuota => {
14116                // unit
14117                let mut s = serializer.serialize_struct("RelocationError", 1)?;
14118                s.serialize_field(".tag", "insufficient_quota")?;
14119                s.end()
14120            }
14121            RelocationError::InternalError => {
14122                // unit
14123                let mut s = serializer.serialize_struct("RelocationError", 1)?;
14124                s.serialize_field(".tag", "internal_error")?;
14125                s.end()
14126            }
14127            RelocationError::CantMoveSharedFolder => {
14128                // unit
14129                let mut s = serializer.serialize_struct("RelocationError", 1)?;
14130                s.serialize_field(".tag", "cant_move_shared_folder")?;
14131                s.end()
14132            }
14133            RelocationError::CantMoveIntoVault(x) => {
14134                // union or polymporphic struct
14135                let mut s = serializer.serialize_struct("RelocationError", 2)?;
14136                s.serialize_field(".tag", "cant_move_into_vault")?;
14137                s.serialize_field("cant_move_into_vault", x)?;
14138                s.end()
14139            }
14140            RelocationError::CantMoveIntoFamily(x) => {
14141                // union or polymporphic struct
14142                let mut s = serializer.serialize_struct("RelocationError", 2)?;
14143                s.serialize_field(".tag", "cant_move_into_family")?;
14144                s.serialize_field("cant_move_into_family", x)?;
14145                s.end()
14146            }
14147            RelocationError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
14148        }
14149    }
14150}
14151
14152impl ::std::error::Error for RelocationError {
14153    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
14154        match self {
14155            RelocationError::FromLookup(inner) => Some(inner),
14156            RelocationError::FromWrite(inner) => Some(inner),
14157            RelocationError::To(inner) => Some(inner),
14158            RelocationError::CantMoveIntoVault(inner) => Some(inner),
14159            RelocationError::CantMoveIntoFamily(inner) => Some(inner),
14160            _ => None,
14161        }
14162    }
14163}
14164
14165impl ::std::fmt::Display for RelocationError {
14166    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14167        match self {
14168            RelocationError::FromLookup(inner) => write!(f, "RelocationError: {}", inner),
14169            RelocationError::FromWrite(inner) => write!(f, "RelocationError: {}", inner),
14170            RelocationError::To(inner) => write!(f, "RelocationError: {}", inner),
14171            RelocationError::CantCopySharedFolder => f.write_str("Shared folders can't be copied."),
14172            RelocationError::CantNestSharedFolder => f.write_str("Your move operation would result in nested shared folders.  This is not allowed."),
14173            RelocationError::CantMoveFolderIntoItself => f.write_str("You cannot move a folder into itself."),
14174            RelocationError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
14175            RelocationError::InsufficientQuota => f.write_str("The current user does not have enough space to move or copy the files."),
14176            RelocationError::InternalError => f.write_str("Something went wrong with the job on Dropbox's end. You'll need to verify that the action you were taking succeeded, and if not, try again. This should happen very rarely."),
14177            RelocationError::CantMoveSharedFolder => f.write_str("Can't move the shared folder to the given destination."),
14178            RelocationError::CantMoveIntoVault(inner) => write!(f, "Some content cannot be moved into Vault under certain circumstances, see detailed error: {}", inner),
14179            RelocationError::CantMoveIntoFamily(inner) => write!(f, "Some content cannot be moved into the Family Room folder under certain circumstances, see detailed error: {}", inner),
14180            _ => write!(f, "{:?}", *self),
14181        }
14182    }
14183}
14184
14185#[derive(Debug, Clone, PartialEq, Eq)]
14186#[non_exhaustive] // structs may have more fields added in the future.
14187pub struct RelocationPath {
14188    /// Path in the user's Dropbox to be copied or moved.
14189    pub from_path: WritePathOrId,
14190    /// Path in the user's Dropbox that is the destination.
14191    pub to_path: WritePathOrId,
14192}
14193
14194impl RelocationPath {
14195    pub fn new(from_path: WritePathOrId, to_path: WritePathOrId) -> Self {
14196        RelocationPath {
14197            from_path,
14198            to_path,
14199        }
14200    }
14201}
14202
14203const RELOCATION_PATH_FIELDS: &[&str] = &["from_path",
14204                                          "to_path"];
14205impl RelocationPath {
14206    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14207        map: V,
14208    ) -> Result<RelocationPath, V::Error> {
14209        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14210    }
14211
14212    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14213        mut map: V,
14214        optional: bool,
14215    ) -> Result<Option<RelocationPath>, V::Error> {
14216        let mut field_from_path = None;
14217        let mut field_to_path = None;
14218        let mut nothing = true;
14219        while let Some(key) = map.next_key::<&str>()? {
14220            nothing = false;
14221            match key {
14222                "from_path" => {
14223                    if field_from_path.is_some() {
14224                        return Err(::serde::de::Error::duplicate_field("from_path"));
14225                    }
14226                    field_from_path = Some(map.next_value()?);
14227                }
14228                "to_path" => {
14229                    if field_to_path.is_some() {
14230                        return Err(::serde::de::Error::duplicate_field("to_path"));
14231                    }
14232                    field_to_path = Some(map.next_value()?);
14233                }
14234                _ => {
14235                    // unknown field allowed and ignored
14236                    map.next_value::<::serde_json::Value>()?;
14237                }
14238            }
14239        }
14240        if optional && nothing {
14241            return Ok(None);
14242        }
14243        let result = RelocationPath {
14244            from_path: field_from_path.ok_or_else(|| ::serde::de::Error::missing_field("from_path"))?,
14245            to_path: field_to_path.ok_or_else(|| ::serde::de::Error::missing_field("to_path"))?,
14246        };
14247        Ok(Some(result))
14248    }
14249
14250    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14251        &self,
14252        s: &mut S::SerializeStruct,
14253    ) -> Result<(), S::Error> {
14254        use serde::ser::SerializeStruct;
14255        s.serialize_field("from_path", &self.from_path)?;
14256        s.serialize_field("to_path", &self.to_path)?;
14257        Ok(())
14258    }
14259}
14260
14261impl<'de> ::serde::de::Deserialize<'de> for RelocationPath {
14262    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14263        // struct deserializer
14264        use serde::de::{MapAccess, Visitor};
14265        struct StructVisitor;
14266        impl<'de> Visitor<'de> for StructVisitor {
14267            type Value = RelocationPath;
14268            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14269                f.write_str("a RelocationPath struct")
14270            }
14271            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14272                RelocationPath::internal_deserialize(map)
14273            }
14274        }
14275        deserializer.deserialize_struct("RelocationPath", RELOCATION_PATH_FIELDS, StructVisitor)
14276    }
14277}
14278
14279impl ::serde::ser::Serialize for RelocationPath {
14280    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14281        // struct serializer
14282        use serde::ser::SerializeStruct;
14283        let mut s = serializer.serialize_struct("RelocationPath", 2)?;
14284        self.internal_serialize::<S>(&mut s)?;
14285        s.end()
14286    }
14287}
14288
14289#[derive(Debug, Clone, PartialEq)]
14290#[non_exhaustive] // structs may have more fields added in the future.
14291pub struct RelocationResult {
14292    /// Metadata of the relocated object.
14293    pub metadata: Metadata,
14294}
14295
14296impl RelocationResult {
14297    pub fn new(metadata: Metadata) -> Self {
14298        RelocationResult {
14299            metadata,
14300        }
14301    }
14302}
14303
14304const RELOCATION_RESULT_FIELDS: &[&str] = &["metadata"];
14305impl RelocationResult {
14306    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14307        map: V,
14308    ) -> Result<RelocationResult, V::Error> {
14309        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14310    }
14311
14312    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14313        mut map: V,
14314        optional: bool,
14315    ) -> Result<Option<RelocationResult>, V::Error> {
14316        let mut field_metadata = None;
14317        let mut nothing = true;
14318        while let Some(key) = map.next_key::<&str>()? {
14319            nothing = false;
14320            match key {
14321                "metadata" => {
14322                    if field_metadata.is_some() {
14323                        return Err(::serde::de::Error::duplicate_field("metadata"));
14324                    }
14325                    field_metadata = Some(map.next_value()?);
14326                }
14327                _ => {
14328                    // unknown field allowed and ignored
14329                    map.next_value::<::serde_json::Value>()?;
14330                }
14331            }
14332        }
14333        if optional && nothing {
14334            return Ok(None);
14335        }
14336        let result = RelocationResult {
14337            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
14338        };
14339        Ok(Some(result))
14340    }
14341
14342    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14343        &self,
14344        s: &mut S::SerializeStruct,
14345    ) -> Result<(), S::Error> {
14346        use serde::ser::SerializeStruct;
14347        s.serialize_field("metadata", &self.metadata)?;
14348        Ok(())
14349    }
14350}
14351
14352impl<'de> ::serde::de::Deserialize<'de> for RelocationResult {
14353    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14354        // struct deserializer
14355        use serde::de::{MapAccess, Visitor};
14356        struct StructVisitor;
14357        impl<'de> Visitor<'de> for StructVisitor {
14358            type Value = RelocationResult;
14359            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14360                f.write_str("a RelocationResult struct")
14361            }
14362            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14363                RelocationResult::internal_deserialize(map)
14364            }
14365        }
14366        deserializer.deserialize_struct("RelocationResult", RELOCATION_RESULT_FIELDS, StructVisitor)
14367    }
14368}
14369
14370impl ::serde::ser::Serialize for RelocationResult {
14371    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14372        // struct serializer
14373        use serde::ser::SerializeStruct;
14374        let mut s = serializer.serialize_struct("RelocationResult", 1)?;
14375        self.internal_serialize::<S>(&mut s)?;
14376        s.end()
14377    }
14378}
14379
14380// struct extends FileOpsResult
14381impl From<RelocationResult> for FileOpsResult {
14382    fn from(_: RelocationResult) -> Self {
14383        Self {}
14384    }
14385}
14386#[derive(Debug, Clone, PartialEq, Eq)]
14387#[non_exhaustive] // structs may have more fields added in the future.
14388pub struct RemoveTagArg {
14389    /// Path to the item to tag.
14390    pub path: Path,
14391    /// The tag to remove. Will be automatically converted to lowercase letters.
14392    pub tag_text: TagText,
14393}
14394
14395impl RemoveTagArg {
14396    pub fn new(path: Path, tag_text: TagText) -> Self {
14397        RemoveTagArg {
14398            path,
14399            tag_text,
14400        }
14401    }
14402}
14403
14404const REMOVE_TAG_ARG_FIELDS: &[&str] = &["path",
14405                                         "tag_text"];
14406impl RemoveTagArg {
14407    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14408        map: V,
14409    ) -> Result<RemoveTagArg, V::Error> {
14410        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14411    }
14412
14413    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14414        mut map: V,
14415        optional: bool,
14416    ) -> Result<Option<RemoveTagArg>, V::Error> {
14417        let mut field_path = None;
14418        let mut field_tag_text = None;
14419        let mut nothing = true;
14420        while let Some(key) = map.next_key::<&str>()? {
14421            nothing = false;
14422            match key {
14423                "path" => {
14424                    if field_path.is_some() {
14425                        return Err(::serde::de::Error::duplicate_field("path"));
14426                    }
14427                    field_path = Some(map.next_value()?);
14428                }
14429                "tag_text" => {
14430                    if field_tag_text.is_some() {
14431                        return Err(::serde::de::Error::duplicate_field("tag_text"));
14432                    }
14433                    field_tag_text = Some(map.next_value()?);
14434                }
14435                _ => {
14436                    // unknown field allowed and ignored
14437                    map.next_value::<::serde_json::Value>()?;
14438                }
14439            }
14440        }
14441        if optional && nothing {
14442            return Ok(None);
14443        }
14444        let result = RemoveTagArg {
14445            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
14446            tag_text: field_tag_text.ok_or_else(|| ::serde::de::Error::missing_field("tag_text"))?,
14447        };
14448        Ok(Some(result))
14449    }
14450
14451    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14452        &self,
14453        s: &mut S::SerializeStruct,
14454    ) -> Result<(), S::Error> {
14455        use serde::ser::SerializeStruct;
14456        s.serialize_field("path", &self.path)?;
14457        s.serialize_field("tag_text", &self.tag_text)?;
14458        Ok(())
14459    }
14460}
14461
14462impl<'de> ::serde::de::Deserialize<'de> for RemoveTagArg {
14463    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14464        // struct deserializer
14465        use serde::de::{MapAccess, Visitor};
14466        struct StructVisitor;
14467        impl<'de> Visitor<'de> for StructVisitor {
14468            type Value = RemoveTagArg;
14469            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14470                f.write_str("a RemoveTagArg struct")
14471            }
14472            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14473                RemoveTagArg::internal_deserialize(map)
14474            }
14475        }
14476        deserializer.deserialize_struct("RemoveTagArg", REMOVE_TAG_ARG_FIELDS, StructVisitor)
14477    }
14478}
14479
14480impl ::serde::ser::Serialize for RemoveTagArg {
14481    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14482        // struct serializer
14483        use serde::ser::SerializeStruct;
14484        let mut s = serializer.serialize_struct("RemoveTagArg", 2)?;
14485        self.internal_serialize::<S>(&mut s)?;
14486        s.end()
14487    }
14488}
14489
14490#[derive(Debug, Clone, PartialEq, Eq)]
14491#[non_exhaustive] // variants may be added in the future
14492pub enum RemoveTagError {
14493    Path(LookupError),
14494    /// That tag doesn't exist at this path.
14495    TagNotPresent,
14496    /// Catch-all used for unrecognized values returned from the server. Encountering this value
14497    /// typically indicates that this SDK version is out of date.
14498    Other,
14499}
14500
14501impl<'de> ::serde::de::Deserialize<'de> for RemoveTagError {
14502    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14503        // union deserializer
14504        use serde::de::{self, MapAccess, Visitor};
14505        struct EnumVisitor;
14506        impl<'de> Visitor<'de> for EnumVisitor {
14507            type Value = RemoveTagError;
14508            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14509                f.write_str("a RemoveTagError structure")
14510            }
14511            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
14512                let tag: &str = match map.next_key()? {
14513                    Some(".tag") => map.next_value()?,
14514                    _ => return Err(de::Error::missing_field(".tag"))
14515                };
14516                let value = match tag {
14517                    "path" => {
14518                        match map.next_key()? {
14519                            Some("path") => RemoveTagError::Path(map.next_value()?),
14520                            None => return Err(de::Error::missing_field("path")),
14521                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14522                        }
14523                    }
14524                    "tag_not_present" => RemoveTagError::TagNotPresent,
14525                    _ => RemoveTagError::Other,
14526                };
14527                crate::eat_json_fields(&mut map)?;
14528                Ok(value)
14529            }
14530        }
14531        const VARIANTS: &[&str] = &["path",
14532                                    "other",
14533                                    "tag_not_present"];
14534        deserializer.deserialize_struct("RemoveTagError", VARIANTS, EnumVisitor)
14535    }
14536}
14537
14538impl ::serde::ser::Serialize for RemoveTagError {
14539    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14540        // union serializer
14541        use serde::ser::SerializeStruct;
14542        match self {
14543            RemoveTagError::Path(x) => {
14544                // union or polymporphic struct
14545                let mut s = serializer.serialize_struct("RemoveTagError", 2)?;
14546                s.serialize_field(".tag", "path")?;
14547                s.serialize_field("path", x)?;
14548                s.end()
14549            }
14550            RemoveTagError::TagNotPresent => {
14551                // unit
14552                let mut s = serializer.serialize_struct("RemoveTagError", 1)?;
14553                s.serialize_field(".tag", "tag_not_present")?;
14554                s.end()
14555            }
14556            RemoveTagError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
14557        }
14558    }
14559}
14560
14561impl ::std::error::Error for RemoveTagError {
14562    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
14563        match self {
14564            RemoveTagError::Path(inner) => Some(inner),
14565            _ => None,
14566        }
14567    }
14568}
14569
14570impl ::std::fmt::Display for RemoveTagError {
14571    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14572        match self {
14573            RemoveTagError::Path(inner) => write!(f, "RemoveTagError: {}", inner),
14574            RemoveTagError::TagNotPresent => f.write_str("That tag doesn't exist at this path."),
14575            _ => write!(f, "{:?}", *self),
14576        }
14577    }
14578}
14579
14580// union extends BaseTagError
14581impl From<BaseTagError> for RemoveTagError {
14582    fn from(parent: BaseTagError) -> Self {
14583        match parent {
14584            BaseTagError::Path(x) => RemoveTagError::Path(x),
14585            BaseTagError::Other => RemoveTagError::Other,
14586        }
14587    }
14588}
14589#[derive(Debug, Clone, PartialEq, Eq)]
14590#[non_exhaustive] // structs may have more fields added in the future.
14591pub struct RestoreArg {
14592    /// The path to save the restored file.
14593    pub path: WritePath,
14594    /// The revision to restore.
14595    pub rev: Rev,
14596}
14597
14598impl RestoreArg {
14599    pub fn new(path: WritePath, rev: Rev) -> Self {
14600        RestoreArg {
14601            path,
14602            rev,
14603        }
14604    }
14605}
14606
14607const RESTORE_ARG_FIELDS: &[&str] = &["path",
14608                                      "rev"];
14609impl RestoreArg {
14610    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14611        map: V,
14612    ) -> Result<RestoreArg, V::Error> {
14613        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14614    }
14615
14616    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14617        mut map: V,
14618        optional: bool,
14619    ) -> Result<Option<RestoreArg>, V::Error> {
14620        let mut field_path = None;
14621        let mut field_rev = None;
14622        let mut nothing = true;
14623        while let Some(key) = map.next_key::<&str>()? {
14624            nothing = false;
14625            match key {
14626                "path" => {
14627                    if field_path.is_some() {
14628                        return Err(::serde::de::Error::duplicate_field("path"));
14629                    }
14630                    field_path = Some(map.next_value()?);
14631                }
14632                "rev" => {
14633                    if field_rev.is_some() {
14634                        return Err(::serde::de::Error::duplicate_field("rev"));
14635                    }
14636                    field_rev = Some(map.next_value()?);
14637                }
14638                _ => {
14639                    // unknown field allowed and ignored
14640                    map.next_value::<::serde_json::Value>()?;
14641                }
14642            }
14643        }
14644        if optional && nothing {
14645            return Ok(None);
14646        }
14647        let result = RestoreArg {
14648            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
14649            rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
14650        };
14651        Ok(Some(result))
14652    }
14653
14654    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14655        &self,
14656        s: &mut S::SerializeStruct,
14657    ) -> Result<(), S::Error> {
14658        use serde::ser::SerializeStruct;
14659        s.serialize_field("path", &self.path)?;
14660        s.serialize_field("rev", &self.rev)?;
14661        Ok(())
14662    }
14663}
14664
14665impl<'de> ::serde::de::Deserialize<'de> for RestoreArg {
14666    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14667        // struct deserializer
14668        use serde::de::{MapAccess, Visitor};
14669        struct StructVisitor;
14670        impl<'de> Visitor<'de> for StructVisitor {
14671            type Value = RestoreArg;
14672            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14673                f.write_str("a RestoreArg struct")
14674            }
14675            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14676                RestoreArg::internal_deserialize(map)
14677            }
14678        }
14679        deserializer.deserialize_struct("RestoreArg", RESTORE_ARG_FIELDS, StructVisitor)
14680    }
14681}
14682
14683impl ::serde::ser::Serialize for RestoreArg {
14684    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14685        // struct serializer
14686        use serde::ser::SerializeStruct;
14687        let mut s = serializer.serialize_struct("RestoreArg", 2)?;
14688        self.internal_serialize::<S>(&mut s)?;
14689        s.end()
14690    }
14691}
14692
14693#[derive(Debug, Clone, PartialEq, Eq)]
14694#[non_exhaustive] // variants may be added in the future
14695pub enum RestoreError {
14696    /// An error occurs when downloading metadata for the file.
14697    PathLookup(LookupError),
14698    /// An error occurs when trying to restore the file to that path.
14699    PathWrite(WriteError),
14700    /// The revision is invalid. It may not exist or may point to a deleted file.
14701    InvalidRevision,
14702    /// The restore is currently executing, but has not yet completed.
14703    InProgress,
14704    /// Catch-all used for unrecognized values returned from the server. Encountering this value
14705    /// typically indicates that this SDK version is out of date.
14706    Other,
14707}
14708
14709impl<'de> ::serde::de::Deserialize<'de> for RestoreError {
14710    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14711        // union deserializer
14712        use serde::de::{self, MapAccess, Visitor};
14713        struct EnumVisitor;
14714        impl<'de> Visitor<'de> for EnumVisitor {
14715            type Value = RestoreError;
14716            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14717                f.write_str("a RestoreError structure")
14718            }
14719            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
14720                let tag: &str = match map.next_key()? {
14721                    Some(".tag") => map.next_value()?,
14722                    _ => return Err(de::Error::missing_field(".tag"))
14723                };
14724                let value = match tag {
14725                    "path_lookup" => {
14726                        match map.next_key()? {
14727                            Some("path_lookup") => RestoreError::PathLookup(map.next_value()?),
14728                            None => return Err(de::Error::missing_field("path_lookup")),
14729                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14730                        }
14731                    }
14732                    "path_write" => {
14733                        match map.next_key()? {
14734                            Some("path_write") => RestoreError::PathWrite(map.next_value()?),
14735                            None => return Err(de::Error::missing_field("path_write")),
14736                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14737                        }
14738                    }
14739                    "invalid_revision" => RestoreError::InvalidRevision,
14740                    "in_progress" => RestoreError::InProgress,
14741                    _ => RestoreError::Other,
14742                };
14743                crate::eat_json_fields(&mut map)?;
14744                Ok(value)
14745            }
14746        }
14747        const VARIANTS: &[&str] = &["path_lookup",
14748                                    "path_write",
14749                                    "invalid_revision",
14750                                    "in_progress",
14751                                    "other"];
14752        deserializer.deserialize_struct("RestoreError", VARIANTS, EnumVisitor)
14753    }
14754}
14755
14756impl ::serde::ser::Serialize for RestoreError {
14757    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14758        // union serializer
14759        use serde::ser::SerializeStruct;
14760        match self {
14761            RestoreError::PathLookup(x) => {
14762                // union or polymporphic struct
14763                let mut s = serializer.serialize_struct("RestoreError", 2)?;
14764                s.serialize_field(".tag", "path_lookup")?;
14765                s.serialize_field("path_lookup", x)?;
14766                s.end()
14767            }
14768            RestoreError::PathWrite(x) => {
14769                // union or polymporphic struct
14770                let mut s = serializer.serialize_struct("RestoreError", 2)?;
14771                s.serialize_field(".tag", "path_write")?;
14772                s.serialize_field("path_write", x)?;
14773                s.end()
14774            }
14775            RestoreError::InvalidRevision => {
14776                // unit
14777                let mut s = serializer.serialize_struct("RestoreError", 1)?;
14778                s.serialize_field(".tag", "invalid_revision")?;
14779                s.end()
14780            }
14781            RestoreError::InProgress => {
14782                // unit
14783                let mut s = serializer.serialize_struct("RestoreError", 1)?;
14784                s.serialize_field(".tag", "in_progress")?;
14785                s.end()
14786            }
14787            RestoreError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
14788        }
14789    }
14790}
14791
14792impl ::std::error::Error for RestoreError {
14793    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
14794        match self {
14795            RestoreError::PathLookup(inner) => Some(inner),
14796            RestoreError::PathWrite(inner) => Some(inner),
14797            _ => None,
14798        }
14799    }
14800}
14801
14802impl ::std::fmt::Display for RestoreError {
14803    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14804        match self {
14805            RestoreError::PathLookup(inner) => write!(f, "An error occurs when downloading metadata for the file: {}", inner),
14806            RestoreError::PathWrite(inner) => write!(f, "An error occurs when trying to restore the file to that path: {}", inner),
14807            RestoreError::InvalidRevision => f.write_str("The revision is invalid. It may not exist or may point to a deleted file."),
14808            RestoreError::InProgress => f.write_str("The restore is currently executing, but has not yet completed."),
14809            _ => write!(f, "{:?}", *self),
14810        }
14811    }
14812}
14813
14814#[derive(Debug, Clone, PartialEq, Eq)]
14815#[non_exhaustive] // structs may have more fields added in the future.
14816pub struct SaveCopyReferenceArg {
14817    /// A copy reference returned by [`copy_reference_get()`](crate::files::copy_reference_get).
14818    pub copy_reference: String,
14819    /// Path in the user's Dropbox that is the destination.
14820    pub path: Path,
14821}
14822
14823impl SaveCopyReferenceArg {
14824    pub fn new(copy_reference: String, path: Path) -> Self {
14825        SaveCopyReferenceArg {
14826            copy_reference,
14827            path,
14828        }
14829    }
14830}
14831
14832const SAVE_COPY_REFERENCE_ARG_FIELDS: &[&str] = &["copy_reference",
14833                                                  "path"];
14834impl SaveCopyReferenceArg {
14835    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14836        map: V,
14837    ) -> Result<SaveCopyReferenceArg, V::Error> {
14838        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14839    }
14840
14841    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14842        mut map: V,
14843        optional: bool,
14844    ) -> Result<Option<SaveCopyReferenceArg>, V::Error> {
14845        let mut field_copy_reference = None;
14846        let mut field_path = None;
14847        let mut nothing = true;
14848        while let Some(key) = map.next_key::<&str>()? {
14849            nothing = false;
14850            match key {
14851                "copy_reference" => {
14852                    if field_copy_reference.is_some() {
14853                        return Err(::serde::de::Error::duplicate_field("copy_reference"));
14854                    }
14855                    field_copy_reference = Some(map.next_value()?);
14856                }
14857                "path" => {
14858                    if field_path.is_some() {
14859                        return Err(::serde::de::Error::duplicate_field("path"));
14860                    }
14861                    field_path = Some(map.next_value()?);
14862                }
14863                _ => {
14864                    // unknown field allowed and ignored
14865                    map.next_value::<::serde_json::Value>()?;
14866                }
14867            }
14868        }
14869        if optional && nothing {
14870            return Ok(None);
14871        }
14872        let result = SaveCopyReferenceArg {
14873            copy_reference: field_copy_reference.ok_or_else(|| ::serde::de::Error::missing_field("copy_reference"))?,
14874            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
14875        };
14876        Ok(Some(result))
14877    }
14878
14879    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14880        &self,
14881        s: &mut S::SerializeStruct,
14882    ) -> Result<(), S::Error> {
14883        use serde::ser::SerializeStruct;
14884        s.serialize_field("copy_reference", &self.copy_reference)?;
14885        s.serialize_field("path", &self.path)?;
14886        Ok(())
14887    }
14888}
14889
14890impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceArg {
14891    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14892        // struct deserializer
14893        use serde::de::{MapAccess, Visitor};
14894        struct StructVisitor;
14895        impl<'de> Visitor<'de> for StructVisitor {
14896            type Value = SaveCopyReferenceArg;
14897            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14898                f.write_str("a SaveCopyReferenceArg struct")
14899            }
14900            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14901                SaveCopyReferenceArg::internal_deserialize(map)
14902            }
14903        }
14904        deserializer.deserialize_struct("SaveCopyReferenceArg", SAVE_COPY_REFERENCE_ARG_FIELDS, StructVisitor)
14905    }
14906}
14907
14908impl ::serde::ser::Serialize for SaveCopyReferenceArg {
14909    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14910        // struct serializer
14911        use serde::ser::SerializeStruct;
14912        let mut s = serializer.serialize_struct("SaveCopyReferenceArg", 2)?;
14913        self.internal_serialize::<S>(&mut s)?;
14914        s.end()
14915    }
14916}
14917
14918#[derive(Debug, Clone, PartialEq, Eq)]
14919#[non_exhaustive] // variants may be added in the future
14920pub enum SaveCopyReferenceError {
14921    Path(WriteError),
14922    /// The copy reference is invalid.
14923    InvalidCopyReference,
14924    /// You don't have permission to save the given copy reference. Please make sure this app is
14925    /// same app which created the copy reference and the source user is still linked to the app.
14926    NoPermission,
14927    /// The file referenced by the copy reference cannot be found.
14928    NotFound,
14929    /// The operation would involve more than 10,000 files and folders.
14930    TooManyFiles,
14931    /// Catch-all used for unrecognized values returned from the server. Encountering this value
14932    /// typically indicates that this SDK version is out of date.
14933    Other,
14934}
14935
14936impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceError {
14937    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14938        // union deserializer
14939        use serde::de::{self, MapAccess, Visitor};
14940        struct EnumVisitor;
14941        impl<'de> Visitor<'de> for EnumVisitor {
14942            type Value = SaveCopyReferenceError;
14943            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14944                f.write_str("a SaveCopyReferenceError structure")
14945            }
14946            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
14947                let tag: &str = match map.next_key()? {
14948                    Some(".tag") => map.next_value()?,
14949                    _ => return Err(de::Error::missing_field(".tag"))
14950                };
14951                let value = match tag {
14952                    "path" => {
14953                        match map.next_key()? {
14954                            Some("path") => SaveCopyReferenceError::Path(map.next_value()?),
14955                            None => return Err(de::Error::missing_field("path")),
14956                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14957                        }
14958                    }
14959                    "invalid_copy_reference" => SaveCopyReferenceError::InvalidCopyReference,
14960                    "no_permission" => SaveCopyReferenceError::NoPermission,
14961                    "not_found" => SaveCopyReferenceError::NotFound,
14962                    "too_many_files" => SaveCopyReferenceError::TooManyFiles,
14963                    _ => SaveCopyReferenceError::Other,
14964                };
14965                crate::eat_json_fields(&mut map)?;
14966                Ok(value)
14967            }
14968        }
14969        const VARIANTS: &[&str] = &["path",
14970                                    "invalid_copy_reference",
14971                                    "no_permission",
14972                                    "not_found",
14973                                    "too_many_files",
14974                                    "other"];
14975        deserializer.deserialize_struct("SaveCopyReferenceError", VARIANTS, EnumVisitor)
14976    }
14977}
14978
14979impl ::serde::ser::Serialize for SaveCopyReferenceError {
14980    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14981        // union serializer
14982        use serde::ser::SerializeStruct;
14983        match self {
14984            SaveCopyReferenceError::Path(x) => {
14985                // union or polymporphic struct
14986                let mut s = serializer.serialize_struct("SaveCopyReferenceError", 2)?;
14987                s.serialize_field(".tag", "path")?;
14988                s.serialize_field("path", x)?;
14989                s.end()
14990            }
14991            SaveCopyReferenceError::InvalidCopyReference => {
14992                // unit
14993                let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
14994                s.serialize_field(".tag", "invalid_copy_reference")?;
14995                s.end()
14996            }
14997            SaveCopyReferenceError::NoPermission => {
14998                // unit
14999                let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15000                s.serialize_field(".tag", "no_permission")?;
15001                s.end()
15002            }
15003            SaveCopyReferenceError::NotFound => {
15004                // unit
15005                let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15006                s.serialize_field(".tag", "not_found")?;
15007                s.end()
15008            }
15009            SaveCopyReferenceError::TooManyFiles => {
15010                // unit
15011                let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15012                s.serialize_field(".tag", "too_many_files")?;
15013                s.end()
15014            }
15015            SaveCopyReferenceError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
15016        }
15017    }
15018}
15019
15020impl ::std::error::Error for SaveCopyReferenceError {
15021    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
15022        match self {
15023            SaveCopyReferenceError::Path(inner) => Some(inner),
15024            _ => None,
15025        }
15026    }
15027}
15028
15029impl ::std::fmt::Display for SaveCopyReferenceError {
15030    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15031        match self {
15032            SaveCopyReferenceError::Path(inner) => write!(f, "SaveCopyReferenceError: {}", inner),
15033            SaveCopyReferenceError::InvalidCopyReference => f.write_str("The copy reference is invalid."),
15034            SaveCopyReferenceError::NoPermission => f.write_str("You don't have permission to save the given copy reference. Please make sure this app is same app which created the copy reference and the source user is still linked to the app."),
15035            SaveCopyReferenceError::NotFound => f.write_str("The file referenced by the copy reference cannot be found."),
15036            SaveCopyReferenceError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
15037            _ => write!(f, "{:?}", *self),
15038        }
15039    }
15040}
15041
15042#[derive(Debug, Clone, PartialEq)]
15043#[non_exhaustive] // structs may have more fields added in the future.
15044pub struct SaveCopyReferenceResult {
15045    /// The metadata of the saved file or folder in the user's Dropbox.
15046    pub metadata: Metadata,
15047}
15048
15049impl SaveCopyReferenceResult {
15050    pub fn new(metadata: Metadata) -> Self {
15051        SaveCopyReferenceResult {
15052            metadata,
15053        }
15054    }
15055}
15056
15057const SAVE_COPY_REFERENCE_RESULT_FIELDS: &[&str] = &["metadata"];
15058impl SaveCopyReferenceResult {
15059    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15060        map: V,
15061    ) -> Result<SaveCopyReferenceResult, V::Error> {
15062        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15063    }
15064
15065    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15066        mut map: V,
15067        optional: bool,
15068    ) -> Result<Option<SaveCopyReferenceResult>, V::Error> {
15069        let mut field_metadata = None;
15070        let mut nothing = true;
15071        while let Some(key) = map.next_key::<&str>()? {
15072            nothing = false;
15073            match key {
15074                "metadata" => {
15075                    if field_metadata.is_some() {
15076                        return Err(::serde::de::Error::duplicate_field("metadata"));
15077                    }
15078                    field_metadata = Some(map.next_value()?);
15079                }
15080                _ => {
15081                    // unknown field allowed and ignored
15082                    map.next_value::<::serde_json::Value>()?;
15083                }
15084            }
15085        }
15086        if optional && nothing {
15087            return Ok(None);
15088        }
15089        let result = SaveCopyReferenceResult {
15090            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
15091        };
15092        Ok(Some(result))
15093    }
15094
15095    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15096        &self,
15097        s: &mut S::SerializeStruct,
15098    ) -> Result<(), S::Error> {
15099        use serde::ser::SerializeStruct;
15100        s.serialize_field("metadata", &self.metadata)?;
15101        Ok(())
15102    }
15103}
15104
15105impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceResult {
15106    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15107        // struct deserializer
15108        use serde::de::{MapAccess, Visitor};
15109        struct StructVisitor;
15110        impl<'de> Visitor<'de> for StructVisitor {
15111            type Value = SaveCopyReferenceResult;
15112            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15113                f.write_str("a SaveCopyReferenceResult struct")
15114            }
15115            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15116                SaveCopyReferenceResult::internal_deserialize(map)
15117            }
15118        }
15119        deserializer.deserialize_struct("SaveCopyReferenceResult", SAVE_COPY_REFERENCE_RESULT_FIELDS, StructVisitor)
15120    }
15121}
15122
15123impl ::serde::ser::Serialize for SaveCopyReferenceResult {
15124    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15125        // struct serializer
15126        use serde::ser::SerializeStruct;
15127        let mut s = serializer.serialize_struct("SaveCopyReferenceResult", 1)?;
15128        self.internal_serialize::<S>(&mut s)?;
15129        s.end()
15130    }
15131}
15132
15133#[derive(Debug, Clone, PartialEq, Eq)]
15134#[non_exhaustive] // structs may have more fields added in the future.
15135pub struct SaveUrlArg {
15136    /// The path in Dropbox where the URL will be saved to.
15137    pub path: Path,
15138    /// The URL to be saved.
15139    pub url: String,
15140}
15141
15142impl SaveUrlArg {
15143    pub fn new(path: Path, url: String) -> Self {
15144        SaveUrlArg {
15145            path,
15146            url,
15147        }
15148    }
15149}
15150
15151const SAVE_URL_ARG_FIELDS: &[&str] = &["path",
15152                                       "url"];
15153impl SaveUrlArg {
15154    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15155        map: V,
15156    ) -> Result<SaveUrlArg, V::Error> {
15157        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15158    }
15159
15160    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15161        mut map: V,
15162        optional: bool,
15163    ) -> Result<Option<SaveUrlArg>, V::Error> {
15164        let mut field_path = None;
15165        let mut field_url = None;
15166        let mut nothing = true;
15167        while let Some(key) = map.next_key::<&str>()? {
15168            nothing = false;
15169            match key {
15170                "path" => {
15171                    if field_path.is_some() {
15172                        return Err(::serde::de::Error::duplicate_field("path"));
15173                    }
15174                    field_path = Some(map.next_value()?);
15175                }
15176                "url" => {
15177                    if field_url.is_some() {
15178                        return Err(::serde::de::Error::duplicate_field("url"));
15179                    }
15180                    field_url = Some(map.next_value()?);
15181                }
15182                _ => {
15183                    // unknown field allowed and ignored
15184                    map.next_value::<::serde_json::Value>()?;
15185                }
15186            }
15187        }
15188        if optional && nothing {
15189            return Ok(None);
15190        }
15191        let result = SaveUrlArg {
15192            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
15193            url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
15194        };
15195        Ok(Some(result))
15196    }
15197
15198    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15199        &self,
15200        s: &mut S::SerializeStruct,
15201    ) -> Result<(), S::Error> {
15202        use serde::ser::SerializeStruct;
15203        s.serialize_field("path", &self.path)?;
15204        s.serialize_field("url", &self.url)?;
15205        Ok(())
15206    }
15207}
15208
15209impl<'de> ::serde::de::Deserialize<'de> for SaveUrlArg {
15210    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15211        // struct deserializer
15212        use serde::de::{MapAccess, Visitor};
15213        struct StructVisitor;
15214        impl<'de> Visitor<'de> for StructVisitor {
15215            type Value = SaveUrlArg;
15216            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15217                f.write_str("a SaveUrlArg struct")
15218            }
15219            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15220                SaveUrlArg::internal_deserialize(map)
15221            }
15222        }
15223        deserializer.deserialize_struct("SaveUrlArg", SAVE_URL_ARG_FIELDS, StructVisitor)
15224    }
15225}
15226
15227impl ::serde::ser::Serialize for SaveUrlArg {
15228    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15229        // struct serializer
15230        use serde::ser::SerializeStruct;
15231        let mut s = serializer.serialize_struct("SaveUrlArg", 2)?;
15232        self.internal_serialize::<S>(&mut s)?;
15233        s.end()
15234    }
15235}
15236
15237#[derive(Debug, Clone, PartialEq, Eq)]
15238#[non_exhaustive] // variants may be added in the future
15239pub enum SaveUrlError {
15240    Path(WriteError),
15241    /// Failed downloading the given URL. The URL may be  password-protected and the password
15242    /// provided was incorrect,  or the link may be disabled.
15243    DownloadFailed,
15244    /// The given URL is invalid.
15245    InvalidUrl,
15246    /// The file where the URL is saved to no longer exists.
15247    NotFound,
15248    /// Catch-all used for unrecognized values returned from the server. Encountering this value
15249    /// typically indicates that this SDK version is out of date.
15250    Other,
15251}
15252
15253impl<'de> ::serde::de::Deserialize<'de> for SaveUrlError {
15254    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15255        // union deserializer
15256        use serde::de::{self, MapAccess, Visitor};
15257        struct EnumVisitor;
15258        impl<'de> Visitor<'de> for EnumVisitor {
15259            type Value = SaveUrlError;
15260            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15261                f.write_str("a SaveUrlError structure")
15262            }
15263            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15264                let tag: &str = match map.next_key()? {
15265                    Some(".tag") => map.next_value()?,
15266                    _ => return Err(de::Error::missing_field(".tag"))
15267                };
15268                let value = match tag {
15269                    "path" => {
15270                        match map.next_key()? {
15271                            Some("path") => SaveUrlError::Path(map.next_value()?),
15272                            None => return Err(de::Error::missing_field("path")),
15273                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15274                        }
15275                    }
15276                    "download_failed" => SaveUrlError::DownloadFailed,
15277                    "invalid_url" => SaveUrlError::InvalidUrl,
15278                    "not_found" => SaveUrlError::NotFound,
15279                    _ => SaveUrlError::Other,
15280                };
15281                crate::eat_json_fields(&mut map)?;
15282                Ok(value)
15283            }
15284        }
15285        const VARIANTS: &[&str] = &["path",
15286                                    "download_failed",
15287                                    "invalid_url",
15288                                    "not_found",
15289                                    "other"];
15290        deserializer.deserialize_struct("SaveUrlError", VARIANTS, EnumVisitor)
15291    }
15292}
15293
15294impl ::serde::ser::Serialize for SaveUrlError {
15295    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15296        // union serializer
15297        use serde::ser::SerializeStruct;
15298        match self {
15299            SaveUrlError::Path(x) => {
15300                // union or polymporphic struct
15301                let mut s = serializer.serialize_struct("SaveUrlError", 2)?;
15302                s.serialize_field(".tag", "path")?;
15303                s.serialize_field("path", x)?;
15304                s.end()
15305            }
15306            SaveUrlError::DownloadFailed => {
15307                // unit
15308                let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
15309                s.serialize_field(".tag", "download_failed")?;
15310                s.end()
15311            }
15312            SaveUrlError::InvalidUrl => {
15313                // unit
15314                let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
15315                s.serialize_field(".tag", "invalid_url")?;
15316                s.end()
15317            }
15318            SaveUrlError::NotFound => {
15319                // unit
15320                let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
15321                s.serialize_field(".tag", "not_found")?;
15322                s.end()
15323            }
15324            SaveUrlError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
15325        }
15326    }
15327}
15328
15329impl ::std::error::Error for SaveUrlError {
15330    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
15331        match self {
15332            SaveUrlError::Path(inner) => Some(inner),
15333            _ => None,
15334        }
15335    }
15336}
15337
15338impl ::std::fmt::Display for SaveUrlError {
15339    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15340        match self {
15341            SaveUrlError::Path(inner) => write!(f, "SaveUrlError: {}", inner),
15342            SaveUrlError::DownloadFailed => f.write_str("Failed downloading the given URL. The URL may be  password-protected and the password provided was incorrect,  or the link may be disabled."),
15343            SaveUrlError::InvalidUrl => f.write_str("The given URL is invalid."),
15344            SaveUrlError::NotFound => f.write_str("The file where the URL is saved to no longer exists."),
15345            _ => write!(f, "{:?}", *self),
15346        }
15347    }
15348}
15349
15350#[derive(Debug, Clone, PartialEq)]
15351pub enum SaveUrlJobStatus {
15352    /// The asynchronous job is still in progress.
15353    InProgress,
15354    /// Metadata of the file where the URL is saved to.
15355    Complete(FileMetadata),
15356    Failed(SaveUrlError),
15357}
15358
15359impl<'de> ::serde::de::Deserialize<'de> for SaveUrlJobStatus {
15360    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15361        // union deserializer
15362        use serde::de::{self, MapAccess, Visitor};
15363        struct EnumVisitor;
15364        impl<'de> Visitor<'de> for EnumVisitor {
15365            type Value = SaveUrlJobStatus;
15366            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15367                f.write_str("a SaveUrlJobStatus structure")
15368            }
15369            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15370                let tag: &str = match map.next_key()? {
15371                    Some(".tag") => map.next_value()?,
15372                    _ => return Err(de::Error::missing_field(".tag"))
15373                };
15374                let value = match tag {
15375                    "in_progress" => SaveUrlJobStatus::InProgress,
15376                    "complete" => SaveUrlJobStatus::Complete(FileMetadata::internal_deserialize(&mut map)?),
15377                    "failed" => {
15378                        match map.next_key()? {
15379                            Some("failed") => SaveUrlJobStatus::Failed(map.next_value()?),
15380                            None => return Err(de::Error::missing_field("failed")),
15381                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15382                        }
15383                    }
15384                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
15385                };
15386                crate::eat_json_fields(&mut map)?;
15387                Ok(value)
15388            }
15389        }
15390        const VARIANTS: &[&str] = &["in_progress",
15391                                    "complete",
15392                                    "failed"];
15393        deserializer.deserialize_struct("SaveUrlJobStatus", VARIANTS, EnumVisitor)
15394    }
15395}
15396
15397impl ::serde::ser::Serialize for SaveUrlJobStatus {
15398    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15399        // union serializer
15400        use serde::ser::SerializeStruct;
15401        match self {
15402            SaveUrlJobStatus::InProgress => {
15403                // unit
15404                let mut s = serializer.serialize_struct("SaveUrlJobStatus", 1)?;
15405                s.serialize_field(".tag", "in_progress")?;
15406                s.end()
15407            }
15408            SaveUrlJobStatus::Complete(x) => {
15409                // struct
15410                let mut s = serializer.serialize_struct("SaveUrlJobStatus", 20)?;
15411                s.serialize_field(".tag", "complete")?;
15412                x.internal_serialize::<S>(&mut s)?;
15413                s.end()
15414            }
15415            SaveUrlJobStatus::Failed(x) => {
15416                // union or polymporphic struct
15417                let mut s = serializer.serialize_struct("SaveUrlJobStatus", 2)?;
15418                s.serialize_field(".tag", "failed")?;
15419                s.serialize_field("failed", x)?;
15420                s.end()
15421            }
15422        }
15423    }
15424}
15425
15426// union extends crate::types::dbx_async::PollResultBase
15427impl From<crate::types::dbx_async::PollResultBase> for SaveUrlJobStatus {
15428    fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
15429        match parent {
15430            crate::types::dbx_async::PollResultBase::InProgress => SaveUrlJobStatus::InProgress,
15431        }
15432    }
15433}
15434#[derive(Debug, Clone, PartialEq)]
15435pub enum SaveUrlResult {
15436    /// This response indicates that the processing is asynchronous. The string is an id that can be
15437    /// used to obtain the status of the asynchronous job.
15438    AsyncJobId(crate::types::dbx_async::AsyncJobId),
15439    /// Metadata of the file where the URL is saved to.
15440    Complete(FileMetadata),
15441}
15442
15443impl<'de> ::serde::de::Deserialize<'de> for SaveUrlResult {
15444    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15445        // union deserializer
15446        use serde::de::{self, MapAccess, Visitor};
15447        struct EnumVisitor;
15448        impl<'de> Visitor<'de> for EnumVisitor {
15449            type Value = SaveUrlResult;
15450            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15451                f.write_str("a SaveUrlResult structure")
15452            }
15453            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15454                let tag: &str = match map.next_key()? {
15455                    Some(".tag") => map.next_value()?,
15456                    _ => return Err(de::Error::missing_field(".tag"))
15457                };
15458                let value = match tag {
15459                    "async_job_id" => {
15460                        match map.next_key()? {
15461                            Some("async_job_id") => SaveUrlResult::AsyncJobId(map.next_value()?),
15462                            None => return Err(de::Error::missing_field("async_job_id")),
15463                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15464                        }
15465                    }
15466                    "complete" => SaveUrlResult::Complete(FileMetadata::internal_deserialize(&mut map)?),
15467                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
15468                };
15469                crate::eat_json_fields(&mut map)?;
15470                Ok(value)
15471            }
15472        }
15473        const VARIANTS: &[&str] = &["async_job_id",
15474                                    "complete"];
15475        deserializer.deserialize_struct("SaveUrlResult", VARIANTS, EnumVisitor)
15476    }
15477}
15478
15479impl ::serde::ser::Serialize for SaveUrlResult {
15480    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15481        // union serializer
15482        use serde::ser::SerializeStruct;
15483        match self {
15484            SaveUrlResult::AsyncJobId(x) => {
15485                // primitive
15486                let mut s = serializer.serialize_struct("SaveUrlResult", 2)?;
15487                s.serialize_field(".tag", "async_job_id")?;
15488                s.serialize_field("async_job_id", x)?;
15489                s.end()
15490            }
15491            SaveUrlResult::Complete(x) => {
15492                // struct
15493                let mut s = serializer.serialize_struct("SaveUrlResult", 20)?;
15494                s.serialize_field(".tag", "complete")?;
15495                x.internal_serialize::<S>(&mut s)?;
15496                s.end()
15497            }
15498        }
15499    }
15500}
15501
15502// union extends crate::types::dbx_async::LaunchResultBase
15503impl From<crate::types::dbx_async::LaunchResultBase> for SaveUrlResult {
15504    fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
15505        match parent {
15506            crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => SaveUrlResult::AsyncJobId(x),
15507        }
15508    }
15509}
15510#[derive(Debug, Clone, PartialEq, Eq)]
15511#[non_exhaustive] // structs may have more fields added in the future.
15512pub struct SearchArg {
15513    /// The path in the user's Dropbox to search. Should probably be a folder.
15514    pub path: PathROrId,
15515    /// The string to search for. Query string may be rewritten to improve relevance of results. The
15516    /// string is split on spaces into multiple tokens. For file name searching, the last token is
15517    /// used for prefix matching (i.e. "bat c" matches "bat cave" but not "batman car").
15518    pub query: String,
15519    /// The starting index within the search results (used for paging).
15520    pub start: u64,
15521    /// The maximum number of search results to return.
15522    pub max_results: u64,
15523    /// The search mode (filename, filename_and_content, or deleted_filename). Note that searching
15524    /// file content is only available for Dropbox Business accounts.
15525    pub mode: SearchMode,
15526}
15527
15528impl SearchArg {
15529    pub fn new(path: PathROrId, query: String) -> Self {
15530        SearchArg {
15531            path,
15532            query,
15533            start: 0,
15534            max_results: 100,
15535            mode: SearchMode::Filename,
15536        }
15537    }
15538
15539    pub fn with_start(mut self, value: u64) -> Self {
15540        self.start = value;
15541        self
15542    }
15543
15544    pub fn with_max_results(mut self, value: u64) -> Self {
15545        self.max_results = value;
15546        self
15547    }
15548
15549    pub fn with_mode(mut self, value: SearchMode) -> Self {
15550        self.mode = value;
15551        self
15552    }
15553}
15554
15555const SEARCH_ARG_FIELDS: &[&str] = &["path",
15556                                     "query",
15557                                     "start",
15558                                     "max_results",
15559                                     "mode"];
15560impl SearchArg {
15561    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15562        map: V,
15563    ) -> Result<SearchArg, V::Error> {
15564        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15565    }
15566
15567    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15568        mut map: V,
15569        optional: bool,
15570    ) -> Result<Option<SearchArg>, V::Error> {
15571        let mut field_path = None;
15572        let mut field_query = None;
15573        let mut field_start = None;
15574        let mut field_max_results = None;
15575        let mut field_mode = None;
15576        let mut nothing = true;
15577        while let Some(key) = map.next_key::<&str>()? {
15578            nothing = false;
15579            match key {
15580                "path" => {
15581                    if field_path.is_some() {
15582                        return Err(::serde::de::Error::duplicate_field("path"));
15583                    }
15584                    field_path = Some(map.next_value()?);
15585                }
15586                "query" => {
15587                    if field_query.is_some() {
15588                        return Err(::serde::de::Error::duplicate_field("query"));
15589                    }
15590                    field_query = Some(map.next_value()?);
15591                }
15592                "start" => {
15593                    if field_start.is_some() {
15594                        return Err(::serde::de::Error::duplicate_field("start"));
15595                    }
15596                    field_start = Some(map.next_value()?);
15597                }
15598                "max_results" => {
15599                    if field_max_results.is_some() {
15600                        return Err(::serde::de::Error::duplicate_field("max_results"));
15601                    }
15602                    field_max_results = Some(map.next_value()?);
15603                }
15604                "mode" => {
15605                    if field_mode.is_some() {
15606                        return Err(::serde::de::Error::duplicate_field("mode"));
15607                    }
15608                    field_mode = Some(map.next_value()?);
15609                }
15610                _ => {
15611                    // unknown field allowed and ignored
15612                    map.next_value::<::serde_json::Value>()?;
15613                }
15614            }
15615        }
15616        if optional && nothing {
15617            return Ok(None);
15618        }
15619        let result = SearchArg {
15620            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
15621            query: field_query.ok_or_else(|| ::serde::de::Error::missing_field("query"))?,
15622            start: field_start.unwrap_or(0),
15623            max_results: field_max_results.unwrap_or(100),
15624            mode: field_mode.unwrap_or(SearchMode::Filename),
15625        };
15626        Ok(Some(result))
15627    }
15628
15629    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15630        &self,
15631        s: &mut S::SerializeStruct,
15632    ) -> Result<(), S::Error> {
15633        use serde::ser::SerializeStruct;
15634        s.serialize_field("path", &self.path)?;
15635        s.serialize_field("query", &self.query)?;
15636        if self.start != 0 {
15637            s.serialize_field("start", &self.start)?;
15638        }
15639        if self.max_results != 100 {
15640            s.serialize_field("max_results", &self.max_results)?;
15641        }
15642        if self.mode != SearchMode::Filename {
15643            s.serialize_field("mode", &self.mode)?;
15644        }
15645        Ok(())
15646    }
15647}
15648
15649impl<'de> ::serde::de::Deserialize<'de> for SearchArg {
15650    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15651        // struct deserializer
15652        use serde::de::{MapAccess, Visitor};
15653        struct StructVisitor;
15654        impl<'de> Visitor<'de> for StructVisitor {
15655            type Value = SearchArg;
15656            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15657                f.write_str("a SearchArg struct")
15658            }
15659            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15660                SearchArg::internal_deserialize(map)
15661            }
15662        }
15663        deserializer.deserialize_struct("SearchArg", SEARCH_ARG_FIELDS, StructVisitor)
15664    }
15665}
15666
15667impl ::serde::ser::Serialize for SearchArg {
15668    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15669        // struct serializer
15670        use serde::ser::SerializeStruct;
15671        let mut s = serializer.serialize_struct("SearchArg", 5)?;
15672        self.internal_serialize::<S>(&mut s)?;
15673        s.end()
15674    }
15675}
15676
15677#[derive(Debug, Clone, PartialEq, Eq)]
15678#[non_exhaustive] // variants may be added in the future
15679pub enum SearchError {
15680    Path(LookupError),
15681    InvalidArgument(Option<String>),
15682    /// Something went wrong, please try again.
15683    InternalError,
15684    /// Catch-all used for unrecognized values returned from the server. Encountering this value
15685    /// typically indicates that this SDK version is out of date.
15686    Other,
15687}
15688
15689impl<'de> ::serde::de::Deserialize<'de> for SearchError {
15690    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15691        // union deserializer
15692        use serde::de::{self, MapAccess, Visitor};
15693        struct EnumVisitor;
15694        impl<'de> Visitor<'de> for EnumVisitor {
15695            type Value = SearchError;
15696            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15697                f.write_str("a SearchError structure")
15698            }
15699            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15700                let tag: &str = match map.next_key()? {
15701                    Some(".tag") => map.next_value()?,
15702                    _ => return Err(de::Error::missing_field(".tag"))
15703                };
15704                let value = match tag {
15705                    "path" => {
15706                        match map.next_key()? {
15707                            Some("path") => SearchError::Path(map.next_value()?),
15708                            None => return Err(de::Error::missing_field("path")),
15709                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15710                        }
15711                    }
15712                    "invalid_argument" => {
15713                        match map.next_key()? {
15714                            Some("invalid_argument") => SearchError::InvalidArgument(map.next_value()?),
15715                            None => SearchError::InvalidArgument(None),
15716                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15717                        }
15718                    }
15719                    "internal_error" => SearchError::InternalError,
15720                    _ => SearchError::Other,
15721                };
15722                crate::eat_json_fields(&mut map)?;
15723                Ok(value)
15724            }
15725        }
15726        const VARIANTS: &[&str] = &["path",
15727                                    "invalid_argument",
15728                                    "internal_error",
15729                                    "other"];
15730        deserializer.deserialize_struct("SearchError", VARIANTS, EnumVisitor)
15731    }
15732}
15733
15734impl ::serde::ser::Serialize for SearchError {
15735    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15736        // union serializer
15737        use serde::ser::SerializeStruct;
15738        match self {
15739            SearchError::Path(x) => {
15740                // union or polymporphic struct
15741                let mut s = serializer.serialize_struct("SearchError", 2)?;
15742                s.serialize_field(".tag", "path")?;
15743                s.serialize_field("path", x)?;
15744                s.end()
15745            }
15746            SearchError::InvalidArgument(x) => {
15747                // nullable (struct or primitive)
15748                let n = if x.is_some() { 2 } else { 1 };
15749                let mut s = serializer.serialize_struct("SearchError", n)?;
15750                s.serialize_field(".tag", "invalid_argument")?;
15751                if let Some(x) = x {
15752                    s.serialize_field("invalid_argument", &x)?;
15753                }
15754                s.end()
15755            }
15756            SearchError::InternalError => {
15757                // unit
15758                let mut s = serializer.serialize_struct("SearchError", 1)?;
15759                s.serialize_field(".tag", "internal_error")?;
15760                s.end()
15761            }
15762            SearchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
15763        }
15764    }
15765}
15766
15767impl ::std::error::Error for SearchError {
15768    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
15769        match self {
15770            SearchError::Path(inner) => Some(inner),
15771            _ => None,
15772        }
15773    }
15774}
15775
15776impl ::std::fmt::Display for SearchError {
15777    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15778        match self {
15779            SearchError::Path(inner) => write!(f, "SearchError: {}", inner),
15780            SearchError::InvalidArgument(None) => f.write_str("invalid_argument"),
15781            SearchError::InvalidArgument(Some(inner)) => write!(f, "invalid_argument: {:?}", inner),
15782            SearchError::InternalError => f.write_str("Something went wrong, please try again."),
15783            _ => write!(f, "{:?}", *self),
15784        }
15785    }
15786}
15787
15788#[derive(Debug, Clone, PartialEq)]
15789#[non_exhaustive] // structs may have more fields added in the future.
15790pub struct SearchMatch {
15791    /// The type of the match.
15792    pub match_type: SearchMatchType,
15793    /// The metadata for the matched file or folder.
15794    pub metadata: Metadata,
15795}
15796
15797impl SearchMatch {
15798    pub fn new(match_type: SearchMatchType, metadata: Metadata) -> Self {
15799        SearchMatch {
15800            match_type,
15801            metadata,
15802        }
15803    }
15804}
15805
15806const SEARCH_MATCH_FIELDS: &[&str] = &["match_type",
15807                                       "metadata"];
15808impl SearchMatch {
15809    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15810        map: V,
15811    ) -> Result<SearchMatch, V::Error> {
15812        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15813    }
15814
15815    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15816        mut map: V,
15817        optional: bool,
15818    ) -> Result<Option<SearchMatch>, V::Error> {
15819        let mut field_match_type = None;
15820        let mut field_metadata = None;
15821        let mut nothing = true;
15822        while let Some(key) = map.next_key::<&str>()? {
15823            nothing = false;
15824            match key {
15825                "match_type" => {
15826                    if field_match_type.is_some() {
15827                        return Err(::serde::de::Error::duplicate_field("match_type"));
15828                    }
15829                    field_match_type = Some(map.next_value()?);
15830                }
15831                "metadata" => {
15832                    if field_metadata.is_some() {
15833                        return Err(::serde::de::Error::duplicate_field("metadata"));
15834                    }
15835                    field_metadata = Some(map.next_value()?);
15836                }
15837                _ => {
15838                    // unknown field allowed and ignored
15839                    map.next_value::<::serde_json::Value>()?;
15840                }
15841            }
15842        }
15843        if optional && nothing {
15844            return Ok(None);
15845        }
15846        let result = SearchMatch {
15847            match_type: field_match_type.ok_or_else(|| ::serde::de::Error::missing_field("match_type"))?,
15848            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
15849        };
15850        Ok(Some(result))
15851    }
15852
15853    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15854        &self,
15855        s: &mut S::SerializeStruct,
15856    ) -> Result<(), S::Error> {
15857        use serde::ser::SerializeStruct;
15858        s.serialize_field("match_type", &self.match_type)?;
15859        s.serialize_field("metadata", &self.metadata)?;
15860        Ok(())
15861    }
15862}
15863
15864impl<'de> ::serde::de::Deserialize<'de> for SearchMatch {
15865    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15866        // struct deserializer
15867        use serde::de::{MapAccess, Visitor};
15868        struct StructVisitor;
15869        impl<'de> Visitor<'de> for StructVisitor {
15870            type Value = SearchMatch;
15871            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15872                f.write_str("a SearchMatch struct")
15873            }
15874            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15875                SearchMatch::internal_deserialize(map)
15876            }
15877        }
15878        deserializer.deserialize_struct("SearchMatch", SEARCH_MATCH_FIELDS, StructVisitor)
15879    }
15880}
15881
15882impl ::serde::ser::Serialize for SearchMatch {
15883    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15884        // struct serializer
15885        use serde::ser::SerializeStruct;
15886        let mut s = serializer.serialize_struct("SearchMatch", 2)?;
15887        self.internal_serialize::<S>(&mut s)?;
15888        s.end()
15889    }
15890}
15891
15892#[derive(Debug, Clone, PartialEq, Eq, Default)]
15893#[non_exhaustive] // structs may have more fields added in the future.
15894pub struct SearchMatchFieldOptions {
15895    /// Whether to include highlight span from file title.
15896    pub include_highlights: bool,
15897}
15898
15899impl SearchMatchFieldOptions {
15900    pub fn with_include_highlights(mut self, value: bool) -> Self {
15901        self.include_highlights = value;
15902        self
15903    }
15904}
15905
15906const SEARCH_MATCH_FIELD_OPTIONS_FIELDS: &[&str] = &["include_highlights"];
15907impl SearchMatchFieldOptions {
15908    // no _opt deserializer
15909    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15910        mut map: V,
15911    ) -> Result<SearchMatchFieldOptions, V::Error> {
15912        let mut field_include_highlights = None;
15913        while let Some(key) = map.next_key::<&str>()? {
15914            match key {
15915                "include_highlights" => {
15916                    if field_include_highlights.is_some() {
15917                        return Err(::serde::de::Error::duplicate_field("include_highlights"));
15918                    }
15919                    field_include_highlights = Some(map.next_value()?);
15920                }
15921                _ => {
15922                    // unknown field allowed and ignored
15923                    map.next_value::<::serde_json::Value>()?;
15924                }
15925            }
15926        }
15927        let result = SearchMatchFieldOptions {
15928            include_highlights: field_include_highlights.unwrap_or(false),
15929        };
15930        Ok(result)
15931    }
15932
15933    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15934        &self,
15935        s: &mut S::SerializeStruct,
15936    ) -> Result<(), S::Error> {
15937        use serde::ser::SerializeStruct;
15938        if self.include_highlights {
15939            s.serialize_field("include_highlights", &self.include_highlights)?;
15940        }
15941        Ok(())
15942    }
15943}
15944
15945impl<'de> ::serde::de::Deserialize<'de> for SearchMatchFieldOptions {
15946    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15947        // struct deserializer
15948        use serde::de::{MapAccess, Visitor};
15949        struct StructVisitor;
15950        impl<'de> Visitor<'de> for StructVisitor {
15951            type Value = SearchMatchFieldOptions;
15952            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15953                f.write_str("a SearchMatchFieldOptions struct")
15954            }
15955            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15956                SearchMatchFieldOptions::internal_deserialize(map)
15957            }
15958        }
15959        deserializer.deserialize_struct("SearchMatchFieldOptions", SEARCH_MATCH_FIELD_OPTIONS_FIELDS, StructVisitor)
15960    }
15961}
15962
15963impl ::serde::ser::Serialize for SearchMatchFieldOptions {
15964    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15965        // struct serializer
15966        use serde::ser::SerializeStruct;
15967        let mut s = serializer.serialize_struct("SearchMatchFieldOptions", 1)?;
15968        self.internal_serialize::<S>(&mut s)?;
15969        s.end()
15970    }
15971}
15972
15973/// Indicates what type of match was found for a given item.
15974#[derive(Debug, Clone, PartialEq, Eq)]
15975pub enum SearchMatchType {
15976    /// This item was matched on its file or folder name.
15977    Filename,
15978    /// This item was matched based on its file contents.
15979    Content,
15980    /// This item was matched based on both its contents and its file name.
15981    Both,
15982}
15983
15984impl<'de> ::serde::de::Deserialize<'de> for SearchMatchType {
15985    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15986        // union deserializer
15987        use serde::de::{self, MapAccess, Visitor};
15988        struct EnumVisitor;
15989        impl<'de> Visitor<'de> for EnumVisitor {
15990            type Value = SearchMatchType;
15991            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15992                f.write_str("a SearchMatchType structure")
15993            }
15994            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15995                let tag: &str = match map.next_key()? {
15996                    Some(".tag") => map.next_value()?,
15997                    _ => return Err(de::Error::missing_field(".tag"))
15998                };
15999                let value = match tag {
16000                    "filename" => SearchMatchType::Filename,
16001                    "content" => SearchMatchType::Content,
16002                    "both" => SearchMatchType::Both,
16003                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
16004                };
16005                crate::eat_json_fields(&mut map)?;
16006                Ok(value)
16007            }
16008        }
16009        const VARIANTS: &[&str] = &["filename",
16010                                    "content",
16011                                    "both"];
16012        deserializer.deserialize_struct("SearchMatchType", VARIANTS, EnumVisitor)
16013    }
16014}
16015
16016impl ::serde::ser::Serialize for SearchMatchType {
16017    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16018        // union serializer
16019        use serde::ser::SerializeStruct;
16020        match self {
16021            SearchMatchType::Filename => {
16022                // unit
16023                let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
16024                s.serialize_field(".tag", "filename")?;
16025                s.end()
16026            }
16027            SearchMatchType::Content => {
16028                // unit
16029                let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
16030                s.serialize_field(".tag", "content")?;
16031                s.end()
16032            }
16033            SearchMatchType::Both => {
16034                // unit
16035                let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
16036                s.serialize_field(".tag", "both")?;
16037                s.end()
16038            }
16039        }
16040    }
16041}
16042
16043/// Indicates what type of match was found for a given item.
16044#[derive(Debug, Clone, PartialEq, Eq)]
16045#[non_exhaustive] // variants may be added in the future
16046pub enum SearchMatchTypeV2 {
16047    /// This item was matched on its file or folder name.
16048    Filename,
16049    /// This item was matched based on its file contents.
16050    FileContent,
16051    /// This item was matched based on both its contents and its file name.
16052    FilenameAndContent,
16053    /// This item was matched on image content.
16054    ImageContent,
16055    /// Catch-all used for unrecognized values returned from the server. Encountering this value
16056    /// typically indicates that this SDK version is out of date.
16057    Other,
16058}
16059
16060impl<'de> ::serde::de::Deserialize<'de> for SearchMatchTypeV2 {
16061    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16062        // union deserializer
16063        use serde::de::{self, MapAccess, Visitor};
16064        struct EnumVisitor;
16065        impl<'de> Visitor<'de> for EnumVisitor {
16066            type Value = SearchMatchTypeV2;
16067            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16068                f.write_str("a SearchMatchTypeV2 structure")
16069            }
16070            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16071                let tag: &str = match map.next_key()? {
16072                    Some(".tag") => map.next_value()?,
16073                    _ => return Err(de::Error::missing_field(".tag"))
16074                };
16075                let value = match tag {
16076                    "filename" => SearchMatchTypeV2::Filename,
16077                    "file_content" => SearchMatchTypeV2::FileContent,
16078                    "filename_and_content" => SearchMatchTypeV2::FilenameAndContent,
16079                    "image_content" => SearchMatchTypeV2::ImageContent,
16080                    _ => SearchMatchTypeV2::Other,
16081                };
16082                crate::eat_json_fields(&mut map)?;
16083                Ok(value)
16084            }
16085        }
16086        const VARIANTS: &[&str] = &["filename",
16087                                    "file_content",
16088                                    "filename_and_content",
16089                                    "image_content",
16090                                    "other"];
16091        deserializer.deserialize_struct("SearchMatchTypeV2", VARIANTS, EnumVisitor)
16092    }
16093}
16094
16095impl ::serde::ser::Serialize for SearchMatchTypeV2 {
16096    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16097        // union serializer
16098        use serde::ser::SerializeStruct;
16099        match self {
16100            SearchMatchTypeV2::Filename => {
16101                // unit
16102                let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16103                s.serialize_field(".tag", "filename")?;
16104                s.end()
16105            }
16106            SearchMatchTypeV2::FileContent => {
16107                // unit
16108                let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16109                s.serialize_field(".tag", "file_content")?;
16110                s.end()
16111            }
16112            SearchMatchTypeV2::FilenameAndContent => {
16113                // unit
16114                let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16115                s.serialize_field(".tag", "filename_and_content")?;
16116                s.end()
16117            }
16118            SearchMatchTypeV2::ImageContent => {
16119                // unit
16120                let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16121                s.serialize_field(".tag", "image_content")?;
16122                s.end()
16123            }
16124            SearchMatchTypeV2::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
16125        }
16126    }
16127}
16128
16129#[derive(Debug, Clone, PartialEq)]
16130#[non_exhaustive] // structs may have more fields added in the future.
16131pub struct SearchMatchV2 {
16132    /// The metadata for the matched file or folder.
16133    pub metadata: MetadataV2,
16134    /// The type of the match.
16135    pub match_type: Option<SearchMatchTypeV2>,
16136    /// The list of HighlightSpan determines which parts of the file title should be highlighted.
16137    pub highlight_spans: Option<Vec<HighlightSpan>>,
16138}
16139
16140impl SearchMatchV2 {
16141    pub fn new(metadata: MetadataV2) -> Self {
16142        SearchMatchV2 {
16143            metadata,
16144            match_type: None,
16145            highlight_spans: None,
16146        }
16147    }
16148
16149    pub fn with_match_type(mut self, value: SearchMatchTypeV2) -> Self {
16150        self.match_type = Some(value);
16151        self
16152    }
16153
16154    pub fn with_highlight_spans(mut self, value: Vec<HighlightSpan>) -> Self {
16155        self.highlight_spans = Some(value);
16156        self
16157    }
16158}
16159
16160const SEARCH_MATCH_V2_FIELDS: &[&str] = &["metadata",
16161                                          "match_type",
16162                                          "highlight_spans"];
16163impl SearchMatchV2 {
16164    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16165        map: V,
16166    ) -> Result<SearchMatchV2, V::Error> {
16167        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16168    }
16169
16170    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16171        mut map: V,
16172        optional: bool,
16173    ) -> Result<Option<SearchMatchV2>, V::Error> {
16174        let mut field_metadata = None;
16175        let mut field_match_type = None;
16176        let mut field_highlight_spans = None;
16177        let mut nothing = true;
16178        while let Some(key) = map.next_key::<&str>()? {
16179            nothing = false;
16180            match key {
16181                "metadata" => {
16182                    if field_metadata.is_some() {
16183                        return Err(::serde::de::Error::duplicate_field("metadata"));
16184                    }
16185                    field_metadata = Some(map.next_value()?);
16186                }
16187                "match_type" => {
16188                    if field_match_type.is_some() {
16189                        return Err(::serde::de::Error::duplicate_field("match_type"));
16190                    }
16191                    field_match_type = Some(map.next_value()?);
16192                }
16193                "highlight_spans" => {
16194                    if field_highlight_spans.is_some() {
16195                        return Err(::serde::de::Error::duplicate_field("highlight_spans"));
16196                    }
16197                    field_highlight_spans = Some(map.next_value()?);
16198                }
16199                _ => {
16200                    // unknown field allowed and ignored
16201                    map.next_value::<::serde_json::Value>()?;
16202                }
16203            }
16204        }
16205        if optional && nothing {
16206            return Ok(None);
16207        }
16208        let result = SearchMatchV2 {
16209            metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
16210            match_type: field_match_type.and_then(Option::flatten),
16211            highlight_spans: field_highlight_spans.and_then(Option::flatten),
16212        };
16213        Ok(Some(result))
16214    }
16215
16216    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16217        &self,
16218        s: &mut S::SerializeStruct,
16219    ) -> Result<(), S::Error> {
16220        use serde::ser::SerializeStruct;
16221        s.serialize_field("metadata", &self.metadata)?;
16222        if let Some(val) = &self.match_type {
16223            s.serialize_field("match_type", val)?;
16224        }
16225        if let Some(val) = &self.highlight_spans {
16226            s.serialize_field("highlight_spans", val)?;
16227        }
16228        Ok(())
16229    }
16230}
16231
16232impl<'de> ::serde::de::Deserialize<'de> for SearchMatchV2 {
16233    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16234        // struct deserializer
16235        use serde::de::{MapAccess, Visitor};
16236        struct StructVisitor;
16237        impl<'de> Visitor<'de> for StructVisitor {
16238            type Value = SearchMatchV2;
16239            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16240                f.write_str("a SearchMatchV2 struct")
16241            }
16242            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16243                SearchMatchV2::internal_deserialize(map)
16244            }
16245        }
16246        deserializer.deserialize_struct("SearchMatchV2", SEARCH_MATCH_V2_FIELDS, StructVisitor)
16247    }
16248}
16249
16250impl ::serde::ser::Serialize for SearchMatchV2 {
16251    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16252        // struct serializer
16253        use serde::ser::SerializeStruct;
16254        let mut s = serializer.serialize_struct("SearchMatchV2", 3)?;
16255        self.internal_serialize::<S>(&mut s)?;
16256        s.end()
16257    }
16258}
16259
16260#[derive(Debug, Clone, PartialEq, Eq)]
16261pub enum SearchMode {
16262    /// Search file and folder names.
16263    Filename,
16264    /// Search file and folder names as well as file contents.
16265    FilenameAndContent,
16266    /// Search for deleted file and folder names.
16267    DeletedFilename,
16268}
16269
16270impl<'de> ::serde::de::Deserialize<'de> for SearchMode {
16271    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16272        // union deserializer
16273        use serde::de::{self, MapAccess, Visitor};
16274        struct EnumVisitor;
16275        impl<'de> Visitor<'de> for EnumVisitor {
16276            type Value = SearchMode;
16277            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16278                f.write_str("a SearchMode structure")
16279            }
16280            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16281                let tag: &str = match map.next_key()? {
16282                    Some(".tag") => map.next_value()?,
16283                    _ => return Err(de::Error::missing_field(".tag"))
16284                };
16285                let value = match tag {
16286                    "filename" => SearchMode::Filename,
16287                    "filename_and_content" => SearchMode::FilenameAndContent,
16288                    "deleted_filename" => SearchMode::DeletedFilename,
16289                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
16290                };
16291                crate::eat_json_fields(&mut map)?;
16292                Ok(value)
16293            }
16294        }
16295        const VARIANTS: &[&str] = &["filename",
16296                                    "filename_and_content",
16297                                    "deleted_filename"];
16298        deserializer.deserialize_struct("SearchMode", VARIANTS, EnumVisitor)
16299    }
16300}
16301
16302impl ::serde::ser::Serialize for SearchMode {
16303    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16304        // union serializer
16305        use serde::ser::SerializeStruct;
16306        match self {
16307            SearchMode::Filename => {
16308                // unit
16309                let mut s = serializer.serialize_struct("SearchMode", 1)?;
16310                s.serialize_field(".tag", "filename")?;
16311                s.end()
16312            }
16313            SearchMode::FilenameAndContent => {
16314                // unit
16315                let mut s = serializer.serialize_struct("SearchMode", 1)?;
16316                s.serialize_field(".tag", "filename_and_content")?;
16317                s.end()
16318            }
16319            SearchMode::DeletedFilename => {
16320                // unit
16321                let mut s = serializer.serialize_struct("SearchMode", 1)?;
16322                s.serialize_field(".tag", "deleted_filename")?;
16323                s.end()
16324            }
16325        }
16326    }
16327}
16328
16329#[derive(Debug, Clone, PartialEq, Eq)]
16330#[non_exhaustive] // structs may have more fields added in the future.
16331pub struct SearchOptions {
16332    /// Scopes the search to a path in the user's Dropbox. Searches the entire Dropbox if not
16333    /// specified.
16334    pub path: Option<PathROrId>,
16335    /// The maximum number of search results to return.
16336    pub max_results: u64,
16337    /// Specified property of the order of search results. By default, results are sorted by
16338    /// relevance.
16339    pub order_by: Option<SearchOrderBy>,
16340    /// Restricts search to the given file status.
16341    pub file_status: FileStatus,
16342    /// Restricts search to only match on filenames.
16343    pub filename_only: bool,
16344    /// Restricts search to only the extensions specified. Only supported for active file search.
16345    pub file_extensions: Option<Vec<String>>,
16346    /// Restricts search to only the file categories specified. Only supported for active file
16347    /// search.
16348    pub file_categories: Option<Vec<FileCategory>>,
16349    /// Restricts results to the given account id.
16350    pub account_id: Option<crate::types::users_common::AccountId>,
16351}
16352
16353impl Default for SearchOptions {
16354    fn default() -> Self {
16355        SearchOptions {
16356            path: None,
16357            max_results: 100,
16358            order_by: None,
16359            file_status: FileStatus::Active,
16360            filename_only: false,
16361            file_extensions: None,
16362            file_categories: None,
16363            account_id: None,
16364        }
16365    }
16366}
16367
16368impl SearchOptions {
16369    pub fn with_path(mut self, value: PathROrId) -> Self {
16370        self.path = Some(value);
16371        self
16372    }
16373
16374    pub fn with_max_results(mut self, value: u64) -> Self {
16375        self.max_results = value;
16376        self
16377    }
16378
16379    pub fn with_order_by(mut self, value: SearchOrderBy) -> Self {
16380        self.order_by = Some(value);
16381        self
16382    }
16383
16384    pub fn with_file_status(mut self, value: FileStatus) -> Self {
16385        self.file_status = value;
16386        self
16387    }
16388
16389    pub fn with_filename_only(mut self, value: bool) -> Self {
16390        self.filename_only = value;
16391        self
16392    }
16393
16394    pub fn with_file_extensions(mut self, value: Vec<String>) -> Self {
16395        self.file_extensions = Some(value);
16396        self
16397    }
16398
16399    pub fn with_file_categories(mut self, value: Vec<FileCategory>) -> Self {
16400        self.file_categories = Some(value);
16401        self
16402    }
16403
16404    pub fn with_account_id(mut self, value: crate::types::users_common::AccountId) -> Self {
16405        self.account_id = Some(value);
16406        self
16407    }
16408}
16409
16410const SEARCH_OPTIONS_FIELDS: &[&str] = &["path",
16411                                         "max_results",
16412                                         "order_by",
16413                                         "file_status",
16414                                         "filename_only",
16415                                         "file_extensions",
16416                                         "file_categories",
16417                                         "account_id"];
16418impl SearchOptions {
16419    // no _opt deserializer
16420    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16421        mut map: V,
16422    ) -> Result<SearchOptions, V::Error> {
16423        let mut field_path = None;
16424        let mut field_max_results = None;
16425        let mut field_order_by = None;
16426        let mut field_file_status = None;
16427        let mut field_filename_only = None;
16428        let mut field_file_extensions = None;
16429        let mut field_file_categories = None;
16430        let mut field_account_id = None;
16431        while let Some(key) = map.next_key::<&str>()? {
16432            match key {
16433                "path" => {
16434                    if field_path.is_some() {
16435                        return Err(::serde::de::Error::duplicate_field("path"));
16436                    }
16437                    field_path = Some(map.next_value()?);
16438                }
16439                "max_results" => {
16440                    if field_max_results.is_some() {
16441                        return Err(::serde::de::Error::duplicate_field("max_results"));
16442                    }
16443                    field_max_results = Some(map.next_value()?);
16444                }
16445                "order_by" => {
16446                    if field_order_by.is_some() {
16447                        return Err(::serde::de::Error::duplicate_field("order_by"));
16448                    }
16449                    field_order_by = Some(map.next_value()?);
16450                }
16451                "file_status" => {
16452                    if field_file_status.is_some() {
16453                        return Err(::serde::de::Error::duplicate_field("file_status"));
16454                    }
16455                    field_file_status = Some(map.next_value()?);
16456                }
16457                "filename_only" => {
16458                    if field_filename_only.is_some() {
16459                        return Err(::serde::de::Error::duplicate_field("filename_only"));
16460                    }
16461                    field_filename_only = Some(map.next_value()?);
16462                }
16463                "file_extensions" => {
16464                    if field_file_extensions.is_some() {
16465                        return Err(::serde::de::Error::duplicate_field("file_extensions"));
16466                    }
16467                    field_file_extensions = Some(map.next_value()?);
16468                }
16469                "file_categories" => {
16470                    if field_file_categories.is_some() {
16471                        return Err(::serde::de::Error::duplicate_field("file_categories"));
16472                    }
16473                    field_file_categories = Some(map.next_value()?);
16474                }
16475                "account_id" => {
16476                    if field_account_id.is_some() {
16477                        return Err(::serde::de::Error::duplicate_field("account_id"));
16478                    }
16479                    field_account_id = Some(map.next_value()?);
16480                }
16481                _ => {
16482                    // unknown field allowed and ignored
16483                    map.next_value::<::serde_json::Value>()?;
16484                }
16485            }
16486        }
16487        let result = SearchOptions {
16488            path: field_path.and_then(Option::flatten),
16489            max_results: field_max_results.unwrap_or(100),
16490            order_by: field_order_by.and_then(Option::flatten),
16491            file_status: field_file_status.unwrap_or(FileStatus::Active),
16492            filename_only: field_filename_only.unwrap_or(false),
16493            file_extensions: field_file_extensions.and_then(Option::flatten),
16494            file_categories: field_file_categories.and_then(Option::flatten),
16495            account_id: field_account_id.and_then(Option::flatten),
16496        };
16497        Ok(result)
16498    }
16499
16500    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16501        &self,
16502        s: &mut S::SerializeStruct,
16503    ) -> Result<(), S::Error> {
16504        use serde::ser::SerializeStruct;
16505        if let Some(val) = &self.path {
16506            s.serialize_field("path", val)?;
16507        }
16508        if self.max_results != 100 {
16509            s.serialize_field("max_results", &self.max_results)?;
16510        }
16511        if let Some(val) = &self.order_by {
16512            s.serialize_field("order_by", val)?;
16513        }
16514        if self.file_status != FileStatus::Active {
16515            s.serialize_field("file_status", &self.file_status)?;
16516        }
16517        if self.filename_only {
16518            s.serialize_field("filename_only", &self.filename_only)?;
16519        }
16520        if let Some(val) = &self.file_extensions {
16521            s.serialize_field("file_extensions", val)?;
16522        }
16523        if let Some(val) = &self.file_categories {
16524            s.serialize_field("file_categories", val)?;
16525        }
16526        if let Some(val) = &self.account_id {
16527            s.serialize_field("account_id", val)?;
16528        }
16529        Ok(())
16530    }
16531}
16532
16533impl<'de> ::serde::de::Deserialize<'de> for SearchOptions {
16534    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16535        // struct deserializer
16536        use serde::de::{MapAccess, Visitor};
16537        struct StructVisitor;
16538        impl<'de> Visitor<'de> for StructVisitor {
16539            type Value = SearchOptions;
16540            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16541                f.write_str("a SearchOptions struct")
16542            }
16543            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16544                SearchOptions::internal_deserialize(map)
16545            }
16546        }
16547        deserializer.deserialize_struct("SearchOptions", SEARCH_OPTIONS_FIELDS, StructVisitor)
16548    }
16549}
16550
16551impl ::serde::ser::Serialize for SearchOptions {
16552    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16553        // struct serializer
16554        use serde::ser::SerializeStruct;
16555        let mut s = serializer.serialize_struct("SearchOptions", 8)?;
16556        self.internal_serialize::<S>(&mut s)?;
16557        s.end()
16558    }
16559}
16560
16561#[derive(Debug, Clone, PartialEq, Eq)]
16562#[non_exhaustive] // variants may be added in the future
16563pub enum SearchOrderBy {
16564    Relevance,
16565    LastModifiedTime,
16566    /// Catch-all used for unrecognized values returned from the server. Encountering this value
16567    /// typically indicates that this SDK version is out of date.
16568    Other,
16569}
16570
16571impl<'de> ::serde::de::Deserialize<'de> for SearchOrderBy {
16572    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16573        // union deserializer
16574        use serde::de::{self, MapAccess, Visitor};
16575        struct EnumVisitor;
16576        impl<'de> Visitor<'de> for EnumVisitor {
16577            type Value = SearchOrderBy;
16578            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16579                f.write_str("a SearchOrderBy structure")
16580            }
16581            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16582                let tag: &str = match map.next_key()? {
16583                    Some(".tag") => map.next_value()?,
16584                    _ => return Err(de::Error::missing_field(".tag"))
16585                };
16586                let value = match tag {
16587                    "relevance" => SearchOrderBy::Relevance,
16588                    "last_modified_time" => SearchOrderBy::LastModifiedTime,
16589                    _ => SearchOrderBy::Other,
16590                };
16591                crate::eat_json_fields(&mut map)?;
16592                Ok(value)
16593            }
16594        }
16595        const VARIANTS: &[&str] = &["relevance",
16596                                    "last_modified_time",
16597                                    "other"];
16598        deserializer.deserialize_struct("SearchOrderBy", VARIANTS, EnumVisitor)
16599    }
16600}
16601
16602impl ::serde::ser::Serialize for SearchOrderBy {
16603    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16604        // union serializer
16605        use serde::ser::SerializeStruct;
16606        match self {
16607            SearchOrderBy::Relevance => {
16608                // unit
16609                let mut s = serializer.serialize_struct("SearchOrderBy", 1)?;
16610                s.serialize_field(".tag", "relevance")?;
16611                s.end()
16612            }
16613            SearchOrderBy::LastModifiedTime => {
16614                // unit
16615                let mut s = serializer.serialize_struct("SearchOrderBy", 1)?;
16616                s.serialize_field(".tag", "last_modified_time")?;
16617                s.end()
16618            }
16619            SearchOrderBy::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
16620        }
16621    }
16622}
16623
16624#[derive(Debug, Clone, PartialEq)]
16625#[non_exhaustive] // structs may have more fields added in the future.
16626pub struct SearchResult {
16627    /// A list (possibly empty) of matches for the query.
16628    pub matches: Vec<SearchMatch>,
16629    /// Used for paging. If true, indicates there is another page of results available that can be
16630    /// fetched by calling [`search()`](crate::files::search) again.
16631    pub more: bool,
16632    /// Used for paging. Value to set the start argument to when calling
16633    /// [`search()`](crate::files::search) to fetch the next page of results.
16634    pub start: u64,
16635}
16636
16637impl SearchResult {
16638    pub fn new(matches: Vec<SearchMatch>, more: bool, start: u64) -> Self {
16639        SearchResult {
16640            matches,
16641            more,
16642            start,
16643        }
16644    }
16645}
16646
16647const SEARCH_RESULT_FIELDS: &[&str] = &["matches",
16648                                        "more",
16649                                        "start"];
16650impl SearchResult {
16651    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16652        map: V,
16653    ) -> Result<SearchResult, V::Error> {
16654        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16655    }
16656
16657    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16658        mut map: V,
16659        optional: bool,
16660    ) -> Result<Option<SearchResult>, V::Error> {
16661        let mut field_matches = None;
16662        let mut field_more = None;
16663        let mut field_start = None;
16664        let mut nothing = true;
16665        while let Some(key) = map.next_key::<&str>()? {
16666            nothing = false;
16667            match key {
16668                "matches" => {
16669                    if field_matches.is_some() {
16670                        return Err(::serde::de::Error::duplicate_field("matches"));
16671                    }
16672                    field_matches = Some(map.next_value()?);
16673                }
16674                "more" => {
16675                    if field_more.is_some() {
16676                        return Err(::serde::de::Error::duplicate_field("more"));
16677                    }
16678                    field_more = Some(map.next_value()?);
16679                }
16680                "start" => {
16681                    if field_start.is_some() {
16682                        return Err(::serde::de::Error::duplicate_field("start"));
16683                    }
16684                    field_start = Some(map.next_value()?);
16685                }
16686                _ => {
16687                    // unknown field allowed and ignored
16688                    map.next_value::<::serde_json::Value>()?;
16689                }
16690            }
16691        }
16692        if optional && nothing {
16693            return Ok(None);
16694        }
16695        let result = SearchResult {
16696            matches: field_matches.ok_or_else(|| ::serde::de::Error::missing_field("matches"))?,
16697            more: field_more.ok_or_else(|| ::serde::de::Error::missing_field("more"))?,
16698            start: field_start.ok_or_else(|| ::serde::de::Error::missing_field("start"))?,
16699        };
16700        Ok(Some(result))
16701    }
16702
16703    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16704        &self,
16705        s: &mut S::SerializeStruct,
16706    ) -> Result<(), S::Error> {
16707        use serde::ser::SerializeStruct;
16708        s.serialize_field("matches", &self.matches)?;
16709        s.serialize_field("more", &self.more)?;
16710        s.serialize_field("start", &self.start)?;
16711        Ok(())
16712    }
16713}
16714
16715impl<'de> ::serde::de::Deserialize<'de> for SearchResult {
16716    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16717        // struct deserializer
16718        use serde::de::{MapAccess, Visitor};
16719        struct StructVisitor;
16720        impl<'de> Visitor<'de> for StructVisitor {
16721            type Value = SearchResult;
16722            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16723                f.write_str("a SearchResult struct")
16724            }
16725            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16726                SearchResult::internal_deserialize(map)
16727            }
16728        }
16729        deserializer.deserialize_struct("SearchResult", SEARCH_RESULT_FIELDS, StructVisitor)
16730    }
16731}
16732
16733impl ::serde::ser::Serialize for SearchResult {
16734    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16735        // struct serializer
16736        use serde::ser::SerializeStruct;
16737        let mut s = serializer.serialize_struct("SearchResult", 3)?;
16738        self.internal_serialize::<S>(&mut s)?;
16739        s.end()
16740    }
16741}
16742
16743#[derive(Debug, Clone, PartialEq, Eq)]
16744#[non_exhaustive] // structs may have more fields added in the future.
16745pub struct SearchV2Arg {
16746    /// The string to search for. May match across multiple fields based on the request arguments.
16747    pub query: String,
16748    /// Options for more targeted search results.
16749    pub options: Option<SearchOptions>,
16750    /// Options for search results match fields.
16751    pub match_field_options: Option<SearchMatchFieldOptions>,
16752    /// Deprecated and moved this option to SearchMatchFieldOptions.
16753    pub include_highlights: Option<bool>,
16754}
16755
16756impl SearchV2Arg {
16757    pub fn new(query: String) -> Self {
16758        SearchV2Arg {
16759            query,
16760            options: None,
16761            match_field_options: None,
16762            include_highlights: None,
16763        }
16764    }
16765
16766    pub fn with_options(mut self, value: SearchOptions) -> Self {
16767        self.options = Some(value);
16768        self
16769    }
16770
16771    pub fn with_match_field_options(mut self, value: SearchMatchFieldOptions) -> Self {
16772        self.match_field_options = Some(value);
16773        self
16774    }
16775
16776    pub fn with_include_highlights(mut self, value: bool) -> Self {
16777        self.include_highlights = Some(value);
16778        self
16779    }
16780}
16781
16782const SEARCH_V2_ARG_FIELDS: &[&str] = &["query",
16783                                        "options",
16784                                        "match_field_options",
16785                                        "include_highlights"];
16786impl SearchV2Arg {
16787    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16788        map: V,
16789    ) -> Result<SearchV2Arg, V::Error> {
16790        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16791    }
16792
16793    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16794        mut map: V,
16795        optional: bool,
16796    ) -> Result<Option<SearchV2Arg>, V::Error> {
16797        let mut field_query = None;
16798        let mut field_options = None;
16799        let mut field_match_field_options = None;
16800        let mut field_include_highlights = None;
16801        let mut nothing = true;
16802        while let Some(key) = map.next_key::<&str>()? {
16803            nothing = false;
16804            match key {
16805                "query" => {
16806                    if field_query.is_some() {
16807                        return Err(::serde::de::Error::duplicate_field("query"));
16808                    }
16809                    field_query = Some(map.next_value()?);
16810                }
16811                "options" => {
16812                    if field_options.is_some() {
16813                        return Err(::serde::de::Error::duplicate_field("options"));
16814                    }
16815                    field_options = Some(map.next_value()?);
16816                }
16817                "match_field_options" => {
16818                    if field_match_field_options.is_some() {
16819                        return Err(::serde::de::Error::duplicate_field("match_field_options"));
16820                    }
16821                    field_match_field_options = Some(map.next_value()?);
16822                }
16823                "include_highlights" => {
16824                    if field_include_highlights.is_some() {
16825                        return Err(::serde::de::Error::duplicate_field("include_highlights"));
16826                    }
16827                    field_include_highlights = Some(map.next_value()?);
16828                }
16829                _ => {
16830                    // unknown field allowed and ignored
16831                    map.next_value::<::serde_json::Value>()?;
16832                }
16833            }
16834        }
16835        if optional && nothing {
16836            return Ok(None);
16837        }
16838        let result = SearchV2Arg {
16839            query: field_query.ok_or_else(|| ::serde::de::Error::missing_field("query"))?,
16840            options: field_options.and_then(Option::flatten),
16841            match_field_options: field_match_field_options.and_then(Option::flatten),
16842            include_highlights: field_include_highlights.and_then(Option::flatten),
16843        };
16844        Ok(Some(result))
16845    }
16846
16847    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16848        &self,
16849        s: &mut S::SerializeStruct,
16850    ) -> Result<(), S::Error> {
16851        use serde::ser::SerializeStruct;
16852        s.serialize_field("query", &self.query)?;
16853        if let Some(val) = &self.options {
16854            s.serialize_field("options", val)?;
16855        }
16856        if let Some(val) = &self.match_field_options {
16857            s.serialize_field("match_field_options", val)?;
16858        }
16859        if let Some(val) = &self.include_highlights {
16860            s.serialize_field("include_highlights", val)?;
16861        }
16862        Ok(())
16863    }
16864}
16865
16866impl<'de> ::serde::de::Deserialize<'de> for SearchV2Arg {
16867    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16868        // struct deserializer
16869        use serde::de::{MapAccess, Visitor};
16870        struct StructVisitor;
16871        impl<'de> Visitor<'de> for StructVisitor {
16872            type Value = SearchV2Arg;
16873            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16874                f.write_str("a SearchV2Arg struct")
16875            }
16876            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16877                SearchV2Arg::internal_deserialize(map)
16878            }
16879        }
16880        deserializer.deserialize_struct("SearchV2Arg", SEARCH_V2_ARG_FIELDS, StructVisitor)
16881    }
16882}
16883
16884impl ::serde::ser::Serialize for SearchV2Arg {
16885    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16886        // struct serializer
16887        use serde::ser::SerializeStruct;
16888        let mut s = serializer.serialize_struct("SearchV2Arg", 4)?;
16889        self.internal_serialize::<S>(&mut s)?;
16890        s.end()
16891    }
16892}
16893
16894#[derive(Debug, Clone, PartialEq, Eq)]
16895#[non_exhaustive] // structs may have more fields added in the future.
16896pub struct SearchV2ContinueArg {
16897    /// The cursor returned by your last call to [`search_v2()`](crate::files::search_v2). Used to
16898    /// fetch the next page of results.
16899    pub cursor: SearchV2Cursor,
16900}
16901
16902impl SearchV2ContinueArg {
16903    pub fn new(cursor: SearchV2Cursor) -> Self {
16904        SearchV2ContinueArg {
16905            cursor,
16906        }
16907    }
16908}
16909
16910const SEARCH_V2_CONTINUE_ARG_FIELDS: &[&str] = &["cursor"];
16911impl SearchV2ContinueArg {
16912    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16913        map: V,
16914    ) -> Result<SearchV2ContinueArg, V::Error> {
16915        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16916    }
16917
16918    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16919        mut map: V,
16920        optional: bool,
16921    ) -> Result<Option<SearchV2ContinueArg>, V::Error> {
16922        let mut field_cursor = None;
16923        let mut nothing = true;
16924        while let Some(key) = map.next_key::<&str>()? {
16925            nothing = false;
16926            match key {
16927                "cursor" => {
16928                    if field_cursor.is_some() {
16929                        return Err(::serde::de::Error::duplicate_field("cursor"));
16930                    }
16931                    field_cursor = Some(map.next_value()?);
16932                }
16933                _ => {
16934                    // unknown field allowed and ignored
16935                    map.next_value::<::serde_json::Value>()?;
16936                }
16937            }
16938        }
16939        if optional && nothing {
16940            return Ok(None);
16941        }
16942        let result = SearchV2ContinueArg {
16943            cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
16944        };
16945        Ok(Some(result))
16946    }
16947
16948    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16949        &self,
16950        s: &mut S::SerializeStruct,
16951    ) -> Result<(), S::Error> {
16952        use serde::ser::SerializeStruct;
16953        s.serialize_field("cursor", &self.cursor)?;
16954        Ok(())
16955    }
16956}
16957
16958impl<'de> ::serde::de::Deserialize<'de> for SearchV2ContinueArg {
16959    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16960        // struct deserializer
16961        use serde::de::{MapAccess, Visitor};
16962        struct StructVisitor;
16963        impl<'de> Visitor<'de> for StructVisitor {
16964            type Value = SearchV2ContinueArg;
16965            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16966                f.write_str("a SearchV2ContinueArg struct")
16967            }
16968            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16969                SearchV2ContinueArg::internal_deserialize(map)
16970            }
16971        }
16972        deserializer.deserialize_struct("SearchV2ContinueArg", SEARCH_V2_CONTINUE_ARG_FIELDS, StructVisitor)
16973    }
16974}
16975
16976impl ::serde::ser::Serialize for SearchV2ContinueArg {
16977    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16978        // struct serializer
16979        use serde::ser::SerializeStruct;
16980        let mut s = serializer.serialize_struct("SearchV2ContinueArg", 1)?;
16981        self.internal_serialize::<S>(&mut s)?;
16982        s.end()
16983    }
16984}
16985
16986#[derive(Debug, Clone, PartialEq)]
16987#[non_exhaustive] // structs may have more fields added in the future.
16988pub struct SearchV2Result {
16989    /// A list (possibly empty) of matches for the query.
16990    pub matches: Vec<SearchMatchV2>,
16991    /// Used for paging. If true, indicates there is another page of results available that can be
16992    /// fetched by calling [`search_continue_v2()`](crate::files::search_continue_v2) with the
16993    /// cursor.
16994    pub has_more: bool,
16995    /// Pass the cursor into [`search_continue_v2()`](crate::files::search_continue_v2) to fetch the
16996    /// next page of results.
16997    pub cursor: Option<SearchV2Cursor>,
16998}
16999
17000impl SearchV2Result {
17001    pub fn new(matches: Vec<SearchMatchV2>, has_more: bool) -> Self {
17002        SearchV2Result {
17003            matches,
17004            has_more,
17005            cursor: None,
17006        }
17007    }
17008
17009    pub fn with_cursor(mut self, value: SearchV2Cursor) -> Self {
17010        self.cursor = Some(value);
17011        self
17012    }
17013}
17014
17015const SEARCH_V2_RESULT_FIELDS: &[&str] = &["matches",
17016                                           "has_more",
17017                                           "cursor"];
17018impl SearchV2Result {
17019    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17020        map: V,
17021    ) -> Result<SearchV2Result, V::Error> {
17022        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17023    }
17024
17025    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17026        mut map: V,
17027        optional: bool,
17028    ) -> Result<Option<SearchV2Result>, V::Error> {
17029        let mut field_matches = None;
17030        let mut field_has_more = None;
17031        let mut field_cursor = None;
17032        let mut nothing = true;
17033        while let Some(key) = map.next_key::<&str>()? {
17034            nothing = false;
17035            match key {
17036                "matches" => {
17037                    if field_matches.is_some() {
17038                        return Err(::serde::de::Error::duplicate_field("matches"));
17039                    }
17040                    field_matches = Some(map.next_value()?);
17041                }
17042                "has_more" => {
17043                    if field_has_more.is_some() {
17044                        return Err(::serde::de::Error::duplicate_field("has_more"));
17045                    }
17046                    field_has_more = Some(map.next_value()?);
17047                }
17048                "cursor" => {
17049                    if field_cursor.is_some() {
17050                        return Err(::serde::de::Error::duplicate_field("cursor"));
17051                    }
17052                    field_cursor = Some(map.next_value()?);
17053                }
17054                _ => {
17055                    // unknown field allowed and ignored
17056                    map.next_value::<::serde_json::Value>()?;
17057                }
17058            }
17059        }
17060        if optional && nothing {
17061            return Ok(None);
17062        }
17063        let result = SearchV2Result {
17064            matches: field_matches.ok_or_else(|| ::serde::de::Error::missing_field("matches"))?,
17065            has_more: field_has_more.ok_or_else(|| ::serde::de::Error::missing_field("has_more"))?,
17066            cursor: field_cursor.and_then(Option::flatten),
17067        };
17068        Ok(Some(result))
17069    }
17070
17071    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17072        &self,
17073        s: &mut S::SerializeStruct,
17074    ) -> Result<(), S::Error> {
17075        use serde::ser::SerializeStruct;
17076        s.serialize_field("matches", &self.matches)?;
17077        s.serialize_field("has_more", &self.has_more)?;
17078        if let Some(val) = &self.cursor {
17079            s.serialize_field("cursor", val)?;
17080        }
17081        Ok(())
17082    }
17083}
17084
17085impl<'de> ::serde::de::Deserialize<'de> for SearchV2Result {
17086    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17087        // struct deserializer
17088        use serde::de::{MapAccess, Visitor};
17089        struct StructVisitor;
17090        impl<'de> Visitor<'de> for StructVisitor {
17091            type Value = SearchV2Result;
17092            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17093                f.write_str("a SearchV2Result struct")
17094            }
17095            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17096                SearchV2Result::internal_deserialize(map)
17097            }
17098        }
17099        deserializer.deserialize_struct("SearchV2Result", SEARCH_V2_RESULT_FIELDS, StructVisitor)
17100    }
17101}
17102
17103impl ::serde::ser::Serialize for SearchV2Result {
17104    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17105        // struct serializer
17106        use serde::ser::SerializeStruct;
17107        let mut s = serializer.serialize_struct("SearchV2Result", 3)?;
17108        self.internal_serialize::<S>(&mut s)?;
17109        s.end()
17110    }
17111}
17112
17113#[derive(Debug, Clone, PartialEq, Eq)]
17114#[non_exhaustive] // structs may have more fields added in the future.
17115pub struct SharedLink {
17116    /// Shared link url.
17117    pub url: SharedLinkUrl,
17118    /// Password for the shared link.
17119    pub password: Option<String>,
17120}
17121
17122impl SharedLink {
17123    pub fn new(url: SharedLinkUrl) -> Self {
17124        SharedLink {
17125            url,
17126            password: None,
17127        }
17128    }
17129
17130    pub fn with_password(mut self, value: String) -> Self {
17131        self.password = Some(value);
17132        self
17133    }
17134}
17135
17136const SHARED_LINK_FIELDS: &[&str] = &["url",
17137                                      "password"];
17138impl SharedLink {
17139    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17140        map: V,
17141    ) -> Result<SharedLink, V::Error> {
17142        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17143    }
17144
17145    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17146        mut map: V,
17147        optional: bool,
17148    ) -> Result<Option<SharedLink>, V::Error> {
17149        let mut field_url = None;
17150        let mut field_password = None;
17151        let mut nothing = true;
17152        while let Some(key) = map.next_key::<&str>()? {
17153            nothing = false;
17154            match key {
17155                "url" => {
17156                    if field_url.is_some() {
17157                        return Err(::serde::de::Error::duplicate_field("url"));
17158                    }
17159                    field_url = Some(map.next_value()?);
17160                }
17161                "password" => {
17162                    if field_password.is_some() {
17163                        return Err(::serde::de::Error::duplicate_field("password"));
17164                    }
17165                    field_password = Some(map.next_value()?);
17166                }
17167                _ => {
17168                    // unknown field allowed and ignored
17169                    map.next_value::<::serde_json::Value>()?;
17170                }
17171            }
17172        }
17173        if optional && nothing {
17174            return Ok(None);
17175        }
17176        let result = SharedLink {
17177            url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
17178            password: field_password.and_then(Option::flatten),
17179        };
17180        Ok(Some(result))
17181    }
17182
17183    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17184        &self,
17185        s: &mut S::SerializeStruct,
17186    ) -> Result<(), S::Error> {
17187        use serde::ser::SerializeStruct;
17188        s.serialize_field("url", &self.url)?;
17189        if let Some(val) = &self.password {
17190            s.serialize_field("password", val)?;
17191        }
17192        Ok(())
17193    }
17194}
17195
17196impl<'de> ::serde::de::Deserialize<'de> for SharedLink {
17197    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17198        // struct deserializer
17199        use serde::de::{MapAccess, Visitor};
17200        struct StructVisitor;
17201        impl<'de> Visitor<'de> for StructVisitor {
17202            type Value = SharedLink;
17203            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17204                f.write_str("a SharedLink struct")
17205            }
17206            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17207                SharedLink::internal_deserialize(map)
17208            }
17209        }
17210        deserializer.deserialize_struct("SharedLink", SHARED_LINK_FIELDS, StructVisitor)
17211    }
17212}
17213
17214impl ::serde::ser::Serialize for SharedLink {
17215    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17216        // struct serializer
17217        use serde::ser::SerializeStruct;
17218        let mut s = serializer.serialize_struct("SharedLink", 2)?;
17219        self.internal_serialize::<S>(&mut s)?;
17220        s.end()
17221    }
17222}
17223
17224#[derive(Debug, Clone, PartialEq, Eq)]
17225#[non_exhaustive] // structs may have more fields added in the future.
17226pub struct SharedLinkFileInfo {
17227    /// The shared link corresponding to either a file or shared link to a folder. If it is for a
17228    /// folder shared link, we use the path param to determine for which file in the folder the view
17229    /// is for.
17230    pub url: String,
17231    /// The path corresponding to a file in a shared link to a folder. Required for shared links to
17232    /// folders.
17233    pub path: Option<String>,
17234    /// Password for the shared link. Required for password-protected shared links to files  unless
17235    /// it can be read from a cookie.
17236    pub password: Option<String>,
17237}
17238
17239impl SharedLinkFileInfo {
17240    pub fn new(url: String) -> Self {
17241        SharedLinkFileInfo {
17242            url,
17243            path: None,
17244            password: None,
17245        }
17246    }
17247
17248    pub fn with_path(mut self, value: String) -> Self {
17249        self.path = Some(value);
17250        self
17251    }
17252
17253    pub fn with_password(mut self, value: String) -> Self {
17254        self.password = Some(value);
17255        self
17256    }
17257}
17258
17259const SHARED_LINK_FILE_INFO_FIELDS: &[&str] = &["url",
17260                                                "path",
17261                                                "password"];
17262impl SharedLinkFileInfo {
17263    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17264        map: V,
17265    ) -> Result<SharedLinkFileInfo, V::Error> {
17266        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17267    }
17268
17269    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17270        mut map: V,
17271        optional: bool,
17272    ) -> Result<Option<SharedLinkFileInfo>, V::Error> {
17273        let mut field_url = None;
17274        let mut field_path = None;
17275        let mut field_password = None;
17276        let mut nothing = true;
17277        while let Some(key) = map.next_key::<&str>()? {
17278            nothing = false;
17279            match key {
17280                "url" => {
17281                    if field_url.is_some() {
17282                        return Err(::serde::de::Error::duplicate_field("url"));
17283                    }
17284                    field_url = Some(map.next_value()?);
17285                }
17286                "path" => {
17287                    if field_path.is_some() {
17288                        return Err(::serde::de::Error::duplicate_field("path"));
17289                    }
17290                    field_path = Some(map.next_value()?);
17291                }
17292                "password" => {
17293                    if field_password.is_some() {
17294                        return Err(::serde::de::Error::duplicate_field("password"));
17295                    }
17296                    field_password = Some(map.next_value()?);
17297                }
17298                _ => {
17299                    // unknown field allowed and ignored
17300                    map.next_value::<::serde_json::Value>()?;
17301                }
17302            }
17303        }
17304        if optional && nothing {
17305            return Ok(None);
17306        }
17307        let result = SharedLinkFileInfo {
17308            url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
17309            path: field_path.and_then(Option::flatten),
17310            password: field_password.and_then(Option::flatten),
17311        };
17312        Ok(Some(result))
17313    }
17314
17315    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17316        &self,
17317        s: &mut S::SerializeStruct,
17318    ) -> Result<(), S::Error> {
17319        use serde::ser::SerializeStruct;
17320        s.serialize_field("url", &self.url)?;
17321        if let Some(val) = &self.path {
17322            s.serialize_field("path", val)?;
17323        }
17324        if let Some(val) = &self.password {
17325            s.serialize_field("password", val)?;
17326        }
17327        Ok(())
17328    }
17329}
17330
17331impl<'de> ::serde::de::Deserialize<'de> for SharedLinkFileInfo {
17332    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17333        // struct deserializer
17334        use serde::de::{MapAccess, Visitor};
17335        struct StructVisitor;
17336        impl<'de> Visitor<'de> for StructVisitor {
17337            type Value = SharedLinkFileInfo;
17338            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17339                f.write_str("a SharedLinkFileInfo struct")
17340            }
17341            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17342                SharedLinkFileInfo::internal_deserialize(map)
17343            }
17344        }
17345        deserializer.deserialize_struct("SharedLinkFileInfo", SHARED_LINK_FILE_INFO_FIELDS, StructVisitor)
17346    }
17347}
17348
17349impl ::serde::ser::Serialize for SharedLinkFileInfo {
17350    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17351        // struct serializer
17352        use serde::ser::SerializeStruct;
17353        let mut s = serializer.serialize_struct("SharedLinkFileInfo", 3)?;
17354        self.internal_serialize::<S>(&mut s)?;
17355        s.end()
17356    }
17357}
17358
17359/// Sharing info for a file or folder.
17360#[derive(Debug, Clone, PartialEq, Eq)]
17361#[non_exhaustive] // structs may have more fields added in the future.
17362pub struct SharingInfo {
17363    /// True if the file or folder is inside a read-only shared folder.
17364    pub read_only: bool,
17365}
17366
17367impl SharingInfo {
17368    pub fn new(read_only: bool) -> Self {
17369        SharingInfo {
17370            read_only,
17371        }
17372    }
17373}
17374
17375const SHARING_INFO_FIELDS: &[&str] = &["read_only"];
17376impl SharingInfo {
17377    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17378        map: V,
17379    ) -> Result<SharingInfo, V::Error> {
17380        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17381    }
17382
17383    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17384        mut map: V,
17385        optional: bool,
17386    ) -> Result<Option<SharingInfo>, V::Error> {
17387        let mut field_read_only = None;
17388        let mut nothing = true;
17389        while let Some(key) = map.next_key::<&str>()? {
17390            nothing = false;
17391            match key {
17392                "read_only" => {
17393                    if field_read_only.is_some() {
17394                        return Err(::serde::de::Error::duplicate_field("read_only"));
17395                    }
17396                    field_read_only = Some(map.next_value()?);
17397                }
17398                _ => {
17399                    // unknown field allowed and ignored
17400                    map.next_value::<::serde_json::Value>()?;
17401                }
17402            }
17403        }
17404        if optional && nothing {
17405            return Ok(None);
17406        }
17407        let result = SharingInfo {
17408            read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
17409        };
17410        Ok(Some(result))
17411    }
17412
17413    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17414        &self,
17415        s: &mut S::SerializeStruct,
17416    ) -> Result<(), S::Error> {
17417        use serde::ser::SerializeStruct;
17418        s.serialize_field("read_only", &self.read_only)?;
17419        Ok(())
17420    }
17421}
17422
17423impl<'de> ::serde::de::Deserialize<'de> for SharingInfo {
17424    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17425        // struct deserializer
17426        use serde::de::{MapAccess, Visitor};
17427        struct StructVisitor;
17428        impl<'de> Visitor<'de> for StructVisitor {
17429            type Value = SharingInfo;
17430            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17431                f.write_str("a SharingInfo struct")
17432            }
17433            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17434                SharingInfo::internal_deserialize(map)
17435            }
17436        }
17437        deserializer.deserialize_struct("SharingInfo", SHARING_INFO_FIELDS, StructVisitor)
17438    }
17439}
17440
17441impl ::serde::ser::Serialize for SharingInfo {
17442    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17443        // struct serializer
17444        use serde::ser::SerializeStruct;
17445        let mut s = serializer.serialize_struct("SharingInfo", 1)?;
17446        self.internal_serialize::<S>(&mut s)?;
17447        s.end()
17448    }
17449}
17450
17451#[derive(Debug, Clone, PartialEq, Eq)]
17452#[non_exhaustive] // structs may have more fields added in the future.
17453pub struct SingleUserLock {
17454    /// The time the lock was created.
17455    pub created: crate::types::common::DropboxTimestamp,
17456    /// The account ID of the lock holder if known.
17457    pub lock_holder_account_id: crate::types::users_common::AccountId,
17458    /// The id of the team of the account holder if it exists.
17459    pub lock_holder_team_id: Option<String>,
17460}
17461
17462impl SingleUserLock {
17463    pub fn new(
17464        created: crate::types::common::DropboxTimestamp,
17465        lock_holder_account_id: crate::types::users_common::AccountId,
17466    ) -> Self {
17467        SingleUserLock {
17468            created,
17469            lock_holder_account_id,
17470            lock_holder_team_id: None,
17471        }
17472    }
17473
17474    pub fn with_lock_holder_team_id(mut self, value: String) -> Self {
17475        self.lock_holder_team_id = Some(value);
17476        self
17477    }
17478}
17479
17480const SINGLE_USER_LOCK_FIELDS: &[&str] = &["created",
17481                                           "lock_holder_account_id",
17482                                           "lock_holder_team_id"];
17483impl SingleUserLock {
17484    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17485        map: V,
17486    ) -> Result<SingleUserLock, V::Error> {
17487        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17488    }
17489
17490    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17491        mut map: V,
17492        optional: bool,
17493    ) -> Result<Option<SingleUserLock>, V::Error> {
17494        let mut field_created = None;
17495        let mut field_lock_holder_account_id = None;
17496        let mut field_lock_holder_team_id = None;
17497        let mut nothing = true;
17498        while let Some(key) = map.next_key::<&str>()? {
17499            nothing = false;
17500            match key {
17501                "created" => {
17502                    if field_created.is_some() {
17503                        return Err(::serde::de::Error::duplicate_field("created"));
17504                    }
17505                    field_created = Some(map.next_value()?);
17506                }
17507                "lock_holder_account_id" => {
17508                    if field_lock_holder_account_id.is_some() {
17509                        return Err(::serde::de::Error::duplicate_field("lock_holder_account_id"));
17510                    }
17511                    field_lock_holder_account_id = Some(map.next_value()?);
17512                }
17513                "lock_holder_team_id" => {
17514                    if field_lock_holder_team_id.is_some() {
17515                        return Err(::serde::de::Error::duplicate_field("lock_holder_team_id"));
17516                    }
17517                    field_lock_holder_team_id = Some(map.next_value()?);
17518                }
17519                _ => {
17520                    // unknown field allowed and ignored
17521                    map.next_value::<::serde_json::Value>()?;
17522                }
17523            }
17524        }
17525        if optional && nothing {
17526            return Ok(None);
17527        }
17528        let result = SingleUserLock {
17529            created: field_created.ok_or_else(|| ::serde::de::Error::missing_field("created"))?,
17530            lock_holder_account_id: field_lock_holder_account_id.ok_or_else(|| ::serde::de::Error::missing_field("lock_holder_account_id"))?,
17531            lock_holder_team_id: field_lock_holder_team_id.and_then(Option::flatten),
17532        };
17533        Ok(Some(result))
17534    }
17535
17536    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17537        &self,
17538        s: &mut S::SerializeStruct,
17539    ) -> Result<(), S::Error> {
17540        use serde::ser::SerializeStruct;
17541        s.serialize_field("created", &self.created)?;
17542        s.serialize_field("lock_holder_account_id", &self.lock_holder_account_id)?;
17543        if let Some(val) = &self.lock_holder_team_id {
17544            s.serialize_field("lock_holder_team_id", val)?;
17545        }
17546        Ok(())
17547    }
17548}
17549
17550impl<'de> ::serde::de::Deserialize<'de> for SingleUserLock {
17551    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17552        // struct deserializer
17553        use serde::de::{MapAccess, Visitor};
17554        struct StructVisitor;
17555        impl<'de> Visitor<'de> for StructVisitor {
17556            type Value = SingleUserLock;
17557            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17558                f.write_str("a SingleUserLock struct")
17559            }
17560            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17561                SingleUserLock::internal_deserialize(map)
17562            }
17563        }
17564        deserializer.deserialize_struct("SingleUserLock", SINGLE_USER_LOCK_FIELDS, StructVisitor)
17565    }
17566}
17567
17568impl ::serde::ser::Serialize for SingleUserLock {
17569    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17570        // struct serializer
17571        use serde::ser::SerializeStruct;
17572        let mut s = serializer.serialize_struct("SingleUserLock", 3)?;
17573        self.internal_serialize::<S>(&mut s)?;
17574        s.end()
17575    }
17576}
17577
17578#[derive(Debug, Clone, PartialEq, Eq)]
17579#[non_exhaustive] // structs may have more fields added in the future.
17580pub struct SymlinkInfo {
17581    /// The target this symlink points to.
17582    pub target: String,
17583}
17584
17585impl SymlinkInfo {
17586    pub fn new(target: String) -> Self {
17587        SymlinkInfo {
17588            target,
17589        }
17590    }
17591}
17592
17593const SYMLINK_INFO_FIELDS: &[&str] = &["target"];
17594impl SymlinkInfo {
17595    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17596        map: V,
17597    ) -> Result<SymlinkInfo, V::Error> {
17598        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17599    }
17600
17601    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17602        mut map: V,
17603        optional: bool,
17604    ) -> Result<Option<SymlinkInfo>, V::Error> {
17605        let mut field_target = None;
17606        let mut nothing = true;
17607        while let Some(key) = map.next_key::<&str>()? {
17608            nothing = false;
17609            match key {
17610                "target" => {
17611                    if field_target.is_some() {
17612                        return Err(::serde::de::Error::duplicate_field("target"));
17613                    }
17614                    field_target = Some(map.next_value()?);
17615                }
17616                _ => {
17617                    // unknown field allowed and ignored
17618                    map.next_value::<::serde_json::Value>()?;
17619                }
17620            }
17621        }
17622        if optional && nothing {
17623            return Ok(None);
17624        }
17625        let result = SymlinkInfo {
17626            target: field_target.ok_or_else(|| ::serde::de::Error::missing_field("target"))?,
17627        };
17628        Ok(Some(result))
17629    }
17630
17631    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17632        &self,
17633        s: &mut S::SerializeStruct,
17634    ) -> Result<(), S::Error> {
17635        use serde::ser::SerializeStruct;
17636        s.serialize_field("target", &self.target)?;
17637        Ok(())
17638    }
17639}
17640
17641impl<'de> ::serde::de::Deserialize<'de> for SymlinkInfo {
17642    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17643        // struct deserializer
17644        use serde::de::{MapAccess, Visitor};
17645        struct StructVisitor;
17646        impl<'de> Visitor<'de> for StructVisitor {
17647            type Value = SymlinkInfo;
17648            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17649                f.write_str("a SymlinkInfo struct")
17650            }
17651            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17652                SymlinkInfo::internal_deserialize(map)
17653            }
17654        }
17655        deserializer.deserialize_struct("SymlinkInfo", SYMLINK_INFO_FIELDS, StructVisitor)
17656    }
17657}
17658
17659impl ::serde::ser::Serialize for SymlinkInfo {
17660    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17661        // struct serializer
17662        use serde::ser::SerializeStruct;
17663        let mut s = serializer.serialize_struct("SymlinkInfo", 1)?;
17664        self.internal_serialize::<S>(&mut s)?;
17665        s.end()
17666    }
17667}
17668
17669#[derive(Debug, Clone, PartialEq, Eq)]
17670#[non_exhaustive] // variants may be added in the future
17671pub enum SyncSetting {
17672    /// On first sync to members' computers, the specified folder will follow its parent folder's
17673    /// setting or otherwise follow default sync behavior.
17674    Default,
17675    /// On first sync to members' computers, the specified folder will be set to not sync with
17676    /// selective sync.
17677    NotSynced,
17678    /// The specified folder's not_synced setting is inactive due to its location or other
17679    /// configuration changes. It will follow its parent folder's setting.
17680    NotSyncedInactive,
17681    /// Catch-all used for unrecognized values returned from the server. Encountering this value
17682    /// typically indicates that this SDK version is out of date.
17683    Other,
17684}
17685
17686impl<'de> ::serde::de::Deserialize<'de> for SyncSetting {
17687    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17688        // union deserializer
17689        use serde::de::{self, MapAccess, Visitor};
17690        struct EnumVisitor;
17691        impl<'de> Visitor<'de> for EnumVisitor {
17692            type Value = SyncSetting;
17693            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17694                f.write_str("a SyncSetting structure")
17695            }
17696            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
17697                let tag: &str = match map.next_key()? {
17698                    Some(".tag") => map.next_value()?,
17699                    _ => return Err(de::Error::missing_field(".tag"))
17700                };
17701                let value = match tag {
17702                    "default" => SyncSetting::Default,
17703                    "not_synced" => SyncSetting::NotSynced,
17704                    "not_synced_inactive" => SyncSetting::NotSyncedInactive,
17705                    _ => SyncSetting::Other,
17706                };
17707                crate::eat_json_fields(&mut map)?;
17708                Ok(value)
17709            }
17710        }
17711        const VARIANTS: &[&str] = &["default",
17712                                    "not_synced",
17713                                    "not_synced_inactive",
17714                                    "other"];
17715        deserializer.deserialize_struct("SyncSetting", VARIANTS, EnumVisitor)
17716    }
17717}
17718
17719impl ::serde::ser::Serialize for SyncSetting {
17720    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17721        // union serializer
17722        use serde::ser::SerializeStruct;
17723        match self {
17724            SyncSetting::Default => {
17725                // unit
17726                let mut s = serializer.serialize_struct("SyncSetting", 1)?;
17727                s.serialize_field(".tag", "default")?;
17728                s.end()
17729            }
17730            SyncSetting::NotSynced => {
17731                // unit
17732                let mut s = serializer.serialize_struct("SyncSetting", 1)?;
17733                s.serialize_field(".tag", "not_synced")?;
17734                s.end()
17735            }
17736            SyncSetting::NotSyncedInactive => {
17737                // unit
17738                let mut s = serializer.serialize_struct("SyncSetting", 1)?;
17739                s.serialize_field(".tag", "not_synced_inactive")?;
17740                s.end()
17741            }
17742            SyncSetting::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
17743        }
17744    }
17745}
17746
17747#[derive(Debug, Clone, PartialEq, Eq)]
17748#[non_exhaustive] // variants may be added in the future
17749pub enum SyncSettingArg {
17750    /// On first sync to members' computers, the specified folder will follow its parent folder's
17751    /// setting or otherwise follow default sync behavior.
17752    Default,
17753    /// On first sync to members' computers, the specified folder will be set to not sync with
17754    /// selective sync.
17755    NotSynced,
17756    /// Catch-all used for unrecognized values returned from the server. Encountering this value
17757    /// typically indicates that this SDK version is out of date.
17758    Other,
17759}
17760
17761impl<'de> ::serde::de::Deserialize<'de> for SyncSettingArg {
17762    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17763        // union deserializer
17764        use serde::de::{self, MapAccess, Visitor};
17765        struct EnumVisitor;
17766        impl<'de> Visitor<'de> for EnumVisitor {
17767            type Value = SyncSettingArg;
17768            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17769                f.write_str("a SyncSettingArg structure")
17770            }
17771            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
17772                let tag: &str = match map.next_key()? {
17773                    Some(".tag") => map.next_value()?,
17774                    _ => return Err(de::Error::missing_field(".tag"))
17775                };
17776                let value = match tag {
17777                    "default" => SyncSettingArg::Default,
17778                    "not_synced" => SyncSettingArg::NotSynced,
17779                    _ => SyncSettingArg::Other,
17780                };
17781                crate::eat_json_fields(&mut map)?;
17782                Ok(value)
17783            }
17784        }
17785        const VARIANTS: &[&str] = &["default",
17786                                    "not_synced",
17787                                    "other"];
17788        deserializer.deserialize_struct("SyncSettingArg", VARIANTS, EnumVisitor)
17789    }
17790}
17791
17792impl ::serde::ser::Serialize for SyncSettingArg {
17793    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17794        // union serializer
17795        use serde::ser::SerializeStruct;
17796        match self {
17797            SyncSettingArg::Default => {
17798                // unit
17799                let mut s = serializer.serialize_struct("SyncSettingArg", 1)?;
17800                s.serialize_field(".tag", "default")?;
17801                s.end()
17802            }
17803            SyncSettingArg::NotSynced => {
17804                // unit
17805                let mut s = serializer.serialize_struct("SyncSettingArg", 1)?;
17806                s.serialize_field(".tag", "not_synced")?;
17807                s.end()
17808            }
17809            SyncSettingArg::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
17810        }
17811    }
17812}
17813
17814#[derive(Debug, Clone, PartialEq, Eq)]
17815#[non_exhaustive] // variants may be added in the future
17816pub enum SyncSettingsError {
17817    Path(LookupError),
17818    /// Setting this combination of sync settings simultaneously is not supported.
17819    UnsupportedCombination,
17820    /// The specified configuration is not supported.
17821    UnsupportedConfiguration,
17822    /// Catch-all used for unrecognized values returned from the server. Encountering this value
17823    /// typically indicates that this SDK version is out of date.
17824    Other,
17825}
17826
17827impl<'de> ::serde::de::Deserialize<'de> for SyncSettingsError {
17828    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17829        // union deserializer
17830        use serde::de::{self, MapAccess, Visitor};
17831        struct EnumVisitor;
17832        impl<'de> Visitor<'de> for EnumVisitor {
17833            type Value = SyncSettingsError;
17834            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17835                f.write_str("a SyncSettingsError structure")
17836            }
17837            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
17838                let tag: &str = match map.next_key()? {
17839                    Some(".tag") => map.next_value()?,
17840                    _ => return Err(de::Error::missing_field(".tag"))
17841                };
17842                let value = match tag {
17843                    "path" => {
17844                        match map.next_key()? {
17845                            Some("path") => SyncSettingsError::Path(map.next_value()?),
17846                            None => return Err(de::Error::missing_field("path")),
17847                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
17848                        }
17849                    }
17850                    "unsupported_combination" => SyncSettingsError::UnsupportedCombination,
17851                    "unsupported_configuration" => SyncSettingsError::UnsupportedConfiguration,
17852                    _ => SyncSettingsError::Other,
17853                };
17854                crate::eat_json_fields(&mut map)?;
17855                Ok(value)
17856            }
17857        }
17858        const VARIANTS: &[&str] = &["path",
17859                                    "unsupported_combination",
17860                                    "unsupported_configuration",
17861                                    "other"];
17862        deserializer.deserialize_struct("SyncSettingsError", VARIANTS, EnumVisitor)
17863    }
17864}
17865
17866impl ::serde::ser::Serialize for SyncSettingsError {
17867    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17868        // union serializer
17869        use serde::ser::SerializeStruct;
17870        match self {
17871            SyncSettingsError::Path(x) => {
17872                // union or polymporphic struct
17873                let mut s = serializer.serialize_struct("SyncSettingsError", 2)?;
17874                s.serialize_field(".tag", "path")?;
17875                s.serialize_field("path", x)?;
17876                s.end()
17877            }
17878            SyncSettingsError::UnsupportedCombination => {
17879                // unit
17880                let mut s = serializer.serialize_struct("SyncSettingsError", 1)?;
17881                s.serialize_field(".tag", "unsupported_combination")?;
17882                s.end()
17883            }
17884            SyncSettingsError::UnsupportedConfiguration => {
17885                // unit
17886                let mut s = serializer.serialize_struct("SyncSettingsError", 1)?;
17887                s.serialize_field(".tag", "unsupported_configuration")?;
17888                s.end()
17889            }
17890            SyncSettingsError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
17891        }
17892    }
17893}
17894
17895impl ::std::error::Error for SyncSettingsError {
17896    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
17897        match self {
17898            SyncSettingsError::Path(inner) => Some(inner),
17899            _ => None,
17900        }
17901    }
17902}
17903
17904impl ::std::fmt::Display for SyncSettingsError {
17905    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17906        match self {
17907            SyncSettingsError::Path(inner) => write!(f, "SyncSettingsError: {}", inner),
17908            SyncSettingsError::UnsupportedCombination => f.write_str("Setting this combination of sync settings simultaneously is not supported."),
17909            SyncSettingsError::UnsupportedConfiguration => f.write_str("The specified configuration is not supported."),
17910            _ => write!(f, "{:?}", *self),
17911        }
17912    }
17913}
17914
17915/// Tag that can be added in multiple ways.
17916#[derive(Debug, Clone, PartialEq, Eq)]
17917#[non_exhaustive] // variants may be added in the future
17918pub enum Tag {
17919    /// Tag generated by the user.
17920    UserGeneratedTag(UserGeneratedTag),
17921    /// Catch-all used for unrecognized values returned from the server. Encountering this value
17922    /// typically indicates that this SDK version is out of date.
17923    Other,
17924}
17925
17926impl<'de> ::serde::de::Deserialize<'de> for Tag {
17927    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17928        // union deserializer
17929        use serde::de::{self, MapAccess, Visitor};
17930        struct EnumVisitor;
17931        impl<'de> Visitor<'de> for EnumVisitor {
17932            type Value = Tag;
17933            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17934                f.write_str("a Tag structure")
17935            }
17936            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
17937                let tag: &str = match map.next_key()? {
17938                    Some(".tag") => map.next_value()?,
17939                    _ => return Err(de::Error::missing_field(".tag"))
17940                };
17941                let value = match tag {
17942                    "user_generated_tag" => Tag::UserGeneratedTag(UserGeneratedTag::internal_deserialize(&mut map)?),
17943                    _ => Tag::Other,
17944                };
17945                crate::eat_json_fields(&mut map)?;
17946                Ok(value)
17947            }
17948        }
17949        const VARIANTS: &[&str] = &["user_generated_tag",
17950                                    "other"];
17951        deserializer.deserialize_struct("Tag", VARIANTS, EnumVisitor)
17952    }
17953}
17954
17955impl ::serde::ser::Serialize for Tag {
17956    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17957        // union serializer
17958        use serde::ser::SerializeStruct;
17959        match self {
17960            Tag::UserGeneratedTag(x) => {
17961                // struct
17962                let mut s = serializer.serialize_struct("Tag", 2)?;
17963                s.serialize_field(".tag", "user_generated_tag")?;
17964                x.internal_serialize::<S>(&mut s)?;
17965                s.end()
17966            }
17967            Tag::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
17968        }
17969    }
17970}
17971
17972#[derive(Debug, Clone, PartialEq, Eq)]
17973#[non_exhaustive] // structs may have more fields added in the future.
17974pub struct ThumbnailArg {
17975    /// The path to the image file you want to thumbnail.
17976    pub path: ReadPath,
17977    /// The format for the thumbnail image, jpeg (default) or png. For  images that are photos, jpeg
17978    /// should be preferred, while png is  better for screenshots and digital arts.
17979    pub format: ThumbnailFormat,
17980    /// The size for the thumbnail image.
17981    pub size: ThumbnailSize,
17982    /// How to resize and crop the image to achieve the desired size.
17983    pub mode: ThumbnailMode,
17984}
17985
17986impl ThumbnailArg {
17987    pub fn new(path: ReadPath) -> Self {
17988        ThumbnailArg {
17989            path,
17990            format: ThumbnailFormat::Jpeg,
17991            size: ThumbnailSize::W64h64,
17992            mode: ThumbnailMode::Strict,
17993        }
17994    }
17995
17996    pub fn with_format(mut self, value: ThumbnailFormat) -> Self {
17997        self.format = value;
17998        self
17999    }
18000
18001    pub fn with_size(mut self, value: ThumbnailSize) -> Self {
18002        self.size = value;
18003        self
18004    }
18005
18006    pub fn with_mode(mut self, value: ThumbnailMode) -> Self {
18007        self.mode = value;
18008        self
18009    }
18010}
18011
18012const THUMBNAIL_ARG_FIELDS: &[&str] = &["path",
18013                                        "format",
18014                                        "size",
18015                                        "mode"];
18016impl ThumbnailArg {
18017    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
18018        map: V,
18019    ) -> Result<ThumbnailArg, V::Error> {
18020        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
18021    }
18022
18023    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
18024        mut map: V,
18025        optional: bool,
18026    ) -> Result<Option<ThumbnailArg>, V::Error> {
18027        let mut field_path = None;
18028        let mut field_format = None;
18029        let mut field_size = None;
18030        let mut field_mode = None;
18031        let mut nothing = true;
18032        while let Some(key) = map.next_key::<&str>()? {
18033            nothing = false;
18034            match key {
18035                "path" => {
18036                    if field_path.is_some() {
18037                        return Err(::serde::de::Error::duplicate_field("path"));
18038                    }
18039                    field_path = Some(map.next_value()?);
18040                }
18041                "format" => {
18042                    if field_format.is_some() {
18043                        return Err(::serde::de::Error::duplicate_field("format"));
18044                    }
18045                    field_format = Some(map.next_value()?);
18046                }
18047                "size" => {
18048                    if field_size.is_some() {
18049                        return Err(::serde::de::Error::duplicate_field("size"));
18050                    }
18051                    field_size = Some(map.next_value()?);
18052                }
18053                "mode" => {
18054                    if field_mode.is_some() {
18055                        return Err(::serde::de::Error::duplicate_field("mode"));
18056                    }
18057                    field_mode = Some(map.next_value()?);
18058                }
18059                _ => {
18060                    // unknown field allowed and ignored
18061                    map.next_value::<::serde_json::Value>()?;
18062                }
18063            }
18064        }
18065        if optional && nothing {
18066            return Ok(None);
18067        }
18068        let result = ThumbnailArg {
18069            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
18070            format: field_format.unwrap_or(ThumbnailFormat::Jpeg),
18071            size: field_size.unwrap_or(ThumbnailSize::W64h64),
18072            mode: field_mode.unwrap_or(ThumbnailMode::Strict),
18073        };
18074        Ok(Some(result))
18075    }
18076
18077    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
18078        &self,
18079        s: &mut S::SerializeStruct,
18080    ) -> Result<(), S::Error> {
18081        use serde::ser::SerializeStruct;
18082        s.serialize_field("path", &self.path)?;
18083        if self.format != ThumbnailFormat::Jpeg {
18084            s.serialize_field("format", &self.format)?;
18085        }
18086        if self.size != ThumbnailSize::W64h64 {
18087            s.serialize_field("size", &self.size)?;
18088        }
18089        if self.mode != ThumbnailMode::Strict {
18090            s.serialize_field("mode", &self.mode)?;
18091        }
18092        Ok(())
18093    }
18094}
18095
18096impl<'de> ::serde::de::Deserialize<'de> for ThumbnailArg {
18097    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18098        // struct deserializer
18099        use serde::de::{MapAccess, Visitor};
18100        struct StructVisitor;
18101        impl<'de> Visitor<'de> for StructVisitor {
18102            type Value = ThumbnailArg;
18103            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18104                f.write_str("a ThumbnailArg struct")
18105            }
18106            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
18107                ThumbnailArg::internal_deserialize(map)
18108            }
18109        }
18110        deserializer.deserialize_struct("ThumbnailArg", THUMBNAIL_ARG_FIELDS, StructVisitor)
18111    }
18112}
18113
18114impl ::serde::ser::Serialize for ThumbnailArg {
18115    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18116        // struct serializer
18117        use serde::ser::SerializeStruct;
18118        let mut s = serializer.serialize_struct("ThumbnailArg", 4)?;
18119        self.internal_serialize::<S>(&mut s)?;
18120        s.end()
18121    }
18122}
18123
18124#[derive(Debug, Clone, PartialEq, Eq)]
18125pub enum ThumbnailError {
18126    /// An error occurs when downloading metadata for the image.
18127    Path(LookupError),
18128    /// The file extension doesn't allow conversion to a thumbnail.
18129    UnsupportedExtension,
18130    /// The image cannot be converted to a thumbnail.
18131    UnsupportedImage,
18132    /// An error occurs during thumbnail conversion.
18133    ConversionError,
18134}
18135
18136impl<'de> ::serde::de::Deserialize<'de> for ThumbnailError {
18137    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18138        // union deserializer
18139        use serde::de::{self, MapAccess, Visitor};
18140        struct EnumVisitor;
18141        impl<'de> Visitor<'de> for EnumVisitor {
18142            type Value = ThumbnailError;
18143            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18144                f.write_str("a ThumbnailError structure")
18145            }
18146            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18147                let tag: &str = match map.next_key()? {
18148                    Some(".tag") => map.next_value()?,
18149                    _ => return Err(de::Error::missing_field(".tag"))
18150                };
18151                let value = match tag {
18152                    "path" => {
18153                        match map.next_key()? {
18154                            Some("path") => ThumbnailError::Path(map.next_value()?),
18155                            None => return Err(de::Error::missing_field("path")),
18156                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
18157                        }
18158                    }
18159                    "unsupported_extension" => ThumbnailError::UnsupportedExtension,
18160                    "unsupported_image" => ThumbnailError::UnsupportedImage,
18161                    "conversion_error" => ThumbnailError::ConversionError,
18162                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18163                };
18164                crate::eat_json_fields(&mut map)?;
18165                Ok(value)
18166            }
18167        }
18168        const VARIANTS: &[&str] = &["path",
18169                                    "unsupported_extension",
18170                                    "unsupported_image",
18171                                    "conversion_error"];
18172        deserializer.deserialize_struct("ThumbnailError", VARIANTS, EnumVisitor)
18173    }
18174}
18175
18176impl ::serde::ser::Serialize for ThumbnailError {
18177    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18178        // union serializer
18179        use serde::ser::SerializeStruct;
18180        match self {
18181            ThumbnailError::Path(x) => {
18182                // union or polymporphic struct
18183                let mut s = serializer.serialize_struct("ThumbnailError", 2)?;
18184                s.serialize_field(".tag", "path")?;
18185                s.serialize_field("path", x)?;
18186                s.end()
18187            }
18188            ThumbnailError::UnsupportedExtension => {
18189                // unit
18190                let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18191                s.serialize_field(".tag", "unsupported_extension")?;
18192                s.end()
18193            }
18194            ThumbnailError::UnsupportedImage => {
18195                // unit
18196                let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18197                s.serialize_field(".tag", "unsupported_image")?;
18198                s.end()
18199            }
18200            ThumbnailError::ConversionError => {
18201                // unit
18202                let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18203                s.serialize_field(".tag", "conversion_error")?;
18204                s.end()
18205            }
18206        }
18207    }
18208}
18209
18210impl ::std::error::Error for ThumbnailError {
18211    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
18212        match self {
18213            ThumbnailError::Path(inner) => Some(inner),
18214            _ => None,
18215        }
18216    }
18217}
18218
18219impl ::std::fmt::Display for ThumbnailError {
18220    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18221        match self {
18222            ThumbnailError::Path(inner) => write!(f, "An error occurs when downloading metadata for the image: {}", inner),
18223            ThumbnailError::UnsupportedExtension => f.write_str("The file extension doesn't allow conversion to a thumbnail."),
18224            ThumbnailError::UnsupportedImage => f.write_str("The image cannot be converted to a thumbnail."),
18225            ThumbnailError::ConversionError => f.write_str("An error occurs during thumbnail conversion."),
18226        }
18227    }
18228}
18229
18230#[derive(Debug, Clone, PartialEq, Eq)]
18231pub enum ThumbnailFormat {
18232    Jpeg,
18233    Png,
18234}
18235
18236impl<'de> ::serde::de::Deserialize<'de> for ThumbnailFormat {
18237    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18238        // union deserializer
18239        use serde::de::{self, MapAccess, Visitor};
18240        struct EnumVisitor;
18241        impl<'de> Visitor<'de> for EnumVisitor {
18242            type Value = ThumbnailFormat;
18243            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18244                f.write_str("a ThumbnailFormat structure")
18245            }
18246            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18247                let tag: &str = match map.next_key()? {
18248                    Some(".tag") => map.next_value()?,
18249                    _ => return Err(de::Error::missing_field(".tag"))
18250                };
18251                let value = match tag {
18252                    "jpeg" => ThumbnailFormat::Jpeg,
18253                    "png" => ThumbnailFormat::Png,
18254                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18255                };
18256                crate::eat_json_fields(&mut map)?;
18257                Ok(value)
18258            }
18259        }
18260        const VARIANTS: &[&str] = &["jpeg",
18261                                    "png"];
18262        deserializer.deserialize_struct("ThumbnailFormat", VARIANTS, EnumVisitor)
18263    }
18264}
18265
18266impl ::serde::ser::Serialize for ThumbnailFormat {
18267    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18268        // union serializer
18269        use serde::ser::SerializeStruct;
18270        match self {
18271            ThumbnailFormat::Jpeg => {
18272                // unit
18273                let mut s = serializer.serialize_struct("ThumbnailFormat", 1)?;
18274                s.serialize_field(".tag", "jpeg")?;
18275                s.end()
18276            }
18277            ThumbnailFormat::Png => {
18278                // unit
18279                let mut s = serializer.serialize_struct("ThumbnailFormat", 1)?;
18280                s.serialize_field(".tag", "png")?;
18281                s.end()
18282            }
18283        }
18284    }
18285}
18286
18287#[derive(Debug, Clone, PartialEq, Eq)]
18288pub enum ThumbnailMode {
18289    /// Scale down the image to fit within the given size.
18290    Strict,
18291    /// Scale down the image to fit within the given size or its transpose.
18292    Bestfit,
18293    /// Scale down the image to completely cover the given size or its transpose.
18294    FitoneBestfit,
18295}
18296
18297impl<'de> ::serde::de::Deserialize<'de> for ThumbnailMode {
18298    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18299        // union deserializer
18300        use serde::de::{self, MapAccess, Visitor};
18301        struct EnumVisitor;
18302        impl<'de> Visitor<'de> for EnumVisitor {
18303            type Value = ThumbnailMode;
18304            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18305                f.write_str("a ThumbnailMode structure")
18306            }
18307            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18308                let tag: &str = match map.next_key()? {
18309                    Some(".tag") => map.next_value()?,
18310                    _ => return Err(de::Error::missing_field(".tag"))
18311                };
18312                let value = match tag {
18313                    "strict" => ThumbnailMode::Strict,
18314                    "bestfit" => ThumbnailMode::Bestfit,
18315                    "fitone_bestfit" => ThumbnailMode::FitoneBestfit,
18316                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18317                };
18318                crate::eat_json_fields(&mut map)?;
18319                Ok(value)
18320            }
18321        }
18322        const VARIANTS: &[&str] = &["strict",
18323                                    "bestfit",
18324                                    "fitone_bestfit"];
18325        deserializer.deserialize_struct("ThumbnailMode", VARIANTS, EnumVisitor)
18326    }
18327}
18328
18329impl ::serde::ser::Serialize for ThumbnailMode {
18330    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18331        // union serializer
18332        use serde::ser::SerializeStruct;
18333        match self {
18334            ThumbnailMode::Strict => {
18335                // unit
18336                let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18337                s.serialize_field(".tag", "strict")?;
18338                s.end()
18339            }
18340            ThumbnailMode::Bestfit => {
18341                // unit
18342                let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18343                s.serialize_field(".tag", "bestfit")?;
18344                s.end()
18345            }
18346            ThumbnailMode::FitoneBestfit => {
18347                // unit
18348                let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18349                s.serialize_field(".tag", "fitone_bestfit")?;
18350                s.end()
18351            }
18352        }
18353    }
18354}
18355
18356#[derive(Debug, Clone, PartialEq, Eq)]
18357pub enum ThumbnailSize {
18358    /// 32 by 32 px.
18359    W32h32,
18360    /// 64 by 64 px.
18361    W64h64,
18362    /// 128 by 128 px.
18363    W128h128,
18364    /// 256 by 256 px.
18365    W256h256,
18366    /// 480 by 320 px.
18367    W480h320,
18368    /// 640 by 480 px.
18369    W640h480,
18370    /// 960 by 640 px.
18371    W960h640,
18372    /// 1024 by 768 px.
18373    W1024h768,
18374    /// 2048 by 1536 px.
18375    W2048h1536,
18376}
18377
18378impl<'de> ::serde::de::Deserialize<'de> for ThumbnailSize {
18379    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18380        // union deserializer
18381        use serde::de::{self, MapAccess, Visitor};
18382        struct EnumVisitor;
18383        impl<'de> Visitor<'de> for EnumVisitor {
18384            type Value = ThumbnailSize;
18385            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18386                f.write_str("a ThumbnailSize structure")
18387            }
18388            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18389                let tag: &str = match map.next_key()? {
18390                    Some(".tag") => map.next_value()?,
18391                    _ => return Err(de::Error::missing_field(".tag"))
18392                };
18393                let value = match tag {
18394                    "w32h32" => ThumbnailSize::W32h32,
18395                    "w64h64" => ThumbnailSize::W64h64,
18396                    "w128h128" => ThumbnailSize::W128h128,
18397                    "w256h256" => ThumbnailSize::W256h256,
18398                    "w480h320" => ThumbnailSize::W480h320,
18399                    "w640h480" => ThumbnailSize::W640h480,
18400                    "w960h640" => ThumbnailSize::W960h640,
18401                    "w1024h768" => ThumbnailSize::W1024h768,
18402                    "w2048h1536" => ThumbnailSize::W2048h1536,
18403                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18404                };
18405                crate::eat_json_fields(&mut map)?;
18406                Ok(value)
18407            }
18408        }
18409        const VARIANTS: &[&str] = &["w32h32",
18410                                    "w64h64",
18411                                    "w128h128",
18412                                    "w256h256",
18413                                    "w480h320",
18414                                    "w640h480",
18415                                    "w960h640",
18416                                    "w1024h768",
18417                                    "w2048h1536"];
18418        deserializer.deserialize_struct("ThumbnailSize", VARIANTS, EnumVisitor)
18419    }
18420}
18421
18422impl ::serde::ser::Serialize for ThumbnailSize {
18423    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18424        // union serializer
18425        use serde::ser::SerializeStruct;
18426        match self {
18427            ThumbnailSize::W32h32 => {
18428                // unit
18429                let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18430                s.serialize_field(".tag", "w32h32")?;
18431                s.end()
18432            }
18433            ThumbnailSize::W64h64 => {
18434                // unit
18435                let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18436                s.serialize_field(".tag", "w64h64")?;
18437                s.end()
18438            }
18439            ThumbnailSize::W128h128 => {
18440                // unit
18441                let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18442                s.serialize_field(".tag", "w128h128")?;
18443                s.end()
18444            }
18445            ThumbnailSize::W256h256 => {
18446                // unit
18447                let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18448                s.serialize_field(".tag", "w256h256")?;
18449                s.end()
18450            }
18451            ThumbnailSize::W480h320 => {
18452                // unit
18453                let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18454                s.serialize_field(".tag", "w480h320")?;
18455                s.end()
18456            }
18457            ThumbnailSize::W640h480 => {
18458                // unit
18459                let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18460                s.serialize_field(".tag", "w640h480")?;
18461                s.end()
18462            }
18463            ThumbnailSize::W960h640 => {
18464                // unit
18465                let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18466                s.serialize_field(".tag", "w960h640")?;
18467                s.end()
18468            }
18469            ThumbnailSize::W1024h768 => {
18470                // unit
18471                let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18472                s.serialize_field(".tag", "w1024h768")?;
18473                s.end()
18474            }
18475            ThumbnailSize::W2048h1536 => {
18476                // unit
18477                let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18478                s.serialize_field(".tag", "w2048h1536")?;
18479                s.end()
18480            }
18481        }
18482    }
18483}
18484
18485#[derive(Debug, Clone, PartialEq, Eq)]
18486#[non_exhaustive] // structs may have more fields added in the future.
18487pub struct ThumbnailV2Arg {
18488    /// Information specifying which file to preview. This could be a path to a file, a shared link
18489    /// pointing to a file, or a shared link pointing to a folder, with a relative path.
18490    pub resource: PathOrLink,
18491    /// The format for the thumbnail image, jpeg (default) or png. For  images that are photos, jpeg
18492    /// should be preferred, while png is  better for screenshots and digital arts.
18493    pub format: ThumbnailFormat,
18494    /// The size for the thumbnail image.
18495    pub size: ThumbnailSize,
18496    /// How to resize and crop the image to achieve the desired size.
18497    pub mode: ThumbnailMode,
18498}
18499
18500impl ThumbnailV2Arg {
18501    pub fn new(resource: PathOrLink) -> Self {
18502        ThumbnailV2Arg {
18503            resource,
18504            format: ThumbnailFormat::Jpeg,
18505            size: ThumbnailSize::W64h64,
18506            mode: ThumbnailMode::Strict,
18507        }
18508    }
18509
18510    pub fn with_format(mut self, value: ThumbnailFormat) -> Self {
18511        self.format = value;
18512        self
18513    }
18514
18515    pub fn with_size(mut self, value: ThumbnailSize) -> Self {
18516        self.size = value;
18517        self
18518    }
18519
18520    pub fn with_mode(mut self, value: ThumbnailMode) -> Self {
18521        self.mode = value;
18522        self
18523    }
18524}
18525
18526const THUMBNAIL_V2_ARG_FIELDS: &[&str] = &["resource",
18527                                           "format",
18528                                           "size",
18529                                           "mode"];
18530impl ThumbnailV2Arg {
18531    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
18532        map: V,
18533    ) -> Result<ThumbnailV2Arg, V::Error> {
18534        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
18535    }
18536
18537    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
18538        mut map: V,
18539        optional: bool,
18540    ) -> Result<Option<ThumbnailV2Arg>, V::Error> {
18541        let mut field_resource = None;
18542        let mut field_format = None;
18543        let mut field_size = None;
18544        let mut field_mode = None;
18545        let mut nothing = true;
18546        while let Some(key) = map.next_key::<&str>()? {
18547            nothing = false;
18548            match key {
18549                "resource" => {
18550                    if field_resource.is_some() {
18551                        return Err(::serde::de::Error::duplicate_field("resource"));
18552                    }
18553                    field_resource = Some(map.next_value()?);
18554                }
18555                "format" => {
18556                    if field_format.is_some() {
18557                        return Err(::serde::de::Error::duplicate_field("format"));
18558                    }
18559                    field_format = Some(map.next_value()?);
18560                }
18561                "size" => {
18562                    if field_size.is_some() {
18563                        return Err(::serde::de::Error::duplicate_field("size"));
18564                    }
18565                    field_size = Some(map.next_value()?);
18566                }
18567                "mode" => {
18568                    if field_mode.is_some() {
18569                        return Err(::serde::de::Error::duplicate_field("mode"));
18570                    }
18571                    field_mode = Some(map.next_value()?);
18572                }
18573                _ => {
18574                    // unknown field allowed and ignored
18575                    map.next_value::<::serde_json::Value>()?;
18576                }
18577            }
18578        }
18579        if optional && nothing {
18580            return Ok(None);
18581        }
18582        let result = ThumbnailV2Arg {
18583            resource: field_resource.ok_or_else(|| ::serde::de::Error::missing_field("resource"))?,
18584            format: field_format.unwrap_or(ThumbnailFormat::Jpeg),
18585            size: field_size.unwrap_or(ThumbnailSize::W64h64),
18586            mode: field_mode.unwrap_or(ThumbnailMode::Strict),
18587        };
18588        Ok(Some(result))
18589    }
18590
18591    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
18592        &self,
18593        s: &mut S::SerializeStruct,
18594    ) -> Result<(), S::Error> {
18595        use serde::ser::SerializeStruct;
18596        s.serialize_field("resource", &self.resource)?;
18597        if self.format != ThumbnailFormat::Jpeg {
18598            s.serialize_field("format", &self.format)?;
18599        }
18600        if self.size != ThumbnailSize::W64h64 {
18601            s.serialize_field("size", &self.size)?;
18602        }
18603        if self.mode != ThumbnailMode::Strict {
18604            s.serialize_field("mode", &self.mode)?;
18605        }
18606        Ok(())
18607    }
18608}
18609
18610impl<'de> ::serde::de::Deserialize<'de> for ThumbnailV2Arg {
18611    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18612        // struct deserializer
18613        use serde::de::{MapAccess, Visitor};
18614        struct StructVisitor;
18615        impl<'de> Visitor<'de> for StructVisitor {
18616            type Value = ThumbnailV2Arg;
18617            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18618                f.write_str("a ThumbnailV2Arg struct")
18619            }
18620            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
18621                ThumbnailV2Arg::internal_deserialize(map)
18622            }
18623        }
18624        deserializer.deserialize_struct("ThumbnailV2Arg", THUMBNAIL_V2_ARG_FIELDS, StructVisitor)
18625    }
18626}
18627
18628impl ::serde::ser::Serialize for ThumbnailV2Arg {
18629    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18630        // struct serializer
18631        use serde::ser::SerializeStruct;
18632        let mut s = serializer.serialize_struct("ThumbnailV2Arg", 4)?;
18633        self.internal_serialize::<S>(&mut s)?;
18634        s.end()
18635    }
18636}
18637
18638#[derive(Debug, Clone, PartialEq, Eq)]
18639#[non_exhaustive] // variants may be added in the future
18640pub enum ThumbnailV2Error {
18641    /// An error occurred when downloading metadata for the image.
18642    Path(LookupError),
18643    /// The file extension doesn't allow conversion to a thumbnail.
18644    UnsupportedExtension,
18645    /// The image cannot be converted to a thumbnail.
18646    UnsupportedImage,
18647    /// An error occurred during thumbnail conversion.
18648    ConversionError,
18649    /// Access to this shared link is forbidden.
18650    AccessDenied,
18651    /// The shared link does not exist.
18652    NotFound,
18653    /// Catch-all used for unrecognized values returned from the server. Encountering this value
18654    /// typically indicates that this SDK version is out of date.
18655    Other,
18656}
18657
18658impl<'de> ::serde::de::Deserialize<'de> for ThumbnailV2Error {
18659    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18660        // union deserializer
18661        use serde::de::{self, MapAccess, Visitor};
18662        struct EnumVisitor;
18663        impl<'de> Visitor<'de> for EnumVisitor {
18664            type Value = ThumbnailV2Error;
18665            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18666                f.write_str("a ThumbnailV2Error structure")
18667            }
18668            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18669                let tag: &str = match map.next_key()? {
18670                    Some(".tag") => map.next_value()?,
18671                    _ => return Err(de::Error::missing_field(".tag"))
18672                };
18673                let value = match tag {
18674                    "path" => {
18675                        match map.next_key()? {
18676                            Some("path") => ThumbnailV2Error::Path(map.next_value()?),
18677                            None => return Err(de::Error::missing_field("path")),
18678                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
18679                        }
18680                    }
18681                    "unsupported_extension" => ThumbnailV2Error::UnsupportedExtension,
18682                    "unsupported_image" => ThumbnailV2Error::UnsupportedImage,
18683                    "conversion_error" => ThumbnailV2Error::ConversionError,
18684                    "access_denied" => ThumbnailV2Error::AccessDenied,
18685                    "not_found" => ThumbnailV2Error::NotFound,
18686                    _ => ThumbnailV2Error::Other,
18687                };
18688                crate::eat_json_fields(&mut map)?;
18689                Ok(value)
18690            }
18691        }
18692        const VARIANTS: &[&str] = &["path",
18693                                    "unsupported_extension",
18694                                    "unsupported_image",
18695                                    "conversion_error",
18696                                    "access_denied",
18697                                    "not_found",
18698                                    "other"];
18699        deserializer.deserialize_struct("ThumbnailV2Error", VARIANTS, EnumVisitor)
18700    }
18701}
18702
18703impl ::serde::ser::Serialize for ThumbnailV2Error {
18704    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18705        // union serializer
18706        use serde::ser::SerializeStruct;
18707        match self {
18708            ThumbnailV2Error::Path(x) => {
18709                // union or polymporphic struct
18710                let mut s = serializer.serialize_struct("ThumbnailV2Error", 2)?;
18711                s.serialize_field(".tag", "path")?;
18712                s.serialize_field("path", x)?;
18713                s.end()
18714            }
18715            ThumbnailV2Error::UnsupportedExtension => {
18716                // unit
18717                let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
18718                s.serialize_field(".tag", "unsupported_extension")?;
18719                s.end()
18720            }
18721            ThumbnailV2Error::UnsupportedImage => {
18722                // unit
18723                let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
18724                s.serialize_field(".tag", "unsupported_image")?;
18725                s.end()
18726            }
18727            ThumbnailV2Error::ConversionError => {
18728                // unit
18729                let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
18730                s.serialize_field(".tag", "conversion_error")?;
18731                s.end()
18732            }
18733            ThumbnailV2Error::AccessDenied => {
18734                // unit
18735                let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
18736                s.serialize_field(".tag", "access_denied")?;
18737                s.end()
18738            }
18739            ThumbnailV2Error::NotFound => {
18740                // unit
18741                let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
18742                s.serialize_field(".tag", "not_found")?;
18743                s.end()
18744            }
18745            ThumbnailV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
18746        }
18747    }
18748}
18749
18750impl ::std::error::Error for ThumbnailV2Error {
18751    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
18752        match self {
18753            ThumbnailV2Error::Path(inner) => Some(inner),
18754            _ => None,
18755        }
18756    }
18757}
18758
18759impl ::std::fmt::Display for ThumbnailV2Error {
18760    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18761        match self {
18762            ThumbnailV2Error::Path(inner) => write!(f, "An error occurred when downloading metadata for the image: {}", inner),
18763            ThumbnailV2Error::UnsupportedExtension => f.write_str("The file extension doesn't allow conversion to a thumbnail."),
18764            ThumbnailV2Error::UnsupportedImage => f.write_str("The image cannot be converted to a thumbnail."),
18765            ThumbnailV2Error::ConversionError => f.write_str("An error occurred during thumbnail conversion."),
18766            ThumbnailV2Error::AccessDenied => f.write_str("Access to this shared link is forbidden."),
18767            ThumbnailV2Error::NotFound => f.write_str("The shared link does not exist."),
18768            _ => write!(f, "{:?}", *self),
18769        }
18770    }
18771}
18772
18773#[derive(Debug, Clone, PartialEq, Eq)]
18774#[non_exhaustive] // structs may have more fields added in the future.
18775pub struct UnlockFileArg {
18776    /// Path in the user's Dropbox to a file.
18777    pub path: WritePathOrId,
18778}
18779
18780impl UnlockFileArg {
18781    pub fn new(path: WritePathOrId) -> Self {
18782        UnlockFileArg {
18783            path,
18784        }
18785    }
18786}
18787
18788const UNLOCK_FILE_ARG_FIELDS: &[&str] = &["path"];
18789impl UnlockFileArg {
18790    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
18791        map: V,
18792    ) -> Result<UnlockFileArg, V::Error> {
18793        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
18794    }
18795
18796    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
18797        mut map: V,
18798        optional: bool,
18799    ) -> Result<Option<UnlockFileArg>, V::Error> {
18800        let mut field_path = None;
18801        let mut nothing = true;
18802        while let Some(key) = map.next_key::<&str>()? {
18803            nothing = false;
18804            match key {
18805                "path" => {
18806                    if field_path.is_some() {
18807                        return Err(::serde::de::Error::duplicate_field("path"));
18808                    }
18809                    field_path = Some(map.next_value()?);
18810                }
18811                _ => {
18812                    // unknown field allowed and ignored
18813                    map.next_value::<::serde_json::Value>()?;
18814                }
18815            }
18816        }
18817        if optional && nothing {
18818            return Ok(None);
18819        }
18820        let result = UnlockFileArg {
18821            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
18822        };
18823        Ok(Some(result))
18824    }
18825
18826    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
18827        &self,
18828        s: &mut S::SerializeStruct,
18829    ) -> Result<(), S::Error> {
18830        use serde::ser::SerializeStruct;
18831        s.serialize_field("path", &self.path)?;
18832        Ok(())
18833    }
18834}
18835
18836impl<'de> ::serde::de::Deserialize<'de> for UnlockFileArg {
18837    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18838        // struct deserializer
18839        use serde::de::{MapAccess, Visitor};
18840        struct StructVisitor;
18841        impl<'de> Visitor<'de> for StructVisitor {
18842            type Value = UnlockFileArg;
18843            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18844                f.write_str("a UnlockFileArg struct")
18845            }
18846            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
18847                UnlockFileArg::internal_deserialize(map)
18848            }
18849        }
18850        deserializer.deserialize_struct("UnlockFileArg", UNLOCK_FILE_ARG_FIELDS, StructVisitor)
18851    }
18852}
18853
18854impl ::serde::ser::Serialize for UnlockFileArg {
18855    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18856        // struct serializer
18857        use serde::ser::SerializeStruct;
18858        let mut s = serializer.serialize_struct("UnlockFileArg", 1)?;
18859        self.internal_serialize::<S>(&mut s)?;
18860        s.end()
18861    }
18862}
18863
18864#[derive(Debug, Clone, PartialEq, Eq)]
18865#[non_exhaustive] // structs may have more fields added in the future.
18866pub struct UnlockFileBatchArg {
18867    /// List of 'entries'. Each 'entry' contains a path of the file which will be unlocked.
18868    /// Duplicate path arguments in the batch are considered only once.
18869    pub entries: Vec<UnlockFileArg>,
18870}
18871
18872impl UnlockFileBatchArg {
18873    pub fn new(entries: Vec<UnlockFileArg>) -> Self {
18874        UnlockFileBatchArg {
18875            entries,
18876        }
18877    }
18878}
18879
18880const UNLOCK_FILE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
18881impl UnlockFileBatchArg {
18882    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
18883        map: V,
18884    ) -> Result<UnlockFileBatchArg, V::Error> {
18885        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
18886    }
18887
18888    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
18889        mut map: V,
18890        optional: bool,
18891    ) -> Result<Option<UnlockFileBatchArg>, V::Error> {
18892        let mut field_entries = None;
18893        let mut nothing = true;
18894        while let Some(key) = map.next_key::<&str>()? {
18895            nothing = false;
18896            match key {
18897                "entries" => {
18898                    if field_entries.is_some() {
18899                        return Err(::serde::de::Error::duplicate_field("entries"));
18900                    }
18901                    field_entries = Some(map.next_value()?);
18902                }
18903                _ => {
18904                    // unknown field allowed and ignored
18905                    map.next_value::<::serde_json::Value>()?;
18906                }
18907            }
18908        }
18909        if optional && nothing {
18910            return Ok(None);
18911        }
18912        let result = UnlockFileBatchArg {
18913            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
18914        };
18915        Ok(Some(result))
18916    }
18917
18918    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
18919        &self,
18920        s: &mut S::SerializeStruct,
18921    ) -> Result<(), S::Error> {
18922        use serde::ser::SerializeStruct;
18923        s.serialize_field("entries", &self.entries)?;
18924        Ok(())
18925    }
18926}
18927
18928impl<'de> ::serde::de::Deserialize<'de> for UnlockFileBatchArg {
18929    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18930        // struct deserializer
18931        use serde::de::{MapAccess, Visitor};
18932        struct StructVisitor;
18933        impl<'de> Visitor<'de> for StructVisitor {
18934            type Value = UnlockFileBatchArg;
18935            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18936                f.write_str("a UnlockFileBatchArg struct")
18937            }
18938            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
18939                UnlockFileBatchArg::internal_deserialize(map)
18940            }
18941        }
18942        deserializer.deserialize_struct("UnlockFileBatchArg", UNLOCK_FILE_BATCH_ARG_FIELDS, StructVisitor)
18943    }
18944}
18945
18946impl ::serde::ser::Serialize for UnlockFileBatchArg {
18947    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18948        // struct serializer
18949        use serde::ser::SerializeStruct;
18950        let mut s = serializer.serialize_struct("UnlockFileBatchArg", 1)?;
18951        self.internal_serialize::<S>(&mut s)?;
18952        s.end()
18953    }
18954}
18955
18956#[derive(Debug, Clone, PartialEq, Eq)]
18957#[non_exhaustive] // structs may have more fields added in the future.
18958pub struct UploadArg {
18959    /// Path in the user's Dropbox to save the file.
18960    pub path: WritePathOrId,
18961    /// Selects what to do if the file already exists.
18962    pub mode: WriteMode,
18963    /// If there's a conflict, as determined by `mode`, have the Dropbox server try to autorename
18964    /// the file to avoid conflict.
18965    pub autorename: bool,
18966    /// The value to store as the `client_modified` timestamp. Dropbox automatically records the
18967    /// time at which the file was written to the Dropbox servers. It can also record an additional
18968    /// timestamp, provided by Dropbox desktop clients, mobile clients, and API apps of when the
18969    /// file was actually created or modified.
18970    pub client_modified: Option<crate::types::common::DropboxTimestamp>,
18971    /// Normally, users are made aware of any file modifications in their Dropbox account via
18972    /// notifications in the client software. If `true`, this tells the clients that this
18973    /// modification shouldn't result in a user notification.
18974    pub mute: bool,
18975    /// List of custom properties to add to file.
18976    pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
18977    /// Be more strict about how each [`WriteMode`] detects conflict. For example, always return a
18978    /// conflict error when `mode` = [`WriteMode::Update`] and the given "rev" doesn't match the
18979    /// existing file's "rev", even if the existing file has been deleted. This also forces a
18980    /// conflict even when the target path refers to a file with identical contents.
18981    pub strict_conflict: bool,
18982    /// A hash of the file content uploaded in this call. If provided and the uploaded content does
18983    /// not match this hash, an error will be returned. For more information see our [Content
18984    /// hash](https://www.dropbox.com/developers/reference/content-hash) page.
18985    pub content_hash: Option<Sha256HexHash>,
18986}
18987
18988impl UploadArg {
18989    pub fn new(path: WritePathOrId) -> Self {
18990        UploadArg {
18991            path,
18992            mode: WriteMode::Add,
18993            autorename: false,
18994            client_modified: None,
18995            mute: false,
18996            property_groups: None,
18997            strict_conflict: false,
18998            content_hash: None,
18999        }
19000    }
19001
19002    pub fn with_mode(mut self, value: WriteMode) -> Self {
19003        self.mode = value;
19004        self
19005    }
19006
19007    pub fn with_autorename(mut self, value: bool) -> Self {
19008        self.autorename = value;
19009        self
19010    }
19011
19012    pub fn with_client_modified(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
19013        self.client_modified = Some(value);
19014        self
19015    }
19016
19017    pub fn with_mute(mut self, value: bool) -> Self {
19018        self.mute = value;
19019        self
19020    }
19021
19022    pub fn with_property_groups(
19023        mut self,
19024        value: Vec<crate::types::file_properties::PropertyGroup>,
19025    ) -> Self {
19026        self.property_groups = Some(value);
19027        self
19028    }
19029
19030    pub fn with_strict_conflict(mut self, value: bool) -> Self {
19031        self.strict_conflict = value;
19032        self
19033    }
19034
19035    pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
19036        self.content_hash = Some(value);
19037        self
19038    }
19039}
19040
19041const UPLOAD_ARG_FIELDS: &[&str] = &["path",
19042                                     "mode",
19043                                     "autorename",
19044                                     "client_modified",
19045                                     "mute",
19046                                     "property_groups",
19047                                     "strict_conflict",
19048                                     "content_hash"];
19049impl UploadArg {
19050    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19051        map: V,
19052    ) -> Result<UploadArg, V::Error> {
19053        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19054    }
19055
19056    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19057        mut map: V,
19058        optional: bool,
19059    ) -> Result<Option<UploadArg>, V::Error> {
19060        let mut field_path = None;
19061        let mut field_mode = None;
19062        let mut field_autorename = None;
19063        let mut field_client_modified = None;
19064        let mut field_mute = None;
19065        let mut field_property_groups = None;
19066        let mut field_strict_conflict = None;
19067        let mut field_content_hash = None;
19068        let mut nothing = true;
19069        while let Some(key) = map.next_key::<&str>()? {
19070            nothing = false;
19071            match key {
19072                "path" => {
19073                    if field_path.is_some() {
19074                        return Err(::serde::de::Error::duplicate_field("path"));
19075                    }
19076                    field_path = Some(map.next_value()?);
19077                }
19078                "mode" => {
19079                    if field_mode.is_some() {
19080                        return Err(::serde::de::Error::duplicate_field("mode"));
19081                    }
19082                    field_mode = Some(map.next_value()?);
19083                }
19084                "autorename" => {
19085                    if field_autorename.is_some() {
19086                        return Err(::serde::de::Error::duplicate_field("autorename"));
19087                    }
19088                    field_autorename = Some(map.next_value()?);
19089                }
19090                "client_modified" => {
19091                    if field_client_modified.is_some() {
19092                        return Err(::serde::de::Error::duplicate_field("client_modified"));
19093                    }
19094                    field_client_modified = Some(map.next_value()?);
19095                }
19096                "mute" => {
19097                    if field_mute.is_some() {
19098                        return Err(::serde::de::Error::duplicate_field("mute"));
19099                    }
19100                    field_mute = Some(map.next_value()?);
19101                }
19102                "property_groups" => {
19103                    if field_property_groups.is_some() {
19104                        return Err(::serde::de::Error::duplicate_field("property_groups"));
19105                    }
19106                    field_property_groups = Some(map.next_value()?);
19107                }
19108                "strict_conflict" => {
19109                    if field_strict_conflict.is_some() {
19110                        return Err(::serde::de::Error::duplicate_field("strict_conflict"));
19111                    }
19112                    field_strict_conflict = Some(map.next_value()?);
19113                }
19114                "content_hash" => {
19115                    if field_content_hash.is_some() {
19116                        return Err(::serde::de::Error::duplicate_field("content_hash"));
19117                    }
19118                    field_content_hash = Some(map.next_value()?);
19119                }
19120                _ => {
19121                    // unknown field allowed and ignored
19122                    map.next_value::<::serde_json::Value>()?;
19123                }
19124            }
19125        }
19126        if optional && nothing {
19127            return Ok(None);
19128        }
19129        let result = UploadArg {
19130            path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
19131            mode: field_mode.unwrap_or(WriteMode::Add),
19132            autorename: field_autorename.unwrap_or(false),
19133            client_modified: field_client_modified.and_then(Option::flatten),
19134            mute: field_mute.unwrap_or(false),
19135            property_groups: field_property_groups.and_then(Option::flatten),
19136            strict_conflict: field_strict_conflict.unwrap_or(false),
19137            content_hash: field_content_hash.and_then(Option::flatten),
19138        };
19139        Ok(Some(result))
19140    }
19141
19142    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19143        &self,
19144        s: &mut S::SerializeStruct,
19145    ) -> Result<(), S::Error> {
19146        use serde::ser::SerializeStruct;
19147        s.serialize_field("path", &self.path)?;
19148        if self.mode != WriteMode::Add {
19149            s.serialize_field("mode", &self.mode)?;
19150        }
19151        if self.autorename {
19152            s.serialize_field("autorename", &self.autorename)?;
19153        }
19154        if let Some(val) = &self.client_modified {
19155            s.serialize_field("client_modified", val)?;
19156        }
19157        if self.mute {
19158            s.serialize_field("mute", &self.mute)?;
19159        }
19160        if let Some(val) = &self.property_groups {
19161            s.serialize_field("property_groups", val)?;
19162        }
19163        if self.strict_conflict {
19164            s.serialize_field("strict_conflict", &self.strict_conflict)?;
19165        }
19166        if let Some(val) = &self.content_hash {
19167            s.serialize_field("content_hash", val)?;
19168        }
19169        Ok(())
19170    }
19171}
19172
19173impl<'de> ::serde::de::Deserialize<'de> for UploadArg {
19174    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19175        // struct deserializer
19176        use serde::de::{MapAccess, Visitor};
19177        struct StructVisitor;
19178        impl<'de> Visitor<'de> for StructVisitor {
19179            type Value = UploadArg;
19180            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19181                f.write_str("a UploadArg struct")
19182            }
19183            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19184                UploadArg::internal_deserialize(map)
19185            }
19186        }
19187        deserializer.deserialize_struct("UploadArg", UPLOAD_ARG_FIELDS, StructVisitor)
19188    }
19189}
19190
19191impl ::serde::ser::Serialize for UploadArg {
19192    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19193        // struct serializer
19194        use serde::ser::SerializeStruct;
19195        let mut s = serializer.serialize_struct("UploadArg", 8)?;
19196        self.internal_serialize::<S>(&mut s)?;
19197        s.end()
19198    }
19199}
19200
19201// struct extends CommitInfo
19202impl From<UploadArg> for CommitInfo {
19203    fn from(subtype: UploadArg) -> Self {
19204        Self {
19205            path: subtype.path,
19206            mode: subtype.mode,
19207            autorename: subtype.autorename,
19208            client_modified: subtype.client_modified,
19209            mute: subtype.mute,
19210            property_groups: subtype.property_groups,
19211            strict_conflict: subtype.strict_conflict,
19212        }
19213    }
19214}
19215#[derive(Debug, Clone, PartialEq, Eq)]
19216#[non_exhaustive] // variants may be added in the future
19217pub enum UploadError {
19218    /// Unable to save the uploaded contents to a file.
19219    Path(UploadWriteFailed),
19220    /// The supplied property group is invalid. The file has uploaded without property groups.
19221    PropertiesError(crate::types::file_properties::InvalidPropertyGroupError),
19222    /// The request payload must be at most 150 MB.
19223    PayloadTooLarge,
19224    /// The content received by the Dropbox server in this call does not match the provided content
19225    /// hash.
19226    ContentHashMismatch,
19227    /// Catch-all used for unrecognized values returned from the server. Encountering this value
19228    /// typically indicates that this SDK version is out of date.
19229    Other,
19230}
19231
19232impl<'de> ::serde::de::Deserialize<'de> for UploadError {
19233    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19234        // union deserializer
19235        use serde::de::{self, MapAccess, Visitor};
19236        struct EnumVisitor;
19237        impl<'de> Visitor<'de> for EnumVisitor {
19238            type Value = UploadError;
19239            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19240                f.write_str("a UploadError structure")
19241            }
19242            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
19243                let tag: &str = match map.next_key()? {
19244                    Some(".tag") => map.next_value()?,
19245                    _ => return Err(de::Error::missing_field(".tag"))
19246                };
19247                let value = match tag {
19248                    "path" => UploadError::Path(UploadWriteFailed::internal_deserialize(&mut map)?),
19249                    "properties_error" => {
19250                        match map.next_key()? {
19251                            Some("properties_error") => UploadError::PropertiesError(map.next_value()?),
19252                            None => return Err(de::Error::missing_field("properties_error")),
19253                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
19254                        }
19255                    }
19256                    "payload_too_large" => UploadError::PayloadTooLarge,
19257                    "content_hash_mismatch" => UploadError::ContentHashMismatch,
19258                    _ => UploadError::Other,
19259                };
19260                crate::eat_json_fields(&mut map)?;
19261                Ok(value)
19262            }
19263        }
19264        const VARIANTS: &[&str] = &["path",
19265                                    "properties_error",
19266                                    "payload_too_large",
19267                                    "content_hash_mismatch",
19268                                    "other"];
19269        deserializer.deserialize_struct("UploadError", VARIANTS, EnumVisitor)
19270    }
19271}
19272
19273impl ::serde::ser::Serialize for UploadError {
19274    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19275        // union serializer
19276        use serde::ser::SerializeStruct;
19277        match self {
19278            UploadError::Path(x) => {
19279                // struct
19280                let mut s = serializer.serialize_struct("UploadError", 3)?;
19281                s.serialize_field(".tag", "path")?;
19282                x.internal_serialize::<S>(&mut s)?;
19283                s.end()
19284            }
19285            UploadError::PropertiesError(x) => {
19286                // union or polymporphic struct
19287                let mut s = serializer.serialize_struct("UploadError", 2)?;
19288                s.serialize_field(".tag", "properties_error")?;
19289                s.serialize_field("properties_error", x)?;
19290                s.end()
19291            }
19292            UploadError::PayloadTooLarge => {
19293                // unit
19294                let mut s = serializer.serialize_struct("UploadError", 1)?;
19295                s.serialize_field(".tag", "payload_too_large")?;
19296                s.end()
19297            }
19298            UploadError::ContentHashMismatch => {
19299                // unit
19300                let mut s = serializer.serialize_struct("UploadError", 1)?;
19301                s.serialize_field(".tag", "content_hash_mismatch")?;
19302                s.end()
19303            }
19304            UploadError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
19305        }
19306    }
19307}
19308
19309impl ::std::error::Error for UploadError {
19310    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
19311        match self {
19312            UploadError::PropertiesError(inner) => Some(inner),
19313            _ => None,
19314        }
19315    }
19316}
19317
19318impl ::std::fmt::Display for UploadError {
19319    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19320        match self {
19321            UploadError::Path(inner) => write!(f, "Unable to save the uploaded contents to a file: {:?}", inner),
19322            UploadError::PropertiesError(inner) => write!(f, "The supplied property group is invalid. The file has uploaded without property groups: {}", inner),
19323            UploadError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MB."),
19324            UploadError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
19325            _ => write!(f, "{:?}", *self),
19326        }
19327    }
19328}
19329
19330#[derive(Debug, Clone, PartialEq, Eq)]
19331#[non_exhaustive] // structs may have more fields added in the future.
19332pub struct UploadSessionAppendArg {
19333    /// Contains the upload session ID and the offset.
19334    pub cursor: UploadSessionCursor,
19335    /// If true, the current session will be closed, at which point you won't be able to call
19336    /// [`upload_session_append_v2()`](crate::files::upload_session_append_v2) anymore with the
19337    /// current session.
19338    pub close: bool,
19339    /// A hash of the file content uploaded in this call. If provided and the uploaded content does
19340    /// not match this hash, an error will be returned. For more information see our [Content
19341    /// hash](https://www.dropbox.com/developers/reference/content-hash) page.
19342    pub content_hash: Option<Sha256HexHash>,
19343}
19344
19345impl UploadSessionAppendArg {
19346    pub fn new(cursor: UploadSessionCursor) -> Self {
19347        UploadSessionAppendArg {
19348            cursor,
19349            close: false,
19350            content_hash: None,
19351        }
19352    }
19353
19354    pub fn with_close(mut self, value: bool) -> Self {
19355        self.close = value;
19356        self
19357    }
19358
19359    pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
19360        self.content_hash = Some(value);
19361        self
19362    }
19363}
19364
19365const UPLOAD_SESSION_APPEND_ARG_FIELDS: &[&str] = &["cursor",
19366                                                    "close",
19367                                                    "content_hash"];
19368impl UploadSessionAppendArg {
19369    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19370        map: V,
19371    ) -> Result<UploadSessionAppendArg, V::Error> {
19372        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19373    }
19374
19375    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19376        mut map: V,
19377        optional: bool,
19378    ) -> Result<Option<UploadSessionAppendArg>, V::Error> {
19379        let mut field_cursor = None;
19380        let mut field_close = None;
19381        let mut field_content_hash = None;
19382        let mut nothing = true;
19383        while let Some(key) = map.next_key::<&str>()? {
19384            nothing = false;
19385            match key {
19386                "cursor" => {
19387                    if field_cursor.is_some() {
19388                        return Err(::serde::de::Error::duplicate_field("cursor"));
19389                    }
19390                    field_cursor = Some(map.next_value()?);
19391                }
19392                "close" => {
19393                    if field_close.is_some() {
19394                        return Err(::serde::de::Error::duplicate_field("close"));
19395                    }
19396                    field_close = Some(map.next_value()?);
19397                }
19398                "content_hash" => {
19399                    if field_content_hash.is_some() {
19400                        return Err(::serde::de::Error::duplicate_field("content_hash"));
19401                    }
19402                    field_content_hash = Some(map.next_value()?);
19403                }
19404                _ => {
19405                    // unknown field allowed and ignored
19406                    map.next_value::<::serde_json::Value>()?;
19407                }
19408            }
19409        }
19410        if optional && nothing {
19411            return Ok(None);
19412        }
19413        let result = UploadSessionAppendArg {
19414            cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
19415            close: field_close.unwrap_or(false),
19416            content_hash: field_content_hash.and_then(Option::flatten),
19417        };
19418        Ok(Some(result))
19419    }
19420
19421    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19422        &self,
19423        s: &mut S::SerializeStruct,
19424    ) -> Result<(), S::Error> {
19425        use serde::ser::SerializeStruct;
19426        s.serialize_field("cursor", &self.cursor)?;
19427        if self.close {
19428            s.serialize_field("close", &self.close)?;
19429        }
19430        if let Some(val) = &self.content_hash {
19431            s.serialize_field("content_hash", val)?;
19432        }
19433        Ok(())
19434    }
19435}
19436
19437impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendArg {
19438    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19439        // struct deserializer
19440        use serde::de::{MapAccess, Visitor};
19441        struct StructVisitor;
19442        impl<'de> Visitor<'de> for StructVisitor {
19443            type Value = UploadSessionAppendArg;
19444            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19445                f.write_str("a UploadSessionAppendArg struct")
19446            }
19447            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19448                UploadSessionAppendArg::internal_deserialize(map)
19449            }
19450        }
19451        deserializer.deserialize_struct("UploadSessionAppendArg", UPLOAD_SESSION_APPEND_ARG_FIELDS, StructVisitor)
19452    }
19453}
19454
19455impl ::serde::ser::Serialize for UploadSessionAppendArg {
19456    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19457        // struct serializer
19458        use serde::ser::SerializeStruct;
19459        let mut s = serializer.serialize_struct("UploadSessionAppendArg", 3)?;
19460        self.internal_serialize::<S>(&mut s)?;
19461        s.end()
19462    }
19463}
19464
19465#[derive(Debug, Clone, PartialEq, Eq)]
19466#[non_exhaustive] // variants may be added in the future
19467pub enum UploadSessionAppendError {
19468    /// The upload session ID was not found or has expired. Upload sessions are valid for 7 days.
19469    NotFound,
19470    /// The specified offset was incorrect. See the value for the correct offset. This error may
19471    /// occur when a previous request was received and processed successfully but the client did not
19472    /// receive the response, e.g. due to a network error.
19473    IncorrectOffset(UploadSessionOffsetError),
19474    /// You are attempting to append data to an upload session that has already been closed (i.e.
19475    /// committed).
19476    Closed,
19477    /// The session must be closed before calling upload_session/finish_batch.
19478    NotClosed,
19479    /// You can not append to the upload session because the size of a file should not reach the max
19480    /// file size limit (i.e. 350GB).
19481    TooLarge,
19482    /// For concurrent upload sessions, offset needs to be multiple of 4194304 bytes.
19483    ConcurrentSessionInvalidOffset,
19484    /// For concurrent upload sessions, only chunks with size multiple of 4194304 bytes can be
19485    /// uploaded.
19486    ConcurrentSessionInvalidDataSize,
19487    /// The request payload must be at most 150 MB.
19488    PayloadTooLarge,
19489    /// The content received by the Dropbox server in this call does not match the provided content
19490    /// hash.
19491    ContentHashMismatch,
19492    /// Catch-all used for unrecognized values returned from the server. Encountering this value
19493    /// typically indicates that this SDK version is out of date.
19494    Other,
19495}
19496
19497impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendError {
19498    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19499        // union deserializer
19500        use serde::de::{self, MapAccess, Visitor};
19501        struct EnumVisitor;
19502        impl<'de> Visitor<'de> for EnumVisitor {
19503            type Value = UploadSessionAppendError;
19504            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19505                f.write_str("a UploadSessionAppendError structure")
19506            }
19507            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
19508                let tag: &str = match map.next_key()? {
19509                    Some(".tag") => map.next_value()?,
19510                    _ => return Err(de::Error::missing_field(".tag"))
19511                };
19512                let value = match tag {
19513                    "not_found" => UploadSessionAppendError::NotFound,
19514                    "incorrect_offset" => UploadSessionAppendError::IncorrectOffset(UploadSessionOffsetError::internal_deserialize(&mut map)?),
19515                    "closed" => UploadSessionAppendError::Closed,
19516                    "not_closed" => UploadSessionAppendError::NotClosed,
19517                    "too_large" => UploadSessionAppendError::TooLarge,
19518                    "concurrent_session_invalid_offset" => UploadSessionAppendError::ConcurrentSessionInvalidOffset,
19519                    "concurrent_session_invalid_data_size" => UploadSessionAppendError::ConcurrentSessionInvalidDataSize,
19520                    "payload_too_large" => UploadSessionAppendError::PayloadTooLarge,
19521                    "content_hash_mismatch" => UploadSessionAppendError::ContentHashMismatch,
19522                    _ => UploadSessionAppendError::Other,
19523                };
19524                crate::eat_json_fields(&mut map)?;
19525                Ok(value)
19526            }
19527        }
19528        const VARIANTS: &[&str] = &["not_found",
19529                                    "incorrect_offset",
19530                                    "closed",
19531                                    "not_closed",
19532                                    "too_large",
19533                                    "concurrent_session_invalid_offset",
19534                                    "concurrent_session_invalid_data_size",
19535                                    "payload_too_large",
19536                                    "other",
19537                                    "content_hash_mismatch"];
19538        deserializer.deserialize_struct("UploadSessionAppendError", VARIANTS, EnumVisitor)
19539    }
19540}
19541
19542impl ::serde::ser::Serialize for UploadSessionAppendError {
19543    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19544        // union serializer
19545        use serde::ser::SerializeStruct;
19546        match self {
19547            UploadSessionAppendError::NotFound => {
19548                // unit
19549                let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
19550                s.serialize_field(".tag", "not_found")?;
19551                s.end()
19552            }
19553            UploadSessionAppendError::IncorrectOffset(x) => {
19554                // struct
19555                let mut s = serializer.serialize_struct("UploadSessionAppendError", 2)?;
19556                s.serialize_field(".tag", "incorrect_offset")?;
19557                x.internal_serialize::<S>(&mut s)?;
19558                s.end()
19559            }
19560            UploadSessionAppendError::Closed => {
19561                // unit
19562                let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
19563                s.serialize_field(".tag", "closed")?;
19564                s.end()
19565            }
19566            UploadSessionAppendError::NotClosed => {
19567                // unit
19568                let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
19569                s.serialize_field(".tag", "not_closed")?;
19570                s.end()
19571            }
19572            UploadSessionAppendError::TooLarge => {
19573                // unit
19574                let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
19575                s.serialize_field(".tag", "too_large")?;
19576                s.end()
19577            }
19578            UploadSessionAppendError::ConcurrentSessionInvalidOffset => {
19579                // unit
19580                let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
19581                s.serialize_field(".tag", "concurrent_session_invalid_offset")?;
19582                s.end()
19583            }
19584            UploadSessionAppendError::ConcurrentSessionInvalidDataSize => {
19585                // unit
19586                let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
19587                s.serialize_field(".tag", "concurrent_session_invalid_data_size")?;
19588                s.end()
19589            }
19590            UploadSessionAppendError::PayloadTooLarge => {
19591                // unit
19592                let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
19593                s.serialize_field(".tag", "payload_too_large")?;
19594                s.end()
19595            }
19596            UploadSessionAppendError::ContentHashMismatch => {
19597                // unit
19598                let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
19599                s.serialize_field(".tag", "content_hash_mismatch")?;
19600                s.end()
19601            }
19602            UploadSessionAppendError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
19603        }
19604    }
19605}
19606
19607impl ::std::error::Error for UploadSessionAppendError {
19608}
19609
19610impl ::std::fmt::Display for UploadSessionAppendError {
19611    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19612        match self {
19613            UploadSessionAppendError::NotFound => f.write_str("The upload session ID was not found or has expired. Upload sessions are valid for 7 days."),
19614            UploadSessionAppendError::IncorrectOffset(inner) => write!(f, "The specified offset was incorrect. See the value for the correct offset. This error may occur when a previous request was received and processed successfully but the client did not receive the response, e.g. due to a network error: {:?}", inner),
19615            UploadSessionAppendError::Closed => f.write_str("You are attempting to append data to an upload session that has already been closed (i.e. committed)."),
19616            UploadSessionAppendError::NotClosed => f.write_str("The session must be closed before calling upload_session/finish_batch."),
19617            UploadSessionAppendError::TooLarge => f.write_str("You can not append to the upload session because the size of a file should not reach the max file size limit (i.e. 350GB)."),
19618            UploadSessionAppendError::ConcurrentSessionInvalidOffset => f.write_str("For concurrent upload sessions, offset needs to be multiple of 4194304 bytes."),
19619            UploadSessionAppendError::ConcurrentSessionInvalidDataSize => f.write_str("For concurrent upload sessions, only chunks with size multiple of 4194304 bytes can be uploaded."),
19620            UploadSessionAppendError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MB."),
19621            UploadSessionAppendError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
19622            _ => write!(f, "{:?}", *self),
19623        }
19624    }
19625}
19626
19627// union extends UploadSessionLookupError
19628impl From<UploadSessionLookupError> for UploadSessionAppendError {
19629    fn from(parent: UploadSessionLookupError) -> Self {
19630        match parent {
19631            UploadSessionLookupError::NotFound => UploadSessionAppendError::NotFound,
19632            UploadSessionLookupError::IncorrectOffset(x) => UploadSessionAppendError::IncorrectOffset(x),
19633            UploadSessionLookupError::Closed => UploadSessionAppendError::Closed,
19634            UploadSessionLookupError::NotClosed => UploadSessionAppendError::NotClosed,
19635            UploadSessionLookupError::TooLarge => UploadSessionAppendError::TooLarge,
19636            UploadSessionLookupError::ConcurrentSessionInvalidOffset => UploadSessionAppendError::ConcurrentSessionInvalidOffset,
19637            UploadSessionLookupError::ConcurrentSessionInvalidDataSize => UploadSessionAppendError::ConcurrentSessionInvalidDataSize,
19638            UploadSessionLookupError::PayloadTooLarge => UploadSessionAppendError::PayloadTooLarge,
19639            UploadSessionLookupError::Other => UploadSessionAppendError::Other,
19640        }
19641    }
19642}
19643#[derive(Debug, Clone, PartialEq, Eq)]
19644#[non_exhaustive] // structs may have more fields added in the future.
19645pub struct UploadSessionCursor {
19646    /// The upload session ID (returned by
19647    /// [`upload_session_start()`](crate::files::upload_session_start)).
19648    pub session_id: String,
19649    /// Offset in bytes at which data should be appended. We use this to make sure upload data isn't
19650    /// lost or duplicated in the event of a network error.
19651    pub offset: u64,
19652}
19653
19654impl UploadSessionCursor {
19655    pub fn new(session_id: String, offset: u64) -> Self {
19656        UploadSessionCursor {
19657            session_id,
19658            offset,
19659        }
19660    }
19661}
19662
19663const UPLOAD_SESSION_CURSOR_FIELDS: &[&str] = &["session_id",
19664                                                "offset"];
19665impl UploadSessionCursor {
19666    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19667        map: V,
19668    ) -> Result<UploadSessionCursor, V::Error> {
19669        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19670    }
19671
19672    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19673        mut map: V,
19674        optional: bool,
19675    ) -> Result<Option<UploadSessionCursor>, V::Error> {
19676        let mut field_session_id = None;
19677        let mut field_offset = None;
19678        let mut nothing = true;
19679        while let Some(key) = map.next_key::<&str>()? {
19680            nothing = false;
19681            match key {
19682                "session_id" => {
19683                    if field_session_id.is_some() {
19684                        return Err(::serde::de::Error::duplicate_field("session_id"));
19685                    }
19686                    field_session_id = Some(map.next_value()?);
19687                }
19688                "offset" => {
19689                    if field_offset.is_some() {
19690                        return Err(::serde::de::Error::duplicate_field("offset"));
19691                    }
19692                    field_offset = Some(map.next_value()?);
19693                }
19694                _ => {
19695                    // unknown field allowed and ignored
19696                    map.next_value::<::serde_json::Value>()?;
19697                }
19698            }
19699        }
19700        if optional && nothing {
19701            return Ok(None);
19702        }
19703        let result = UploadSessionCursor {
19704            session_id: field_session_id.ok_or_else(|| ::serde::de::Error::missing_field("session_id"))?,
19705            offset: field_offset.ok_or_else(|| ::serde::de::Error::missing_field("offset"))?,
19706        };
19707        Ok(Some(result))
19708    }
19709
19710    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19711        &self,
19712        s: &mut S::SerializeStruct,
19713    ) -> Result<(), S::Error> {
19714        use serde::ser::SerializeStruct;
19715        s.serialize_field("session_id", &self.session_id)?;
19716        s.serialize_field("offset", &self.offset)?;
19717        Ok(())
19718    }
19719}
19720
19721impl<'de> ::serde::de::Deserialize<'de> for UploadSessionCursor {
19722    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19723        // struct deserializer
19724        use serde::de::{MapAccess, Visitor};
19725        struct StructVisitor;
19726        impl<'de> Visitor<'de> for StructVisitor {
19727            type Value = UploadSessionCursor;
19728            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19729                f.write_str("a UploadSessionCursor struct")
19730            }
19731            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19732                UploadSessionCursor::internal_deserialize(map)
19733            }
19734        }
19735        deserializer.deserialize_struct("UploadSessionCursor", UPLOAD_SESSION_CURSOR_FIELDS, StructVisitor)
19736    }
19737}
19738
19739impl ::serde::ser::Serialize for UploadSessionCursor {
19740    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19741        // struct serializer
19742        use serde::ser::SerializeStruct;
19743        let mut s = serializer.serialize_struct("UploadSessionCursor", 2)?;
19744        self.internal_serialize::<S>(&mut s)?;
19745        s.end()
19746    }
19747}
19748
19749#[derive(Debug, Clone, PartialEq, Eq)]
19750#[non_exhaustive] // structs may have more fields added in the future.
19751pub struct UploadSessionFinishArg {
19752    /// Contains the upload session ID and the offset.
19753    pub cursor: UploadSessionCursor,
19754    /// Contains the path and other optional modifiers for the commit.
19755    pub commit: CommitInfo,
19756    /// A hash of the file content uploaded in this call. If provided and the uploaded content does
19757    /// not match this hash, an error will be returned. For more information see our [Content
19758    /// hash](https://www.dropbox.com/developers/reference/content-hash) page.
19759    pub content_hash: Option<Sha256HexHash>,
19760}
19761
19762impl UploadSessionFinishArg {
19763    pub fn new(cursor: UploadSessionCursor, commit: CommitInfo) -> Self {
19764        UploadSessionFinishArg {
19765            cursor,
19766            commit,
19767            content_hash: None,
19768        }
19769    }
19770
19771    pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
19772        self.content_hash = Some(value);
19773        self
19774    }
19775}
19776
19777const UPLOAD_SESSION_FINISH_ARG_FIELDS: &[&str] = &["cursor",
19778                                                    "commit",
19779                                                    "content_hash"];
19780impl UploadSessionFinishArg {
19781    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19782        map: V,
19783    ) -> Result<UploadSessionFinishArg, V::Error> {
19784        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19785    }
19786
19787    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19788        mut map: V,
19789        optional: bool,
19790    ) -> Result<Option<UploadSessionFinishArg>, V::Error> {
19791        let mut field_cursor = None;
19792        let mut field_commit = None;
19793        let mut field_content_hash = None;
19794        let mut nothing = true;
19795        while let Some(key) = map.next_key::<&str>()? {
19796            nothing = false;
19797            match key {
19798                "cursor" => {
19799                    if field_cursor.is_some() {
19800                        return Err(::serde::de::Error::duplicate_field("cursor"));
19801                    }
19802                    field_cursor = Some(map.next_value()?);
19803                }
19804                "commit" => {
19805                    if field_commit.is_some() {
19806                        return Err(::serde::de::Error::duplicate_field("commit"));
19807                    }
19808                    field_commit = Some(map.next_value()?);
19809                }
19810                "content_hash" => {
19811                    if field_content_hash.is_some() {
19812                        return Err(::serde::de::Error::duplicate_field("content_hash"));
19813                    }
19814                    field_content_hash = Some(map.next_value()?);
19815                }
19816                _ => {
19817                    // unknown field allowed and ignored
19818                    map.next_value::<::serde_json::Value>()?;
19819                }
19820            }
19821        }
19822        if optional && nothing {
19823            return Ok(None);
19824        }
19825        let result = UploadSessionFinishArg {
19826            cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
19827            commit: field_commit.ok_or_else(|| ::serde::de::Error::missing_field("commit"))?,
19828            content_hash: field_content_hash.and_then(Option::flatten),
19829        };
19830        Ok(Some(result))
19831    }
19832
19833    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19834        &self,
19835        s: &mut S::SerializeStruct,
19836    ) -> Result<(), S::Error> {
19837        use serde::ser::SerializeStruct;
19838        s.serialize_field("cursor", &self.cursor)?;
19839        s.serialize_field("commit", &self.commit)?;
19840        if let Some(val) = &self.content_hash {
19841            s.serialize_field("content_hash", val)?;
19842        }
19843        Ok(())
19844    }
19845}
19846
19847impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishArg {
19848    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19849        // struct deserializer
19850        use serde::de::{MapAccess, Visitor};
19851        struct StructVisitor;
19852        impl<'de> Visitor<'de> for StructVisitor {
19853            type Value = UploadSessionFinishArg;
19854            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19855                f.write_str("a UploadSessionFinishArg struct")
19856            }
19857            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19858                UploadSessionFinishArg::internal_deserialize(map)
19859            }
19860        }
19861        deserializer.deserialize_struct("UploadSessionFinishArg", UPLOAD_SESSION_FINISH_ARG_FIELDS, StructVisitor)
19862    }
19863}
19864
19865impl ::serde::ser::Serialize for UploadSessionFinishArg {
19866    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19867        // struct serializer
19868        use serde::ser::SerializeStruct;
19869        let mut s = serializer.serialize_struct("UploadSessionFinishArg", 3)?;
19870        self.internal_serialize::<S>(&mut s)?;
19871        s.end()
19872    }
19873}
19874
19875#[derive(Debug, Clone, PartialEq, Eq)]
19876#[non_exhaustive] // structs may have more fields added in the future.
19877pub struct UploadSessionFinishBatchArg {
19878    /// Commit information for each file in the batch.
19879    pub entries: Vec<UploadSessionFinishArg>,
19880}
19881
19882impl UploadSessionFinishBatchArg {
19883    pub fn new(entries: Vec<UploadSessionFinishArg>) -> Self {
19884        UploadSessionFinishBatchArg {
19885            entries,
19886        }
19887    }
19888}
19889
19890const UPLOAD_SESSION_FINISH_BATCH_ARG_FIELDS: &[&str] = &["entries"];
19891impl UploadSessionFinishBatchArg {
19892    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19893        map: V,
19894    ) -> Result<UploadSessionFinishBatchArg, V::Error> {
19895        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19896    }
19897
19898    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19899        mut map: V,
19900        optional: bool,
19901    ) -> Result<Option<UploadSessionFinishBatchArg>, V::Error> {
19902        let mut field_entries = None;
19903        let mut nothing = true;
19904        while let Some(key) = map.next_key::<&str>()? {
19905            nothing = false;
19906            match key {
19907                "entries" => {
19908                    if field_entries.is_some() {
19909                        return Err(::serde::de::Error::duplicate_field("entries"));
19910                    }
19911                    field_entries = Some(map.next_value()?);
19912                }
19913                _ => {
19914                    // unknown field allowed and ignored
19915                    map.next_value::<::serde_json::Value>()?;
19916                }
19917            }
19918        }
19919        if optional && nothing {
19920            return Ok(None);
19921        }
19922        let result = UploadSessionFinishBatchArg {
19923            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
19924        };
19925        Ok(Some(result))
19926    }
19927
19928    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19929        &self,
19930        s: &mut S::SerializeStruct,
19931    ) -> Result<(), S::Error> {
19932        use serde::ser::SerializeStruct;
19933        s.serialize_field("entries", &self.entries)?;
19934        Ok(())
19935    }
19936}
19937
19938impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchArg {
19939    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19940        // struct deserializer
19941        use serde::de::{MapAccess, Visitor};
19942        struct StructVisitor;
19943        impl<'de> Visitor<'de> for StructVisitor {
19944            type Value = UploadSessionFinishBatchArg;
19945            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19946                f.write_str("a UploadSessionFinishBatchArg struct")
19947            }
19948            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19949                UploadSessionFinishBatchArg::internal_deserialize(map)
19950            }
19951        }
19952        deserializer.deserialize_struct("UploadSessionFinishBatchArg", UPLOAD_SESSION_FINISH_BATCH_ARG_FIELDS, StructVisitor)
19953    }
19954}
19955
19956impl ::serde::ser::Serialize for UploadSessionFinishBatchArg {
19957    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19958        // struct serializer
19959        use serde::ser::SerializeStruct;
19960        let mut s = serializer.serialize_struct("UploadSessionFinishBatchArg", 1)?;
19961        self.internal_serialize::<S>(&mut s)?;
19962        s.end()
19963    }
19964}
19965
19966#[derive(Debug, Clone, PartialEq)]
19967pub enum UploadSessionFinishBatchJobStatus {
19968    /// The asynchronous job is still in progress.
19969    InProgress,
19970    /// The [`upload_session_finish_batch()`](crate::files::upload_session_finish_batch) has
19971    /// finished.
19972    Complete(UploadSessionFinishBatchResult),
19973}
19974
19975impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchJobStatus {
19976    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19977        // union deserializer
19978        use serde::de::{self, MapAccess, Visitor};
19979        struct EnumVisitor;
19980        impl<'de> Visitor<'de> for EnumVisitor {
19981            type Value = UploadSessionFinishBatchJobStatus;
19982            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19983                f.write_str("a UploadSessionFinishBatchJobStatus structure")
19984            }
19985            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
19986                let tag: &str = match map.next_key()? {
19987                    Some(".tag") => map.next_value()?,
19988                    _ => return Err(de::Error::missing_field(".tag"))
19989                };
19990                let value = match tag {
19991                    "in_progress" => UploadSessionFinishBatchJobStatus::InProgress,
19992                    "complete" => UploadSessionFinishBatchJobStatus::Complete(UploadSessionFinishBatchResult::internal_deserialize(&mut map)?),
19993                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
19994                };
19995                crate::eat_json_fields(&mut map)?;
19996                Ok(value)
19997            }
19998        }
19999        const VARIANTS: &[&str] = &["in_progress",
20000                                    "complete"];
20001        deserializer.deserialize_struct("UploadSessionFinishBatchJobStatus", VARIANTS, EnumVisitor)
20002    }
20003}
20004
20005impl ::serde::ser::Serialize for UploadSessionFinishBatchJobStatus {
20006    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20007        // union serializer
20008        use serde::ser::SerializeStruct;
20009        match self {
20010            UploadSessionFinishBatchJobStatus::InProgress => {
20011                // unit
20012                let mut s = serializer.serialize_struct("UploadSessionFinishBatchJobStatus", 1)?;
20013                s.serialize_field(".tag", "in_progress")?;
20014                s.end()
20015            }
20016            UploadSessionFinishBatchJobStatus::Complete(x) => {
20017                // struct
20018                let mut s = serializer.serialize_struct("UploadSessionFinishBatchJobStatus", 2)?;
20019                s.serialize_field(".tag", "complete")?;
20020                x.internal_serialize::<S>(&mut s)?;
20021                s.end()
20022            }
20023        }
20024    }
20025}
20026
20027// union extends crate::types::dbx_async::PollResultBase
20028impl From<crate::types::dbx_async::PollResultBase> for UploadSessionFinishBatchJobStatus {
20029    fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
20030        match parent {
20031            crate::types::dbx_async::PollResultBase::InProgress => UploadSessionFinishBatchJobStatus::InProgress,
20032        }
20033    }
20034}
20035/// Result returned by [`upload_session_finish_batch()`](crate::files::upload_session_finish_batch)
20036/// that may either launch an asynchronous job or complete synchronously.
20037#[derive(Debug, Clone, PartialEq)]
20038#[non_exhaustive] // variants may be added in the future
20039pub enum UploadSessionFinishBatchLaunch {
20040    /// This response indicates that the processing is asynchronous. The string is an id that can be
20041    /// used to obtain the status of the asynchronous job.
20042    AsyncJobId(crate::types::dbx_async::AsyncJobId),
20043    Complete(UploadSessionFinishBatchResult),
20044    /// Catch-all used for unrecognized values returned from the server. Encountering this value
20045    /// typically indicates that this SDK version is out of date.
20046    Other,
20047}
20048
20049impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchLaunch {
20050    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20051        // union deserializer
20052        use serde::de::{self, MapAccess, Visitor};
20053        struct EnumVisitor;
20054        impl<'de> Visitor<'de> for EnumVisitor {
20055            type Value = UploadSessionFinishBatchLaunch;
20056            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20057                f.write_str("a UploadSessionFinishBatchLaunch structure")
20058            }
20059            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20060                let tag: &str = match map.next_key()? {
20061                    Some(".tag") => map.next_value()?,
20062                    _ => return Err(de::Error::missing_field(".tag"))
20063                };
20064                let value = match tag {
20065                    "async_job_id" => {
20066                        match map.next_key()? {
20067                            Some("async_job_id") => UploadSessionFinishBatchLaunch::AsyncJobId(map.next_value()?),
20068                            None => return Err(de::Error::missing_field("async_job_id")),
20069                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
20070                        }
20071                    }
20072                    "complete" => UploadSessionFinishBatchLaunch::Complete(UploadSessionFinishBatchResult::internal_deserialize(&mut map)?),
20073                    _ => UploadSessionFinishBatchLaunch::Other,
20074                };
20075                crate::eat_json_fields(&mut map)?;
20076                Ok(value)
20077            }
20078        }
20079        const VARIANTS: &[&str] = &["async_job_id",
20080                                    "complete",
20081                                    "other"];
20082        deserializer.deserialize_struct("UploadSessionFinishBatchLaunch", VARIANTS, EnumVisitor)
20083    }
20084}
20085
20086impl ::serde::ser::Serialize for UploadSessionFinishBatchLaunch {
20087    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20088        // union serializer
20089        use serde::ser::SerializeStruct;
20090        match self {
20091            UploadSessionFinishBatchLaunch::AsyncJobId(x) => {
20092                // primitive
20093                let mut s = serializer.serialize_struct("UploadSessionFinishBatchLaunch", 2)?;
20094                s.serialize_field(".tag", "async_job_id")?;
20095                s.serialize_field("async_job_id", x)?;
20096                s.end()
20097            }
20098            UploadSessionFinishBatchLaunch::Complete(x) => {
20099                // struct
20100                let mut s = serializer.serialize_struct("UploadSessionFinishBatchLaunch", 2)?;
20101                s.serialize_field(".tag", "complete")?;
20102                x.internal_serialize::<S>(&mut s)?;
20103                s.end()
20104            }
20105            UploadSessionFinishBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
20106        }
20107    }
20108}
20109
20110// union extends crate::types::dbx_async::LaunchResultBase
20111impl From<crate::types::dbx_async::LaunchResultBase> for UploadSessionFinishBatchLaunch {
20112    fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
20113        match parent {
20114            crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => UploadSessionFinishBatchLaunch::AsyncJobId(x),
20115        }
20116    }
20117}
20118#[derive(Debug, Clone, PartialEq)]
20119#[non_exhaustive] // structs may have more fields added in the future.
20120pub struct UploadSessionFinishBatchResult {
20121    /// Each entry in [`UploadSessionFinishBatchArg::entries`](UploadSessionFinishBatchArg) will
20122    /// appear at the same position inside
20123    /// [`UploadSessionFinishBatchResult::entries`](UploadSessionFinishBatchResult).
20124    pub entries: Vec<UploadSessionFinishBatchResultEntry>,
20125}
20126
20127impl UploadSessionFinishBatchResult {
20128    pub fn new(entries: Vec<UploadSessionFinishBatchResultEntry>) -> Self {
20129        UploadSessionFinishBatchResult {
20130            entries,
20131        }
20132    }
20133}
20134
20135const UPLOAD_SESSION_FINISH_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
20136impl UploadSessionFinishBatchResult {
20137    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20138        map: V,
20139    ) -> Result<UploadSessionFinishBatchResult, V::Error> {
20140        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20141    }
20142
20143    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20144        mut map: V,
20145        optional: bool,
20146    ) -> Result<Option<UploadSessionFinishBatchResult>, V::Error> {
20147        let mut field_entries = None;
20148        let mut nothing = true;
20149        while let Some(key) = map.next_key::<&str>()? {
20150            nothing = false;
20151            match key {
20152                "entries" => {
20153                    if field_entries.is_some() {
20154                        return Err(::serde::de::Error::duplicate_field("entries"));
20155                    }
20156                    field_entries = Some(map.next_value()?);
20157                }
20158                _ => {
20159                    // unknown field allowed and ignored
20160                    map.next_value::<::serde_json::Value>()?;
20161                }
20162            }
20163        }
20164        if optional && nothing {
20165            return Ok(None);
20166        }
20167        let result = UploadSessionFinishBatchResult {
20168            entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
20169        };
20170        Ok(Some(result))
20171    }
20172
20173    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20174        &self,
20175        s: &mut S::SerializeStruct,
20176    ) -> Result<(), S::Error> {
20177        use serde::ser::SerializeStruct;
20178        s.serialize_field("entries", &self.entries)?;
20179        Ok(())
20180    }
20181}
20182
20183impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchResult {
20184    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20185        // struct deserializer
20186        use serde::de::{MapAccess, Visitor};
20187        struct StructVisitor;
20188        impl<'de> Visitor<'de> for StructVisitor {
20189            type Value = UploadSessionFinishBatchResult;
20190            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20191                f.write_str("a UploadSessionFinishBatchResult struct")
20192            }
20193            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20194                UploadSessionFinishBatchResult::internal_deserialize(map)
20195            }
20196        }
20197        deserializer.deserialize_struct("UploadSessionFinishBatchResult", UPLOAD_SESSION_FINISH_BATCH_RESULT_FIELDS, StructVisitor)
20198    }
20199}
20200
20201impl ::serde::ser::Serialize for UploadSessionFinishBatchResult {
20202    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20203        // struct serializer
20204        use serde::ser::SerializeStruct;
20205        let mut s = serializer.serialize_struct("UploadSessionFinishBatchResult", 1)?;
20206        self.internal_serialize::<S>(&mut s)?;
20207        s.end()
20208    }
20209}
20210
20211#[derive(Debug, Clone, PartialEq)]
20212pub enum UploadSessionFinishBatchResultEntry {
20213    Success(FileMetadata),
20214    Failure(UploadSessionFinishError),
20215}
20216
20217impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchResultEntry {
20218    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20219        // union deserializer
20220        use serde::de::{self, MapAccess, Visitor};
20221        struct EnumVisitor;
20222        impl<'de> Visitor<'de> for EnumVisitor {
20223            type Value = UploadSessionFinishBatchResultEntry;
20224            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20225                f.write_str("a UploadSessionFinishBatchResultEntry structure")
20226            }
20227            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20228                let tag: &str = match map.next_key()? {
20229                    Some(".tag") => map.next_value()?,
20230                    _ => return Err(de::Error::missing_field(".tag"))
20231                };
20232                let value = match tag {
20233                    "success" => UploadSessionFinishBatchResultEntry::Success(FileMetadata::internal_deserialize(&mut map)?),
20234                    "failure" => {
20235                        match map.next_key()? {
20236                            Some("failure") => UploadSessionFinishBatchResultEntry::Failure(map.next_value()?),
20237                            None => return Err(de::Error::missing_field("failure")),
20238                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
20239                        }
20240                    }
20241                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
20242                };
20243                crate::eat_json_fields(&mut map)?;
20244                Ok(value)
20245            }
20246        }
20247        const VARIANTS: &[&str] = &["success",
20248                                    "failure"];
20249        deserializer.deserialize_struct("UploadSessionFinishBatchResultEntry", VARIANTS, EnumVisitor)
20250    }
20251}
20252
20253impl ::serde::ser::Serialize for UploadSessionFinishBatchResultEntry {
20254    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20255        // union serializer
20256        use serde::ser::SerializeStruct;
20257        match self {
20258            UploadSessionFinishBatchResultEntry::Success(x) => {
20259                // struct
20260                let mut s = serializer.serialize_struct("UploadSessionFinishBatchResultEntry", 20)?;
20261                s.serialize_field(".tag", "success")?;
20262                x.internal_serialize::<S>(&mut s)?;
20263                s.end()
20264            }
20265            UploadSessionFinishBatchResultEntry::Failure(x) => {
20266                // union or polymporphic struct
20267                let mut s = serializer.serialize_struct("UploadSessionFinishBatchResultEntry", 2)?;
20268                s.serialize_field(".tag", "failure")?;
20269                s.serialize_field("failure", x)?;
20270                s.end()
20271            }
20272        }
20273    }
20274}
20275
20276#[derive(Debug, Clone, PartialEq, Eq)]
20277#[non_exhaustive] // variants may be added in the future
20278pub enum UploadSessionFinishError {
20279    /// The session arguments are incorrect; the value explains the reason.
20280    LookupFailed(UploadSessionLookupError),
20281    /// Unable to save the uploaded contents to a file. Data has already been appended to the upload
20282    /// session. Please retry with empty data body and updated offset.
20283    Path(WriteError),
20284    /// The supplied property group is invalid. The file has uploaded without property groups.
20285    PropertiesError(crate::types::file_properties::InvalidPropertyGroupError),
20286    /// The batch request commits files into too many different shared folders. Please limit your
20287    /// batch request to files contained in a single shared folder.
20288    TooManySharedFolderTargets,
20289    /// There are too many write operations happening in the user's Dropbox. You should retry
20290    /// uploading this file.
20291    TooManyWriteOperations,
20292    /// Uploading data not allowed when finishing concurrent upload session.
20293    ConcurrentSessionDataNotAllowed,
20294    /// Concurrent upload sessions need to be closed before finishing.
20295    ConcurrentSessionNotClosed,
20296    /// Not all pieces of data were uploaded before trying to finish the session.
20297    ConcurrentSessionMissingData,
20298    /// The request payload must be at most 150 MB.
20299    PayloadTooLarge,
20300    /// The content received by the Dropbox server in this call does not match the provided content
20301    /// hash.
20302    ContentHashMismatch,
20303    /// Catch-all used for unrecognized values returned from the server. Encountering this value
20304    /// typically indicates that this SDK version is out of date.
20305    Other,
20306}
20307
20308impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishError {
20309    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20310        // union deserializer
20311        use serde::de::{self, MapAccess, Visitor};
20312        struct EnumVisitor;
20313        impl<'de> Visitor<'de> for EnumVisitor {
20314            type Value = UploadSessionFinishError;
20315            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20316                f.write_str("a UploadSessionFinishError structure")
20317            }
20318            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20319                let tag: &str = match map.next_key()? {
20320                    Some(".tag") => map.next_value()?,
20321                    _ => return Err(de::Error::missing_field(".tag"))
20322                };
20323                let value = match tag {
20324                    "lookup_failed" => {
20325                        match map.next_key()? {
20326                            Some("lookup_failed") => UploadSessionFinishError::LookupFailed(map.next_value()?),
20327                            None => return Err(de::Error::missing_field("lookup_failed")),
20328                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
20329                        }
20330                    }
20331                    "path" => {
20332                        match map.next_key()? {
20333                            Some("path") => UploadSessionFinishError::Path(map.next_value()?),
20334                            None => return Err(de::Error::missing_field("path")),
20335                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
20336                        }
20337                    }
20338                    "properties_error" => {
20339                        match map.next_key()? {
20340                            Some("properties_error") => UploadSessionFinishError::PropertiesError(map.next_value()?),
20341                            None => return Err(de::Error::missing_field("properties_error")),
20342                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
20343                        }
20344                    }
20345                    "too_many_shared_folder_targets" => UploadSessionFinishError::TooManySharedFolderTargets,
20346                    "too_many_write_operations" => UploadSessionFinishError::TooManyWriteOperations,
20347                    "concurrent_session_data_not_allowed" => UploadSessionFinishError::ConcurrentSessionDataNotAllowed,
20348                    "concurrent_session_not_closed" => UploadSessionFinishError::ConcurrentSessionNotClosed,
20349                    "concurrent_session_missing_data" => UploadSessionFinishError::ConcurrentSessionMissingData,
20350                    "payload_too_large" => UploadSessionFinishError::PayloadTooLarge,
20351                    "content_hash_mismatch" => UploadSessionFinishError::ContentHashMismatch,
20352                    _ => UploadSessionFinishError::Other,
20353                };
20354                crate::eat_json_fields(&mut map)?;
20355                Ok(value)
20356            }
20357        }
20358        const VARIANTS: &[&str] = &["lookup_failed",
20359                                    "path",
20360                                    "properties_error",
20361                                    "too_many_shared_folder_targets",
20362                                    "too_many_write_operations",
20363                                    "concurrent_session_data_not_allowed",
20364                                    "concurrent_session_not_closed",
20365                                    "concurrent_session_missing_data",
20366                                    "payload_too_large",
20367                                    "content_hash_mismatch",
20368                                    "other"];
20369        deserializer.deserialize_struct("UploadSessionFinishError", VARIANTS, EnumVisitor)
20370    }
20371}
20372
20373impl ::serde::ser::Serialize for UploadSessionFinishError {
20374    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20375        // union serializer
20376        use serde::ser::SerializeStruct;
20377        match self {
20378            UploadSessionFinishError::LookupFailed(x) => {
20379                // union or polymporphic struct
20380                let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
20381                s.serialize_field(".tag", "lookup_failed")?;
20382                s.serialize_field("lookup_failed", x)?;
20383                s.end()
20384            }
20385            UploadSessionFinishError::Path(x) => {
20386                // union or polymporphic struct
20387                let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
20388                s.serialize_field(".tag", "path")?;
20389                s.serialize_field("path", x)?;
20390                s.end()
20391            }
20392            UploadSessionFinishError::PropertiesError(x) => {
20393                // union or polymporphic struct
20394                let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
20395                s.serialize_field(".tag", "properties_error")?;
20396                s.serialize_field("properties_error", x)?;
20397                s.end()
20398            }
20399            UploadSessionFinishError::TooManySharedFolderTargets => {
20400                // unit
20401                let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
20402                s.serialize_field(".tag", "too_many_shared_folder_targets")?;
20403                s.end()
20404            }
20405            UploadSessionFinishError::TooManyWriteOperations => {
20406                // unit
20407                let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
20408                s.serialize_field(".tag", "too_many_write_operations")?;
20409                s.end()
20410            }
20411            UploadSessionFinishError::ConcurrentSessionDataNotAllowed => {
20412                // unit
20413                let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
20414                s.serialize_field(".tag", "concurrent_session_data_not_allowed")?;
20415                s.end()
20416            }
20417            UploadSessionFinishError::ConcurrentSessionNotClosed => {
20418                // unit
20419                let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
20420                s.serialize_field(".tag", "concurrent_session_not_closed")?;
20421                s.end()
20422            }
20423            UploadSessionFinishError::ConcurrentSessionMissingData => {
20424                // unit
20425                let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
20426                s.serialize_field(".tag", "concurrent_session_missing_data")?;
20427                s.end()
20428            }
20429            UploadSessionFinishError::PayloadTooLarge => {
20430                // unit
20431                let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
20432                s.serialize_field(".tag", "payload_too_large")?;
20433                s.end()
20434            }
20435            UploadSessionFinishError::ContentHashMismatch => {
20436                // unit
20437                let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
20438                s.serialize_field(".tag", "content_hash_mismatch")?;
20439                s.end()
20440            }
20441            UploadSessionFinishError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
20442        }
20443    }
20444}
20445
20446impl ::std::error::Error for UploadSessionFinishError {
20447    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
20448        match self {
20449            UploadSessionFinishError::LookupFailed(inner) => Some(inner),
20450            UploadSessionFinishError::Path(inner) => Some(inner),
20451            UploadSessionFinishError::PropertiesError(inner) => Some(inner),
20452            _ => None,
20453        }
20454    }
20455}
20456
20457impl ::std::fmt::Display for UploadSessionFinishError {
20458    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20459        match self {
20460            UploadSessionFinishError::LookupFailed(inner) => write!(f, "The session arguments are incorrect; the value explains the reason: {}", inner),
20461            UploadSessionFinishError::Path(inner) => write!(f, "Unable to save the uploaded contents to a file. Data has already been appended to the upload session. Please retry with empty data body and updated offset: {}", inner),
20462            UploadSessionFinishError::PropertiesError(inner) => write!(f, "The supplied property group is invalid. The file has uploaded without property groups: {}", inner),
20463            UploadSessionFinishError::TooManySharedFolderTargets => f.write_str("The batch request commits files into too many different shared folders. Please limit your batch request to files contained in a single shared folder."),
20464            UploadSessionFinishError::TooManyWriteOperations => f.write_str("There are too many write operations happening in the user's Dropbox. You should retry uploading this file."),
20465            UploadSessionFinishError::ConcurrentSessionDataNotAllowed => f.write_str("Uploading data not allowed when finishing concurrent upload session."),
20466            UploadSessionFinishError::ConcurrentSessionNotClosed => f.write_str("Concurrent upload sessions need to be closed before finishing."),
20467            UploadSessionFinishError::ConcurrentSessionMissingData => f.write_str("Not all pieces of data were uploaded before trying to finish the session."),
20468            UploadSessionFinishError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MB."),
20469            UploadSessionFinishError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
20470            _ => write!(f, "{:?}", *self),
20471        }
20472    }
20473}
20474
20475#[derive(Debug, Clone, PartialEq, Eq)]
20476#[non_exhaustive] // variants may be added in the future
20477pub enum UploadSessionLookupError {
20478    /// The upload session ID was not found or has expired. Upload sessions are valid for 7 days.
20479    NotFound,
20480    /// The specified offset was incorrect. See the value for the correct offset. This error may
20481    /// occur when a previous request was received and processed successfully but the client did not
20482    /// receive the response, e.g. due to a network error.
20483    IncorrectOffset(UploadSessionOffsetError),
20484    /// You are attempting to append data to an upload session that has already been closed (i.e.
20485    /// committed).
20486    Closed,
20487    /// The session must be closed before calling upload_session/finish_batch.
20488    NotClosed,
20489    /// You can not append to the upload session because the size of a file should not reach the max
20490    /// file size limit (i.e. 350GB).
20491    TooLarge,
20492    /// For concurrent upload sessions, offset needs to be multiple of 4194304 bytes.
20493    ConcurrentSessionInvalidOffset,
20494    /// For concurrent upload sessions, only chunks with size multiple of 4194304 bytes can be
20495    /// uploaded.
20496    ConcurrentSessionInvalidDataSize,
20497    /// The request payload must be at most 150 MB.
20498    PayloadTooLarge,
20499    /// Catch-all used for unrecognized values returned from the server. Encountering this value
20500    /// typically indicates that this SDK version is out of date.
20501    Other,
20502}
20503
20504impl<'de> ::serde::de::Deserialize<'de> for UploadSessionLookupError {
20505    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20506        // union deserializer
20507        use serde::de::{self, MapAccess, Visitor};
20508        struct EnumVisitor;
20509        impl<'de> Visitor<'de> for EnumVisitor {
20510            type Value = UploadSessionLookupError;
20511            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20512                f.write_str("a UploadSessionLookupError structure")
20513            }
20514            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20515                let tag: &str = match map.next_key()? {
20516                    Some(".tag") => map.next_value()?,
20517                    _ => return Err(de::Error::missing_field(".tag"))
20518                };
20519                let value = match tag {
20520                    "not_found" => UploadSessionLookupError::NotFound,
20521                    "incorrect_offset" => UploadSessionLookupError::IncorrectOffset(UploadSessionOffsetError::internal_deserialize(&mut map)?),
20522                    "closed" => UploadSessionLookupError::Closed,
20523                    "not_closed" => UploadSessionLookupError::NotClosed,
20524                    "too_large" => UploadSessionLookupError::TooLarge,
20525                    "concurrent_session_invalid_offset" => UploadSessionLookupError::ConcurrentSessionInvalidOffset,
20526                    "concurrent_session_invalid_data_size" => UploadSessionLookupError::ConcurrentSessionInvalidDataSize,
20527                    "payload_too_large" => UploadSessionLookupError::PayloadTooLarge,
20528                    _ => UploadSessionLookupError::Other,
20529                };
20530                crate::eat_json_fields(&mut map)?;
20531                Ok(value)
20532            }
20533        }
20534        const VARIANTS: &[&str] = &["not_found",
20535                                    "incorrect_offset",
20536                                    "closed",
20537                                    "not_closed",
20538                                    "too_large",
20539                                    "concurrent_session_invalid_offset",
20540                                    "concurrent_session_invalid_data_size",
20541                                    "payload_too_large",
20542                                    "other"];
20543        deserializer.deserialize_struct("UploadSessionLookupError", VARIANTS, EnumVisitor)
20544    }
20545}
20546
20547impl ::serde::ser::Serialize for UploadSessionLookupError {
20548    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20549        // union serializer
20550        use serde::ser::SerializeStruct;
20551        match self {
20552            UploadSessionLookupError::NotFound => {
20553                // unit
20554                let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
20555                s.serialize_field(".tag", "not_found")?;
20556                s.end()
20557            }
20558            UploadSessionLookupError::IncorrectOffset(x) => {
20559                // struct
20560                let mut s = serializer.serialize_struct("UploadSessionLookupError", 2)?;
20561                s.serialize_field(".tag", "incorrect_offset")?;
20562                x.internal_serialize::<S>(&mut s)?;
20563                s.end()
20564            }
20565            UploadSessionLookupError::Closed => {
20566                // unit
20567                let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
20568                s.serialize_field(".tag", "closed")?;
20569                s.end()
20570            }
20571            UploadSessionLookupError::NotClosed => {
20572                // unit
20573                let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
20574                s.serialize_field(".tag", "not_closed")?;
20575                s.end()
20576            }
20577            UploadSessionLookupError::TooLarge => {
20578                // unit
20579                let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
20580                s.serialize_field(".tag", "too_large")?;
20581                s.end()
20582            }
20583            UploadSessionLookupError::ConcurrentSessionInvalidOffset => {
20584                // unit
20585                let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
20586                s.serialize_field(".tag", "concurrent_session_invalid_offset")?;
20587                s.end()
20588            }
20589            UploadSessionLookupError::ConcurrentSessionInvalidDataSize => {
20590                // unit
20591                let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
20592                s.serialize_field(".tag", "concurrent_session_invalid_data_size")?;
20593                s.end()
20594            }
20595            UploadSessionLookupError::PayloadTooLarge => {
20596                // unit
20597                let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
20598                s.serialize_field(".tag", "payload_too_large")?;
20599                s.end()
20600            }
20601            UploadSessionLookupError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
20602        }
20603    }
20604}
20605
20606impl ::std::error::Error for UploadSessionLookupError {
20607}
20608
20609impl ::std::fmt::Display for UploadSessionLookupError {
20610    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20611        match self {
20612            UploadSessionLookupError::NotFound => f.write_str("The upload session ID was not found or has expired. Upload sessions are valid for 7 days."),
20613            UploadSessionLookupError::IncorrectOffset(inner) => write!(f, "The specified offset was incorrect. See the value for the correct offset. This error may occur when a previous request was received and processed successfully but the client did not receive the response, e.g. due to a network error: {:?}", inner),
20614            UploadSessionLookupError::Closed => f.write_str("You are attempting to append data to an upload session that has already been closed (i.e. committed)."),
20615            UploadSessionLookupError::NotClosed => f.write_str("The session must be closed before calling upload_session/finish_batch."),
20616            UploadSessionLookupError::TooLarge => f.write_str("You can not append to the upload session because the size of a file should not reach the max file size limit (i.e. 350GB)."),
20617            UploadSessionLookupError::ConcurrentSessionInvalidOffset => f.write_str("For concurrent upload sessions, offset needs to be multiple of 4194304 bytes."),
20618            UploadSessionLookupError::ConcurrentSessionInvalidDataSize => f.write_str("For concurrent upload sessions, only chunks with size multiple of 4194304 bytes can be uploaded."),
20619            UploadSessionLookupError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MB."),
20620            _ => write!(f, "{:?}", *self),
20621        }
20622    }
20623}
20624
20625#[derive(Debug, Clone, PartialEq, Eq)]
20626#[non_exhaustive] // structs may have more fields added in the future.
20627pub struct UploadSessionOffsetError {
20628    /// The offset up to which data has been collected.
20629    pub correct_offset: u64,
20630}
20631
20632impl UploadSessionOffsetError {
20633    pub fn new(correct_offset: u64) -> Self {
20634        UploadSessionOffsetError {
20635            correct_offset,
20636        }
20637    }
20638}
20639
20640const UPLOAD_SESSION_OFFSET_ERROR_FIELDS: &[&str] = &["correct_offset"];
20641impl UploadSessionOffsetError {
20642    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20643        map: V,
20644    ) -> Result<UploadSessionOffsetError, V::Error> {
20645        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20646    }
20647
20648    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20649        mut map: V,
20650        optional: bool,
20651    ) -> Result<Option<UploadSessionOffsetError>, V::Error> {
20652        let mut field_correct_offset = None;
20653        let mut nothing = true;
20654        while let Some(key) = map.next_key::<&str>()? {
20655            nothing = false;
20656            match key {
20657                "correct_offset" => {
20658                    if field_correct_offset.is_some() {
20659                        return Err(::serde::de::Error::duplicate_field("correct_offset"));
20660                    }
20661                    field_correct_offset = Some(map.next_value()?);
20662                }
20663                _ => {
20664                    // unknown field allowed and ignored
20665                    map.next_value::<::serde_json::Value>()?;
20666                }
20667            }
20668        }
20669        if optional && nothing {
20670            return Ok(None);
20671        }
20672        let result = UploadSessionOffsetError {
20673            correct_offset: field_correct_offset.ok_or_else(|| ::serde::de::Error::missing_field("correct_offset"))?,
20674        };
20675        Ok(Some(result))
20676    }
20677
20678    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20679        &self,
20680        s: &mut S::SerializeStruct,
20681    ) -> Result<(), S::Error> {
20682        use serde::ser::SerializeStruct;
20683        s.serialize_field("correct_offset", &self.correct_offset)?;
20684        Ok(())
20685    }
20686}
20687
20688impl<'de> ::serde::de::Deserialize<'de> for UploadSessionOffsetError {
20689    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20690        // struct deserializer
20691        use serde::de::{MapAccess, Visitor};
20692        struct StructVisitor;
20693        impl<'de> Visitor<'de> for StructVisitor {
20694            type Value = UploadSessionOffsetError;
20695            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20696                f.write_str("a UploadSessionOffsetError struct")
20697            }
20698            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20699                UploadSessionOffsetError::internal_deserialize(map)
20700            }
20701        }
20702        deserializer.deserialize_struct("UploadSessionOffsetError", UPLOAD_SESSION_OFFSET_ERROR_FIELDS, StructVisitor)
20703    }
20704}
20705
20706impl ::serde::ser::Serialize for UploadSessionOffsetError {
20707    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20708        // struct serializer
20709        use serde::ser::SerializeStruct;
20710        let mut s = serializer.serialize_struct("UploadSessionOffsetError", 1)?;
20711        self.internal_serialize::<S>(&mut s)?;
20712        s.end()
20713    }
20714}
20715
20716#[derive(Debug, Clone, PartialEq, Eq, Default)]
20717#[non_exhaustive] // structs may have more fields added in the future.
20718pub struct UploadSessionStartArg {
20719    /// If true, the current session will be closed, at which point you won't be able to call
20720    /// [`upload_session_append_v2()`](crate::files::upload_session_append_v2) anymore with the
20721    /// current session.
20722    pub close: bool,
20723    /// Type of upload session you want to start. If not specified, default is
20724    /// [`UploadSessionType::Sequential`].
20725    pub session_type: Option<UploadSessionType>,
20726    /// A hash of the file content uploaded in this call. If provided and the uploaded content does
20727    /// not match this hash, an error will be returned. For more information see our [Content
20728    /// hash](https://www.dropbox.com/developers/reference/content-hash) page.
20729    pub content_hash: Option<Sha256HexHash>,
20730}
20731
20732impl UploadSessionStartArg {
20733    pub fn with_close(mut self, value: bool) -> Self {
20734        self.close = value;
20735        self
20736    }
20737
20738    pub fn with_session_type(mut self, value: UploadSessionType) -> Self {
20739        self.session_type = Some(value);
20740        self
20741    }
20742
20743    pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
20744        self.content_hash = Some(value);
20745        self
20746    }
20747}
20748
20749const UPLOAD_SESSION_START_ARG_FIELDS: &[&str] = &["close",
20750                                                   "session_type",
20751                                                   "content_hash"];
20752impl UploadSessionStartArg {
20753    // no _opt deserializer
20754    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20755        mut map: V,
20756    ) -> Result<UploadSessionStartArg, V::Error> {
20757        let mut field_close = None;
20758        let mut field_session_type = None;
20759        let mut field_content_hash = None;
20760        while let Some(key) = map.next_key::<&str>()? {
20761            match key {
20762                "close" => {
20763                    if field_close.is_some() {
20764                        return Err(::serde::de::Error::duplicate_field("close"));
20765                    }
20766                    field_close = Some(map.next_value()?);
20767                }
20768                "session_type" => {
20769                    if field_session_type.is_some() {
20770                        return Err(::serde::de::Error::duplicate_field("session_type"));
20771                    }
20772                    field_session_type = Some(map.next_value()?);
20773                }
20774                "content_hash" => {
20775                    if field_content_hash.is_some() {
20776                        return Err(::serde::de::Error::duplicate_field("content_hash"));
20777                    }
20778                    field_content_hash = Some(map.next_value()?);
20779                }
20780                _ => {
20781                    // unknown field allowed and ignored
20782                    map.next_value::<::serde_json::Value>()?;
20783                }
20784            }
20785        }
20786        let result = UploadSessionStartArg {
20787            close: field_close.unwrap_or(false),
20788            session_type: field_session_type.and_then(Option::flatten),
20789            content_hash: field_content_hash.and_then(Option::flatten),
20790        };
20791        Ok(result)
20792    }
20793
20794    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20795        &self,
20796        s: &mut S::SerializeStruct,
20797    ) -> Result<(), S::Error> {
20798        use serde::ser::SerializeStruct;
20799        if self.close {
20800            s.serialize_field("close", &self.close)?;
20801        }
20802        if let Some(val) = &self.session_type {
20803            s.serialize_field("session_type", val)?;
20804        }
20805        if let Some(val) = &self.content_hash {
20806            s.serialize_field("content_hash", val)?;
20807        }
20808        Ok(())
20809    }
20810}
20811
20812impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartArg {
20813    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20814        // struct deserializer
20815        use serde::de::{MapAccess, Visitor};
20816        struct StructVisitor;
20817        impl<'de> Visitor<'de> for StructVisitor {
20818            type Value = UploadSessionStartArg;
20819            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20820                f.write_str("a UploadSessionStartArg struct")
20821            }
20822            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20823                UploadSessionStartArg::internal_deserialize(map)
20824            }
20825        }
20826        deserializer.deserialize_struct("UploadSessionStartArg", UPLOAD_SESSION_START_ARG_FIELDS, StructVisitor)
20827    }
20828}
20829
20830impl ::serde::ser::Serialize for UploadSessionStartArg {
20831    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20832        // struct serializer
20833        use serde::ser::SerializeStruct;
20834        let mut s = serializer.serialize_struct("UploadSessionStartArg", 3)?;
20835        self.internal_serialize::<S>(&mut s)?;
20836        s.end()
20837    }
20838}
20839
20840#[derive(Debug, Clone, PartialEq, Eq)]
20841#[non_exhaustive] // structs may have more fields added in the future.
20842pub struct UploadSessionStartBatchArg {
20843    /// The number of upload sessions to start.
20844    pub num_sessions: u64,
20845    /// Type of upload session you want to start. If not specified, default is
20846    /// [`UploadSessionType::Sequential`].
20847    pub session_type: Option<UploadSessionType>,
20848}
20849
20850impl UploadSessionStartBatchArg {
20851    pub fn new(num_sessions: u64) -> Self {
20852        UploadSessionStartBatchArg {
20853            num_sessions,
20854            session_type: None,
20855        }
20856    }
20857
20858    pub fn with_session_type(mut self, value: UploadSessionType) -> Self {
20859        self.session_type = Some(value);
20860        self
20861    }
20862}
20863
20864const UPLOAD_SESSION_START_BATCH_ARG_FIELDS: &[&str] = &["num_sessions",
20865                                                         "session_type"];
20866impl UploadSessionStartBatchArg {
20867    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20868        map: V,
20869    ) -> Result<UploadSessionStartBatchArg, V::Error> {
20870        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20871    }
20872
20873    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20874        mut map: V,
20875        optional: bool,
20876    ) -> Result<Option<UploadSessionStartBatchArg>, V::Error> {
20877        let mut field_num_sessions = None;
20878        let mut field_session_type = None;
20879        let mut nothing = true;
20880        while let Some(key) = map.next_key::<&str>()? {
20881            nothing = false;
20882            match key {
20883                "num_sessions" => {
20884                    if field_num_sessions.is_some() {
20885                        return Err(::serde::de::Error::duplicate_field("num_sessions"));
20886                    }
20887                    field_num_sessions = Some(map.next_value()?);
20888                }
20889                "session_type" => {
20890                    if field_session_type.is_some() {
20891                        return Err(::serde::de::Error::duplicate_field("session_type"));
20892                    }
20893                    field_session_type = Some(map.next_value()?);
20894                }
20895                _ => {
20896                    // unknown field allowed and ignored
20897                    map.next_value::<::serde_json::Value>()?;
20898                }
20899            }
20900        }
20901        if optional && nothing {
20902            return Ok(None);
20903        }
20904        let result = UploadSessionStartBatchArg {
20905            num_sessions: field_num_sessions.ok_or_else(|| ::serde::de::Error::missing_field("num_sessions"))?,
20906            session_type: field_session_type.and_then(Option::flatten),
20907        };
20908        Ok(Some(result))
20909    }
20910
20911    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20912        &self,
20913        s: &mut S::SerializeStruct,
20914    ) -> Result<(), S::Error> {
20915        use serde::ser::SerializeStruct;
20916        s.serialize_field("num_sessions", &self.num_sessions)?;
20917        if let Some(val) = &self.session_type {
20918            s.serialize_field("session_type", val)?;
20919        }
20920        Ok(())
20921    }
20922}
20923
20924impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartBatchArg {
20925    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20926        // struct deserializer
20927        use serde::de::{MapAccess, Visitor};
20928        struct StructVisitor;
20929        impl<'de> Visitor<'de> for StructVisitor {
20930            type Value = UploadSessionStartBatchArg;
20931            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20932                f.write_str("a UploadSessionStartBatchArg struct")
20933            }
20934            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20935                UploadSessionStartBatchArg::internal_deserialize(map)
20936            }
20937        }
20938        deserializer.deserialize_struct("UploadSessionStartBatchArg", UPLOAD_SESSION_START_BATCH_ARG_FIELDS, StructVisitor)
20939    }
20940}
20941
20942impl ::serde::ser::Serialize for UploadSessionStartBatchArg {
20943    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20944        // struct serializer
20945        use serde::ser::SerializeStruct;
20946        let mut s = serializer.serialize_struct("UploadSessionStartBatchArg", 2)?;
20947        self.internal_serialize::<S>(&mut s)?;
20948        s.end()
20949    }
20950}
20951
20952#[derive(Debug, Clone, PartialEq, Eq)]
20953#[non_exhaustive] // structs may have more fields added in the future.
20954pub struct UploadSessionStartBatchResult {
20955    /// A List of unique identifiers for the upload session. Pass each session_id to
20956    /// [`upload_session_append_v2()`](crate::files::upload_session_append_v2) and
20957    /// [`upload_session_finish()`](crate::files::upload_session_finish).
20958    pub session_ids: Vec<String>,
20959}
20960
20961impl UploadSessionStartBatchResult {
20962    pub fn new(session_ids: Vec<String>) -> Self {
20963        UploadSessionStartBatchResult {
20964            session_ids,
20965        }
20966    }
20967}
20968
20969const UPLOAD_SESSION_START_BATCH_RESULT_FIELDS: &[&str] = &["session_ids"];
20970impl UploadSessionStartBatchResult {
20971    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20972        map: V,
20973    ) -> Result<UploadSessionStartBatchResult, V::Error> {
20974        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20975    }
20976
20977    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20978        mut map: V,
20979        optional: bool,
20980    ) -> Result<Option<UploadSessionStartBatchResult>, V::Error> {
20981        let mut field_session_ids = None;
20982        let mut nothing = true;
20983        while let Some(key) = map.next_key::<&str>()? {
20984            nothing = false;
20985            match key {
20986                "session_ids" => {
20987                    if field_session_ids.is_some() {
20988                        return Err(::serde::de::Error::duplicate_field("session_ids"));
20989                    }
20990                    field_session_ids = Some(map.next_value()?);
20991                }
20992                _ => {
20993                    // unknown field allowed and ignored
20994                    map.next_value::<::serde_json::Value>()?;
20995                }
20996            }
20997        }
20998        if optional && nothing {
20999            return Ok(None);
21000        }
21001        let result = UploadSessionStartBatchResult {
21002            session_ids: field_session_ids.ok_or_else(|| ::serde::de::Error::missing_field("session_ids"))?,
21003        };
21004        Ok(Some(result))
21005    }
21006
21007    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21008        &self,
21009        s: &mut S::SerializeStruct,
21010    ) -> Result<(), S::Error> {
21011        use serde::ser::SerializeStruct;
21012        s.serialize_field("session_ids", &self.session_ids)?;
21013        Ok(())
21014    }
21015}
21016
21017impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartBatchResult {
21018    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21019        // struct deserializer
21020        use serde::de::{MapAccess, Visitor};
21021        struct StructVisitor;
21022        impl<'de> Visitor<'de> for StructVisitor {
21023            type Value = UploadSessionStartBatchResult;
21024            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21025                f.write_str("a UploadSessionStartBatchResult struct")
21026            }
21027            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21028                UploadSessionStartBatchResult::internal_deserialize(map)
21029            }
21030        }
21031        deserializer.deserialize_struct("UploadSessionStartBatchResult", UPLOAD_SESSION_START_BATCH_RESULT_FIELDS, StructVisitor)
21032    }
21033}
21034
21035impl ::serde::ser::Serialize for UploadSessionStartBatchResult {
21036    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21037        // struct serializer
21038        use serde::ser::SerializeStruct;
21039        let mut s = serializer.serialize_struct("UploadSessionStartBatchResult", 1)?;
21040        self.internal_serialize::<S>(&mut s)?;
21041        s.end()
21042    }
21043}
21044
21045#[derive(Debug, Clone, PartialEq, Eq)]
21046#[non_exhaustive] // variants may be added in the future
21047pub enum UploadSessionStartError {
21048    /// Uploading data not allowed when starting concurrent upload session.
21049    ConcurrentSessionDataNotAllowed,
21050    /// Can not start a closed concurrent upload session.
21051    ConcurrentSessionCloseNotAllowed,
21052    /// The request payload must be at most 150 MB.
21053    PayloadTooLarge,
21054    /// The content received by the Dropbox server in this call does not match the provided content
21055    /// hash.
21056    ContentHashMismatch,
21057    /// Catch-all used for unrecognized values returned from the server. Encountering this value
21058    /// typically indicates that this SDK version is out of date.
21059    Other,
21060}
21061
21062impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartError {
21063    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21064        // union deserializer
21065        use serde::de::{self, MapAccess, Visitor};
21066        struct EnumVisitor;
21067        impl<'de> Visitor<'de> for EnumVisitor {
21068            type Value = UploadSessionStartError;
21069            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21070                f.write_str("a UploadSessionStartError structure")
21071            }
21072            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21073                let tag: &str = match map.next_key()? {
21074                    Some(".tag") => map.next_value()?,
21075                    _ => return Err(de::Error::missing_field(".tag"))
21076                };
21077                let value = match tag {
21078                    "concurrent_session_data_not_allowed" => UploadSessionStartError::ConcurrentSessionDataNotAllowed,
21079                    "concurrent_session_close_not_allowed" => UploadSessionStartError::ConcurrentSessionCloseNotAllowed,
21080                    "payload_too_large" => UploadSessionStartError::PayloadTooLarge,
21081                    "content_hash_mismatch" => UploadSessionStartError::ContentHashMismatch,
21082                    _ => UploadSessionStartError::Other,
21083                };
21084                crate::eat_json_fields(&mut map)?;
21085                Ok(value)
21086            }
21087        }
21088        const VARIANTS: &[&str] = &["concurrent_session_data_not_allowed",
21089                                    "concurrent_session_close_not_allowed",
21090                                    "payload_too_large",
21091                                    "content_hash_mismatch",
21092                                    "other"];
21093        deserializer.deserialize_struct("UploadSessionStartError", VARIANTS, EnumVisitor)
21094    }
21095}
21096
21097impl ::serde::ser::Serialize for UploadSessionStartError {
21098    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21099        // union serializer
21100        use serde::ser::SerializeStruct;
21101        match self {
21102            UploadSessionStartError::ConcurrentSessionDataNotAllowed => {
21103                // unit
21104                let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
21105                s.serialize_field(".tag", "concurrent_session_data_not_allowed")?;
21106                s.end()
21107            }
21108            UploadSessionStartError::ConcurrentSessionCloseNotAllowed => {
21109                // unit
21110                let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
21111                s.serialize_field(".tag", "concurrent_session_close_not_allowed")?;
21112                s.end()
21113            }
21114            UploadSessionStartError::PayloadTooLarge => {
21115                // unit
21116                let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
21117                s.serialize_field(".tag", "payload_too_large")?;
21118                s.end()
21119            }
21120            UploadSessionStartError::ContentHashMismatch => {
21121                // unit
21122                let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
21123                s.serialize_field(".tag", "content_hash_mismatch")?;
21124                s.end()
21125            }
21126            UploadSessionStartError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
21127        }
21128    }
21129}
21130
21131impl ::std::error::Error for UploadSessionStartError {
21132}
21133
21134impl ::std::fmt::Display for UploadSessionStartError {
21135    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21136        match self {
21137            UploadSessionStartError::ConcurrentSessionDataNotAllowed => f.write_str("Uploading data not allowed when starting concurrent upload session."),
21138            UploadSessionStartError::ConcurrentSessionCloseNotAllowed => f.write_str("Can not start a closed concurrent upload session."),
21139            UploadSessionStartError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MB."),
21140            UploadSessionStartError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
21141            _ => write!(f, "{:?}", *self),
21142        }
21143    }
21144}
21145
21146#[derive(Debug, Clone, PartialEq, Eq)]
21147#[non_exhaustive] // structs may have more fields added in the future.
21148pub struct UploadSessionStartResult {
21149    /// A unique identifier for the upload session. Pass this to
21150    /// [`upload_session_append_v2()`](crate::files::upload_session_append_v2) and
21151    /// [`upload_session_finish()`](crate::files::upload_session_finish).
21152    pub session_id: String,
21153}
21154
21155impl UploadSessionStartResult {
21156    pub fn new(session_id: String) -> Self {
21157        UploadSessionStartResult {
21158            session_id,
21159        }
21160    }
21161}
21162
21163const UPLOAD_SESSION_START_RESULT_FIELDS: &[&str] = &["session_id"];
21164impl UploadSessionStartResult {
21165    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21166        map: V,
21167    ) -> Result<UploadSessionStartResult, V::Error> {
21168        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21169    }
21170
21171    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21172        mut map: V,
21173        optional: bool,
21174    ) -> Result<Option<UploadSessionStartResult>, V::Error> {
21175        let mut field_session_id = None;
21176        let mut nothing = true;
21177        while let Some(key) = map.next_key::<&str>()? {
21178            nothing = false;
21179            match key {
21180                "session_id" => {
21181                    if field_session_id.is_some() {
21182                        return Err(::serde::de::Error::duplicate_field("session_id"));
21183                    }
21184                    field_session_id = Some(map.next_value()?);
21185                }
21186                _ => {
21187                    // unknown field allowed and ignored
21188                    map.next_value::<::serde_json::Value>()?;
21189                }
21190            }
21191        }
21192        if optional && nothing {
21193            return Ok(None);
21194        }
21195        let result = UploadSessionStartResult {
21196            session_id: field_session_id.ok_or_else(|| ::serde::de::Error::missing_field("session_id"))?,
21197        };
21198        Ok(Some(result))
21199    }
21200
21201    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21202        &self,
21203        s: &mut S::SerializeStruct,
21204    ) -> Result<(), S::Error> {
21205        use serde::ser::SerializeStruct;
21206        s.serialize_field("session_id", &self.session_id)?;
21207        Ok(())
21208    }
21209}
21210
21211impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartResult {
21212    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21213        // struct deserializer
21214        use serde::de::{MapAccess, Visitor};
21215        struct StructVisitor;
21216        impl<'de> Visitor<'de> for StructVisitor {
21217            type Value = UploadSessionStartResult;
21218            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21219                f.write_str("a UploadSessionStartResult struct")
21220            }
21221            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21222                UploadSessionStartResult::internal_deserialize(map)
21223            }
21224        }
21225        deserializer.deserialize_struct("UploadSessionStartResult", UPLOAD_SESSION_START_RESULT_FIELDS, StructVisitor)
21226    }
21227}
21228
21229impl ::serde::ser::Serialize for UploadSessionStartResult {
21230    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21231        // struct serializer
21232        use serde::ser::SerializeStruct;
21233        let mut s = serializer.serialize_struct("UploadSessionStartResult", 1)?;
21234        self.internal_serialize::<S>(&mut s)?;
21235        s.end()
21236    }
21237}
21238
21239#[derive(Debug, Clone, PartialEq, Eq)]
21240#[non_exhaustive] // variants may be added in the future
21241pub enum UploadSessionType {
21242    /// Pieces of data are uploaded sequentially one after another. This is the default behavior.
21243    Sequential,
21244    /// Pieces of data can be uploaded in concurrent RPCs in any order.
21245    Concurrent,
21246    /// Catch-all used for unrecognized values returned from the server. Encountering this value
21247    /// typically indicates that this SDK version is out of date.
21248    Other,
21249}
21250
21251impl<'de> ::serde::de::Deserialize<'de> for UploadSessionType {
21252    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21253        // union deserializer
21254        use serde::de::{self, MapAccess, Visitor};
21255        struct EnumVisitor;
21256        impl<'de> Visitor<'de> for EnumVisitor {
21257            type Value = UploadSessionType;
21258            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21259                f.write_str("a UploadSessionType structure")
21260            }
21261            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21262                let tag: &str = match map.next_key()? {
21263                    Some(".tag") => map.next_value()?,
21264                    _ => return Err(de::Error::missing_field(".tag"))
21265                };
21266                let value = match tag {
21267                    "sequential" => UploadSessionType::Sequential,
21268                    "concurrent" => UploadSessionType::Concurrent,
21269                    _ => UploadSessionType::Other,
21270                };
21271                crate::eat_json_fields(&mut map)?;
21272                Ok(value)
21273            }
21274        }
21275        const VARIANTS: &[&str] = &["sequential",
21276                                    "concurrent",
21277                                    "other"];
21278        deserializer.deserialize_struct("UploadSessionType", VARIANTS, EnumVisitor)
21279    }
21280}
21281
21282impl ::serde::ser::Serialize for UploadSessionType {
21283    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21284        // union serializer
21285        use serde::ser::SerializeStruct;
21286        match self {
21287            UploadSessionType::Sequential => {
21288                // unit
21289                let mut s = serializer.serialize_struct("UploadSessionType", 1)?;
21290                s.serialize_field(".tag", "sequential")?;
21291                s.end()
21292            }
21293            UploadSessionType::Concurrent => {
21294                // unit
21295                let mut s = serializer.serialize_struct("UploadSessionType", 1)?;
21296                s.serialize_field(".tag", "concurrent")?;
21297                s.end()
21298            }
21299            UploadSessionType::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
21300        }
21301    }
21302}
21303
21304#[derive(Debug, Clone, PartialEq, Eq)]
21305#[non_exhaustive] // structs may have more fields added in the future.
21306pub struct UploadWriteFailed {
21307    /// The reason why the file couldn't be saved.
21308    pub reason: WriteError,
21309    /// The upload session ID; data has already been uploaded to the corresponding upload session
21310    /// and this ID may be used to retry the commit with
21311    /// [`upload_session_finish()`](crate::files::upload_session_finish).
21312    pub upload_session_id: String,
21313}
21314
21315impl UploadWriteFailed {
21316    pub fn new(reason: WriteError, upload_session_id: String) -> Self {
21317        UploadWriteFailed {
21318            reason,
21319            upload_session_id,
21320        }
21321    }
21322}
21323
21324const UPLOAD_WRITE_FAILED_FIELDS: &[&str] = &["reason",
21325                                              "upload_session_id"];
21326impl UploadWriteFailed {
21327    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21328        map: V,
21329    ) -> Result<UploadWriteFailed, V::Error> {
21330        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21331    }
21332
21333    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21334        mut map: V,
21335        optional: bool,
21336    ) -> Result<Option<UploadWriteFailed>, V::Error> {
21337        let mut field_reason = None;
21338        let mut field_upload_session_id = None;
21339        let mut nothing = true;
21340        while let Some(key) = map.next_key::<&str>()? {
21341            nothing = false;
21342            match key {
21343                "reason" => {
21344                    if field_reason.is_some() {
21345                        return Err(::serde::de::Error::duplicate_field("reason"));
21346                    }
21347                    field_reason = Some(map.next_value()?);
21348                }
21349                "upload_session_id" => {
21350                    if field_upload_session_id.is_some() {
21351                        return Err(::serde::de::Error::duplicate_field("upload_session_id"));
21352                    }
21353                    field_upload_session_id = Some(map.next_value()?);
21354                }
21355                _ => {
21356                    // unknown field allowed and ignored
21357                    map.next_value::<::serde_json::Value>()?;
21358                }
21359            }
21360        }
21361        if optional && nothing {
21362            return Ok(None);
21363        }
21364        let result = UploadWriteFailed {
21365            reason: field_reason.ok_or_else(|| ::serde::de::Error::missing_field("reason"))?,
21366            upload_session_id: field_upload_session_id.ok_or_else(|| ::serde::de::Error::missing_field("upload_session_id"))?,
21367        };
21368        Ok(Some(result))
21369    }
21370
21371    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21372        &self,
21373        s: &mut S::SerializeStruct,
21374    ) -> Result<(), S::Error> {
21375        use serde::ser::SerializeStruct;
21376        s.serialize_field("reason", &self.reason)?;
21377        s.serialize_field("upload_session_id", &self.upload_session_id)?;
21378        Ok(())
21379    }
21380}
21381
21382impl<'de> ::serde::de::Deserialize<'de> for UploadWriteFailed {
21383    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21384        // struct deserializer
21385        use serde::de::{MapAccess, Visitor};
21386        struct StructVisitor;
21387        impl<'de> Visitor<'de> for StructVisitor {
21388            type Value = UploadWriteFailed;
21389            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21390                f.write_str("a UploadWriteFailed struct")
21391            }
21392            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21393                UploadWriteFailed::internal_deserialize(map)
21394            }
21395        }
21396        deserializer.deserialize_struct("UploadWriteFailed", UPLOAD_WRITE_FAILED_FIELDS, StructVisitor)
21397    }
21398}
21399
21400impl ::serde::ser::Serialize for UploadWriteFailed {
21401    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21402        // struct serializer
21403        use serde::ser::SerializeStruct;
21404        let mut s = serializer.serialize_struct("UploadWriteFailed", 2)?;
21405        self.internal_serialize::<S>(&mut s)?;
21406        s.end()
21407    }
21408}
21409
21410#[derive(Debug, Clone, PartialEq, Eq)]
21411#[non_exhaustive] // structs may have more fields added in the future.
21412pub struct UserGeneratedTag {
21413    pub tag_text: TagText,
21414}
21415
21416impl UserGeneratedTag {
21417    pub fn new(tag_text: TagText) -> Self {
21418        UserGeneratedTag {
21419            tag_text,
21420        }
21421    }
21422}
21423
21424const USER_GENERATED_TAG_FIELDS: &[&str] = &["tag_text"];
21425impl UserGeneratedTag {
21426    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21427        map: V,
21428    ) -> Result<UserGeneratedTag, V::Error> {
21429        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21430    }
21431
21432    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21433        mut map: V,
21434        optional: bool,
21435    ) -> Result<Option<UserGeneratedTag>, V::Error> {
21436        let mut field_tag_text = None;
21437        let mut nothing = true;
21438        while let Some(key) = map.next_key::<&str>()? {
21439            nothing = false;
21440            match key {
21441                "tag_text" => {
21442                    if field_tag_text.is_some() {
21443                        return Err(::serde::de::Error::duplicate_field("tag_text"));
21444                    }
21445                    field_tag_text = Some(map.next_value()?);
21446                }
21447                _ => {
21448                    // unknown field allowed and ignored
21449                    map.next_value::<::serde_json::Value>()?;
21450                }
21451            }
21452        }
21453        if optional && nothing {
21454            return Ok(None);
21455        }
21456        let result = UserGeneratedTag {
21457            tag_text: field_tag_text.ok_or_else(|| ::serde::de::Error::missing_field("tag_text"))?,
21458        };
21459        Ok(Some(result))
21460    }
21461
21462    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21463        &self,
21464        s: &mut S::SerializeStruct,
21465    ) -> Result<(), S::Error> {
21466        use serde::ser::SerializeStruct;
21467        s.serialize_field("tag_text", &self.tag_text)?;
21468        Ok(())
21469    }
21470}
21471
21472impl<'de> ::serde::de::Deserialize<'de> for UserGeneratedTag {
21473    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21474        // struct deserializer
21475        use serde::de::{MapAccess, Visitor};
21476        struct StructVisitor;
21477        impl<'de> Visitor<'de> for StructVisitor {
21478            type Value = UserGeneratedTag;
21479            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21480                f.write_str("a UserGeneratedTag struct")
21481            }
21482            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21483                UserGeneratedTag::internal_deserialize(map)
21484            }
21485        }
21486        deserializer.deserialize_struct("UserGeneratedTag", USER_GENERATED_TAG_FIELDS, StructVisitor)
21487    }
21488}
21489
21490impl ::serde::ser::Serialize for UserGeneratedTag {
21491    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21492        // struct serializer
21493        use serde::ser::SerializeStruct;
21494        let mut s = serializer.serialize_struct("UserGeneratedTag", 1)?;
21495        self.internal_serialize::<S>(&mut s)?;
21496        s.end()
21497    }
21498}
21499
21500/// Metadata for a video.
21501#[derive(Debug, Clone, PartialEq, Default)]
21502#[non_exhaustive] // structs may have more fields added in the future.
21503pub struct VideoMetadata {
21504    /// Dimension of the photo/video.
21505    pub dimensions: Option<Dimensions>,
21506    /// The GPS coordinate of the photo/video.
21507    pub location: Option<GpsCoordinates>,
21508    /// The timestamp when the photo/video is taken.
21509    pub time_taken: Option<crate::types::common::DropboxTimestamp>,
21510    /// The duration of the video in milliseconds.
21511    pub duration: Option<u64>,
21512}
21513
21514impl VideoMetadata {
21515    pub fn with_dimensions(mut self, value: Dimensions) -> Self {
21516        self.dimensions = Some(value);
21517        self
21518    }
21519
21520    pub fn with_location(mut self, value: GpsCoordinates) -> Self {
21521        self.location = Some(value);
21522        self
21523    }
21524
21525    pub fn with_time_taken(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
21526        self.time_taken = Some(value);
21527        self
21528    }
21529
21530    pub fn with_duration(mut self, value: u64) -> Self {
21531        self.duration = Some(value);
21532        self
21533    }
21534}
21535
21536const VIDEO_METADATA_FIELDS: &[&str] = &["dimensions",
21537                                         "location",
21538                                         "time_taken",
21539                                         "duration"];
21540impl VideoMetadata {
21541    // no _opt deserializer
21542    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21543        mut map: V,
21544    ) -> Result<VideoMetadata, V::Error> {
21545        let mut field_dimensions = None;
21546        let mut field_location = None;
21547        let mut field_time_taken = None;
21548        let mut field_duration = None;
21549        while let Some(key) = map.next_key::<&str>()? {
21550            match key {
21551                "dimensions" => {
21552                    if field_dimensions.is_some() {
21553                        return Err(::serde::de::Error::duplicate_field("dimensions"));
21554                    }
21555                    field_dimensions = Some(map.next_value()?);
21556                }
21557                "location" => {
21558                    if field_location.is_some() {
21559                        return Err(::serde::de::Error::duplicate_field("location"));
21560                    }
21561                    field_location = Some(map.next_value()?);
21562                }
21563                "time_taken" => {
21564                    if field_time_taken.is_some() {
21565                        return Err(::serde::de::Error::duplicate_field("time_taken"));
21566                    }
21567                    field_time_taken = Some(map.next_value()?);
21568                }
21569                "duration" => {
21570                    if field_duration.is_some() {
21571                        return Err(::serde::de::Error::duplicate_field("duration"));
21572                    }
21573                    field_duration = Some(map.next_value()?);
21574                }
21575                _ => {
21576                    // unknown field allowed and ignored
21577                    map.next_value::<::serde_json::Value>()?;
21578                }
21579            }
21580        }
21581        let result = VideoMetadata {
21582            dimensions: field_dimensions.and_then(Option::flatten),
21583            location: field_location.and_then(Option::flatten),
21584            time_taken: field_time_taken.and_then(Option::flatten),
21585            duration: field_duration.and_then(Option::flatten),
21586        };
21587        Ok(result)
21588    }
21589
21590    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21591        &self,
21592        s: &mut S::SerializeStruct,
21593    ) -> Result<(), S::Error> {
21594        use serde::ser::SerializeStruct;
21595        if let Some(val) = &self.dimensions {
21596            s.serialize_field("dimensions", val)?;
21597        }
21598        if let Some(val) = &self.location {
21599            s.serialize_field("location", val)?;
21600        }
21601        if let Some(val) = &self.time_taken {
21602            s.serialize_field("time_taken", val)?;
21603        }
21604        if let Some(val) = &self.duration {
21605            s.serialize_field("duration", val)?;
21606        }
21607        Ok(())
21608    }
21609}
21610
21611impl<'de> ::serde::de::Deserialize<'de> for VideoMetadata {
21612    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21613        // struct deserializer
21614        use serde::de::{MapAccess, Visitor};
21615        struct StructVisitor;
21616        impl<'de> Visitor<'de> for StructVisitor {
21617            type Value = VideoMetadata;
21618            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21619                f.write_str("a VideoMetadata struct")
21620            }
21621            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21622                VideoMetadata::internal_deserialize(map)
21623            }
21624        }
21625        deserializer.deserialize_struct("VideoMetadata", VIDEO_METADATA_FIELDS, StructVisitor)
21626    }
21627}
21628
21629impl ::serde::ser::Serialize for VideoMetadata {
21630    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21631        // struct serializer
21632        use serde::ser::SerializeStruct;
21633        let mut s = serializer.serialize_struct("VideoMetadata", 4)?;
21634        self.internal_serialize::<S>(&mut s)?;
21635        s.end()
21636    }
21637}
21638
21639// struct extends polymorphic struct MediaMetadata
21640impl From<VideoMetadata> for MediaMetadata {
21641    fn from(subtype: VideoMetadata) -> Self {
21642        MediaMetadata::Video(subtype)
21643    }
21644}
21645#[derive(Debug, Clone, PartialEq, Eq)]
21646#[non_exhaustive] // variants may be added in the future
21647pub enum WriteConflictError {
21648    /// There's a file in the way.
21649    File,
21650    /// There's a folder in the way.
21651    Folder,
21652    /// There's a file at an ancestor path, so we couldn't create the required parent folders.
21653    FileAncestor,
21654    /// Catch-all used for unrecognized values returned from the server. Encountering this value
21655    /// typically indicates that this SDK version is out of date.
21656    Other,
21657}
21658
21659impl<'de> ::serde::de::Deserialize<'de> for WriteConflictError {
21660    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21661        // union deserializer
21662        use serde::de::{self, MapAccess, Visitor};
21663        struct EnumVisitor;
21664        impl<'de> Visitor<'de> for EnumVisitor {
21665            type Value = WriteConflictError;
21666            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21667                f.write_str("a WriteConflictError structure")
21668            }
21669            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21670                let tag: &str = match map.next_key()? {
21671                    Some(".tag") => map.next_value()?,
21672                    _ => return Err(de::Error::missing_field(".tag"))
21673                };
21674                let value = match tag {
21675                    "file" => WriteConflictError::File,
21676                    "folder" => WriteConflictError::Folder,
21677                    "file_ancestor" => WriteConflictError::FileAncestor,
21678                    _ => WriteConflictError::Other,
21679                };
21680                crate::eat_json_fields(&mut map)?;
21681                Ok(value)
21682            }
21683        }
21684        const VARIANTS: &[&str] = &["file",
21685                                    "folder",
21686                                    "file_ancestor",
21687                                    "other"];
21688        deserializer.deserialize_struct("WriteConflictError", VARIANTS, EnumVisitor)
21689    }
21690}
21691
21692impl ::serde::ser::Serialize for WriteConflictError {
21693    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21694        // union serializer
21695        use serde::ser::SerializeStruct;
21696        match self {
21697            WriteConflictError::File => {
21698                // unit
21699                let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
21700                s.serialize_field(".tag", "file")?;
21701                s.end()
21702            }
21703            WriteConflictError::Folder => {
21704                // unit
21705                let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
21706                s.serialize_field(".tag", "folder")?;
21707                s.end()
21708            }
21709            WriteConflictError::FileAncestor => {
21710                // unit
21711                let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
21712                s.serialize_field(".tag", "file_ancestor")?;
21713                s.end()
21714            }
21715            WriteConflictError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
21716        }
21717    }
21718}
21719
21720impl ::std::error::Error for WriteConflictError {
21721}
21722
21723impl ::std::fmt::Display for WriteConflictError {
21724    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21725        match self {
21726            WriteConflictError::File => f.write_str("There's a file in the way."),
21727            WriteConflictError::Folder => f.write_str("There's a folder in the way."),
21728            WriteConflictError::FileAncestor => f.write_str("There's a file at an ancestor path, so we couldn't create the required parent folders."),
21729            _ => write!(f, "{:?}", *self),
21730        }
21731    }
21732}
21733
21734#[derive(Debug, Clone, PartialEq, Eq)]
21735#[non_exhaustive] // variants may be added in the future
21736pub enum WriteError {
21737    /// The given path does not satisfy the required path format. Please refer to the [Path formats
21738    /// documentation](https://www.dropbox.com/developers/documentation/http/documentation#path-formats)
21739    /// for more information.
21740    MalformedPath(MalformedPathError),
21741    /// Couldn't write to the target path because there was something in the way.
21742    Conflict(WriteConflictError),
21743    /// The user doesn't have permissions to write to the target location.
21744    NoWritePermission,
21745    /// The user doesn't have enough available space (bytes) to write more data.
21746    InsufficientSpace,
21747    /// Dropbox will not save the file or folder because of its name.
21748    DisallowedName,
21749    /// This endpoint cannot move or delete team folders.
21750    TeamFolder,
21751    /// This file operation is not allowed at this path.
21752    OperationSuppressed,
21753    /// There are too many write operations in user's Dropbox. Please retry this request.
21754    TooManyWriteOperations,
21755    /// Catch-all used for unrecognized values returned from the server. Encountering this value
21756    /// typically indicates that this SDK version is out of date.
21757    Other,
21758}
21759
21760impl<'de> ::serde::de::Deserialize<'de> for WriteError {
21761    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21762        // union deserializer
21763        use serde::de::{self, MapAccess, Visitor};
21764        struct EnumVisitor;
21765        impl<'de> Visitor<'de> for EnumVisitor {
21766            type Value = WriteError;
21767            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21768                f.write_str("a WriteError structure")
21769            }
21770            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21771                let tag: &str = match map.next_key()? {
21772                    Some(".tag") => map.next_value()?,
21773                    _ => return Err(de::Error::missing_field(".tag"))
21774                };
21775                let value = match tag {
21776                    "malformed_path" => {
21777                        match map.next_key()? {
21778                            Some("malformed_path") => WriteError::MalformedPath(map.next_value()?),
21779                            None => WriteError::MalformedPath(None),
21780                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21781                        }
21782                    }
21783                    "conflict" => {
21784                        match map.next_key()? {
21785                            Some("conflict") => WriteError::Conflict(map.next_value()?),
21786                            None => return Err(de::Error::missing_field("conflict")),
21787                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21788                        }
21789                    }
21790                    "no_write_permission" => WriteError::NoWritePermission,
21791                    "insufficient_space" => WriteError::InsufficientSpace,
21792                    "disallowed_name" => WriteError::DisallowedName,
21793                    "team_folder" => WriteError::TeamFolder,
21794                    "operation_suppressed" => WriteError::OperationSuppressed,
21795                    "too_many_write_operations" => WriteError::TooManyWriteOperations,
21796                    _ => WriteError::Other,
21797                };
21798                crate::eat_json_fields(&mut map)?;
21799                Ok(value)
21800            }
21801        }
21802        const VARIANTS: &[&str] = &["malformed_path",
21803                                    "conflict",
21804                                    "no_write_permission",
21805                                    "insufficient_space",
21806                                    "disallowed_name",
21807                                    "team_folder",
21808                                    "operation_suppressed",
21809                                    "too_many_write_operations",
21810                                    "other"];
21811        deserializer.deserialize_struct("WriteError", VARIANTS, EnumVisitor)
21812    }
21813}
21814
21815impl ::serde::ser::Serialize for WriteError {
21816    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21817        // union serializer
21818        use serde::ser::SerializeStruct;
21819        match self {
21820            WriteError::MalformedPath(x) => {
21821                // nullable (struct or primitive)
21822                let n = if x.is_some() { 2 } else { 1 };
21823                let mut s = serializer.serialize_struct("WriteError", n)?;
21824                s.serialize_field(".tag", "malformed_path")?;
21825                if let Some(x) = x {
21826                    s.serialize_field("malformed_path", &x)?;
21827                }
21828                s.end()
21829            }
21830            WriteError::Conflict(x) => {
21831                // union or polymporphic struct
21832                let mut s = serializer.serialize_struct("WriteError", 2)?;
21833                s.serialize_field(".tag", "conflict")?;
21834                s.serialize_field("conflict", x)?;
21835                s.end()
21836            }
21837            WriteError::NoWritePermission => {
21838                // unit
21839                let mut s = serializer.serialize_struct("WriteError", 1)?;
21840                s.serialize_field(".tag", "no_write_permission")?;
21841                s.end()
21842            }
21843            WriteError::InsufficientSpace => {
21844                // unit
21845                let mut s = serializer.serialize_struct("WriteError", 1)?;
21846                s.serialize_field(".tag", "insufficient_space")?;
21847                s.end()
21848            }
21849            WriteError::DisallowedName => {
21850                // unit
21851                let mut s = serializer.serialize_struct("WriteError", 1)?;
21852                s.serialize_field(".tag", "disallowed_name")?;
21853                s.end()
21854            }
21855            WriteError::TeamFolder => {
21856                // unit
21857                let mut s = serializer.serialize_struct("WriteError", 1)?;
21858                s.serialize_field(".tag", "team_folder")?;
21859                s.end()
21860            }
21861            WriteError::OperationSuppressed => {
21862                // unit
21863                let mut s = serializer.serialize_struct("WriteError", 1)?;
21864                s.serialize_field(".tag", "operation_suppressed")?;
21865                s.end()
21866            }
21867            WriteError::TooManyWriteOperations => {
21868                // unit
21869                let mut s = serializer.serialize_struct("WriteError", 1)?;
21870                s.serialize_field(".tag", "too_many_write_operations")?;
21871                s.end()
21872            }
21873            WriteError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
21874        }
21875    }
21876}
21877
21878impl ::std::error::Error for WriteError {
21879    fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
21880        match self {
21881            WriteError::Conflict(inner) => Some(inner),
21882            _ => None,
21883        }
21884    }
21885}
21886
21887impl ::std::fmt::Display for WriteError {
21888    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21889        match self {
21890            WriteError::MalformedPath(inner) => write!(f, "malformed_path: {:?}", inner),
21891            WriteError::Conflict(inner) => write!(f, "Couldn't write to the target path because there was something in the way: {}", inner),
21892            WriteError::NoWritePermission => f.write_str("The user doesn't have permissions to write to the target location."),
21893            WriteError::InsufficientSpace => f.write_str("The user doesn't have enough available space (bytes) to write more data."),
21894            WriteError::DisallowedName => f.write_str("Dropbox will not save the file or folder because of its name."),
21895            WriteError::TeamFolder => f.write_str("This endpoint cannot move or delete team folders."),
21896            WriteError::OperationSuppressed => f.write_str("This file operation is not allowed at this path."),
21897            WriteError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
21898            _ => write!(f, "{:?}", *self),
21899        }
21900    }
21901}
21902
21903/// Your intent when writing a file to some path. This is used to determine what constitutes a
21904/// conflict and what the autorename strategy is. In some situations, the conflict behavior is
21905/// identical: (a) If the target path doesn't refer to anything, the file is always written; no
21906/// conflict. (b) If the target path refers to a folder, it's always a conflict. (c) If the target
21907/// path refers to a file with identical contents, nothing gets written; no conflict. The conflict
21908/// checking differs in the case where there's a file at the target path with contents different
21909/// from the contents you're trying to write.
21910#[derive(Debug, Clone, PartialEq, Eq)]
21911pub enum WriteMode {
21912    /// Do not overwrite an existing file if there is a conflict. The autorename strategy is to
21913    /// append a number to the file name. For example, "document.txt" might become "document
21914    /// (2).txt".
21915    Add,
21916    /// Always overwrite the existing file. The autorename strategy is the same as it is for
21917    /// [`Add`](WriteMode::Add).
21918    Overwrite,
21919    /// Overwrite if the given "rev" matches the existing file's "rev". The supplied value should be
21920    /// the latest known "rev" of the file, for example, from [`FileMetadata`], from when the file
21921    /// was last downloaded by the app. This will cause the file on the Dropbox servers to be
21922    /// overwritten if the given "rev" matches the existing file's current "rev" on the Dropbox
21923    /// servers. The autorename strategy is to append the string "conflicted copy" to the file name.
21924    /// For example, "document.txt" might become "document (conflicted copy).txt" or "document
21925    /// (Panda's conflicted copy).txt".
21926    Update(Rev),
21927}
21928
21929impl<'de> ::serde::de::Deserialize<'de> for WriteMode {
21930    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21931        // union deserializer
21932        use serde::de::{self, MapAccess, Visitor};
21933        struct EnumVisitor;
21934        impl<'de> Visitor<'de> for EnumVisitor {
21935            type Value = WriteMode;
21936            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21937                f.write_str("a WriteMode structure")
21938            }
21939            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21940                let tag: &str = match map.next_key()? {
21941                    Some(".tag") => map.next_value()?,
21942                    _ => return Err(de::Error::missing_field(".tag"))
21943                };
21944                let value = match tag {
21945                    "add" => WriteMode::Add,
21946                    "overwrite" => WriteMode::Overwrite,
21947                    "update" => {
21948                        match map.next_key()? {
21949                            Some("update") => WriteMode::Update(map.next_value()?),
21950                            None => return Err(de::Error::missing_field("update")),
21951                            _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21952                        }
21953                    }
21954                    _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
21955                };
21956                crate::eat_json_fields(&mut map)?;
21957                Ok(value)
21958            }
21959        }
21960        const VARIANTS: &[&str] = &["add",
21961                                    "overwrite",
21962                                    "update"];
21963        deserializer.deserialize_struct("WriteMode", VARIANTS, EnumVisitor)
21964    }
21965}
21966
21967impl ::serde::ser::Serialize for WriteMode {
21968    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21969        // union serializer
21970        use serde::ser::SerializeStruct;
21971        match self {
21972            WriteMode::Add => {
21973                // unit
21974                let mut s = serializer.serialize_struct("WriteMode", 1)?;
21975                s.serialize_field(".tag", "add")?;
21976                s.end()
21977            }
21978            WriteMode::Overwrite => {
21979                // unit
21980                let mut s = serializer.serialize_struct("WriteMode", 1)?;
21981                s.serialize_field(".tag", "overwrite")?;
21982                s.end()
21983            }
21984            WriteMode::Update(x) => {
21985                // primitive
21986                let mut s = serializer.serialize_struct("WriteMode", 2)?;
21987                s.serialize_field(".tag", "update")?;
21988                s.serialize_field("update", x)?;
21989                s.end()
21990            }
21991        }
21992    }
21993}
21994