1#![allow(
5 clippy::too_many_arguments,
6 clippy::large_enum_variant,
7 clippy::result_large_err,
8 clippy::doc_markdown,
9 clippy::doc_lazy_continuation,
10)]
11
12pub type CopyBatchArg = RelocationBatchArgBase;
15pub type FileId = String;
16pub type Id = String;
17pub type ListFolderCursor = String;
18pub type MalformedPathError = Option<String>;
19pub type Path = String;
20pub type PathOrId = String;
21pub type PathR = String;
22pub type PathROrId = String;
23pub type ReadPath = String;
24pub type Rev = String;
25pub type SearchV2Cursor = String;
26pub type Sha256HexHash = String;
27pub type SharedLinkUrl = String;
28pub type TagText = String;
29pub type WritePath = String;
30pub type WritePathOrId = String;
31
32#[derive(Debug, Clone, PartialEq, Eq)]
33#[non_exhaustive] pub struct AddTagArg {
35 pub path: Path,
37 pub tag_text: TagText,
39}
40
41impl AddTagArg {
42 pub fn new(path: Path, tag_text: TagText) -> Self {
43 AddTagArg {
44 path,
45 tag_text,
46 }
47 }
48}
49
50const ADD_TAG_ARG_FIELDS: &[&str] = &["path",
51 "tag_text"];
52impl AddTagArg {
53 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
54 map: V,
55 ) -> Result<AddTagArg, V::Error> {
56 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
57 }
58
59 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
60 mut map: V,
61 optional: bool,
62 ) -> Result<Option<AddTagArg>, V::Error> {
63 let mut field_path = None;
64 let mut field_tag_text = None;
65 let mut nothing = true;
66 while let Some(key) = map.next_key::<&str>()? {
67 nothing = false;
68 match key {
69 "path" => {
70 if field_path.is_some() {
71 return Err(::serde::de::Error::duplicate_field("path"));
72 }
73 field_path = Some(map.next_value()?);
74 }
75 "tag_text" => {
76 if field_tag_text.is_some() {
77 return Err(::serde::de::Error::duplicate_field("tag_text"));
78 }
79 field_tag_text = Some(map.next_value()?);
80 }
81 _ => {
82 map.next_value::<::serde_json::Value>()?;
84 }
85 }
86 }
87 if optional && nothing {
88 return Ok(None);
89 }
90 let result = AddTagArg {
91 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
92 tag_text: field_tag_text.ok_or_else(|| ::serde::de::Error::missing_field("tag_text"))?,
93 };
94 Ok(Some(result))
95 }
96
97 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
98 &self,
99 s: &mut S::SerializeStruct,
100 ) -> Result<(), S::Error> {
101 use serde::ser::SerializeStruct;
102 s.serialize_field("path", &self.path)?;
103 s.serialize_field("tag_text", &self.tag_text)?;
104 Ok(())
105 }
106}
107
108impl<'de> ::serde::de::Deserialize<'de> for AddTagArg {
109 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
110 use serde::de::{MapAccess, Visitor};
112 struct StructVisitor;
113 impl<'de> Visitor<'de> for StructVisitor {
114 type Value = AddTagArg;
115 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
116 f.write_str("a AddTagArg struct")
117 }
118 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
119 AddTagArg::internal_deserialize(map)
120 }
121 }
122 deserializer.deserialize_struct("AddTagArg", ADD_TAG_ARG_FIELDS, StructVisitor)
123 }
124}
125
126impl ::serde::ser::Serialize for AddTagArg {
127 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
128 use serde::ser::SerializeStruct;
130 let mut s = serializer.serialize_struct("AddTagArg", 2)?;
131 self.internal_serialize::<S>(&mut s)?;
132 s.end()
133 }
134}
135
136#[derive(Debug, Clone, PartialEq, Eq)]
137#[non_exhaustive] pub enum AddTagError {
139 Path(LookupError),
140 TooManyTags,
142 Other,
145}
146
147impl<'de> ::serde::de::Deserialize<'de> for AddTagError {
148 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
149 use serde::de::{self, MapAccess, Visitor};
151 struct EnumVisitor;
152 impl<'de> Visitor<'de> for EnumVisitor {
153 type Value = AddTagError;
154 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
155 f.write_str("a AddTagError structure")
156 }
157 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
158 let tag: &str = match map.next_key()? {
159 Some(".tag") => map.next_value()?,
160 _ => return Err(de::Error::missing_field(".tag"))
161 };
162 let value = match tag {
163 "path" => {
164 match map.next_key()? {
165 Some("path") => AddTagError::Path(map.next_value()?),
166 None => return Err(de::Error::missing_field("path")),
167 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
168 }
169 }
170 "too_many_tags" => AddTagError::TooManyTags,
171 _ => AddTagError::Other,
172 };
173 crate::eat_json_fields(&mut map)?;
174 Ok(value)
175 }
176 }
177 const VARIANTS: &[&str] = &["path",
178 "other",
179 "too_many_tags"];
180 deserializer.deserialize_struct("AddTagError", VARIANTS, EnumVisitor)
181 }
182}
183
184impl ::serde::ser::Serialize for AddTagError {
185 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
186 use serde::ser::SerializeStruct;
188 match self {
189 AddTagError::Path(x) => {
190 let mut s = serializer.serialize_struct("AddTagError", 2)?;
192 s.serialize_field(".tag", "path")?;
193 s.serialize_field("path", x)?;
194 s.end()
195 }
196 AddTagError::TooManyTags => {
197 let mut s = serializer.serialize_struct("AddTagError", 1)?;
199 s.serialize_field(".tag", "too_many_tags")?;
200 s.end()
201 }
202 AddTagError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
203 }
204 }
205}
206
207impl ::std::error::Error for AddTagError {
208 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
209 match self {
210 AddTagError::Path(inner) => Some(inner),
211 _ => None,
212 }
213 }
214}
215
216impl ::std::fmt::Display for AddTagError {
217 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
218 match self {
219 AddTagError::Path(inner) => write!(f, "AddTagError: {}", inner),
220 AddTagError::TooManyTags => f.write_str("The item already has the maximum supported number of tags."),
221 _ => write!(f, "{:?}", *self),
222 }
223 }
224}
225
226impl From<BaseTagError> for AddTagError {
228 fn from(parent: BaseTagError) -> Self {
229 match parent {
230 BaseTagError::Path(x) => AddTagError::Path(x),
231 BaseTagError::Other => AddTagError::Other,
232 }
233 }
234}
235#[derive(Debug, Clone, PartialEq, Eq)]
236#[non_exhaustive] pub struct AlphaGetMetadataArg {
238 pub path: ReadPath,
240 pub include_media_info: bool,
242 pub include_deleted: bool,
245 pub include_has_explicit_shared_members: bool,
248 pub include_property_groups: Option<crate::types::file_properties::TemplateFilterBase>,
251 pub include_property_templates: Option<Vec<crate::types::file_properties::TemplateId>>,
254}
255
256impl AlphaGetMetadataArg {
257 pub fn new(path: ReadPath) -> Self {
258 AlphaGetMetadataArg {
259 path,
260 include_media_info: false,
261 include_deleted: false,
262 include_has_explicit_shared_members: false,
263 include_property_groups: None,
264 include_property_templates: None,
265 }
266 }
267
268 pub fn with_include_media_info(mut self, value: bool) -> Self {
269 self.include_media_info = value;
270 self
271 }
272
273 pub fn with_include_deleted(mut self, value: bool) -> Self {
274 self.include_deleted = value;
275 self
276 }
277
278 pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
279 self.include_has_explicit_shared_members = value;
280 self
281 }
282
283 pub fn with_include_property_groups(
284 mut self,
285 value: crate::types::file_properties::TemplateFilterBase,
286 ) -> Self {
287 self.include_property_groups = Some(value);
288 self
289 }
290
291 pub fn with_include_property_templates(
292 mut self,
293 value: Vec<crate::types::file_properties::TemplateId>,
294 ) -> Self {
295 self.include_property_templates = Some(value);
296 self
297 }
298}
299
300const ALPHA_GET_METADATA_ARG_FIELDS: &[&str] = &["path",
301 "include_media_info",
302 "include_deleted",
303 "include_has_explicit_shared_members",
304 "include_property_groups",
305 "include_property_templates"];
306impl AlphaGetMetadataArg {
307 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
308 map: V,
309 ) -> Result<AlphaGetMetadataArg, V::Error> {
310 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
311 }
312
313 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
314 mut map: V,
315 optional: bool,
316 ) -> Result<Option<AlphaGetMetadataArg>, V::Error> {
317 let mut field_path = None;
318 let mut field_include_media_info = None;
319 let mut field_include_deleted = None;
320 let mut field_include_has_explicit_shared_members = None;
321 let mut field_include_property_groups = None;
322 let mut field_include_property_templates = None;
323 let mut nothing = true;
324 while let Some(key) = map.next_key::<&str>()? {
325 nothing = false;
326 match key {
327 "path" => {
328 if field_path.is_some() {
329 return Err(::serde::de::Error::duplicate_field("path"));
330 }
331 field_path = Some(map.next_value()?);
332 }
333 "include_media_info" => {
334 if field_include_media_info.is_some() {
335 return Err(::serde::de::Error::duplicate_field("include_media_info"));
336 }
337 field_include_media_info = Some(map.next_value()?);
338 }
339 "include_deleted" => {
340 if field_include_deleted.is_some() {
341 return Err(::serde::de::Error::duplicate_field("include_deleted"));
342 }
343 field_include_deleted = Some(map.next_value()?);
344 }
345 "include_has_explicit_shared_members" => {
346 if field_include_has_explicit_shared_members.is_some() {
347 return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
348 }
349 field_include_has_explicit_shared_members = Some(map.next_value()?);
350 }
351 "include_property_groups" => {
352 if field_include_property_groups.is_some() {
353 return Err(::serde::de::Error::duplicate_field("include_property_groups"));
354 }
355 field_include_property_groups = Some(map.next_value()?);
356 }
357 "include_property_templates" => {
358 if field_include_property_templates.is_some() {
359 return Err(::serde::de::Error::duplicate_field("include_property_templates"));
360 }
361 field_include_property_templates = Some(map.next_value()?);
362 }
363 _ => {
364 map.next_value::<::serde_json::Value>()?;
366 }
367 }
368 }
369 if optional && nothing {
370 return Ok(None);
371 }
372 let result = AlphaGetMetadataArg {
373 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
374 include_media_info: field_include_media_info.unwrap_or(false),
375 include_deleted: field_include_deleted.unwrap_or(false),
376 include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
377 include_property_groups: field_include_property_groups.and_then(Option::flatten),
378 include_property_templates: field_include_property_templates.and_then(Option::flatten),
379 };
380 Ok(Some(result))
381 }
382
383 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
384 &self,
385 s: &mut S::SerializeStruct,
386 ) -> Result<(), S::Error> {
387 use serde::ser::SerializeStruct;
388 s.serialize_field("path", &self.path)?;
389 if self.include_media_info {
390 s.serialize_field("include_media_info", &self.include_media_info)?;
391 }
392 if self.include_deleted {
393 s.serialize_field("include_deleted", &self.include_deleted)?;
394 }
395 if self.include_has_explicit_shared_members {
396 s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
397 }
398 if let Some(val) = &self.include_property_groups {
399 s.serialize_field("include_property_groups", val)?;
400 }
401 if let Some(val) = &self.include_property_templates {
402 s.serialize_field("include_property_templates", val)?;
403 }
404 Ok(())
405 }
406}
407
408impl<'de> ::serde::de::Deserialize<'de> for AlphaGetMetadataArg {
409 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
410 use serde::de::{MapAccess, Visitor};
412 struct StructVisitor;
413 impl<'de> Visitor<'de> for StructVisitor {
414 type Value = AlphaGetMetadataArg;
415 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
416 f.write_str("a AlphaGetMetadataArg struct")
417 }
418 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
419 AlphaGetMetadataArg::internal_deserialize(map)
420 }
421 }
422 deserializer.deserialize_struct("AlphaGetMetadataArg", ALPHA_GET_METADATA_ARG_FIELDS, StructVisitor)
423 }
424}
425
426impl ::serde::ser::Serialize for AlphaGetMetadataArg {
427 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
428 use serde::ser::SerializeStruct;
430 let mut s = serializer.serialize_struct("AlphaGetMetadataArg", 6)?;
431 self.internal_serialize::<S>(&mut s)?;
432 s.end()
433 }
434}
435
436impl From<AlphaGetMetadataArg> for GetMetadataArg {
438 fn from(subtype: AlphaGetMetadataArg) -> Self {
439 Self {
440 path: subtype.path,
441 include_media_info: subtype.include_media_info,
442 include_deleted: subtype.include_deleted,
443 include_has_explicit_shared_members: subtype.include_has_explicit_shared_members,
444 include_property_groups: subtype.include_property_groups,
445 }
446 }
447}
448#[derive(Debug, Clone, PartialEq, Eq)]
449pub enum AlphaGetMetadataError {
450 Path(LookupError),
451 PropertiesError(crate::types::file_properties::LookUpPropertiesError),
452}
453
454impl<'de> ::serde::de::Deserialize<'de> for AlphaGetMetadataError {
455 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
456 use serde::de::{self, MapAccess, Visitor};
458 struct EnumVisitor;
459 impl<'de> Visitor<'de> for EnumVisitor {
460 type Value = AlphaGetMetadataError;
461 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
462 f.write_str("a AlphaGetMetadataError structure")
463 }
464 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
465 let tag: &str = match map.next_key()? {
466 Some(".tag") => map.next_value()?,
467 _ => return Err(de::Error::missing_field(".tag"))
468 };
469 let value = match tag {
470 "path" => {
471 match map.next_key()? {
472 Some("path") => AlphaGetMetadataError::Path(map.next_value()?),
473 None => return Err(de::Error::missing_field("path")),
474 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
475 }
476 }
477 "properties_error" => {
478 match map.next_key()? {
479 Some("properties_error") => AlphaGetMetadataError::PropertiesError(map.next_value()?),
480 None => return Err(de::Error::missing_field("properties_error")),
481 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
482 }
483 }
484 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
485 };
486 crate::eat_json_fields(&mut map)?;
487 Ok(value)
488 }
489 }
490 const VARIANTS: &[&str] = &["path",
491 "properties_error"];
492 deserializer.deserialize_struct("AlphaGetMetadataError", VARIANTS, EnumVisitor)
493 }
494}
495
496impl ::serde::ser::Serialize for AlphaGetMetadataError {
497 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
498 use serde::ser::SerializeStruct;
500 match self {
501 AlphaGetMetadataError::Path(x) => {
502 let mut s = serializer.serialize_struct("AlphaGetMetadataError", 2)?;
504 s.serialize_field(".tag", "path")?;
505 s.serialize_field("path", x)?;
506 s.end()
507 }
508 AlphaGetMetadataError::PropertiesError(x) => {
509 let mut s = serializer.serialize_struct("AlphaGetMetadataError", 2)?;
511 s.serialize_field(".tag", "properties_error")?;
512 s.serialize_field("properties_error", x)?;
513 s.end()
514 }
515 }
516 }
517}
518
519impl ::std::error::Error for AlphaGetMetadataError {
520 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
521 match self {
522 AlphaGetMetadataError::Path(inner) => Some(inner),
523 AlphaGetMetadataError::PropertiesError(inner) => Some(inner),
524 }
525 }
526}
527
528impl ::std::fmt::Display for AlphaGetMetadataError {
529 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
530 match self {
531 AlphaGetMetadataError::Path(inner) => write!(f, "AlphaGetMetadataError: {}", inner),
532 AlphaGetMetadataError::PropertiesError(inner) => write!(f, "AlphaGetMetadataError: {}", inner),
533 }
534 }
535}
536
537impl From<GetMetadataError> for AlphaGetMetadataError {
539 fn from(parent: GetMetadataError) -> Self {
540 match parent {
541 GetMetadataError::Path(x) => AlphaGetMetadataError::Path(x),
542 }
543 }
544}
545#[derive(Debug, Clone, PartialEq, Eq)]
546#[non_exhaustive] pub enum BaseTagError {
548 Path(LookupError),
549 Other,
552}
553
554impl<'de> ::serde::de::Deserialize<'de> for BaseTagError {
555 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
556 use serde::de::{self, MapAccess, Visitor};
558 struct EnumVisitor;
559 impl<'de> Visitor<'de> for EnumVisitor {
560 type Value = BaseTagError;
561 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
562 f.write_str("a BaseTagError structure")
563 }
564 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
565 let tag: &str = match map.next_key()? {
566 Some(".tag") => map.next_value()?,
567 _ => return Err(de::Error::missing_field(".tag"))
568 };
569 let value = match tag {
570 "path" => {
571 match map.next_key()? {
572 Some("path") => BaseTagError::Path(map.next_value()?),
573 None => return Err(de::Error::missing_field("path")),
574 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
575 }
576 }
577 _ => BaseTagError::Other,
578 };
579 crate::eat_json_fields(&mut map)?;
580 Ok(value)
581 }
582 }
583 const VARIANTS: &[&str] = &["path",
584 "other"];
585 deserializer.deserialize_struct("BaseTagError", VARIANTS, EnumVisitor)
586 }
587}
588
589impl ::serde::ser::Serialize for BaseTagError {
590 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
591 use serde::ser::SerializeStruct;
593 match self {
594 BaseTagError::Path(x) => {
595 let mut s = serializer.serialize_struct("BaseTagError", 2)?;
597 s.serialize_field(".tag", "path")?;
598 s.serialize_field("path", x)?;
599 s.end()
600 }
601 BaseTagError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
602 }
603 }
604}
605
606impl ::std::error::Error for BaseTagError {
607 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
608 match self {
609 BaseTagError::Path(inner) => Some(inner),
610 _ => None,
611 }
612 }
613}
614
615impl ::std::fmt::Display for BaseTagError {
616 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
617 match self {
618 BaseTagError::Path(inner) => write!(f, "BaseTagError: {}", inner),
619 _ => write!(f, "{:?}", *self),
620 }
621 }
622}
623
624#[derive(Debug, Clone, PartialEq, Eq)]
625#[non_exhaustive] pub struct CommitInfo {
627 pub path: WritePathOrId,
629 pub mode: WriteMode,
631 pub autorename: bool,
634 pub client_modified: Option<crate::types::common::DropboxTimestamp>,
639 pub mute: bool,
643 pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
645 pub strict_conflict: bool,
650}
651
652impl CommitInfo {
653 pub fn new(path: WritePathOrId) -> Self {
654 CommitInfo {
655 path,
656 mode: WriteMode::Add,
657 autorename: false,
658 client_modified: None,
659 mute: false,
660 property_groups: None,
661 strict_conflict: false,
662 }
663 }
664
665 pub fn with_mode(mut self, value: WriteMode) -> Self {
666 self.mode = value;
667 self
668 }
669
670 pub fn with_autorename(mut self, value: bool) -> Self {
671 self.autorename = value;
672 self
673 }
674
675 pub fn with_client_modified(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
676 self.client_modified = Some(value);
677 self
678 }
679
680 pub fn with_mute(mut self, value: bool) -> Self {
681 self.mute = value;
682 self
683 }
684
685 pub fn with_property_groups(
686 mut self,
687 value: Vec<crate::types::file_properties::PropertyGroup>,
688 ) -> Self {
689 self.property_groups = Some(value);
690 self
691 }
692
693 pub fn with_strict_conflict(mut self, value: bool) -> Self {
694 self.strict_conflict = value;
695 self
696 }
697}
698
699const COMMIT_INFO_FIELDS: &[&str] = &["path",
700 "mode",
701 "autorename",
702 "client_modified",
703 "mute",
704 "property_groups",
705 "strict_conflict"];
706impl CommitInfo {
707 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
708 map: V,
709 ) -> Result<CommitInfo, V::Error> {
710 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
711 }
712
713 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
714 mut map: V,
715 optional: bool,
716 ) -> Result<Option<CommitInfo>, V::Error> {
717 let mut field_path = None;
718 let mut field_mode = None;
719 let mut field_autorename = None;
720 let mut field_client_modified = None;
721 let mut field_mute = None;
722 let mut field_property_groups = None;
723 let mut field_strict_conflict = None;
724 let mut nothing = true;
725 while let Some(key) = map.next_key::<&str>()? {
726 nothing = false;
727 match key {
728 "path" => {
729 if field_path.is_some() {
730 return Err(::serde::de::Error::duplicate_field("path"));
731 }
732 field_path = Some(map.next_value()?);
733 }
734 "mode" => {
735 if field_mode.is_some() {
736 return Err(::serde::de::Error::duplicate_field("mode"));
737 }
738 field_mode = Some(map.next_value()?);
739 }
740 "autorename" => {
741 if field_autorename.is_some() {
742 return Err(::serde::de::Error::duplicate_field("autorename"));
743 }
744 field_autorename = Some(map.next_value()?);
745 }
746 "client_modified" => {
747 if field_client_modified.is_some() {
748 return Err(::serde::de::Error::duplicate_field("client_modified"));
749 }
750 field_client_modified = Some(map.next_value()?);
751 }
752 "mute" => {
753 if field_mute.is_some() {
754 return Err(::serde::de::Error::duplicate_field("mute"));
755 }
756 field_mute = Some(map.next_value()?);
757 }
758 "property_groups" => {
759 if field_property_groups.is_some() {
760 return Err(::serde::de::Error::duplicate_field("property_groups"));
761 }
762 field_property_groups = Some(map.next_value()?);
763 }
764 "strict_conflict" => {
765 if field_strict_conflict.is_some() {
766 return Err(::serde::de::Error::duplicate_field("strict_conflict"));
767 }
768 field_strict_conflict = Some(map.next_value()?);
769 }
770 _ => {
771 map.next_value::<::serde_json::Value>()?;
773 }
774 }
775 }
776 if optional && nothing {
777 return Ok(None);
778 }
779 let result = CommitInfo {
780 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
781 mode: field_mode.unwrap_or(WriteMode::Add),
782 autorename: field_autorename.unwrap_or(false),
783 client_modified: field_client_modified.and_then(Option::flatten),
784 mute: field_mute.unwrap_or(false),
785 property_groups: field_property_groups.and_then(Option::flatten),
786 strict_conflict: field_strict_conflict.unwrap_or(false),
787 };
788 Ok(Some(result))
789 }
790
791 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
792 &self,
793 s: &mut S::SerializeStruct,
794 ) -> Result<(), S::Error> {
795 use serde::ser::SerializeStruct;
796 s.serialize_field("path", &self.path)?;
797 if self.mode != WriteMode::Add {
798 s.serialize_field("mode", &self.mode)?;
799 }
800 if self.autorename {
801 s.serialize_field("autorename", &self.autorename)?;
802 }
803 if let Some(val) = &self.client_modified {
804 s.serialize_field("client_modified", val)?;
805 }
806 if self.mute {
807 s.serialize_field("mute", &self.mute)?;
808 }
809 if let Some(val) = &self.property_groups {
810 s.serialize_field("property_groups", val)?;
811 }
812 if self.strict_conflict {
813 s.serialize_field("strict_conflict", &self.strict_conflict)?;
814 }
815 Ok(())
816 }
817}
818
819impl<'de> ::serde::de::Deserialize<'de> for CommitInfo {
820 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
821 use serde::de::{MapAccess, Visitor};
823 struct StructVisitor;
824 impl<'de> Visitor<'de> for StructVisitor {
825 type Value = CommitInfo;
826 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
827 f.write_str("a CommitInfo struct")
828 }
829 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
830 CommitInfo::internal_deserialize(map)
831 }
832 }
833 deserializer.deserialize_struct("CommitInfo", COMMIT_INFO_FIELDS, StructVisitor)
834 }
835}
836
837impl ::serde::ser::Serialize for CommitInfo {
838 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
839 use serde::ser::SerializeStruct;
841 let mut s = serializer.serialize_struct("CommitInfo", 7)?;
842 self.internal_serialize::<S>(&mut s)?;
843 s.end()
844 }
845}
846
847#[derive(Debug, Clone, PartialEq, Eq)]
848#[non_exhaustive] pub struct ContentSyncSetting {
850 pub id: FileId,
852 pub sync_setting: SyncSetting,
854}
855
856impl ContentSyncSetting {
857 pub fn new(id: FileId, sync_setting: SyncSetting) -> Self {
858 ContentSyncSetting {
859 id,
860 sync_setting,
861 }
862 }
863}
864
865const CONTENT_SYNC_SETTING_FIELDS: &[&str] = &["id",
866 "sync_setting"];
867impl ContentSyncSetting {
868 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
869 map: V,
870 ) -> Result<ContentSyncSetting, V::Error> {
871 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
872 }
873
874 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
875 mut map: V,
876 optional: bool,
877 ) -> Result<Option<ContentSyncSetting>, V::Error> {
878 let mut field_id = None;
879 let mut field_sync_setting = None;
880 let mut nothing = true;
881 while let Some(key) = map.next_key::<&str>()? {
882 nothing = false;
883 match key {
884 "id" => {
885 if field_id.is_some() {
886 return Err(::serde::de::Error::duplicate_field("id"));
887 }
888 field_id = Some(map.next_value()?);
889 }
890 "sync_setting" => {
891 if field_sync_setting.is_some() {
892 return Err(::serde::de::Error::duplicate_field("sync_setting"));
893 }
894 field_sync_setting = Some(map.next_value()?);
895 }
896 _ => {
897 map.next_value::<::serde_json::Value>()?;
899 }
900 }
901 }
902 if optional && nothing {
903 return Ok(None);
904 }
905 let result = ContentSyncSetting {
906 id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
907 sync_setting: field_sync_setting.ok_or_else(|| ::serde::de::Error::missing_field("sync_setting"))?,
908 };
909 Ok(Some(result))
910 }
911
912 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
913 &self,
914 s: &mut S::SerializeStruct,
915 ) -> Result<(), S::Error> {
916 use serde::ser::SerializeStruct;
917 s.serialize_field("id", &self.id)?;
918 s.serialize_field("sync_setting", &self.sync_setting)?;
919 Ok(())
920 }
921}
922
923impl<'de> ::serde::de::Deserialize<'de> for ContentSyncSetting {
924 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
925 use serde::de::{MapAccess, Visitor};
927 struct StructVisitor;
928 impl<'de> Visitor<'de> for StructVisitor {
929 type Value = ContentSyncSetting;
930 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
931 f.write_str("a ContentSyncSetting struct")
932 }
933 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
934 ContentSyncSetting::internal_deserialize(map)
935 }
936 }
937 deserializer.deserialize_struct("ContentSyncSetting", CONTENT_SYNC_SETTING_FIELDS, StructVisitor)
938 }
939}
940
941impl ::serde::ser::Serialize for ContentSyncSetting {
942 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
943 use serde::ser::SerializeStruct;
945 let mut s = serializer.serialize_struct("ContentSyncSetting", 2)?;
946 self.internal_serialize::<S>(&mut s)?;
947 s.end()
948 }
949}
950
951#[derive(Debug, Clone, PartialEq, Eq)]
952#[non_exhaustive] pub struct ContentSyncSettingArg {
954 pub id: FileId,
956 pub sync_setting: SyncSettingArg,
958}
959
960impl ContentSyncSettingArg {
961 pub fn new(id: FileId, sync_setting: SyncSettingArg) -> Self {
962 ContentSyncSettingArg {
963 id,
964 sync_setting,
965 }
966 }
967}
968
969const CONTENT_SYNC_SETTING_ARG_FIELDS: &[&str] = &["id",
970 "sync_setting"];
971impl ContentSyncSettingArg {
972 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
973 map: V,
974 ) -> Result<ContentSyncSettingArg, V::Error> {
975 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
976 }
977
978 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
979 mut map: V,
980 optional: bool,
981 ) -> Result<Option<ContentSyncSettingArg>, V::Error> {
982 let mut field_id = None;
983 let mut field_sync_setting = None;
984 let mut nothing = true;
985 while let Some(key) = map.next_key::<&str>()? {
986 nothing = false;
987 match key {
988 "id" => {
989 if field_id.is_some() {
990 return Err(::serde::de::Error::duplicate_field("id"));
991 }
992 field_id = Some(map.next_value()?);
993 }
994 "sync_setting" => {
995 if field_sync_setting.is_some() {
996 return Err(::serde::de::Error::duplicate_field("sync_setting"));
997 }
998 field_sync_setting = Some(map.next_value()?);
999 }
1000 _ => {
1001 map.next_value::<::serde_json::Value>()?;
1003 }
1004 }
1005 }
1006 if optional && nothing {
1007 return Ok(None);
1008 }
1009 let result = ContentSyncSettingArg {
1010 id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
1011 sync_setting: field_sync_setting.ok_or_else(|| ::serde::de::Error::missing_field("sync_setting"))?,
1012 };
1013 Ok(Some(result))
1014 }
1015
1016 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1017 &self,
1018 s: &mut S::SerializeStruct,
1019 ) -> Result<(), S::Error> {
1020 use serde::ser::SerializeStruct;
1021 s.serialize_field("id", &self.id)?;
1022 s.serialize_field("sync_setting", &self.sync_setting)?;
1023 Ok(())
1024 }
1025}
1026
1027impl<'de> ::serde::de::Deserialize<'de> for ContentSyncSettingArg {
1028 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1029 use serde::de::{MapAccess, Visitor};
1031 struct StructVisitor;
1032 impl<'de> Visitor<'de> for StructVisitor {
1033 type Value = ContentSyncSettingArg;
1034 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1035 f.write_str("a ContentSyncSettingArg struct")
1036 }
1037 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1038 ContentSyncSettingArg::internal_deserialize(map)
1039 }
1040 }
1041 deserializer.deserialize_struct("ContentSyncSettingArg", CONTENT_SYNC_SETTING_ARG_FIELDS, StructVisitor)
1042 }
1043}
1044
1045impl ::serde::ser::Serialize for ContentSyncSettingArg {
1046 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1047 use serde::ser::SerializeStruct;
1049 let mut s = serializer.serialize_struct("ContentSyncSettingArg", 2)?;
1050 self.internal_serialize::<S>(&mut s)?;
1051 s.end()
1052 }
1053}
1054
1055#[derive(Debug, Clone, PartialEq, Eq)]
1056#[non_exhaustive] pub struct CreateFolderArg {
1058 pub path: WritePath,
1060 pub autorename: bool,
1063}
1064
1065impl CreateFolderArg {
1066 pub fn new(path: WritePath) -> Self {
1067 CreateFolderArg {
1068 path,
1069 autorename: false,
1070 }
1071 }
1072
1073 pub fn with_autorename(mut self, value: bool) -> Self {
1074 self.autorename = value;
1075 self
1076 }
1077}
1078
1079const CREATE_FOLDER_ARG_FIELDS: &[&str] = &["path",
1080 "autorename"];
1081impl CreateFolderArg {
1082 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1083 map: V,
1084 ) -> Result<CreateFolderArg, V::Error> {
1085 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1086 }
1087
1088 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1089 mut map: V,
1090 optional: bool,
1091 ) -> Result<Option<CreateFolderArg>, V::Error> {
1092 let mut field_path = None;
1093 let mut field_autorename = None;
1094 let mut nothing = true;
1095 while let Some(key) = map.next_key::<&str>()? {
1096 nothing = false;
1097 match key {
1098 "path" => {
1099 if field_path.is_some() {
1100 return Err(::serde::de::Error::duplicate_field("path"));
1101 }
1102 field_path = Some(map.next_value()?);
1103 }
1104 "autorename" => {
1105 if field_autorename.is_some() {
1106 return Err(::serde::de::Error::duplicate_field("autorename"));
1107 }
1108 field_autorename = Some(map.next_value()?);
1109 }
1110 _ => {
1111 map.next_value::<::serde_json::Value>()?;
1113 }
1114 }
1115 }
1116 if optional && nothing {
1117 return Ok(None);
1118 }
1119 let result = CreateFolderArg {
1120 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
1121 autorename: field_autorename.unwrap_or(false),
1122 };
1123 Ok(Some(result))
1124 }
1125
1126 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1127 &self,
1128 s: &mut S::SerializeStruct,
1129 ) -> Result<(), S::Error> {
1130 use serde::ser::SerializeStruct;
1131 s.serialize_field("path", &self.path)?;
1132 if self.autorename {
1133 s.serialize_field("autorename", &self.autorename)?;
1134 }
1135 Ok(())
1136 }
1137}
1138
1139impl<'de> ::serde::de::Deserialize<'de> for CreateFolderArg {
1140 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1141 use serde::de::{MapAccess, Visitor};
1143 struct StructVisitor;
1144 impl<'de> Visitor<'de> for StructVisitor {
1145 type Value = CreateFolderArg;
1146 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1147 f.write_str("a CreateFolderArg struct")
1148 }
1149 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1150 CreateFolderArg::internal_deserialize(map)
1151 }
1152 }
1153 deserializer.deserialize_struct("CreateFolderArg", CREATE_FOLDER_ARG_FIELDS, StructVisitor)
1154 }
1155}
1156
1157impl ::serde::ser::Serialize for CreateFolderArg {
1158 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1159 use serde::ser::SerializeStruct;
1161 let mut s = serializer.serialize_struct("CreateFolderArg", 2)?;
1162 self.internal_serialize::<S>(&mut s)?;
1163 s.end()
1164 }
1165}
1166
1167#[derive(Debug, Clone, PartialEq, Eq)]
1168#[non_exhaustive] pub struct CreateFolderBatchArg {
1170 pub paths: Vec<WritePath>,
1173 pub autorename: bool,
1176 pub force_async: bool,
1178}
1179
1180impl CreateFolderBatchArg {
1181 pub fn new(paths: Vec<WritePath>) -> Self {
1182 CreateFolderBatchArg {
1183 paths,
1184 autorename: false,
1185 force_async: false,
1186 }
1187 }
1188
1189 pub fn with_autorename(mut self, value: bool) -> Self {
1190 self.autorename = value;
1191 self
1192 }
1193
1194 pub fn with_force_async(mut self, value: bool) -> Self {
1195 self.force_async = value;
1196 self
1197 }
1198}
1199
1200const CREATE_FOLDER_BATCH_ARG_FIELDS: &[&str] = &["paths",
1201 "autorename",
1202 "force_async"];
1203impl CreateFolderBatchArg {
1204 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1205 map: V,
1206 ) -> Result<CreateFolderBatchArg, V::Error> {
1207 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1208 }
1209
1210 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1211 mut map: V,
1212 optional: bool,
1213 ) -> Result<Option<CreateFolderBatchArg>, V::Error> {
1214 let mut field_paths = None;
1215 let mut field_autorename = None;
1216 let mut field_force_async = None;
1217 let mut nothing = true;
1218 while let Some(key) = map.next_key::<&str>()? {
1219 nothing = false;
1220 match key {
1221 "paths" => {
1222 if field_paths.is_some() {
1223 return Err(::serde::de::Error::duplicate_field("paths"));
1224 }
1225 field_paths = Some(map.next_value()?);
1226 }
1227 "autorename" => {
1228 if field_autorename.is_some() {
1229 return Err(::serde::de::Error::duplicate_field("autorename"));
1230 }
1231 field_autorename = Some(map.next_value()?);
1232 }
1233 "force_async" => {
1234 if field_force_async.is_some() {
1235 return Err(::serde::de::Error::duplicate_field("force_async"));
1236 }
1237 field_force_async = Some(map.next_value()?);
1238 }
1239 _ => {
1240 map.next_value::<::serde_json::Value>()?;
1242 }
1243 }
1244 }
1245 if optional && nothing {
1246 return Ok(None);
1247 }
1248 let result = CreateFolderBatchArg {
1249 paths: field_paths.ok_or_else(|| ::serde::de::Error::missing_field("paths"))?,
1250 autorename: field_autorename.unwrap_or(false),
1251 force_async: field_force_async.unwrap_or(false),
1252 };
1253 Ok(Some(result))
1254 }
1255
1256 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1257 &self,
1258 s: &mut S::SerializeStruct,
1259 ) -> Result<(), S::Error> {
1260 use serde::ser::SerializeStruct;
1261 s.serialize_field("paths", &self.paths)?;
1262 if self.autorename {
1263 s.serialize_field("autorename", &self.autorename)?;
1264 }
1265 if self.force_async {
1266 s.serialize_field("force_async", &self.force_async)?;
1267 }
1268 Ok(())
1269 }
1270}
1271
1272impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchArg {
1273 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1274 use serde::de::{MapAccess, Visitor};
1276 struct StructVisitor;
1277 impl<'de> Visitor<'de> for StructVisitor {
1278 type Value = CreateFolderBatchArg;
1279 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1280 f.write_str("a CreateFolderBatchArg struct")
1281 }
1282 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1283 CreateFolderBatchArg::internal_deserialize(map)
1284 }
1285 }
1286 deserializer.deserialize_struct("CreateFolderBatchArg", CREATE_FOLDER_BATCH_ARG_FIELDS, StructVisitor)
1287 }
1288}
1289
1290impl ::serde::ser::Serialize for CreateFolderBatchArg {
1291 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1292 use serde::ser::SerializeStruct;
1294 let mut s = serializer.serialize_struct("CreateFolderBatchArg", 3)?;
1295 self.internal_serialize::<S>(&mut s)?;
1296 s.end()
1297 }
1298}
1299
1300#[derive(Debug, Clone, PartialEq, Eq)]
1301#[non_exhaustive] pub enum CreateFolderBatchError {
1303 TooManyFiles,
1305 Other,
1308}
1309
1310impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchError {
1311 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1312 use serde::de::{self, MapAccess, Visitor};
1314 struct EnumVisitor;
1315 impl<'de> Visitor<'de> for EnumVisitor {
1316 type Value = CreateFolderBatchError;
1317 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1318 f.write_str("a CreateFolderBatchError structure")
1319 }
1320 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1321 let tag: &str = match map.next_key()? {
1322 Some(".tag") => map.next_value()?,
1323 _ => return Err(de::Error::missing_field(".tag"))
1324 };
1325 let value = match tag {
1326 "too_many_files" => CreateFolderBatchError::TooManyFiles,
1327 _ => CreateFolderBatchError::Other,
1328 };
1329 crate::eat_json_fields(&mut map)?;
1330 Ok(value)
1331 }
1332 }
1333 const VARIANTS: &[&str] = &["too_many_files",
1334 "other"];
1335 deserializer.deserialize_struct("CreateFolderBatchError", VARIANTS, EnumVisitor)
1336 }
1337}
1338
1339impl ::serde::ser::Serialize for CreateFolderBatchError {
1340 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1341 use serde::ser::SerializeStruct;
1343 match self {
1344 CreateFolderBatchError::TooManyFiles => {
1345 let mut s = serializer.serialize_struct("CreateFolderBatchError", 1)?;
1347 s.serialize_field(".tag", "too_many_files")?;
1348 s.end()
1349 }
1350 CreateFolderBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1351 }
1352 }
1353}
1354
1355impl ::std::error::Error for CreateFolderBatchError {
1356}
1357
1358impl ::std::fmt::Display for CreateFolderBatchError {
1359 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1360 match self {
1361 CreateFolderBatchError::TooManyFiles => f.write_str("The operation would involve too many files or folders."),
1362 _ => write!(f, "{:?}", *self),
1363 }
1364 }
1365}
1366
1367#[derive(Debug, Clone, PartialEq, Eq)]
1368#[non_exhaustive] pub enum CreateFolderBatchJobStatus {
1370 InProgress,
1372 Complete(CreateFolderBatchResult),
1374 Failed(CreateFolderBatchError),
1376 Other,
1379}
1380
1381impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchJobStatus {
1382 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1383 use serde::de::{self, MapAccess, Visitor};
1385 struct EnumVisitor;
1386 impl<'de> Visitor<'de> for EnumVisitor {
1387 type Value = CreateFolderBatchJobStatus;
1388 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1389 f.write_str("a CreateFolderBatchJobStatus structure")
1390 }
1391 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1392 let tag: &str = match map.next_key()? {
1393 Some(".tag") => map.next_value()?,
1394 _ => return Err(de::Error::missing_field(".tag"))
1395 };
1396 let value = match tag {
1397 "in_progress" => CreateFolderBatchJobStatus::InProgress,
1398 "complete" => CreateFolderBatchJobStatus::Complete(CreateFolderBatchResult::internal_deserialize(&mut map)?),
1399 "failed" => {
1400 match map.next_key()? {
1401 Some("failed") => CreateFolderBatchJobStatus::Failed(map.next_value()?),
1402 None => return Err(de::Error::missing_field("failed")),
1403 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1404 }
1405 }
1406 _ => CreateFolderBatchJobStatus::Other,
1407 };
1408 crate::eat_json_fields(&mut map)?;
1409 Ok(value)
1410 }
1411 }
1412 const VARIANTS: &[&str] = &["in_progress",
1413 "complete",
1414 "failed",
1415 "other"];
1416 deserializer.deserialize_struct("CreateFolderBatchJobStatus", VARIANTS, EnumVisitor)
1417 }
1418}
1419
1420impl ::serde::ser::Serialize for CreateFolderBatchJobStatus {
1421 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1422 use serde::ser::SerializeStruct;
1424 match self {
1425 CreateFolderBatchJobStatus::InProgress => {
1426 let mut s = serializer.serialize_struct("CreateFolderBatchJobStatus", 1)?;
1428 s.serialize_field(".tag", "in_progress")?;
1429 s.end()
1430 }
1431 CreateFolderBatchJobStatus::Complete(x) => {
1432 let mut s = serializer.serialize_struct("CreateFolderBatchJobStatus", 2)?;
1434 s.serialize_field(".tag", "complete")?;
1435 x.internal_serialize::<S>(&mut s)?;
1436 s.end()
1437 }
1438 CreateFolderBatchJobStatus::Failed(x) => {
1439 let mut s = serializer.serialize_struct("CreateFolderBatchJobStatus", 2)?;
1441 s.serialize_field(".tag", "failed")?;
1442 s.serialize_field("failed", x)?;
1443 s.end()
1444 }
1445 CreateFolderBatchJobStatus::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1446 }
1447 }
1448}
1449
1450impl From<crate::types::dbx_async::PollResultBase> for CreateFolderBatchJobStatus {
1452 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
1453 match parent {
1454 crate::types::dbx_async::PollResultBase::InProgress => CreateFolderBatchJobStatus::InProgress,
1455 }
1456 }
1457}
1458#[derive(Debug, Clone, PartialEq, Eq)]
1461#[non_exhaustive] pub enum CreateFolderBatchLaunch {
1463 AsyncJobId(crate::types::dbx_async::AsyncJobId),
1466 Complete(CreateFolderBatchResult),
1467 Other,
1470}
1471
1472impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchLaunch {
1473 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1474 use serde::de::{self, MapAccess, Visitor};
1476 struct EnumVisitor;
1477 impl<'de> Visitor<'de> for EnumVisitor {
1478 type Value = CreateFolderBatchLaunch;
1479 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1480 f.write_str("a CreateFolderBatchLaunch structure")
1481 }
1482 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1483 let tag: &str = match map.next_key()? {
1484 Some(".tag") => map.next_value()?,
1485 _ => return Err(de::Error::missing_field(".tag"))
1486 };
1487 let value = match tag {
1488 "async_job_id" => {
1489 match map.next_key()? {
1490 Some("async_job_id") => CreateFolderBatchLaunch::AsyncJobId(map.next_value()?),
1491 None => return Err(de::Error::missing_field("async_job_id")),
1492 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1493 }
1494 }
1495 "complete" => CreateFolderBatchLaunch::Complete(CreateFolderBatchResult::internal_deserialize(&mut map)?),
1496 _ => CreateFolderBatchLaunch::Other,
1497 };
1498 crate::eat_json_fields(&mut map)?;
1499 Ok(value)
1500 }
1501 }
1502 const VARIANTS: &[&str] = &["async_job_id",
1503 "complete",
1504 "other"];
1505 deserializer.deserialize_struct("CreateFolderBatchLaunch", VARIANTS, EnumVisitor)
1506 }
1507}
1508
1509impl ::serde::ser::Serialize for CreateFolderBatchLaunch {
1510 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1511 use serde::ser::SerializeStruct;
1513 match self {
1514 CreateFolderBatchLaunch::AsyncJobId(x) => {
1515 let mut s = serializer.serialize_struct("CreateFolderBatchLaunch", 2)?;
1517 s.serialize_field(".tag", "async_job_id")?;
1518 s.serialize_field("async_job_id", x)?;
1519 s.end()
1520 }
1521 CreateFolderBatchLaunch::Complete(x) => {
1522 let mut s = serializer.serialize_struct("CreateFolderBatchLaunch", 2)?;
1524 s.serialize_field(".tag", "complete")?;
1525 x.internal_serialize::<S>(&mut s)?;
1526 s.end()
1527 }
1528 CreateFolderBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1529 }
1530 }
1531}
1532
1533impl From<crate::types::dbx_async::LaunchResultBase> for CreateFolderBatchLaunch {
1535 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
1536 match parent {
1537 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => CreateFolderBatchLaunch::AsyncJobId(x),
1538 }
1539 }
1540}
1541#[derive(Debug, Clone, PartialEq, Eq)]
1542#[non_exhaustive] pub struct CreateFolderBatchResult {
1544 pub entries: Vec<CreateFolderBatchResultEntry>,
1547}
1548
1549impl CreateFolderBatchResult {
1550 pub fn new(entries: Vec<CreateFolderBatchResultEntry>) -> Self {
1551 CreateFolderBatchResult {
1552 entries,
1553 }
1554 }
1555}
1556
1557const CREATE_FOLDER_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
1558impl CreateFolderBatchResult {
1559 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1560 map: V,
1561 ) -> Result<CreateFolderBatchResult, V::Error> {
1562 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1563 }
1564
1565 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1566 mut map: V,
1567 optional: bool,
1568 ) -> Result<Option<CreateFolderBatchResult>, V::Error> {
1569 let mut field_entries = None;
1570 let mut nothing = true;
1571 while let Some(key) = map.next_key::<&str>()? {
1572 nothing = false;
1573 match key {
1574 "entries" => {
1575 if field_entries.is_some() {
1576 return Err(::serde::de::Error::duplicate_field("entries"));
1577 }
1578 field_entries = Some(map.next_value()?);
1579 }
1580 _ => {
1581 map.next_value::<::serde_json::Value>()?;
1583 }
1584 }
1585 }
1586 if optional && nothing {
1587 return Ok(None);
1588 }
1589 let result = CreateFolderBatchResult {
1590 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
1591 };
1592 Ok(Some(result))
1593 }
1594
1595 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1596 &self,
1597 s: &mut S::SerializeStruct,
1598 ) -> Result<(), S::Error> {
1599 use serde::ser::SerializeStruct;
1600 s.serialize_field("entries", &self.entries)?;
1601 Ok(())
1602 }
1603}
1604
1605impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchResult {
1606 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1607 use serde::de::{MapAccess, Visitor};
1609 struct StructVisitor;
1610 impl<'de> Visitor<'de> for StructVisitor {
1611 type Value = CreateFolderBatchResult;
1612 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1613 f.write_str("a CreateFolderBatchResult struct")
1614 }
1615 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1616 CreateFolderBatchResult::internal_deserialize(map)
1617 }
1618 }
1619 deserializer.deserialize_struct("CreateFolderBatchResult", CREATE_FOLDER_BATCH_RESULT_FIELDS, StructVisitor)
1620 }
1621}
1622
1623impl ::serde::ser::Serialize for CreateFolderBatchResult {
1624 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1625 use serde::ser::SerializeStruct;
1627 let mut s = serializer.serialize_struct("CreateFolderBatchResult", 1)?;
1628 self.internal_serialize::<S>(&mut s)?;
1629 s.end()
1630 }
1631}
1632
1633impl From<CreateFolderBatchResult> for FileOpsResult {
1635 fn from(_: CreateFolderBatchResult) -> Self {
1636 Self {}
1637 }
1638}
1639#[derive(Debug, Clone, PartialEq, Eq)]
1640pub enum CreateFolderBatchResultEntry {
1641 Success(CreateFolderEntryResult),
1642 Failure(CreateFolderEntryError),
1643}
1644
1645impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchResultEntry {
1646 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1647 use serde::de::{self, MapAccess, Visitor};
1649 struct EnumVisitor;
1650 impl<'de> Visitor<'de> for EnumVisitor {
1651 type Value = CreateFolderBatchResultEntry;
1652 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1653 f.write_str("a CreateFolderBatchResultEntry structure")
1654 }
1655 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1656 let tag: &str = match map.next_key()? {
1657 Some(".tag") => map.next_value()?,
1658 _ => return Err(de::Error::missing_field(".tag"))
1659 };
1660 let value = match tag {
1661 "success" => CreateFolderBatchResultEntry::Success(CreateFolderEntryResult::internal_deserialize(&mut map)?),
1662 "failure" => {
1663 match map.next_key()? {
1664 Some("failure") => CreateFolderBatchResultEntry::Failure(map.next_value()?),
1665 None => return Err(de::Error::missing_field("failure")),
1666 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1667 }
1668 }
1669 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
1670 };
1671 crate::eat_json_fields(&mut map)?;
1672 Ok(value)
1673 }
1674 }
1675 const VARIANTS: &[&str] = &["success",
1676 "failure"];
1677 deserializer.deserialize_struct("CreateFolderBatchResultEntry", VARIANTS, EnumVisitor)
1678 }
1679}
1680
1681impl ::serde::ser::Serialize for CreateFolderBatchResultEntry {
1682 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1683 use serde::ser::SerializeStruct;
1685 match self {
1686 CreateFolderBatchResultEntry::Success(x) => {
1687 let mut s = serializer.serialize_struct("CreateFolderBatchResultEntry", 2)?;
1689 s.serialize_field(".tag", "success")?;
1690 x.internal_serialize::<S>(&mut s)?;
1691 s.end()
1692 }
1693 CreateFolderBatchResultEntry::Failure(x) => {
1694 let mut s = serializer.serialize_struct("CreateFolderBatchResultEntry", 2)?;
1696 s.serialize_field(".tag", "failure")?;
1697 s.serialize_field("failure", x)?;
1698 s.end()
1699 }
1700 }
1701 }
1702}
1703
1704#[derive(Debug, Clone, PartialEq, Eq)]
1705#[non_exhaustive] pub enum CreateFolderEntryError {
1707 Path(WriteError),
1708 Other,
1711}
1712
1713impl<'de> ::serde::de::Deserialize<'de> for CreateFolderEntryError {
1714 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1715 use serde::de::{self, MapAccess, Visitor};
1717 struct EnumVisitor;
1718 impl<'de> Visitor<'de> for EnumVisitor {
1719 type Value = CreateFolderEntryError;
1720 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1721 f.write_str("a CreateFolderEntryError structure")
1722 }
1723 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1724 let tag: &str = match map.next_key()? {
1725 Some(".tag") => map.next_value()?,
1726 _ => return Err(de::Error::missing_field(".tag"))
1727 };
1728 let value = match tag {
1729 "path" => {
1730 match map.next_key()? {
1731 Some("path") => CreateFolderEntryError::Path(map.next_value()?),
1732 None => return Err(de::Error::missing_field("path")),
1733 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1734 }
1735 }
1736 _ => CreateFolderEntryError::Other,
1737 };
1738 crate::eat_json_fields(&mut map)?;
1739 Ok(value)
1740 }
1741 }
1742 const VARIANTS: &[&str] = &["path",
1743 "other"];
1744 deserializer.deserialize_struct("CreateFolderEntryError", VARIANTS, EnumVisitor)
1745 }
1746}
1747
1748impl ::serde::ser::Serialize for CreateFolderEntryError {
1749 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1750 use serde::ser::SerializeStruct;
1752 match self {
1753 CreateFolderEntryError::Path(x) => {
1754 let mut s = serializer.serialize_struct("CreateFolderEntryError", 2)?;
1756 s.serialize_field(".tag", "path")?;
1757 s.serialize_field("path", x)?;
1758 s.end()
1759 }
1760 CreateFolderEntryError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1761 }
1762 }
1763}
1764
1765impl ::std::error::Error for CreateFolderEntryError {
1766 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
1767 match self {
1768 CreateFolderEntryError::Path(inner) => Some(inner),
1769 _ => None,
1770 }
1771 }
1772}
1773
1774impl ::std::fmt::Display for CreateFolderEntryError {
1775 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1776 match self {
1777 CreateFolderEntryError::Path(inner) => write!(f, "CreateFolderEntryError: {}", inner),
1778 _ => write!(f, "{:?}", *self),
1779 }
1780 }
1781}
1782
1783#[derive(Debug, Clone, PartialEq, Eq)]
1784#[non_exhaustive] pub struct CreateFolderEntryResult {
1786 pub metadata: FolderMetadata,
1788}
1789
1790impl CreateFolderEntryResult {
1791 pub fn new(metadata: FolderMetadata) -> Self {
1792 CreateFolderEntryResult {
1793 metadata,
1794 }
1795 }
1796}
1797
1798const CREATE_FOLDER_ENTRY_RESULT_FIELDS: &[&str] = &["metadata"];
1799impl CreateFolderEntryResult {
1800 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1801 map: V,
1802 ) -> Result<CreateFolderEntryResult, V::Error> {
1803 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1804 }
1805
1806 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1807 mut map: V,
1808 optional: bool,
1809 ) -> Result<Option<CreateFolderEntryResult>, V::Error> {
1810 let mut field_metadata = None;
1811 let mut nothing = true;
1812 while let Some(key) = map.next_key::<&str>()? {
1813 nothing = false;
1814 match key {
1815 "metadata" => {
1816 if field_metadata.is_some() {
1817 return Err(::serde::de::Error::duplicate_field("metadata"));
1818 }
1819 field_metadata = Some(map.next_value()?);
1820 }
1821 _ => {
1822 map.next_value::<::serde_json::Value>()?;
1824 }
1825 }
1826 }
1827 if optional && nothing {
1828 return Ok(None);
1829 }
1830 let result = CreateFolderEntryResult {
1831 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
1832 };
1833 Ok(Some(result))
1834 }
1835
1836 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1837 &self,
1838 s: &mut S::SerializeStruct,
1839 ) -> Result<(), S::Error> {
1840 use serde::ser::SerializeStruct;
1841 s.serialize_field("metadata", &self.metadata)?;
1842 Ok(())
1843 }
1844}
1845
1846impl<'de> ::serde::de::Deserialize<'de> for CreateFolderEntryResult {
1847 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1848 use serde::de::{MapAccess, Visitor};
1850 struct StructVisitor;
1851 impl<'de> Visitor<'de> for StructVisitor {
1852 type Value = CreateFolderEntryResult;
1853 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1854 f.write_str("a CreateFolderEntryResult struct")
1855 }
1856 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1857 CreateFolderEntryResult::internal_deserialize(map)
1858 }
1859 }
1860 deserializer.deserialize_struct("CreateFolderEntryResult", CREATE_FOLDER_ENTRY_RESULT_FIELDS, StructVisitor)
1861 }
1862}
1863
1864impl ::serde::ser::Serialize for CreateFolderEntryResult {
1865 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1866 use serde::ser::SerializeStruct;
1868 let mut s = serializer.serialize_struct("CreateFolderEntryResult", 1)?;
1869 self.internal_serialize::<S>(&mut s)?;
1870 s.end()
1871 }
1872}
1873
1874#[derive(Debug, Clone, PartialEq, Eq)]
1875pub enum CreateFolderError {
1876 Path(WriteError),
1877}
1878
1879impl<'de> ::serde::de::Deserialize<'de> for CreateFolderError {
1880 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1881 use serde::de::{self, MapAccess, Visitor};
1883 struct EnumVisitor;
1884 impl<'de> Visitor<'de> for EnumVisitor {
1885 type Value = CreateFolderError;
1886 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1887 f.write_str("a CreateFolderError structure")
1888 }
1889 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1890 let tag: &str = match map.next_key()? {
1891 Some(".tag") => map.next_value()?,
1892 _ => return Err(de::Error::missing_field(".tag"))
1893 };
1894 let value = match tag {
1895 "path" => {
1896 match map.next_key()? {
1897 Some("path") => CreateFolderError::Path(map.next_value()?),
1898 None => return Err(de::Error::missing_field("path")),
1899 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1900 }
1901 }
1902 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
1903 };
1904 crate::eat_json_fields(&mut map)?;
1905 Ok(value)
1906 }
1907 }
1908 const VARIANTS: &[&str] = &["path"];
1909 deserializer.deserialize_struct("CreateFolderError", VARIANTS, EnumVisitor)
1910 }
1911}
1912
1913impl ::serde::ser::Serialize for CreateFolderError {
1914 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1915 use serde::ser::SerializeStruct;
1917 match self {
1918 CreateFolderError::Path(x) => {
1919 let mut s = serializer.serialize_struct("CreateFolderError", 2)?;
1921 s.serialize_field(".tag", "path")?;
1922 s.serialize_field("path", x)?;
1923 s.end()
1924 }
1925 }
1926 }
1927}
1928
1929impl ::std::error::Error for CreateFolderError {
1930 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
1931 match self {
1932 CreateFolderError::Path(inner) => Some(inner),
1933 }
1934 }
1935}
1936
1937impl ::std::fmt::Display for CreateFolderError {
1938 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1939 match self {
1940 CreateFolderError::Path(inner) => write!(f, "CreateFolderError: {}", inner),
1941 }
1942 }
1943}
1944
1945#[derive(Debug, Clone, PartialEq, Eq)]
1946#[non_exhaustive] pub struct CreateFolderResult {
1948 pub metadata: FolderMetadata,
1950}
1951
1952impl CreateFolderResult {
1953 pub fn new(metadata: FolderMetadata) -> Self {
1954 CreateFolderResult {
1955 metadata,
1956 }
1957 }
1958}
1959
1960const CREATE_FOLDER_RESULT_FIELDS: &[&str] = &["metadata"];
1961impl CreateFolderResult {
1962 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1963 map: V,
1964 ) -> Result<CreateFolderResult, V::Error> {
1965 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1966 }
1967
1968 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1969 mut map: V,
1970 optional: bool,
1971 ) -> Result<Option<CreateFolderResult>, V::Error> {
1972 let mut field_metadata = None;
1973 let mut nothing = true;
1974 while let Some(key) = map.next_key::<&str>()? {
1975 nothing = false;
1976 match key {
1977 "metadata" => {
1978 if field_metadata.is_some() {
1979 return Err(::serde::de::Error::duplicate_field("metadata"));
1980 }
1981 field_metadata = Some(map.next_value()?);
1982 }
1983 _ => {
1984 map.next_value::<::serde_json::Value>()?;
1986 }
1987 }
1988 }
1989 if optional && nothing {
1990 return Ok(None);
1991 }
1992 let result = CreateFolderResult {
1993 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
1994 };
1995 Ok(Some(result))
1996 }
1997
1998 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1999 &self,
2000 s: &mut S::SerializeStruct,
2001 ) -> Result<(), S::Error> {
2002 use serde::ser::SerializeStruct;
2003 s.serialize_field("metadata", &self.metadata)?;
2004 Ok(())
2005 }
2006}
2007
2008impl<'de> ::serde::de::Deserialize<'de> for CreateFolderResult {
2009 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2010 use serde::de::{MapAccess, Visitor};
2012 struct StructVisitor;
2013 impl<'de> Visitor<'de> for StructVisitor {
2014 type Value = CreateFolderResult;
2015 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2016 f.write_str("a CreateFolderResult struct")
2017 }
2018 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2019 CreateFolderResult::internal_deserialize(map)
2020 }
2021 }
2022 deserializer.deserialize_struct("CreateFolderResult", CREATE_FOLDER_RESULT_FIELDS, StructVisitor)
2023 }
2024}
2025
2026impl ::serde::ser::Serialize for CreateFolderResult {
2027 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2028 use serde::ser::SerializeStruct;
2030 let mut s = serializer.serialize_struct("CreateFolderResult", 1)?;
2031 self.internal_serialize::<S>(&mut s)?;
2032 s.end()
2033 }
2034}
2035
2036impl From<CreateFolderResult> for FileOpsResult {
2038 fn from(_: CreateFolderResult) -> Self {
2039 Self {}
2040 }
2041}
2042#[derive(Debug, Clone, PartialEq, Eq)]
2043#[non_exhaustive] pub struct DeleteArg {
2045 pub path: WritePathOrId,
2047 pub parent_rev: Option<Rev>,
2050}
2051
2052impl DeleteArg {
2053 pub fn new(path: WritePathOrId) -> Self {
2054 DeleteArg {
2055 path,
2056 parent_rev: None,
2057 }
2058 }
2059
2060 pub fn with_parent_rev(mut self, value: Rev) -> Self {
2061 self.parent_rev = Some(value);
2062 self
2063 }
2064}
2065
2066const DELETE_ARG_FIELDS: &[&str] = &["path",
2067 "parent_rev"];
2068impl DeleteArg {
2069 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2070 map: V,
2071 ) -> Result<DeleteArg, V::Error> {
2072 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2073 }
2074
2075 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2076 mut map: V,
2077 optional: bool,
2078 ) -> Result<Option<DeleteArg>, V::Error> {
2079 let mut field_path = None;
2080 let mut field_parent_rev = None;
2081 let mut nothing = true;
2082 while let Some(key) = map.next_key::<&str>()? {
2083 nothing = false;
2084 match key {
2085 "path" => {
2086 if field_path.is_some() {
2087 return Err(::serde::de::Error::duplicate_field("path"));
2088 }
2089 field_path = Some(map.next_value()?);
2090 }
2091 "parent_rev" => {
2092 if field_parent_rev.is_some() {
2093 return Err(::serde::de::Error::duplicate_field("parent_rev"));
2094 }
2095 field_parent_rev = Some(map.next_value()?);
2096 }
2097 _ => {
2098 map.next_value::<::serde_json::Value>()?;
2100 }
2101 }
2102 }
2103 if optional && nothing {
2104 return Ok(None);
2105 }
2106 let result = DeleteArg {
2107 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
2108 parent_rev: field_parent_rev.and_then(Option::flatten),
2109 };
2110 Ok(Some(result))
2111 }
2112
2113 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2114 &self,
2115 s: &mut S::SerializeStruct,
2116 ) -> Result<(), S::Error> {
2117 use serde::ser::SerializeStruct;
2118 s.serialize_field("path", &self.path)?;
2119 if let Some(val) = &self.parent_rev {
2120 s.serialize_field("parent_rev", val)?;
2121 }
2122 Ok(())
2123 }
2124}
2125
2126impl<'de> ::serde::de::Deserialize<'de> for DeleteArg {
2127 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2128 use serde::de::{MapAccess, Visitor};
2130 struct StructVisitor;
2131 impl<'de> Visitor<'de> for StructVisitor {
2132 type Value = DeleteArg;
2133 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2134 f.write_str("a DeleteArg struct")
2135 }
2136 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2137 DeleteArg::internal_deserialize(map)
2138 }
2139 }
2140 deserializer.deserialize_struct("DeleteArg", DELETE_ARG_FIELDS, StructVisitor)
2141 }
2142}
2143
2144impl ::serde::ser::Serialize for DeleteArg {
2145 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2146 use serde::ser::SerializeStruct;
2148 let mut s = serializer.serialize_struct("DeleteArg", 2)?;
2149 self.internal_serialize::<S>(&mut s)?;
2150 s.end()
2151 }
2152}
2153
2154#[derive(Debug, Clone, PartialEq, Eq)]
2155#[non_exhaustive] pub struct DeleteBatchArg {
2157 pub entries: Vec<DeleteArg>,
2158}
2159
2160impl DeleteBatchArg {
2161 pub fn new(entries: Vec<DeleteArg>) -> Self {
2162 DeleteBatchArg {
2163 entries,
2164 }
2165 }
2166}
2167
2168const DELETE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
2169impl DeleteBatchArg {
2170 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2171 map: V,
2172 ) -> Result<DeleteBatchArg, V::Error> {
2173 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2174 }
2175
2176 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2177 mut map: V,
2178 optional: bool,
2179 ) -> Result<Option<DeleteBatchArg>, V::Error> {
2180 let mut field_entries = None;
2181 let mut nothing = true;
2182 while let Some(key) = map.next_key::<&str>()? {
2183 nothing = false;
2184 match key {
2185 "entries" => {
2186 if field_entries.is_some() {
2187 return Err(::serde::de::Error::duplicate_field("entries"));
2188 }
2189 field_entries = Some(map.next_value()?);
2190 }
2191 _ => {
2192 map.next_value::<::serde_json::Value>()?;
2194 }
2195 }
2196 }
2197 if optional && nothing {
2198 return Ok(None);
2199 }
2200 let result = DeleteBatchArg {
2201 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
2202 };
2203 Ok(Some(result))
2204 }
2205
2206 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2207 &self,
2208 s: &mut S::SerializeStruct,
2209 ) -> Result<(), S::Error> {
2210 use serde::ser::SerializeStruct;
2211 s.serialize_field("entries", &self.entries)?;
2212 Ok(())
2213 }
2214}
2215
2216impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchArg {
2217 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2218 use serde::de::{MapAccess, Visitor};
2220 struct StructVisitor;
2221 impl<'de> Visitor<'de> for StructVisitor {
2222 type Value = DeleteBatchArg;
2223 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2224 f.write_str("a DeleteBatchArg struct")
2225 }
2226 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2227 DeleteBatchArg::internal_deserialize(map)
2228 }
2229 }
2230 deserializer.deserialize_struct("DeleteBatchArg", DELETE_BATCH_ARG_FIELDS, StructVisitor)
2231 }
2232}
2233
2234impl ::serde::ser::Serialize for DeleteBatchArg {
2235 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2236 use serde::ser::SerializeStruct;
2238 let mut s = serializer.serialize_struct("DeleteBatchArg", 1)?;
2239 self.internal_serialize::<S>(&mut s)?;
2240 s.end()
2241 }
2242}
2243
2244#[derive(Debug, Clone, PartialEq, Eq)]
2245#[non_exhaustive] pub enum DeleteBatchError {
2247 TooManyWriteOperations,
2250 Other,
2253}
2254
2255impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchError {
2256 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2257 use serde::de::{self, MapAccess, Visitor};
2259 struct EnumVisitor;
2260 impl<'de> Visitor<'de> for EnumVisitor {
2261 type Value = DeleteBatchError;
2262 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2263 f.write_str("a DeleteBatchError structure")
2264 }
2265 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2266 let tag: &str = match map.next_key()? {
2267 Some(".tag") => map.next_value()?,
2268 _ => return Err(de::Error::missing_field(".tag"))
2269 };
2270 let value = match tag {
2271 "too_many_write_operations" => DeleteBatchError::TooManyWriteOperations,
2272 _ => DeleteBatchError::Other,
2273 };
2274 crate::eat_json_fields(&mut map)?;
2275 Ok(value)
2276 }
2277 }
2278 const VARIANTS: &[&str] = &["too_many_write_operations",
2279 "other"];
2280 deserializer.deserialize_struct("DeleteBatchError", VARIANTS, EnumVisitor)
2281 }
2282}
2283
2284impl ::serde::ser::Serialize for DeleteBatchError {
2285 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2286 use serde::ser::SerializeStruct;
2288 match self {
2289 DeleteBatchError::TooManyWriteOperations => {
2290 let mut s = serializer.serialize_struct("DeleteBatchError", 1)?;
2292 s.serialize_field(".tag", "too_many_write_operations")?;
2293 s.end()
2294 }
2295 DeleteBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2296 }
2297 }
2298}
2299
2300impl ::std::error::Error for DeleteBatchError {
2301}
2302
2303impl ::std::fmt::Display for DeleteBatchError {
2304 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2305 write!(f, "{:?}", *self)
2306 }
2307}
2308
2309#[derive(Debug, Clone, PartialEq)]
2310#[non_exhaustive] pub enum DeleteBatchJobStatus {
2312 InProgress,
2314 Complete(DeleteBatchResult),
2316 Failed(DeleteBatchError),
2318 Other,
2321}
2322
2323impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchJobStatus {
2324 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2325 use serde::de::{self, MapAccess, Visitor};
2327 struct EnumVisitor;
2328 impl<'de> Visitor<'de> for EnumVisitor {
2329 type Value = DeleteBatchJobStatus;
2330 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2331 f.write_str("a DeleteBatchJobStatus structure")
2332 }
2333 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2334 let tag: &str = match map.next_key()? {
2335 Some(".tag") => map.next_value()?,
2336 _ => return Err(de::Error::missing_field(".tag"))
2337 };
2338 let value = match tag {
2339 "in_progress" => DeleteBatchJobStatus::InProgress,
2340 "complete" => DeleteBatchJobStatus::Complete(DeleteBatchResult::internal_deserialize(&mut map)?),
2341 "failed" => {
2342 match map.next_key()? {
2343 Some("failed") => DeleteBatchJobStatus::Failed(map.next_value()?),
2344 None => return Err(de::Error::missing_field("failed")),
2345 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2346 }
2347 }
2348 _ => DeleteBatchJobStatus::Other,
2349 };
2350 crate::eat_json_fields(&mut map)?;
2351 Ok(value)
2352 }
2353 }
2354 const VARIANTS: &[&str] = &["in_progress",
2355 "complete",
2356 "failed",
2357 "other"];
2358 deserializer.deserialize_struct("DeleteBatchJobStatus", VARIANTS, EnumVisitor)
2359 }
2360}
2361
2362impl ::serde::ser::Serialize for DeleteBatchJobStatus {
2363 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2364 use serde::ser::SerializeStruct;
2366 match self {
2367 DeleteBatchJobStatus::InProgress => {
2368 let mut s = serializer.serialize_struct("DeleteBatchJobStatus", 1)?;
2370 s.serialize_field(".tag", "in_progress")?;
2371 s.end()
2372 }
2373 DeleteBatchJobStatus::Complete(x) => {
2374 let mut s = serializer.serialize_struct("DeleteBatchJobStatus", 2)?;
2376 s.serialize_field(".tag", "complete")?;
2377 x.internal_serialize::<S>(&mut s)?;
2378 s.end()
2379 }
2380 DeleteBatchJobStatus::Failed(x) => {
2381 let mut s = serializer.serialize_struct("DeleteBatchJobStatus", 2)?;
2383 s.serialize_field(".tag", "failed")?;
2384 s.serialize_field("failed", x)?;
2385 s.end()
2386 }
2387 DeleteBatchJobStatus::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2388 }
2389 }
2390}
2391
2392impl From<crate::types::dbx_async::PollResultBase> for DeleteBatchJobStatus {
2394 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
2395 match parent {
2396 crate::types::dbx_async::PollResultBase::InProgress => DeleteBatchJobStatus::InProgress,
2397 }
2398 }
2399}
2400#[derive(Debug, Clone, PartialEq)]
2403#[non_exhaustive] pub enum DeleteBatchLaunch {
2405 AsyncJobId(crate::types::dbx_async::AsyncJobId),
2408 Complete(DeleteBatchResult),
2409 Other,
2412}
2413
2414impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchLaunch {
2415 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2416 use serde::de::{self, MapAccess, Visitor};
2418 struct EnumVisitor;
2419 impl<'de> Visitor<'de> for EnumVisitor {
2420 type Value = DeleteBatchLaunch;
2421 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2422 f.write_str("a DeleteBatchLaunch structure")
2423 }
2424 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2425 let tag: &str = match map.next_key()? {
2426 Some(".tag") => map.next_value()?,
2427 _ => return Err(de::Error::missing_field(".tag"))
2428 };
2429 let value = match tag {
2430 "async_job_id" => {
2431 match map.next_key()? {
2432 Some("async_job_id") => DeleteBatchLaunch::AsyncJobId(map.next_value()?),
2433 None => return Err(de::Error::missing_field("async_job_id")),
2434 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2435 }
2436 }
2437 "complete" => DeleteBatchLaunch::Complete(DeleteBatchResult::internal_deserialize(&mut map)?),
2438 _ => DeleteBatchLaunch::Other,
2439 };
2440 crate::eat_json_fields(&mut map)?;
2441 Ok(value)
2442 }
2443 }
2444 const VARIANTS: &[&str] = &["async_job_id",
2445 "complete",
2446 "other"];
2447 deserializer.deserialize_struct("DeleteBatchLaunch", VARIANTS, EnumVisitor)
2448 }
2449}
2450
2451impl ::serde::ser::Serialize for DeleteBatchLaunch {
2452 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2453 use serde::ser::SerializeStruct;
2455 match self {
2456 DeleteBatchLaunch::AsyncJobId(x) => {
2457 let mut s = serializer.serialize_struct("DeleteBatchLaunch", 2)?;
2459 s.serialize_field(".tag", "async_job_id")?;
2460 s.serialize_field("async_job_id", x)?;
2461 s.end()
2462 }
2463 DeleteBatchLaunch::Complete(x) => {
2464 let mut s = serializer.serialize_struct("DeleteBatchLaunch", 2)?;
2466 s.serialize_field(".tag", "complete")?;
2467 x.internal_serialize::<S>(&mut s)?;
2468 s.end()
2469 }
2470 DeleteBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2471 }
2472 }
2473}
2474
2475impl From<crate::types::dbx_async::LaunchResultBase> for DeleteBatchLaunch {
2477 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
2478 match parent {
2479 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => DeleteBatchLaunch::AsyncJobId(x),
2480 }
2481 }
2482}
2483#[derive(Debug, Clone, PartialEq)]
2484#[non_exhaustive] pub struct DeleteBatchResult {
2486 pub entries: Vec<DeleteBatchResultEntry>,
2489}
2490
2491impl DeleteBatchResult {
2492 pub fn new(entries: Vec<DeleteBatchResultEntry>) -> Self {
2493 DeleteBatchResult {
2494 entries,
2495 }
2496 }
2497}
2498
2499const DELETE_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
2500impl DeleteBatchResult {
2501 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2502 map: V,
2503 ) -> Result<DeleteBatchResult, V::Error> {
2504 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2505 }
2506
2507 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2508 mut map: V,
2509 optional: bool,
2510 ) -> Result<Option<DeleteBatchResult>, V::Error> {
2511 let mut field_entries = None;
2512 let mut nothing = true;
2513 while let Some(key) = map.next_key::<&str>()? {
2514 nothing = false;
2515 match key {
2516 "entries" => {
2517 if field_entries.is_some() {
2518 return Err(::serde::de::Error::duplicate_field("entries"));
2519 }
2520 field_entries = Some(map.next_value()?);
2521 }
2522 _ => {
2523 map.next_value::<::serde_json::Value>()?;
2525 }
2526 }
2527 }
2528 if optional && nothing {
2529 return Ok(None);
2530 }
2531 let result = DeleteBatchResult {
2532 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
2533 };
2534 Ok(Some(result))
2535 }
2536
2537 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2538 &self,
2539 s: &mut S::SerializeStruct,
2540 ) -> Result<(), S::Error> {
2541 use serde::ser::SerializeStruct;
2542 s.serialize_field("entries", &self.entries)?;
2543 Ok(())
2544 }
2545}
2546
2547impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchResult {
2548 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2549 use serde::de::{MapAccess, Visitor};
2551 struct StructVisitor;
2552 impl<'de> Visitor<'de> for StructVisitor {
2553 type Value = DeleteBatchResult;
2554 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2555 f.write_str("a DeleteBatchResult struct")
2556 }
2557 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2558 DeleteBatchResult::internal_deserialize(map)
2559 }
2560 }
2561 deserializer.deserialize_struct("DeleteBatchResult", DELETE_BATCH_RESULT_FIELDS, StructVisitor)
2562 }
2563}
2564
2565impl ::serde::ser::Serialize for DeleteBatchResult {
2566 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2567 use serde::ser::SerializeStruct;
2569 let mut s = serializer.serialize_struct("DeleteBatchResult", 1)?;
2570 self.internal_serialize::<S>(&mut s)?;
2571 s.end()
2572 }
2573}
2574
2575impl From<DeleteBatchResult> for FileOpsResult {
2577 fn from(_: DeleteBatchResult) -> Self {
2578 Self {}
2579 }
2580}
2581#[derive(Debug, Clone, PartialEq)]
2582#[non_exhaustive] pub struct DeleteBatchResultData {
2584 pub metadata: Metadata,
2586}
2587
2588impl DeleteBatchResultData {
2589 pub fn new(metadata: Metadata) -> Self {
2590 DeleteBatchResultData {
2591 metadata,
2592 }
2593 }
2594}
2595
2596const DELETE_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata"];
2597impl DeleteBatchResultData {
2598 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2599 map: V,
2600 ) -> Result<DeleteBatchResultData, V::Error> {
2601 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2602 }
2603
2604 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2605 mut map: V,
2606 optional: bool,
2607 ) -> Result<Option<DeleteBatchResultData>, V::Error> {
2608 let mut field_metadata = None;
2609 let mut nothing = true;
2610 while let Some(key) = map.next_key::<&str>()? {
2611 nothing = false;
2612 match key {
2613 "metadata" => {
2614 if field_metadata.is_some() {
2615 return Err(::serde::de::Error::duplicate_field("metadata"));
2616 }
2617 field_metadata = Some(map.next_value()?);
2618 }
2619 _ => {
2620 map.next_value::<::serde_json::Value>()?;
2622 }
2623 }
2624 }
2625 if optional && nothing {
2626 return Ok(None);
2627 }
2628 let result = DeleteBatchResultData {
2629 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
2630 };
2631 Ok(Some(result))
2632 }
2633
2634 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2635 &self,
2636 s: &mut S::SerializeStruct,
2637 ) -> Result<(), S::Error> {
2638 use serde::ser::SerializeStruct;
2639 s.serialize_field("metadata", &self.metadata)?;
2640 Ok(())
2641 }
2642}
2643
2644impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchResultData {
2645 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2646 use serde::de::{MapAccess, Visitor};
2648 struct StructVisitor;
2649 impl<'de> Visitor<'de> for StructVisitor {
2650 type Value = DeleteBatchResultData;
2651 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2652 f.write_str("a DeleteBatchResultData struct")
2653 }
2654 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2655 DeleteBatchResultData::internal_deserialize(map)
2656 }
2657 }
2658 deserializer.deserialize_struct("DeleteBatchResultData", DELETE_BATCH_RESULT_DATA_FIELDS, StructVisitor)
2659 }
2660}
2661
2662impl ::serde::ser::Serialize for DeleteBatchResultData {
2663 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2664 use serde::ser::SerializeStruct;
2666 let mut s = serializer.serialize_struct("DeleteBatchResultData", 1)?;
2667 self.internal_serialize::<S>(&mut s)?;
2668 s.end()
2669 }
2670}
2671
2672#[derive(Debug, Clone, PartialEq)]
2673pub enum DeleteBatchResultEntry {
2674 Success(DeleteBatchResultData),
2675 Failure(DeleteError),
2676}
2677
2678impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchResultEntry {
2679 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2680 use serde::de::{self, MapAccess, Visitor};
2682 struct EnumVisitor;
2683 impl<'de> Visitor<'de> for EnumVisitor {
2684 type Value = DeleteBatchResultEntry;
2685 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2686 f.write_str("a DeleteBatchResultEntry structure")
2687 }
2688 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2689 let tag: &str = match map.next_key()? {
2690 Some(".tag") => map.next_value()?,
2691 _ => return Err(de::Error::missing_field(".tag"))
2692 };
2693 let value = match tag {
2694 "success" => DeleteBatchResultEntry::Success(DeleteBatchResultData::internal_deserialize(&mut map)?),
2695 "failure" => {
2696 match map.next_key()? {
2697 Some("failure") => DeleteBatchResultEntry::Failure(map.next_value()?),
2698 None => return Err(de::Error::missing_field("failure")),
2699 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2700 }
2701 }
2702 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
2703 };
2704 crate::eat_json_fields(&mut map)?;
2705 Ok(value)
2706 }
2707 }
2708 const VARIANTS: &[&str] = &["success",
2709 "failure"];
2710 deserializer.deserialize_struct("DeleteBatchResultEntry", VARIANTS, EnumVisitor)
2711 }
2712}
2713
2714impl ::serde::ser::Serialize for DeleteBatchResultEntry {
2715 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2716 use serde::ser::SerializeStruct;
2718 match self {
2719 DeleteBatchResultEntry::Success(x) => {
2720 let mut s = serializer.serialize_struct("DeleteBatchResultEntry", 2)?;
2722 s.serialize_field(".tag", "success")?;
2723 x.internal_serialize::<S>(&mut s)?;
2724 s.end()
2725 }
2726 DeleteBatchResultEntry::Failure(x) => {
2727 let mut s = serializer.serialize_struct("DeleteBatchResultEntry", 2)?;
2729 s.serialize_field(".tag", "failure")?;
2730 s.serialize_field("failure", x)?;
2731 s.end()
2732 }
2733 }
2734 }
2735}
2736
2737#[derive(Debug, Clone, PartialEq, Eq)]
2738#[non_exhaustive] pub enum DeleteError {
2740 PathLookup(LookupError),
2741 PathWrite(WriteError),
2742 TooManyWriteOperations,
2744 TooManyFiles,
2746 Other,
2749}
2750
2751impl<'de> ::serde::de::Deserialize<'de> for DeleteError {
2752 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2753 use serde::de::{self, MapAccess, Visitor};
2755 struct EnumVisitor;
2756 impl<'de> Visitor<'de> for EnumVisitor {
2757 type Value = DeleteError;
2758 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2759 f.write_str("a DeleteError structure")
2760 }
2761 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2762 let tag: &str = match map.next_key()? {
2763 Some(".tag") => map.next_value()?,
2764 _ => return Err(de::Error::missing_field(".tag"))
2765 };
2766 let value = match tag {
2767 "path_lookup" => {
2768 match map.next_key()? {
2769 Some("path_lookup") => DeleteError::PathLookup(map.next_value()?),
2770 None => return Err(de::Error::missing_field("path_lookup")),
2771 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2772 }
2773 }
2774 "path_write" => {
2775 match map.next_key()? {
2776 Some("path_write") => DeleteError::PathWrite(map.next_value()?),
2777 None => return Err(de::Error::missing_field("path_write")),
2778 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2779 }
2780 }
2781 "too_many_write_operations" => DeleteError::TooManyWriteOperations,
2782 "too_many_files" => DeleteError::TooManyFiles,
2783 _ => DeleteError::Other,
2784 };
2785 crate::eat_json_fields(&mut map)?;
2786 Ok(value)
2787 }
2788 }
2789 const VARIANTS: &[&str] = &["path_lookup",
2790 "path_write",
2791 "too_many_write_operations",
2792 "too_many_files",
2793 "other"];
2794 deserializer.deserialize_struct("DeleteError", VARIANTS, EnumVisitor)
2795 }
2796}
2797
2798impl ::serde::ser::Serialize for DeleteError {
2799 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2800 use serde::ser::SerializeStruct;
2802 match self {
2803 DeleteError::PathLookup(x) => {
2804 let mut s = serializer.serialize_struct("DeleteError", 2)?;
2806 s.serialize_field(".tag", "path_lookup")?;
2807 s.serialize_field("path_lookup", x)?;
2808 s.end()
2809 }
2810 DeleteError::PathWrite(x) => {
2811 let mut s = serializer.serialize_struct("DeleteError", 2)?;
2813 s.serialize_field(".tag", "path_write")?;
2814 s.serialize_field("path_write", x)?;
2815 s.end()
2816 }
2817 DeleteError::TooManyWriteOperations => {
2818 let mut s = serializer.serialize_struct("DeleteError", 1)?;
2820 s.serialize_field(".tag", "too_many_write_operations")?;
2821 s.end()
2822 }
2823 DeleteError::TooManyFiles => {
2824 let mut s = serializer.serialize_struct("DeleteError", 1)?;
2826 s.serialize_field(".tag", "too_many_files")?;
2827 s.end()
2828 }
2829 DeleteError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2830 }
2831 }
2832}
2833
2834impl ::std::error::Error for DeleteError {
2835 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
2836 match self {
2837 DeleteError::PathLookup(inner) => Some(inner),
2838 DeleteError::PathWrite(inner) => Some(inner),
2839 _ => None,
2840 }
2841 }
2842}
2843
2844impl ::std::fmt::Display for DeleteError {
2845 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2846 match self {
2847 DeleteError::PathLookup(inner) => write!(f, "DeleteError: {}", inner),
2848 DeleteError::PathWrite(inner) => write!(f, "DeleteError: {}", inner),
2849 DeleteError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
2850 DeleteError::TooManyFiles => f.write_str("There are too many files in one request. Please retry with fewer files."),
2851 _ => write!(f, "{:?}", *self),
2852 }
2853 }
2854}
2855
2856#[derive(Debug, Clone, PartialEq)]
2857#[non_exhaustive] pub struct DeleteResult {
2859 pub metadata: Metadata,
2861}
2862
2863impl DeleteResult {
2864 pub fn new(metadata: Metadata) -> Self {
2865 DeleteResult {
2866 metadata,
2867 }
2868 }
2869}
2870
2871const DELETE_RESULT_FIELDS: &[&str] = &["metadata"];
2872impl DeleteResult {
2873 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2874 map: V,
2875 ) -> Result<DeleteResult, V::Error> {
2876 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2877 }
2878
2879 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2880 mut map: V,
2881 optional: bool,
2882 ) -> Result<Option<DeleteResult>, V::Error> {
2883 let mut field_metadata = None;
2884 let mut nothing = true;
2885 while let Some(key) = map.next_key::<&str>()? {
2886 nothing = false;
2887 match key {
2888 "metadata" => {
2889 if field_metadata.is_some() {
2890 return Err(::serde::de::Error::duplicate_field("metadata"));
2891 }
2892 field_metadata = Some(map.next_value()?);
2893 }
2894 _ => {
2895 map.next_value::<::serde_json::Value>()?;
2897 }
2898 }
2899 }
2900 if optional && nothing {
2901 return Ok(None);
2902 }
2903 let result = DeleteResult {
2904 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
2905 };
2906 Ok(Some(result))
2907 }
2908
2909 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2910 &self,
2911 s: &mut S::SerializeStruct,
2912 ) -> Result<(), S::Error> {
2913 use serde::ser::SerializeStruct;
2914 s.serialize_field("metadata", &self.metadata)?;
2915 Ok(())
2916 }
2917}
2918
2919impl<'de> ::serde::de::Deserialize<'de> for DeleteResult {
2920 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2921 use serde::de::{MapAccess, Visitor};
2923 struct StructVisitor;
2924 impl<'de> Visitor<'de> for StructVisitor {
2925 type Value = DeleteResult;
2926 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2927 f.write_str("a DeleteResult struct")
2928 }
2929 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2930 DeleteResult::internal_deserialize(map)
2931 }
2932 }
2933 deserializer.deserialize_struct("DeleteResult", DELETE_RESULT_FIELDS, StructVisitor)
2934 }
2935}
2936
2937impl ::serde::ser::Serialize for DeleteResult {
2938 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2939 use serde::ser::SerializeStruct;
2941 let mut s = serializer.serialize_struct("DeleteResult", 1)?;
2942 self.internal_serialize::<S>(&mut s)?;
2943 s.end()
2944 }
2945}
2946
2947impl From<DeleteResult> for FileOpsResult {
2949 fn from(_: DeleteResult) -> Self {
2950 Self {}
2951 }
2952}
2953#[derive(Debug, Clone, PartialEq, Eq)]
2955#[non_exhaustive] pub struct DeletedMetadata {
2957 pub name: String,
2959 pub path_lower: Option<String>,
2962 pub path_display: Option<String>,
2969 pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
2972 pub preview_url: Option<String>,
2974}
2975
2976impl DeletedMetadata {
2977 pub fn new(name: String) -> Self {
2978 DeletedMetadata {
2979 name,
2980 path_lower: None,
2981 path_display: None,
2982 parent_shared_folder_id: None,
2983 preview_url: None,
2984 }
2985 }
2986
2987 pub fn with_path_lower(mut self, value: String) -> Self {
2988 self.path_lower = Some(value);
2989 self
2990 }
2991
2992 pub fn with_path_display(mut self, value: String) -> Self {
2993 self.path_display = Some(value);
2994 self
2995 }
2996
2997 pub fn with_parent_shared_folder_id(
2998 mut self,
2999 value: crate::types::common::SharedFolderId,
3000 ) -> Self {
3001 self.parent_shared_folder_id = Some(value);
3002 self
3003 }
3004
3005 pub fn with_preview_url(mut self, value: String) -> Self {
3006 self.preview_url = Some(value);
3007 self
3008 }
3009}
3010
3011const DELETED_METADATA_FIELDS: &[&str] = &["name",
3012 "path_lower",
3013 "path_display",
3014 "parent_shared_folder_id",
3015 "preview_url"];
3016impl DeletedMetadata {
3017 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3018 map: V,
3019 ) -> Result<DeletedMetadata, V::Error> {
3020 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3021 }
3022
3023 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3024 mut map: V,
3025 optional: bool,
3026 ) -> Result<Option<DeletedMetadata>, V::Error> {
3027 let mut field_name = None;
3028 let mut field_path_lower = None;
3029 let mut field_path_display = None;
3030 let mut field_parent_shared_folder_id = None;
3031 let mut field_preview_url = None;
3032 let mut nothing = true;
3033 while let Some(key) = map.next_key::<&str>()? {
3034 nothing = false;
3035 match key {
3036 "name" => {
3037 if field_name.is_some() {
3038 return Err(::serde::de::Error::duplicate_field("name"));
3039 }
3040 field_name = Some(map.next_value()?);
3041 }
3042 "path_lower" => {
3043 if field_path_lower.is_some() {
3044 return Err(::serde::de::Error::duplicate_field("path_lower"));
3045 }
3046 field_path_lower = Some(map.next_value()?);
3047 }
3048 "path_display" => {
3049 if field_path_display.is_some() {
3050 return Err(::serde::de::Error::duplicate_field("path_display"));
3051 }
3052 field_path_display = Some(map.next_value()?);
3053 }
3054 "parent_shared_folder_id" => {
3055 if field_parent_shared_folder_id.is_some() {
3056 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
3057 }
3058 field_parent_shared_folder_id = Some(map.next_value()?);
3059 }
3060 "preview_url" => {
3061 if field_preview_url.is_some() {
3062 return Err(::serde::de::Error::duplicate_field("preview_url"));
3063 }
3064 field_preview_url = Some(map.next_value()?);
3065 }
3066 _ => {
3067 map.next_value::<::serde_json::Value>()?;
3069 }
3070 }
3071 }
3072 if optional && nothing {
3073 return Ok(None);
3074 }
3075 let result = DeletedMetadata {
3076 name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
3077 path_lower: field_path_lower.and_then(Option::flatten),
3078 path_display: field_path_display.and_then(Option::flatten),
3079 parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
3080 preview_url: field_preview_url.and_then(Option::flatten),
3081 };
3082 Ok(Some(result))
3083 }
3084
3085 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3086 &self,
3087 s: &mut S::SerializeStruct,
3088 ) -> Result<(), S::Error> {
3089 use serde::ser::SerializeStruct;
3090 s.serialize_field("name", &self.name)?;
3091 if let Some(val) = &self.path_lower {
3092 s.serialize_field("path_lower", val)?;
3093 }
3094 if let Some(val) = &self.path_display {
3095 s.serialize_field("path_display", val)?;
3096 }
3097 if let Some(val) = &self.parent_shared_folder_id {
3098 s.serialize_field("parent_shared_folder_id", val)?;
3099 }
3100 if let Some(val) = &self.preview_url {
3101 s.serialize_field("preview_url", val)?;
3102 }
3103 Ok(())
3104 }
3105}
3106
3107impl<'de> ::serde::de::Deserialize<'de> for DeletedMetadata {
3108 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3109 use serde::de::{MapAccess, Visitor};
3111 struct StructVisitor;
3112 impl<'de> Visitor<'de> for StructVisitor {
3113 type Value = DeletedMetadata;
3114 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3115 f.write_str("a DeletedMetadata struct")
3116 }
3117 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3118 DeletedMetadata::internal_deserialize(map)
3119 }
3120 }
3121 deserializer.deserialize_struct("DeletedMetadata", DELETED_METADATA_FIELDS, StructVisitor)
3122 }
3123}
3124
3125impl ::serde::ser::Serialize for DeletedMetadata {
3126 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3127 use serde::ser::SerializeStruct;
3129 let mut s = serializer.serialize_struct("DeletedMetadata", 5)?;
3130 self.internal_serialize::<S>(&mut s)?;
3131 s.end()
3132 }
3133}
3134
3135impl From<DeletedMetadata> for Metadata {
3137 fn from(subtype: DeletedMetadata) -> Self {
3138 Metadata::Deleted(subtype)
3139 }
3140}
3141#[derive(Debug, Clone, PartialEq, Eq)]
3143#[non_exhaustive] pub struct Dimensions {
3145 pub height: u64,
3147 pub width: u64,
3149}
3150
3151impl Dimensions {
3152 pub fn new(height: u64, width: u64) -> Self {
3153 Dimensions {
3154 height,
3155 width,
3156 }
3157 }
3158}
3159
3160const DIMENSIONS_FIELDS: &[&str] = &["height",
3161 "width"];
3162impl Dimensions {
3163 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3164 map: V,
3165 ) -> Result<Dimensions, V::Error> {
3166 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3167 }
3168
3169 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3170 mut map: V,
3171 optional: bool,
3172 ) -> Result<Option<Dimensions>, V::Error> {
3173 let mut field_height = None;
3174 let mut field_width = None;
3175 let mut nothing = true;
3176 while let Some(key) = map.next_key::<&str>()? {
3177 nothing = false;
3178 match key {
3179 "height" => {
3180 if field_height.is_some() {
3181 return Err(::serde::de::Error::duplicate_field("height"));
3182 }
3183 field_height = Some(map.next_value()?);
3184 }
3185 "width" => {
3186 if field_width.is_some() {
3187 return Err(::serde::de::Error::duplicate_field("width"));
3188 }
3189 field_width = Some(map.next_value()?);
3190 }
3191 _ => {
3192 map.next_value::<::serde_json::Value>()?;
3194 }
3195 }
3196 }
3197 if optional && nothing {
3198 return Ok(None);
3199 }
3200 let result = Dimensions {
3201 height: field_height.ok_or_else(|| ::serde::de::Error::missing_field("height"))?,
3202 width: field_width.ok_or_else(|| ::serde::de::Error::missing_field("width"))?,
3203 };
3204 Ok(Some(result))
3205 }
3206
3207 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3208 &self,
3209 s: &mut S::SerializeStruct,
3210 ) -> Result<(), S::Error> {
3211 use serde::ser::SerializeStruct;
3212 s.serialize_field("height", &self.height)?;
3213 s.serialize_field("width", &self.width)?;
3214 Ok(())
3215 }
3216}
3217
3218impl<'de> ::serde::de::Deserialize<'de> for Dimensions {
3219 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3220 use serde::de::{MapAccess, Visitor};
3222 struct StructVisitor;
3223 impl<'de> Visitor<'de> for StructVisitor {
3224 type Value = Dimensions;
3225 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3226 f.write_str("a Dimensions struct")
3227 }
3228 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3229 Dimensions::internal_deserialize(map)
3230 }
3231 }
3232 deserializer.deserialize_struct("Dimensions", DIMENSIONS_FIELDS, StructVisitor)
3233 }
3234}
3235
3236impl ::serde::ser::Serialize for Dimensions {
3237 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3238 use serde::ser::SerializeStruct;
3240 let mut s = serializer.serialize_struct("Dimensions", 2)?;
3241 self.internal_serialize::<S>(&mut s)?;
3242 s.end()
3243 }
3244}
3245
3246#[derive(Debug, Clone, PartialEq, Eq)]
3247#[non_exhaustive] pub struct DownloadArg {
3249 pub path: ReadPath,
3251 pub rev: Option<Rev>,
3253}
3254
3255impl DownloadArg {
3256 pub fn new(path: ReadPath) -> Self {
3257 DownloadArg {
3258 path,
3259 rev: None,
3260 }
3261 }
3262
3263 pub fn with_rev(mut self, value: Rev) -> Self {
3264 self.rev = Some(value);
3265 self
3266 }
3267}
3268
3269const DOWNLOAD_ARG_FIELDS: &[&str] = &["path",
3270 "rev"];
3271impl DownloadArg {
3272 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3273 map: V,
3274 ) -> Result<DownloadArg, V::Error> {
3275 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3276 }
3277
3278 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3279 mut map: V,
3280 optional: bool,
3281 ) -> Result<Option<DownloadArg>, V::Error> {
3282 let mut field_path = None;
3283 let mut field_rev = None;
3284 let mut nothing = true;
3285 while let Some(key) = map.next_key::<&str>()? {
3286 nothing = false;
3287 match key {
3288 "path" => {
3289 if field_path.is_some() {
3290 return Err(::serde::de::Error::duplicate_field("path"));
3291 }
3292 field_path = Some(map.next_value()?);
3293 }
3294 "rev" => {
3295 if field_rev.is_some() {
3296 return Err(::serde::de::Error::duplicate_field("rev"));
3297 }
3298 field_rev = Some(map.next_value()?);
3299 }
3300 _ => {
3301 map.next_value::<::serde_json::Value>()?;
3303 }
3304 }
3305 }
3306 if optional && nothing {
3307 return Ok(None);
3308 }
3309 let result = DownloadArg {
3310 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
3311 rev: field_rev.and_then(Option::flatten),
3312 };
3313 Ok(Some(result))
3314 }
3315
3316 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3317 &self,
3318 s: &mut S::SerializeStruct,
3319 ) -> Result<(), S::Error> {
3320 use serde::ser::SerializeStruct;
3321 s.serialize_field("path", &self.path)?;
3322 if let Some(val) = &self.rev {
3323 s.serialize_field("rev", val)?;
3324 }
3325 Ok(())
3326 }
3327}
3328
3329impl<'de> ::serde::de::Deserialize<'de> for DownloadArg {
3330 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3331 use serde::de::{MapAccess, Visitor};
3333 struct StructVisitor;
3334 impl<'de> Visitor<'de> for StructVisitor {
3335 type Value = DownloadArg;
3336 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3337 f.write_str("a DownloadArg struct")
3338 }
3339 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3340 DownloadArg::internal_deserialize(map)
3341 }
3342 }
3343 deserializer.deserialize_struct("DownloadArg", DOWNLOAD_ARG_FIELDS, StructVisitor)
3344 }
3345}
3346
3347impl ::serde::ser::Serialize for DownloadArg {
3348 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3349 use serde::ser::SerializeStruct;
3351 let mut s = serializer.serialize_struct("DownloadArg", 2)?;
3352 self.internal_serialize::<S>(&mut s)?;
3353 s.end()
3354 }
3355}
3356
3357#[derive(Debug, Clone, PartialEq, Eq)]
3358#[non_exhaustive] pub enum DownloadError {
3360 Path(LookupError),
3361 UnsupportedFile,
3364 Other,
3367}
3368
3369impl<'de> ::serde::de::Deserialize<'de> for DownloadError {
3370 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3371 use serde::de::{self, MapAccess, Visitor};
3373 struct EnumVisitor;
3374 impl<'de> Visitor<'de> for EnumVisitor {
3375 type Value = DownloadError;
3376 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3377 f.write_str("a DownloadError structure")
3378 }
3379 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3380 let tag: &str = match map.next_key()? {
3381 Some(".tag") => map.next_value()?,
3382 _ => return Err(de::Error::missing_field(".tag"))
3383 };
3384 let value = match tag {
3385 "path" => {
3386 match map.next_key()? {
3387 Some("path") => DownloadError::Path(map.next_value()?),
3388 None => return Err(de::Error::missing_field("path")),
3389 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3390 }
3391 }
3392 "unsupported_file" => DownloadError::UnsupportedFile,
3393 _ => DownloadError::Other,
3394 };
3395 crate::eat_json_fields(&mut map)?;
3396 Ok(value)
3397 }
3398 }
3399 const VARIANTS: &[&str] = &["path",
3400 "unsupported_file",
3401 "other"];
3402 deserializer.deserialize_struct("DownloadError", VARIANTS, EnumVisitor)
3403 }
3404}
3405
3406impl ::serde::ser::Serialize for DownloadError {
3407 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3408 use serde::ser::SerializeStruct;
3410 match self {
3411 DownloadError::Path(x) => {
3412 let mut s = serializer.serialize_struct("DownloadError", 2)?;
3414 s.serialize_field(".tag", "path")?;
3415 s.serialize_field("path", x)?;
3416 s.end()
3417 }
3418 DownloadError::UnsupportedFile => {
3419 let mut s = serializer.serialize_struct("DownloadError", 1)?;
3421 s.serialize_field(".tag", "unsupported_file")?;
3422 s.end()
3423 }
3424 DownloadError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3425 }
3426 }
3427}
3428
3429impl ::std::error::Error for DownloadError {
3430 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
3431 match self {
3432 DownloadError::Path(inner) => Some(inner),
3433 _ => None,
3434 }
3435 }
3436}
3437
3438impl ::std::fmt::Display for DownloadError {
3439 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3440 match self {
3441 DownloadError::Path(inner) => write!(f, "DownloadError: {}", inner),
3442 _ => write!(f, "{:?}", *self),
3443 }
3444 }
3445}
3446
3447#[derive(Debug, Clone, PartialEq, Eq)]
3448#[non_exhaustive] pub struct DownloadZipArg {
3450 pub path: ReadPath,
3452}
3453
3454impl DownloadZipArg {
3455 pub fn new(path: ReadPath) -> Self {
3456 DownloadZipArg {
3457 path,
3458 }
3459 }
3460}
3461
3462const DOWNLOAD_ZIP_ARG_FIELDS: &[&str] = &["path"];
3463impl DownloadZipArg {
3464 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3465 map: V,
3466 ) -> Result<DownloadZipArg, V::Error> {
3467 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3468 }
3469
3470 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3471 mut map: V,
3472 optional: bool,
3473 ) -> Result<Option<DownloadZipArg>, V::Error> {
3474 let mut field_path = None;
3475 let mut nothing = true;
3476 while let Some(key) = map.next_key::<&str>()? {
3477 nothing = false;
3478 match key {
3479 "path" => {
3480 if field_path.is_some() {
3481 return Err(::serde::de::Error::duplicate_field("path"));
3482 }
3483 field_path = Some(map.next_value()?);
3484 }
3485 _ => {
3486 map.next_value::<::serde_json::Value>()?;
3488 }
3489 }
3490 }
3491 if optional && nothing {
3492 return Ok(None);
3493 }
3494 let result = DownloadZipArg {
3495 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
3496 };
3497 Ok(Some(result))
3498 }
3499
3500 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3501 &self,
3502 s: &mut S::SerializeStruct,
3503 ) -> Result<(), S::Error> {
3504 use serde::ser::SerializeStruct;
3505 s.serialize_field("path", &self.path)?;
3506 Ok(())
3507 }
3508}
3509
3510impl<'de> ::serde::de::Deserialize<'de> for DownloadZipArg {
3511 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3512 use serde::de::{MapAccess, Visitor};
3514 struct StructVisitor;
3515 impl<'de> Visitor<'de> for StructVisitor {
3516 type Value = DownloadZipArg;
3517 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3518 f.write_str("a DownloadZipArg struct")
3519 }
3520 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3521 DownloadZipArg::internal_deserialize(map)
3522 }
3523 }
3524 deserializer.deserialize_struct("DownloadZipArg", DOWNLOAD_ZIP_ARG_FIELDS, StructVisitor)
3525 }
3526}
3527
3528impl ::serde::ser::Serialize for DownloadZipArg {
3529 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3530 use serde::ser::SerializeStruct;
3532 let mut s = serializer.serialize_struct("DownloadZipArg", 1)?;
3533 self.internal_serialize::<S>(&mut s)?;
3534 s.end()
3535 }
3536}
3537
3538#[derive(Debug, Clone, PartialEq, Eq)]
3539#[non_exhaustive] pub enum DownloadZipError {
3541 Path(LookupError),
3542 TooLarge,
3544 TooManyFiles,
3546 Other,
3549}
3550
3551impl<'de> ::serde::de::Deserialize<'de> for DownloadZipError {
3552 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3553 use serde::de::{self, MapAccess, Visitor};
3555 struct EnumVisitor;
3556 impl<'de> Visitor<'de> for EnumVisitor {
3557 type Value = DownloadZipError;
3558 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3559 f.write_str("a DownloadZipError structure")
3560 }
3561 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3562 let tag: &str = match map.next_key()? {
3563 Some(".tag") => map.next_value()?,
3564 _ => return Err(de::Error::missing_field(".tag"))
3565 };
3566 let value = match tag {
3567 "path" => {
3568 match map.next_key()? {
3569 Some("path") => DownloadZipError::Path(map.next_value()?),
3570 None => return Err(de::Error::missing_field("path")),
3571 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3572 }
3573 }
3574 "too_large" => DownloadZipError::TooLarge,
3575 "too_many_files" => DownloadZipError::TooManyFiles,
3576 _ => DownloadZipError::Other,
3577 };
3578 crate::eat_json_fields(&mut map)?;
3579 Ok(value)
3580 }
3581 }
3582 const VARIANTS: &[&str] = &["path",
3583 "too_large",
3584 "too_many_files",
3585 "other"];
3586 deserializer.deserialize_struct("DownloadZipError", VARIANTS, EnumVisitor)
3587 }
3588}
3589
3590impl ::serde::ser::Serialize for DownloadZipError {
3591 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3592 use serde::ser::SerializeStruct;
3594 match self {
3595 DownloadZipError::Path(x) => {
3596 let mut s = serializer.serialize_struct("DownloadZipError", 2)?;
3598 s.serialize_field(".tag", "path")?;
3599 s.serialize_field("path", x)?;
3600 s.end()
3601 }
3602 DownloadZipError::TooLarge => {
3603 let mut s = serializer.serialize_struct("DownloadZipError", 1)?;
3605 s.serialize_field(".tag", "too_large")?;
3606 s.end()
3607 }
3608 DownloadZipError::TooManyFiles => {
3609 let mut s = serializer.serialize_struct("DownloadZipError", 1)?;
3611 s.serialize_field(".tag", "too_many_files")?;
3612 s.end()
3613 }
3614 DownloadZipError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3615 }
3616 }
3617}
3618
3619impl ::std::error::Error for DownloadZipError {
3620 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
3621 match self {
3622 DownloadZipError::Path(inner) => Some(inner),
3623 _ => None,
3624 }
3625 }
3626}
3627
3628impl ::std::fmt::Display for DownloadZipError {
3629 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3630 match self {
3631 DownloadZipError::Path(inner) => write!(f, "DownloadZipError: {}", inner),
3632 DownloadZipError::TooLarge => f.write_str("The folder or a file is too large to download."),
3633 DownloadZipError::TooManyFiles => f.write_str("The folder has too many files to download."),
3634 _ => write!(f, "{:?}", *self),
3635 }
3636 }
3637}
3638
3639#[derive(Debug, Clone, PartialEq, Eq)]
3640#[non_exhaustive] pub struct DownloadZipResult {
3642 pub metadata: FolderMetadata,
3643}
3644
3645impl DownloadZipResult {
3646 pub fn new(metadata: FolderMetadata) -> Self {
3647 DownloadZipResult {
3648 metadata,
3649 }
3650 }
3651}
3652
3653const DOWNLOAD_ZIP_RESULT_FIELDS: &[&str] = &["metadata"];
3654impl DownloadZipResult {
3655 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3656 map: V,
3657 ) -> Result<DownloadZipResult, V::Error> {
3658 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3659 }
3660
3661 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3662 mut map: V,
3663 optional: bool,
3664 ) -> Result<Option<DownloadZipResult>, V::Error> {
3665 let mut field_metadata = None;
3666 let mut nothing = true;
3667 while let Some(key) = map.next_key::<&str>()? {
3668 nothing = false;
3669 match key {
3670 "metadata" => {
3671 if field_metadata.is_some() {
3672 return Err(::serde::de::Error::duplicate_field("metadata"));
3673 }
3674 field_metadata = Some(map.next_value()?);
3675 }
3676 _ => {
3677 map.next_value::<::serde_json::Value>()?;
3679 }
3680 }
3681 }
3682 if optional && nothing {
3683 return Ok(None);
3684 }
3685 let result = DownloadZipResult {
3686 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
3687 };
3688 Ok(Some(result))
3689 }
3690
3691 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3692 &self,
3693 s: &mut S::SerializeStruct,
3694 ) -> Result<(), S::Error> {
3695 use serde::ser::SerializeStruct;
3696 s.serialize_field("metadata", &self.metadata)?;
3697 Ok(())
3698 }
3699}
3700
3701impl<'de> ::serde::de::Deserialize<'de> for DownloadZipResult {
3702 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3703 use serde::de::{MapAccess, Visitor};
3705 struct StructVisitor;
3706 impl<'de> Visitor<'de> for StructVisitor {
3707 type Value = DownloadZipResult;
3708 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3709 f.write_str("a DownloadZipResult struct")
3710 }
3711 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3712 DownloadZipResult::internal_deserialize(map)
3713 }
3714 }
3715 deserializer.deserialize_struct("DownloadZipResult", DOWNLOAD_ZIP_RESULT_FIELDS, StructVisitor)
3716 }
3717}
3718
3719impl ::serde::ser::Serialize for DownloadZipResult {
3720 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3721 use serde::ser::SerializeStruct;
3723 let mut s = serializer.serialize_struct("DownloadZipResult", 1)?;
3724 self.internal_serialize::<S>(&mut s)?;
3725 s.end()
3726 }
3727}
3728
3729#[derive(Debug, Clone, PartialEq, Eq)]
3730#[non_exhaustive] pub struct ExportArg {
3732 pub path: ReadPath,
3734 pub export_format: Option<String>,
3739}
3740
3741impl ExportArg {
3742 pub fn new(path: ReadPath) -> Self {
3743 ExportArg {
3744 path,
3745 export_format: None,
3746 }
3747 }
3748
3749 pub fn with_export_format(mut self, value: String) -> Self {
3750 self.export_format = Some(value);
3751 self
3752 }
3753}
3754
3755const EXPORT_ARG_FIELDS: &[&str] = &["path",
3756 "export_format"];
3757impl ExportArg {
3758 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3759 map: V,
3760 ) -> Result<ExportArg, V::Error> {
3761 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3762 }
3763
3764 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3765 mut map: V,
3766 optional: bool,
3767 ) -> Result<Option<ExportArg>, V::Error> {
3768 let mut field_path = None;
3769 let mut field_export_format = None;
3770 let mut nothing = true;
3771 while let Some(key) = map.next_key::<&str>()? {
3772 nothing = false;
3773 match key {
3774 "path" => {
3775 if field_path.is_some() {
3776 return Err(::serde::de::Error::duplicate_field("path"));
3777 }
3778 field_path = Some(map.next_value()?);
3779 }
3780 "export_format" => {
3781 if field_export_format.is_some() {
3782 return Err(::serde::de::Error::duplicate_field("export_format"));
3783 }
3784 field_export_format = Some(map.next_value()?);
3785 }
3786 _ => {
3787 map.next_value::<::serde_json::Value>()?;
3789 }
3790 }
3791 }
3792 if optional && nothing {
3793 return Ok(None);
3794 }
3795 let result = ExportArg {
3796 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
3797 export_format: field_export_format.and_then(Option::flatten),
3798 };
3799 Ok(Some(result))
3800 }
3801
3802 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3803 &self,
3804 s: &mut S::SerializeStruct,
3805 ) -> Result<(), S::Error> {
3806 use serde::ser::SerializeStruct;
3807 s.serialize_field("path", &self.path)?;
3808 if let Some(val) = &self.export_format {
3809 s.serialize_field("export_format", val)?;
3810 }
3811 Ok(())
3812 }
3813}
3814
3815impl<'de> ::serde::de::Deserialize<'de> for ExportArg {
3816 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3817 use serde::de::{MapAccess, Visitor};
3819 struct StructVisitor;
3820 impl<'de> Visitor<'de> for StructVisitor {
3821 type Value = ExportArg;
3822 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3823 f.write_str("a ExportArg struct")
3824 }
3825 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3826 ExportArg::internal_deserialize(map)
3827 }
3828 }
3829 deserializer.deserialize_struct("ExportArg", EXPORT_ARG_FIELDS, StructVisitor)
3830 }
3831}
3832
3833impl ::serde::ser::Serialize for ExportArg {
3834 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3835 use serde::ser::SerializeStruct;
3837 let mut s = serializer.serialize_struct("ExportArg", 2)?;
3838 self.internal_serialize::<S>(&mut s)?;
3839 s.end()
3840 }
3841}
3842
3843#[derive(Debug, Clone, PartialEq, Eq)]
3844#[non_exhaustive] pub enum ExportError {
3846 Path(LookupError),
3847 NonExportable,
3849 InvalidExportFormat,
3851 RetryError,
3853 Other,
3856}
3857
3858impl<'de> ::serde::de::Deserialize<'de> for ExportError {
3859 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3860 use serde::de::{self, MapAccess, Visitor};
3862 struct EnumVisitor;
3863 impl<'de> Visitor<'de> for EnumVisitor {
3864 type Value = ExportError;
3865 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3866 f.write_str("a ExportError structure")
3867 }
3868 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3869 let tag: &str = match map.next_key()? {
3870 Some(".tag") => map.next_value()?,
3871 _ => return Err(de::Error::missing_field(".tag"))
3872 };
3873 let value = match tag {
3874 "path" => {
3875 match map.next_key()? {
3876 Some("path") => ExportError::Path(map.next_value()?),
3877 None => return Err(de::Error::missing_field("path")),
3878 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3879 }
3880 }
3881 "non_exportable" => ExportError::NonExportable,
3882 "invalid_export_format" => ExportError::InvalidExportFormat,
3883 "retry_error" => ExportError::RetryError,
3884 _ => ExportError::Other,
3885 };
3886 crate::eat_json_fields(&mut map)?;
3887 Ok(value)
3888 }
3889 }
3890 const VARIANTS: &[&str] = &["path",
3891 "non_exportable",
3892 "invalid_export_format",
3893 "retry_error",
3894 "other"];
3895 deserializer.deserialize_struct("ExportError", VARIANTS, EnumVisitor)
3896 }
3897}
3898
3899impl ::serde::ser::Serialize for ExportError {
3900 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3901 use serde::ser::SerializeStruct;
3903 match self {
3904 ExportError::Path(x) => {
3905 let mut s = serializer.serialize_struct("ExportError", 2)?;
3907 s.serialize_field(".tag", "path")?;
3908 s.serialize_field("path", x)?;
3909 s.end()
3910 }
3911 ExportError::NonExportable => {
3912 let mut s = serializer.serialize_struct("ExportError", 1)?;
3914 s.serialize_field(".tag", "non_exportable")?;
3915 s.end()
3916 }
3917 ExportError::InvalidExportFormat => {
3918 let mut s = serializer.serialize_struct("ExportError", 1)?;
3920 s.serialize_field(".tag", "invalid_export_format")?;
3921 s.end()
3922 }
3923 ExportError::RetryError => {
3924 let mut s = serializer.serialize_struct("ExportError", 1)?;
3926 s.serialize_field(".tag", "retry_error")?;
3927 s.end()
3928 }
3929 ExportError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3930 }
3931 }
3932}
3933
3934impl ::std::error::Error for ExportError {
3935 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
3936 match self {
3937 ExportError::Path(inner) => Some(inner),
3938 _ => None,
3939 }
3940 }
3941}
3942
3943impl ::std::fmt::Display for ExportError {
3944 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3945 match self {
3946 ExportError::Path(inner) => write!(f, "ExportError: {}", inner),
3947 ExportError::InvalidExportFormat => f.write_str("The specified export format is not a valid option for this file type."),
3948 ExportError::RetryError => f.write_str("The exportable content is not yet available. Please retry later."),
3949 _ => write!(f, "{:?}", *self),
3950 }
3951 }
3952}
3953
3954#[derive(Debug, Clone, PartialEq, Eq, Default)]
3956#[non_exhaustive] pub struct ExportInfo {
3958 pub export_as: Option<String>,
3960 pub export_options: Option<Vec<String>>,
3963}
3964
3965impl ExportInfo {
3966 pub fn with_export_as(mut self, value: String) -> Self {
3967 self.export_as = Some(value);
3968 self
3969 }
3970
3971 pub fn with_export_options(mut self, value: Vec<String>) -> Self {
3972 self.export_options = Some(value);
3973 self
3974 }
3975}
3976
3977const EXPORT_INFO_FIELDS: &[&str] = &["export_as",
3978 "export_options"];
3979impl ExportInfo {
3980 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3982 mut map: V,
3983 ) -> Result<ExportInfo, V::Error> {
3984 let mut field_export_as = None;
3985 let mut field_export_options = None;
3986 while let Some(key) = map.next_key::<&str>()? {
3987 match key {
3988 "export_as" => {
3989 if field_export_as.is_some() {
3990 return Err(::serde::de::Error::duplicate_field("export_as"));
3991 }
3992 field_export_as = Some(map.next_value()?);
3993 }
3994 "export_options" => {
3995 if field_export_options.is_some() {
3996 return Err(::serde::de::Error::duplicate_field("export_options"));
3997 }
3998 field_export_options = Some(map.next_value()?);
3999 }
4000 _ => {
4001 map.next_value::<::serde_json::Value>()?;
4003 }
4004 }
4005 }
4006 let result = ExportInfo {
4007 export_as: field_export_as.and_then(Option::flatten),
4008 export_options: field_export_options.and_then(Option::flatten),
4009 };
4010 Ok(result)
4011 }
4012
4013 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4014 &self,
4015 s: &mut S::SerializeStruct,
4016 ) -> Result<(), S::Error> {
4017 use serde::ser::SerializeStruct;
4018 if let Some(val) = &self.export_as {
4019 s.serialize_field("export_as", val)?;
4020 }
4021 if let Some(val) = &self.export_options {
4022 s.serialize_field("export_options", val)?;
4023 }
4024 Ok(())
4025 }
4026}
4027
4028impl<'de> ::serde::de::Deserialize<'de> for ExportInfo {
4029 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4030 use serde::de::{MapAccess, Visitor};
4032 struct StructVisitor;
4033 impl<'de> Visitor<'de> for StructVisitor {
4034 type Value = ExportInfo;
4035 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4036 f.write_str("a ExportInfo struct")
4037 }
4038 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4039 ExportInfo::internal_deserialize(map)
4040 }
4041 }
4042 deserializer.deserialize_struct("ExportInfo", EXPORT_INFO_FIELDS, StructVisitor)
4043 }
4044}
4045
4046impl ::serde::ser::Serialize for ExportInfo {
4047 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4048 use serde::ser::SerializeStruct;
4050 let mut s = serializer.serialize_struct("ExportInfo", 2)?;
4051 self.internal_serialize::<S>(&mut s)?;
4052 s.end()
4053 }
4054}
4055
4056#[derive(Debug, Clone, PartialEq, Eq)]
4057#[non_exhaustive] pub struct ExportMetadata {
4059 pub name: String,
4061 pub size: u64,
4063 pub export_hash: Option<Sha256HexHash>,
4067 pub paper_revision: Option<i64>,
4070}
4071
4072impl ExportMetadata {
4073 pub fn new(name: String, size: u64) -> Self {
4074 ExportMetadata {
4075 name,
4076 size,
4077 export_hash: None,
4078 paper_revision: None,
4079 }
4080 }
4081
4082 pub fn with_export_hash(mut self, value: Sha256HexHash) -> Self {
4083 self.export_hash = Some(value);
4084 self
4085 }
4086
4087 pub fn with_paper_revision(mut self, value: i64) -> Self {
4088 self.paper_revision = Some(value);
4089 self
4090 }
4091}
4092
4093const EXPORT_METADATA_FIELDS: &[&str] = &["name",
4094 "size",
4095 "export_hash",
4096 "paper_revision"];
4097impl ExportMetadata {
4098 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4099 map: V,
4100 ) -> Result<ExportMetadata, V::Error> {
4101 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4102 }
4103
4104 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4105 mut map: V,
4106 optional: bool,
4107 ) -> Result<Option<ExportMetadata>, V::Error> {
4108 let mut field_name = None;
4109 let mut field_size = None;
4110 let mut field_export_hash = None;
4111 let mut field_paper_revision = None;
4112 let mut nothing = true;
4113 while let Some(key) = map.next_key::<&str>()? {
4114 nothing = false;
4115 match key {
4116 "name" => {
4117 if field_name.is_some() {
4118 return Err(::serde::de::Error::duplicate_field("name"));
4119 }
4120 field_name = Some(map.next_value()?);
4121 }
4122 "size" => {
4123 if field_size.is_some() {
4124 return Err(::serde::de::Error::duplicate_field("size"));
4125 }
4126 field_size = Some(map.next_value()?);
4127 }
4128 "export_hash" => {
4129 if field_export_hash.is_some() {
4130 return Err(::serde::de::Error::duplicate_field("export_hash"));
4131 }
4132 field_export_hash = Some(map.next_value()?);
4133 }
4134 "paper_revision" => {
4135 if field_paper_revision.is_some() {
4136 return Err(::serde::de::Error::duplicate_field("paper_revision"));
4137 }
4138 field_paper_revision = Some(map.next_value()?);
4139 }
4140 _ => {
4141 map.next_value::<::serde_json::Value>()?;
4143 }
4144 }
4145 }
4146 if optional && nothing {
4147 return Ok(None);
4148 }
4149 let result = ExportMetadata {
4150 name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
4151 size: field_size.ok_or_else(|| ::serde::de::Error::missing_field("size"))?,
4152 export_hash: field_export_hash.and_then(Option::flatten),
4153 paper_revision: field_paper_revision.and_then(Option::flatten),
4154 };
4155 Ok(Some(result))
4156 }
4157
4158 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4159 &self,
4160 s: &mut S::SerializeStruct,
4161 ) -> Result<(), S::Error> {
4162 use serde::ser::SerializeStruct;
4163 s.serialize_field("name", &self.name)?;
4164 s.serialize_field("size", &self.size)?;
4165 if let Some(val) = &self.export_hash {
4166 s.serialize_field("export_hash", val)?;
4167 }
4168 if let Some(val) = &self.paper_revision {
4169 s.serialize_field("paper_revision", val)?;
4170 }
4171 Ok(())
4172 }
4173}
4174
4175impl<'de> ::serde::de::Deserialize<'de> for ExportMetadata {
4176 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4177 use serde::de::{MapAccess, Visitor};
4179 struct StructVisitor;
4180 impl<'de> Visitor<'de> for StructVisitor {
4181 type Value = ExportMetadata;
4182 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4183 f.write_str("a ExportMetadata struct")
4184 }
4185 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4186 ExportMetadata::internal_deserialize(map)
4187 }
4188 }
4189 deserializer.deserialize_struct("ExportMetadata", EXPORT_METADATA_FIELDS, StructVisitor)
4190 }
4191}
4192
4193impl ::serde::ser::Serialize for ExportMetadata {
4194 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4195 use serde::ser::SerializeStruct;
4197 let mut s = serializer.serialize_struct("ExportMetadata", 4)?;
4198 self.internal_serialize::<S>(&mut s)?;
4199 s.end()
4200 }
4201}
4202
4203#[derive(Debug, Clone, PartialEq)]
4204#[non_exhaustive] pub struct ExportResult {
4206 pub export_metadata: ExportMetadata,
4208 pub file_metadata: FileMetadata,
4210}
4211
4212impl ExportResult {
4213 pub fn new(export_metadata: ExportMetadata, file_metadata: FileMetadata) -> Self {
4214 ExportResult {
4215 export_metadata,
4216 file_metadata,
4217 }
4218 }
4219}
4220
4221const EXPORT_RESULT_FIELDS: &[&str] = &["export_metadata",
4222 "file_metadata"];
4223impl ExportResult {
4224 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4225 map: V,
4226 ) -> Result<ExportResult, V::Error> {
4227 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4228 }
4229
4230 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4231 mut map: V,
4232 optional: bool,
4233 ) -> Result<Option<ExportResult>, V::Error> {
4234 let mut field_export_metadata = None;
4235 let mut field_file_metadata = None;
4236 let mut nothing = true;
4237 while let Some(key) = map.next_key::<&str>()? {
4238 nothing = false;
4239 match key {
4240 "export_metadata" => {
4241 if field_export_metadata.is_some() {
4242 return Err(::serde::de::Error::duplicate_field("export_metadata"));
4243 }
4244 field_export_metadata = Some(map.next_value()?);
4245 }
4246 "file_metadata" => {
4247 if field_file_metadata.is_some() {
4248 return Err(::serde::de::Error::duplicate_field("file_metadata"));
4249 }
4250 field_file_metadata = Some(map.next_value()?);
4251 }
4252 _ => {
4253 map.next_value::<::serde_json::Value>()?;
4255 }
4256 }
4257 }
4258 if optional && nothing {
4259 return Ok(None);
4260 }
4261 let result = ExportResult {
4262 export_metadata: field_export_metadata.ok_or_else(|| ::serde::de::Error::missing_field("export_metadata"))?,
4263 file_metadata: field_file_metadata.ok_or_else(|| ::serde::de::Error::missing_field("file_metadata"))?,
4264 };
4265 Ok(Some(result))
4266 }
4267
4268 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4269 &self,
4270 s: &mut S::SerializeStruct,
4271 ) -> Result<(), S::Error> {
4272 use serde::ser::SerializeStruct;
4273 s.serialize_field("export_metadata", &self.export_metadata)?;
4274 s.serialize_field("file_metadata", &self.file_metadata)?;
4275 Ok(())
4276 }
4277}
4278
4279impl<'de> ::serde::de::Deserialize<'de> for ExportResult {
4280 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4281 use serde::de::{MapAccess, Visitor};
4283 struct StructVisitor;
4284 impl<'de> Visitor<'de> for StructVisitor {
4285 type Value = ExportResult;
4286 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4287 f.write_str("a ExportResult struct")
4288 }
4289 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4290 ExportResult::internal_deserialize(map)
4291 }
4292 }
4293 deserializer.deserialize_struct("ExportResult", EXPORT_RESULT_FIELDS, StructVisitor)
4294 }
4295}
4296
4297impl ::serde::ser::Serialize for ExportResult {
4298 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4299 use serde::ser::SerializeStruct;
4301 let mut s = serializer.serialize_struct("ExportResult", 2)?;
4302 self.internal_serialize::<S>(&mut s)?;
4303 s.end()
4304 }
4305}
4306
4307#[derive(Debug, Clone, PartialEq, Eq)]
4308#[non_exhaustive] pub enum FileCategory {
4310 Image,
4312 Document,
4314 Pdf,
4316 Spreadsheet,
4318 Presentation,
4320 Audio,
4322 Video,
4324 Folder,
4326 Paper,
4328 Others,
4330 Other,
4333}
4334
4335impl<'de> ::serde::de::Deserialize<'de> for FileCategory {
4336 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4337 use serde::de::{self, MapAccess, Visitor};
4339 struct EnumVisitor;
4340 impl<'de> Visitor<'de> for EnumVisitor {
4341 type Value = FileCategory;
4342 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4343 f.write_str("a FileCategory structure")
4344 }
4345 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
4346 let tag: &str = match map.next_key()? {
4347 Some(".tag") => map.next_value()?,
4348 _ => return Err(de::Error::missing_field(".tag"))
4349 };
4350 let value = match tag {
4351 "image" => FileCategory::Image,
4352 "document" => FileCategory::Document,
4353 "pdf" => FileCategory::Pdf,
4354 "spreadsheet" => FileCategory::Spreadsheet,
4355 "presentation" => FileCategory::Presentation,
4356 "audio" => FileCategory::Audio,
4357 "video" => FileCategory::Video,
4358 "folder" => FileCategory::Folder,
4359 "paper" => FileCategory::Paper,
4360 "others" => FileCategory::Others,
4361 _ => FileCategory::Other,
4362 };
4363 crate::eat_json_fields(&mut map)?;
4364 Ok(value)
4365 }
4366 }
4367 const VARIANTS: &[&str] = &["image",
4368 "document",
4369 "pdf",
4370 "spreadsheet",
4371 "presentation",
4372 "audio",
4373 "video",
4374 "folder",
4375 "paper",
4376 "others",
4377 "other"];
4378 deserializer.deserialize_struct("FileCategory", VARIANTS, EnumVisitor)
4379 }
4380}
4381
4382impl ::serde::ser::Serialize for FileCategory {
4383 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4384 use serde::ser::SerializeStruct;
4386 match self {
4387 FileCategory::Image => {
4388 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4390 s.serialize_field(".tag", "image")?;
4391 s.end()
4392 }
4393 FileCategory::Document => {
4394 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4396 s.serialize_field(".tag", "document")?;
4397 s.end()
4398 }
4399 FileCategory::Pdf => {
4400 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4402 s.serialize_field(".tag", "pdf")?;
4403 s.end()
4404 }
4405 FileCategory::Spreadsheet => {
4406 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4408 s.serialize_field(".tag", "spreadsheet")?;
4409 s.end()
4410 }
4411 FileCategory::Presentation => {
4412 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4414 s.serialize_field(".tag", "presentation")?;
4415 s.end()
4416 }
4417 FileCategory::Audio => {
4418 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4420 s.serialize_field(".tag", "audio")?;
4421 s.end()
4422 }
4423 FileCategory::Video => {
4424 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4426 s.serialize_field(".tag", "video")?;
4427 s.end()
4428 }
4429 FileCategory::Folder => {
4430 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4432 s.serialize_field(".tag", "folder")?;
4433 s.end()
4434 }
4435 FileCategory::Paper => {
4436 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4438 s.serialize_field(".tag", "paper")?;
4439 s.end()
4440 }
4441 FileCategory::Others => {
4442 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4444 s.serialize_field(".tag", "others")?;
4445 s.end()
4446 }
4447 FileCategory::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
4448 }
4449 }
4450}
4451
4452#[derive(Debug, Clone, PartialEq, Eq)]
4453#[non_exhaustive] pub struct FileLock {
4455 pub content: FileLockContent,
4457}
4458
4459impl FileLock {
4460 pub fn new(content: FileLockContent) -> Self {
4461 FileLock {
4462 content,
4463 }
4464 }
4465}
4466
4467const FILE_LOCK_FIELDS: &[&str] = &["content"];
4468impl FileLock {
4469 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4470 map: V,
4471 ) -> Result<FileLock, V::Error> {
4472 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4473 }
4474
4475 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4476 mut map: V,
4477 optional: bool,
4478 ) -> Result<Option<FileLock>, V::Error> {
4479 let mut field_content = None;
4480 let mut nothing = true;
4481 while let Some(key) = map.next_key::<&str>()? {
4482 nothing = false;
4483 match key {
4484 "content" => {
4485 if field_content.is_some() {
4486 return Err(::serde::de::Error::duplicate_field("content"));
4487 }
4488 field_content = Some(map.next_value()?);
4489 }
4490 _ => {
4491 map.next_value::<::serde_json::Value>()?;
4493 }
4494 }
4495 }
4496 if optional && nothing {
4497 return Ok(None);
4498 }
4499 let result = FileLock {
4500 content: field_content.ok_or_else(|| ::serde::de::Error::missing_field("content"))?,
4501 };
4502 Ok(Some(result))
4503 }
4504
4505 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4506 &self,
4507 s: &mut S::SerializeStruct,
4508 ) -> Result<(), S::Error> {
4509 use serde::ser::SerializeStruct;
4510 s.serialize_field("content", &self.content)?;
4511 Ok(())
4512 }
4513}
4514
4515impl<'de> ::serde::de::Deserialize<'de> for FileLock {
4516 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4517 use serde::de::{MapAccess, Visitor};
4519 struct StructVisitor;
4520 impl<'de> Visitor<'de> for StructVisitor {
4521 type Value = FileLock;
4522 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4523 f.write_str("a FileLock struct")
4524 }
4525 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4526 FileLock::internal_deserialize(map)
4527 }
4528 }
4529 deserializer.deserialize_struct("FileLock", FILE_LOCK_FIELDS, StructVisitor)
4530 }
4531}
4532
4533impl ::serde::ser::Serialize for FileLock {
4534 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4535 use serde::ser::SerializeStruct;
4537 let mut s = serializer.serialize_struct("FileLock", 1)?;
4538 self.internal_serialize::<S>(&mut s)?;
4539 s.end()
4540 }
4541}
4542
4543#[derive(Debug, Clone, PartialEq, Eq)]
4544#[non_exhaustive] pub enum FileLockContent {
4546 Unlocked,
4548 SingleUser(SingleUserLock),
4550 Other,
4553}
4554
4555impl<'de> ::serde::de::Deserialize<'de> for FileLockContent {
4556 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4557 use serde::de::{self, MapAccess, Visitor};
4559 struct EnumVisitor;
4560 impl<'de> Visitor<'de> for EnumVisitor {
4561 type Value = FileLockContent;
4562 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4563 f.write_str("a FileLockContent structure")
4564 }
4565 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
4566 let tag: &str = match map.next_key()? {
4567 Some(".tag") => map.next_value()?,
4568 _ => return Err(de::Error::missing_field(".tag"))
4569 };
4570 let value = match tag {
4571 "unlocked" => FileLockContent::Unlocked,
4572 "single_user" => FileLockContent::SingleUser(SingleUserLock::internal_deserialize(&mut map)?),
4573 _ => FileLockContent::Other,
4574 };
4575 crate::eat_json_fields(&mut map)?;
4576 Ok(value)
4577 }
4578 }
4579 const VARIANTS: &[&str] = &["unlocked",
4580 "single_user",
4581 "other"];
4582 deserializer.deserialize_struct("FileLockContent", VARIANTS, EnumVisitor)
4583 }
4584}
4585
4586impl ::serde::ser::Serialize for FileLockContent {
4587 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4588 use serde::ser::SerializeStruct;
4590 match self {
4591 FileLockContent::Unlocked => {
4592 let mut s = serializer.serialize_struct("FileLockContent", 1)?;
4594 s.serialize_field(".tag", "unlocked")?;
4595 s.end()
4596 }
4597 FileLockContent::SingleUser(x) => {
4598 let mut s = serializer.serialize_struct("FileLockContent", 4)?;
4600 s.serialize_field(".tag", "single_user")?;
4601 x.internal_serialize::<S>(&mut s)?;
4602 s.end()
4603 }
4604 FileLockContent::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
4605 }
4606 }
4607}
4608
4609#[derive(Debug, Clone, PartialEq, Eq, Default)]
4610#[non_exhaustive] pub struct FileLockMetadata {
4612 pub is_lockholder: Option<bool>,
4614 pub lockholder_name: Option<String>,
4616 pub lockholder_account_id: Option<crate::types::users_common::AccountId>,
4618 pub created: Option<crate::types::common::DropboxTimestamp>,
4620}
4621
4622impl FileLockMetadata {
4623 pub fn with_is_lockholder(mut self, value: bool) -> Self {
4624 self.is_lockholder = Some(value);
4625 self
4626 }
4627
4628 pub fn with_lockholder_name(mut self, value: String) -> Self {
4629 self.lockholder_name = Some(value);
4630 self
4631 }
4632
4633 pub fn with_lockholder_account_id(
4634 mut self,
4635 value: crate::types::users_common::AccountId,
4636 ) -> Self {
4637 self.lockholder_account_id = Some(value);
4638 self
4639 }
4640
4641 pub fn with_created(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
4642 self.created = Some(value);
4643 self
4644 }
4645}
4646
4647const FILE_LOCK_METADATA_FIELDS: &[&str] = &["is_lockholder",
4648 "lockholder_name",
4649 "lockholder_account_id",
4650 "created"];
4651impl FileLockMetadata {
4652 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4654 mut map: V,
4655 ) -> Result<FileLockMetadata, V::Error> {
4656 let mut field_is_lockholder = None;
4657 let mut field_lockholder_name = None;
4658 let mut field_lockholder_account_id = None;
4659 let mut field_created = None;
4660 while let Some(key) = map.next_key::<&str>()? {
4661 match key {
4662 "is_lockholder" => {
4663 if field_is_lockholder.is_some() {
4664 return Err(::serde::de::Error::duplicate_field("is_lockholder"));
4665 }
4666 field_is_lockholder = Some(map.next_value()?);
4667 }
4668 "lockholder_name" => {
4669 if field_lockholder_name.is_some() {
4670 return Err(::serde::de::Error::duplicate_field("lockholder_name"));
4671 }
4672 field_lockholder_name = Some(map.next_value()?);
4673 }
4674 "lockholder_account_id" => {
4675 if field_lockholder_account_id.is_some() {
4676 return Err(::serde::de::Error::duplicate_field("lockholder_account_id"));
4677 }
4678 field_lockholder_account_id = Some(map.next_value()?);
4679 }
4680 "created" => {
4681 if field_created.is_some() {
4682 return Err(::serde::de::Error::duplicate_field("created"));
4683 }
4684 field_created = Some(map.next_value()?);
4685 }
4686 _ => {
4687 map.next_value::<::serde_json::Value>()?;
4689 }
4690 }
4691 }
4692 let result = FileLockMetadata {
4693 is_lockholder: field_is_lockholder.and_then(Option::flatten),
4694 lockholder_name: field_lockholder_name.and_then(Option::flatten),
4695 lockholder_account_id: field_lockholder_account_id.and_then(Option::flatten),
4696 created: field_created.and_then(Option::flatten),
4697 };
4698 Ok(result)
4699 }
4700
4701 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4702 &self,
4703 s: &mut S::SerializeStruct,
4704 ) -> Result<(), S::Error> {
4705 use serde::ser::SerializeStruct;
4706 if let Some(val) = &self.is_lockholder {
4707 s.serialize_field("is_lockholder", val)?;
4708 }
4709 if let Some(val) = &self.lockholder_name {
4710 s.serialize_field("lockholder_name", val)?;
4711 }
4712 if let Some(val) = &self.lockholder_account_id {
4713 s.serialize_field("lockholder_account_id", val)?;
4714 }
4715 if let Some(val) = &self.created {
4716 s.serialize_field("created", val)?;
4717 }
4718 Ok(())
4719 }
4720}
4721
4722impl<'de> ::serde::de::Deserialize<'de> for FileLockMetadata {
4723 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4724 use serde::de::{MapAccess, Visitor};
4726 struct StructVisitor;
4727 impl<'de> Visitor<'de> for StructVisitor {
4728 type Value = FileLockMetadata;
4729 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4730 f.write_str("a FileLockMetadata struct")
4731 }
4732 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4733 FileLockMetadata::internal_deserialize(map)
4734 }
4735 }
4736 deserializer.deserialize_struct("FileLockMetadata", FILE_LOCK_METADATA_FIELDS, StructVisitor)
4737 }
4738}
4739
4740impl ::serde::ser::Serialize for FileLockMetadata {
4741 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4742 use serde::ser::SerializeStruct;
4744 let mut s = serializer.serialize_struct("FileLockMetadata", 4)?;
4745 self.internal_serialize::<S>(&mut s)?;
4746 s.end()
4747 }
4748}
4749
4750#[derive(Debug, Clone, PartialEq)]
4751#[non_exhaustive] pub struct FileMetadata {
4753 pub name: String,
4755 pub id: Id,
4757 pub client_modified: crate::types::common::DropboxTimestamp,
4762 pub server_modified: crate::types::common::DropboxTimestamp,
4764 pub rev: Rev,
4767 pub size: u64,
4769 pub path_lower: Option<String>,
4772 pub path_display: Option<String>,
4779 pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
4782 pub preview_url: Option<String>,
4784 pub media_info: Option<MediaInfo>,
4789 pub symlink_info: Option<SymlinkInfo>,
4791 pub sharing_info: Option<FileSharingInfo>,
4793 pub is_downloadable: bool,
4795 pub export_info: Option<ExportInfo>,
4798 pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
4801 pub has_explicit_shared_members: Option<bool>,
4808 pub content_hash: Option<Sha256HexHash>,
4812 pub file_lock_info: Option<FileLockMetadata>,
4814}
4815
4816impl FileMetadata {
4817 pub fn new(
4818 name: String,
4819 id: Id,
4820 client_modified: crate::types::common::DropboxTimestamp,
4821 server_modified: crate::types::common::DropboxTimestamp,
4822 rev: Rev,
4823 size: u64,
4824 ) -> Self {
4825 FileMetadata {
4826 name,
4827 id,
4828 client_modified,
4829 server_modified,
4830 rev,
4831 size,
4832 path_lower: None,
4833 path_display: None,
4834 parent_shared_folder_id: None,
4835 preview_url: None,
4836 media_info: None,
4837 symlink_info: None,
4838 sharing_info: None,
4839 is_downloadable: true,
4840 export_info: None,
4841 property_groups: None,
4842 has_explicit_shared_members: None,
4843 content_hash: None,
4844 file_lock_info: None,
4845 }
4846 }
4847
4848 pub fn with_path_lower(mut self, value: String) -> Self {
4849 self.path_lower = Some(value);
4850 self
4851 }
4852
4853 pub fn with_path_display(mut self, value: String) -> Self {
4854 self.path_display = Some(value);
4855 self
4856 }
4857
4858 pub fn with_parent_shared_folder_id(
4859 mut self,
4860 value: crate::types::common::SharedFolderId,
4861 ) -> Self {
4862 self.parent_shared_folder_id = Some(value);
4863 self
4864 }
4865
4866 pub fn with_preview_url(mut self, value: String) -> Self {
4867 self.preview_url = Some(value);
4868 self
4869 }
4870
4871 pub fn with_media_info(mut self, value: MediaInfo) -> Self {
4872 self.media_info = Some(value);
4873 self
4874 }
4875
4876 pub fn with_symlink_info(mut self, value: SymlinkInfo) -> Self {
4877 self.symlink_info = Some(value);
4878 self
4879 }
4880
4881 pub fn with_sharing_info(mut self, value: FileSharingInfo) -> Self {
4882 self.sharing_info = Some(value);
4883 self
4884 }
4885
4886 pub fn with_is_downloadable(mut self, value: bool) -> Self {
4887 self.is_downloadable = value;
4888 self
4889 }
4890
4891 pub fn with_export_info(mut self, value: ExportInfo) -> Self {
4892 self.export_info = Some(value);
4893 self
4894 }
4895
4896 pub fn with_property_groups(
4897 mut self,
4898 value: Vec<crate::types::file_properties::PropertyGroup>,
4899 ) -> Self {
4900 self.property_groups = Some(value);
4901 self
4902 }
4903
4904 pub fn with_has_explicit_shared_members(mut self, value: bool) -> Self {
4905 self.has_explicit_shared_members = Some(value);
4906 self
4907 }
4908
4909 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
4910 self.content_hash = Some(value);
4911 self
4912 }
4913
4914 pub fn with_file_lock_info(mut self, value: FileLockMetadata) -> Self {
4915 self.file_lock_info = Some(value);
4916 self
4917 }
4918}
4919
4920const FILE_METADATA_FIELDS: &[&str] = &["name",
4921 "id",
4922 "client_modified",
4923 "server_modified",
4924 "rev",
4925 "size",
4926 "path_lower",
4927 "path_display",
4928 "parent_shared_folder_id",
4929 "preview_url",
4930 "media_info",
4931 "symlink_info",
4932 "sharing_info",
4933 "is_downloadable",
4934 "export_info",
4935 "property_groups",
4936 "has_explicit_shared_members",
4937 "content_hash",
4938 "file_lock_info"];
4939impl FileMetadata {
4940 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4941 map: V,
4942 ) -> Result<FileMetadata, V::Error> {
4943 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4944 }
4945
4946 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4947 mut map: V,
4948 optional: bool,
4949 ) -> Result<Option<FileMetadata>, V::Error> {
4950 let mut field_name = None;
4951 let mut field_id = None;
4952 let mut field_client_modified = None;
4953 let mut field_server_modified = None;
4954 let mut field_rev = None;
4955 let mut field_size = None;
4956 let mut field_path_lower = None;
4957 let mut field_path_display = None;
4958 let mut field_parent_shared_folder_id = None;
4959 let mut field_preview_url = None;
4960 let mut field_media_info = None;
4961 let mut field_symlink_info = None;
4962 let mut field_sharing_info = None;
4963 let mut field_is_downloadable = None;
4964 let mut field_export_info = None;
4965 let mut field_property_groups = None;
4966 let mut field_has_explicit_shared_members = None;
4967 let mut field_content_hash = None;
4968 let mut field_file_lock_info = None;
4969 let mut nothing = true;
4970 while let Some(key) = map.next_key::<&str>()? {
4971 nothing = false;
4972 match key {
4973 "name" => {
4974 if field_name.is_some() {
4975 return Err(::serde::de::Error::duplicate_field("name"));
4976 }
4977 field_name = Some(map.next_value()?);
4978 }
4979 "id" => {
4980 if field_id.is_some() {
4981 return Err(::serde::de::Error::duplicate_field("id"));
4982 }
4983 field_id = Some(map.next_value()?);
4984 }
4985 "client_modified" => {
4986 if field_client_modified.is_some() {
4987 return Err(::serde::de::Error::duplicate_field("client_modified"));
4988 }
4989 field_client_modified = Some(map.next_value()?);
4990 }
4991 "server_modified" => {
4992 if field_server_modified.is_some() {
4993 return Err(::serde::de::Error::duplicate_field("server_modified"));
4994 }
4995 field_server_modified = Some(map.next_value()?);
4996 }
4997 "rev" => {
4998 if field_rev.is_some() {
4999 return Err(::serde::de::Error::duplicate_field("rev"));
5000 }
5001 field_rev = Some(map.next_value()?);
5002 }
5003 "size" => {
5004 if field_size.is_some() {
5005 return Err(::serde::de::Error::duplicate_field("size"));
5006 }
5007 field_size = Some(map.next_value()?);
5008 }
5009 "path_lower" => {
5010 if field_path_lower.is_some() {
5011 return Err(::serde::de::Error::duplicate_field("path_lower"));
5012 }
5013 field_path_lower = Some(map.next_value()?);
5014 }
5015 "path_display" => {
5016 if field_path_display.is_some() {
5017 return Err(::serde::de::Error::duplicate_field("path_display"));
5018 }
5019 field_path_display = Some(map.next_value()?);
5020 }
5021 "parent_shared_folder_id" => {
5022 if field_parent_shared_folder_id.is_some() {
5023 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5024 }
5025 field_parent_shared_folder_id = Some(map.next_value()?);
5026 }
5027 "preview_url" => {
5028 if field_preview_url.is_some() {
5029 return Err(::serde::de::Error::duplicate_field("preview_url"));
5030 }
5031 field_preview_url = Some(map.next_value()?);
5032 }
5033 "media_info" => {
5034 if field_media_info.is_some() {
5035 return Err(::serde::de::Error::duplicate_field("media_info"));
5036 }
5037 field_media_info = Some(map.next_value()?);
5038 }
5039 "symlink_info" => {
5040 if field_symlink_info.is_some() {
5041 return Err(::serde::de::Error::duplicate_field("symlink_info"));
5042 }
5043 field_symlink_info = Some(map.next_value()?);
5044 }
5045 "sharing_info" => {
5046 if field_sharing_info.is_some() {
5047 return Err(::serde::de::Error::duplicate_field("sharing_info"));
5048 }
5049 field_sharing_info = Some(map.next_value()?);
5050 }
5051 "is_downloadable" => {
5052 if field_is_downloadable.is_some() {
5053 return Err(::serde::de::Error::duplicate_field("is_downloadable"));
5054 }
5055 field_is_downloadable = Some(map.next_value()?);
5056 }
5057 "export_info" => {
5058 if field_export_info.is_some() {
5059 return Err(::serde::de::Error::duplicate_field("export_info"));
5060 }
5061 field_export_info = Some(map.next_value()?);
5062 }
5063 "property_groups" => {
5064 if field_property_groups.is_some() {
5065 return Err(::serde::de::Error::duplicate_field("property_groups"));
5066 }
5067 field_property_groups = Some(map.next_value()?);
5068 }
5069 "has_explicit_shared_members" => {
5070 if field_has_explicit_shared_members.is_some() {
5071 return Err(::serde::de::Error::duplicate_field("has_explicit_shared_members"));
5072 }
5073 field_has_explicit_shared_members = Some(map.next_value()?);
5074 }
5075 "content_hash" => {
5076 if field_content_hash.is_some() {
5077 return Err(::serde::de::Error::duplicate_field("content_hash"));
5078 }
5079 field_content_hash = Some(map.next_value()?);
5080 }
5081 "file_lock_info" => {
5082 if field_file_lock_info.is_some() {
5083 return Err(::serde::de::Error::duplicate_field("file_lock_info"));
5084 }
5085 field_file_lock_info = Some(map.next_value()?);
5086 }
5087 _ => {
5088 map.next_value::<::serde_json::Value>()?;
5090 }
5091 }
5092 }
5093 if optional && nothing {
5094 return Ok(None);
5095 }
5096 let result = FileMetadata {
5097 name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
5098 id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
5099 client_modified: field_client_modified.ok_or_else(|| ::serde::de::Error::missing_field("client_modified"))?,
5100 server_modified: field_server_modified.ok_or_else(|| ::serde::de::Error::missing_field("server_modified"))?,
5101 rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
5102 size: field_size.ok_or_else(|| ::serde::de::Error::missing_field("size"))?,
5103 path_lower: field_path_lower.and_then(Option::flatten),
5104 path_display: field_path_display.and_then(Option::flatten),
5105 parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
5106 preview_url: field_preview_url.and_then(Option::flatten),
5107 media_info: field_media_info.and_then(Option::flatten),
5108 symlink_info: field_symlink_info.and_then(Option::flatten),
5109 sharing_info: field_sharing_info.and_then(Option::flatten),
5110 is_downloadable: field_is_downloadable.unwrap_or(true),
5111 export_info: field_export_info.and_then(Option::flatten),
5112 property_groups: field_property_groups.and_then(Option::flatten),
5113 has_explicit_shared_members: field_has_explicit_shared_members.and_then(Option::flatten),
5114 content_hash: field_content_hash.and_then(Option::flatten),
5115 file_lock_info: field_file_lock_info.and_then(Option::flatten),
5116 };
5117 Ok(Some(result))
5118 }
5119
5120 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5121 &self,
5122 s: &mut S::SerializeStruct,
5123 ) -> Result<(), S::Error> {
5124 use serde::ser::SerializeStruct;
5125 s.serialize_field("name", &self.name)?;
5126 s.serialize_field("id", &self.id)?;
5127 s.serialize_field("client_modified", &self.client_modified)?;
5128 s.serialize_field("server_modified", &self.server_modified)?;
5129 s.serialize_field("rev", &self.rev)?;
5130 s.serialize_field("size", &self.size)?;
5131 if let Some(val) = &self.path_lower {
5132 s.serialize_field("path_lower", val)?;
5133 }
5134 if let Some(val) = &self.path_display {
5135 s.serialize_field("path_display", val)?;
5136 }
5137 if let Some(val) = &self.parent_shared_folder_id {
5138 s.serialize_field("parent_shared_folder_id", val)?;
5139 }
5140 if let Some(val) = &self.preview_url {
5141 s.serialize_field("preview_url", val)?;
5142 }
5143 if let Some(val) = &self.media_info {
5144 s.serialize_field("media_info", val)?;
5145 }
5146 if let Some(val) = &self.symlink_info {
5147 s.serialize_field("symlink_info", val)?;
5148 }
5149 if let Some(val) = &self.sharing_info {
5150 s.serialize_field("sharing_info", val)?;
5151 }
5152 if !self.is_downloadable {
5153 s.serialize_field("is_downloadable", &self.is_downloadable)?;
5154 }
5155 if let Some(val) = &self.export_info {
5156 s.serialize_field("export_info", val)?;
5157 }
5158 if let Some(val) = &self.property_groups {
5159 s.serialize_field("property_groups", val)?;
5160 }
5161 if let Some(val) = &self.has_explicit_shared_members {
5162 s.serialize_field("has_explicit_shared_members", val)?;
5163 }
5164 if let Some(val) = &self.content_hash {
5165 s.serialize_field("content_hash", val)?;
5166 }
5167 if let Some(val) = &self.file_lock_info {
5168 s.serialize_field("file_lock_info", val)?;
5169 }
5170 Ok(())
5171 }
5172}
5173
5174impl<'de> ::serde::de::Deserialize<'de> for FileMetadata {
5175 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5176 use serde::de::{MapAccess, Visitor};
5178 struct StructVisitor;
5179 impl<'de> Visitor<'de> for StructVisitor {
5180 type Value = FileMetadata;
5181 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5182 f.write_str("a FileMetadata struct")
5183 }
5184 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5185 FileMetadata::internal_deserialize(map)
5186 }
5187 }
5188 deserializer.deserialize_struct("FileMetadata", FILE_METADATA_FIELDS, StructVisitor)
5189 }
5190}
5191
5192impl ::serde::ser::Serialize for FileMetadata {
5193 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5194 use serde::ser::SerializeStruct;
5196 let mut s = serializer.serialize_struct("FileMetadata", 19)?;
5197 self.internal_serialize::<S>(&mut s)?;
5198 s.end()
5199 }
5200}
5201
5202impl From<FileMetadata> for Metadata {
5204 fn from(subtype: FileMetadata) -> Self {
5205 Metadata::File(subtype)
5206 }
5207}
5208#[derive(Debug, Clone, PartialEq, Eq, Default)]
5210#[non_exhaustive] pub struct FileOpsResult {
5212}
5213
5214const FILE_OPS_RESULT_FIELDS: &[&str] = &[];
5215impl FileOpsResult {
5216 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5218 mut map: V,
5219 ) -> Result<FileOpsResult, V::Error> {
5220 crate::eat_json_fields(&mut map)?;
5222 Ok(FileOpsResult {})
5223 }
5224}
5225
5226impl<'de> ::serde::de::Deserialize<'de> for FileOpsResult {
5227 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5228 use serde::de::{MapAccess, Visitor};
5230 struct StructVisitor;
5231 impl<'de> Visitor<'de> for StructVisitor {
5232 type Value = FileOpsResult;
5233 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5234 f.write_str("a FileOpsResult struct")
5235 }
5236 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5237 FileOpsResult::internal_deserialize(map)
5238 }
5239 }
5240 deserializer.deserialize_struct("FileOpsResult", FILE_OPS_RESULT_FIELDS, StructVisitor)
5241 }
5242}
5243
5244impl ::serde::ser::Serialize for FileOpsResult {
5245 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5246 use serde::ser::SerializeStruct;
5248 serializer.serialize_struct("FileOpsResult", 0)?.end()
5249 }
5250}
5251
5252#[derive(Debug, Clone, PartialEq, Eq)]
5254#[non_exhaustive] pub struct FileSharingInfo {
5256 pub read_only: bool,
5258 pub parent_shared_folder_id: crate::types::common::SharedFolderId,
5260 pub modified_by: Option<crate::types::users_common::AccountId>,
5263}
5264
5265impl FileSharingInfo {
5266 pub fn new(
5267 read_only: bool,
5268 parent_shared_folder_id: crate::types::common::SharedFolderId,
5269 ) -> Self {
5270 FileSharingInfo {
5271 read_only,
5272 parent_shared_folder_id,
5273 modified_by: None,
5274 }
5275 }
5276
5277 pub fn with_modified_by(mut self, value: crate::types::users_common::AccountId) -> Self {
5278 self.modified_by = Some(value);
5279 self
5280 }
5281}
5282
5283const FILE_SHARING_INFO_FIELDS: &[&str] = &["read_only",
5284 "parent_shared_folder_id",
5285 "modified_by"];
5286impl FileSharingInfo {
5287 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5288 map: V,
5289 ) -> Result<FileSharingInfo, V::Error> {
5290 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5291 }
5292
5293 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5294 mut map: V,
5295 optional: bool,
5296 ) -> Result<Option<FileSharingInfo>, V::Error> {
5297 let mut field_read_only = None;
5298 let mut field_parent_shared_folder_id = None;
5299 let mut field_modified_by = None;
5300 let mut nothing = true;
5301 while let Some(key) = map.next_key::<&str>()? {
5302 nothing = false;
5303 match key {
5304 "read_only" => {
5305 if field_read_only.is_some() {
5306 return Err(::serde::de::Error::duplicate_field("read_only"));
5307 }
5308 field_read_only = Some(map.next_value()?);
5309 }
5310 "parent_shared_folder_id" => {
5311 if field_parent_shared_folder_id.is_some() {
5312 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5313 }
5314 field_parent_shared_folder_id = Some(map.next_value()?);
5315 }
5316 "modified_by" => {
5317 if field_modified_by.is_some() {
5318 return Err(::serde::de::Error::duplicate_field("modified_by"));
5319 }
5320 field_modified_by = Some(map.next_value()?);
5321 }
5322 _ => {
5323 map.next_value::<::serde_json::Value>()?;
5325 }
5326 }
5327 }
5328 if optional && nothing {
5329 return Ok(None);
5330 }
5331 let result = FileSharingInfo {
5332 read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
5333 parent_shared_folder_id: field_parent_shared_folder_id.ok_or_else(|| ::serde::de::Error::missing_field("parent_shared_folder_id"))?,
5334 modified_by: field_modified_by.and_then(Option::flatten),
5335 };
5336 Ok(Some(result))
5337 }
5338
5339 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5340 &self,
5341 s: &mut S::SerializeStruct,
5342 ) -> Result<(), S::Error> {
5343 use serde::ser::SerializeStruct;
5344 s.serialize_field("read_only", &self.read_only)?;
5345 s.serialize_field("parent_shared_folder_id", &self.parent_shared_folder_id)?;
5346 if let Some(val) = &self.modified_by {
5347 s.serialize_field("modified_by", val)?;
5348 }
5349 Ok(())
5350 }
5351}
5352
5353impl<'de> ::serde::de::Deserialize<'de> for FileSharingInfo {
5354 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5355 use serde::de::{MapAccess, Visitor};
5357 struct StructVisitor;
5358 impl<'de> Visitor<'de> for StructVisitor {
5359 type Value = FileSharingInfo;
5360 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5361 f.write_str("a FileSharingInfo struct")
5362 }
5363 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5364 FileSharingInfo::internal_deserialize(map)
5365 }
5366 }
5367 deserializer.deserialize_struct("FileSharingInfo", FILE_SHARING_INFO_FIELDS, StructVisitor)
5368 }
5369}
5370
5371impl ::serde::ser::Serialize for FileSharingInfo {
5372 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5373 use serde::ser::SerializeStruct;
5375 let mut s = serializer.serialize_struct("FileSharingInfo", 3)?;
5376 self.internal_serialize::<S>(&mut s)?;
5377 s.end()
5378 }
5379}
5380
5381impl From<FileSharingInfo> for SharingInfo {
5383 fn from(subtype: FileSharingInfo) -> Self {
5384 Self {
5385 read_only: subtype.read_only,
5386 }
5387 }
5388}
5389#[derive(Debug, Clone, PartialEq, Eq)]
5390#[non_exhaustive] pub enum FileStatus {
5392 Active,
5393 Deleted,
5394 Other,
5397}
5398
5399impl<'de> ::serde::de::Deserialize<'de> for FileStatus {
5400 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5401 use serde::de::{self, MapAccess, Visitor};
5403 struct EnumVisitor;
5404 impl<'de> Visitor<'de> for EnumVisitor {
5405 type Value = FileStatus;
5406 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5407 f.write_str("a FileStatus structure")
5408 }
5409 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
5410 let tag: &str = match map.next_key()? {
5411 Some(".tag") => map.next_value()?,
5412 _ => return Err(de::Error::missing_field(".tag"))
5413 };
5414 let value = match tag {
5415 "active" => FileStatus::Active,
5416 "deleted" => FileStatus::Deleted,
5417 _ => FileStatus::Other,
5418 };
5419 crate::eat_json_fields(&mut map)?;
5420 Ok(value)
5421 }
5422 }
5423 const VARIANTS: &[&str] = &["active",
5424 "deleted",
5425 "other"];
5426 deserializer.deserialize_struct("FileStatus", VARIANTS, EnumVisitor)
5427 }
5428}
5429
5430impl ::serde::ser::Serialize for FileStatus {
5431 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5432 use serde::ser::SerializeStruct;
5434 match self {
5435 FileStatus::Active => {
5436 let mut s = serializer.serialize_struct("FileStatus", 1)?;
5438 s.serialize_field(".tag", "active")?;
5439 s.end()
5440 }
5441 FileStatus::Deleted => {
5442 let mut s = serializer.serialize_struct("FileStatus", 1)?;
5444 s.serialize_field(".tag", "deleted")?;
5445 s.end()
5446 }
5447 FileStatus::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
5448 }
5449 }
5450}
5451
5452#[derive(Debug, Clone, PartialEq, Eq)]
5453#[non_exhaustive] pub struct FolderMetadata {
5455 pub name: String,
5457 pub id: Id,
5459 pub path_lower: Option<String>,
5462 pub path_display: Option<String>,
5469 pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
5472 pub preview_url: Option<String>,
5474 pub shared_folder_id: Option<crate::types::common::SharedFolderId>,
5476 pub sharing_info: Option<FolderSharingInfo>,
5478 pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
5482}
5483
5484impl FolderMetadata {
5485 pub fn new(name: String, id: Id) -> Self {
5486 FolderMetadata {
5487 name,
5488 id,
5489 path_lower: None,
5490 path_display: None,
5491 parent_shared_folder_id: None,
5492 preview_url: None,
5493 shared_folder_id: None,
5494 sharing_info: None,
5495 property_groups: None,
5496 }
5497 }
5498
5499 pub fn with_path_lower(mut self, value: String) -> Self {
5500 self.path_lower = Some(value);
5501 self
5502 }
5503
5504 pub fn with_path_display(mut self, value: String) -> Self {
5505 self.path_display = Some(value);
5506 self
5507 }
5508
5509 pub fn with_parent_shared_folder_id(
5510 mut self,
5511 value: crate::types::common::SharedFolderId,
5512 ) -> Self {
5513 self.parent_shared_folder_id = Some(value);
5514 self
5515 }
5516
5517 pub fn with_preview_url(mut self, value: String) -> Self {
5518 self.preview_url = Some(value);
5519 self
5520 }
5521
5522 pub fn with_shared_folder_id(mut self, value: crate::types::common::SharedFolderId) -> Self {
5523 self.shared_folder_id = Some(value);
5524 self
5525 }
5526
5527 pub fn with_sharing_info(mut self, value: FolderSharingInfo) -> Self {
5528 self.sharing_info = Some(value);
5529 self
5530 }
5531
5532 pub fn with_property_groups(
5533 mut self,
5534 value: Vec<crate::types::file_properties::PropertyGroup>,
5535 ) -> Self {
5536 self.property_groups = Some(value);
5537 self
5538 }
5539}
5540
5541const FOLDER_METADATA_FIELDS: &[&str] = &["name",
5542 "id",
5543 "path_lower",
5544 "path_display",
5545 "parent_shared_folder_id",
5546 "preview_url",
5547 "shared_folder_id",
5548 "sharing_info",
5549 "property_groups"];
5550impl FolderMetadata {
5551 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5552 map: V,
5553 ) -> Result<FolderMetadata, V::Error> {
5554 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5555 }
5556
5557 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5558 mut map: V,
5559 optional: bool,
5560 ) -> Result<Option<FolderMetadata>, V::Error> {
5561 let mut field_name = None;
5562 let mut field_id = None;
5563 let mut field_path_lower = None;
5564 let mut field_path_display = None;
5565 let mut field_parent_shared_folder_id = None;
5566 let mut field_preview_url = None;
5567 let mut field_shared_folder_id = None;
5568 let mut field_sharing_info = None;
5569 let mut field_property_groups = None;
5570 let mut nothing = true;
5571 while let Some(key) = map.next_key::<&str>()? {
5572 nothing = false;
5573 match key {
5574 "name" => {
5575 if field_name.is_some() {
5576 return Err(::serde::de::Error::duplicate_field("name"));
5577 }
5578 field_name = Some(map.next_value()?);
5579 }
5580 "id" => {
5581 if field_id.is_some() {
5582 return Err(::serde::de::Error::duplicate_field("id"));
5583 }
5584 field_id = Some(map.next_value()?);
5585 }
5586 "path_lower" => {
5587 if field_path_lower.is_some() {
5588 return Err(::serde::de::Error::duplicate_field("path_lower"));
5589 }
5590 field_path_lower = Some(map.next_value()?);
5591 }
5592 "path_display" => {
5593 if field_path_display.is_some() {
5594 return Err(::serde::de::Error::duplicate_field("path_display"));
5595 }
5596 field_path_display = Some(map.next_value()?);
5597 }
5598 "parent_shared_folder_id" => {
5599 if field_parent_shared_folder_id.is_some() {
5600 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5601 }
5602 field_parent_shared_folder_id = Some(map.next_value()?);
5603 }
5604 "preview_url" => {
5605 if field_preview_url.is_some() {
5606 return Err(::serde::de::Error::duplicate_field("preview_url"));
5607 }
5608 field_preview_url = Some(map.next_value()?);
5609 }
5610 "shared_folder_id" => {
5611 if field_shared_folder_id.is_some() {
5612 return Err(::serde::de::Error::duplicate_field("shared_folder_id"));
5613 }
5614 field_shared_folder_id = Some(map.next_value()?);
5615 }
5616 "sharing_info" => {
5617 if field_sharing_info.is_some() {
5618 return Err(::serde::de::Error::duplicate_field("sharing_info"));
5619 }
5620 field_sharing_info = Some(map.next_value()?);
5621 }
5622 "property_groups" => {
5623 if field_property_groups.is_some() {
5624 return Err(::serde::de::Error::duplicate_field("property_groups"));
5625 }
5626 field_property_groups = Some(map.next_value()?);
5627 }
5628 _ => {
5629 map.next_value::<::serde_json::Value>()?;
5631 }
5632 }
5633 }
5634 if optional && nothing {
5635 return Ok(None);
5636 }
5637 let result = FolderMetadata {
5638 name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
5639 id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
5640 path_lower: field_path_lower.and_then(Option::flatten),
5641 path_display: field_path_display.and_then(Option::flatten),
5642 parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
5643 preview_url: field_preview_url.and_then(Option::flatten),
5644 shared_folder_id: field_shared_folder_id.and_then(Option::flatten),
5645 sharing_info: field_sharing_info.and_then(Option::flatten),
5646 property_groups: field_property_groups.and_then(Option::flatten),
5647 };
5648 Ok(Some(result))
5649 }
5650
5651 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5652 &self,
5653 s: &mut S::SerializeStruct,
5654 ) -> Result<(), S::Error> {
5655 use serde::ser::SerializeStruct;
5656 s.serialize_field("name", &self.name)?;
5657 s.serialize_field("id", &self.id)?;
5658 if let Some(val) = &self.path_lower {
5659 s.serialize_field("path_lower", val)?;
5660 }
5661 if let Some(val) = &self.path_display {
5662 s.serialize_field("path_display", val)?;
5663 }
5664 if let Some(val) = &self.parent_shared_folder_id {
5665 s.serialize_field("parent_shared_folder_id", val)?;
5666 }
5667 if let Some(val) = &self.preview_url {
5668 s.serialize_field("preview_url", val)?;
5669 }
5670 if let Some(val) = &self.shared_folder_id {
5671 s.serialize_field("shared_folder_id", val)?;
5672 }
5673 if let Some(val) = &self.sharing_info {
5674 s.serialize_field("sharing_info", val)?;
5675 }
5676 if let Some(val) = &self.property_groups {
5677 s.serialize_field("property_groups", val)?;
5678 }
5679 Ok(())
5680 }
5681}
5682
5683impl<'de> ::serde::de::Deserialize<'de> for FolderMetadata {
5684 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5685 use serde::de::{MapAccess, Visitor};
5687 struct StructVisitor;
5688 impl<'de> Visitor<'de> for StructVisitor {
5689 type Value = FolderMetadata;
5690 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5691 f.write_str("a FolderMetadata struct")
5692 }
5693 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5694 FolderMetadata::internal_deserialize(map)
5695 }
5696 }
5697 deserializer.deserialize_struct("FolderMetadata", FOLDER_METADATA_FIELDS, StructVisitor)
5698 }
5699}
5700
5701impl ::serde::ser::Serialize for FolderMetadata {
5702 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5703 use serde::ser::SerializeStruct;
5705 let mut s = serializer.serialize_struct("FolderMetadata", 9)?;
5706 self.internal_serialize::<S>(&mut s)?;
5707 s.end()
5708 }
5709}
5710
5711impl From<FolderMetadata> for Metadata {
5713 fn from(subtype: FolderMetadata) -> Self {
5714 Metadata::Folder(subtype)
5715 }
5716}
5717#[derive(Debug, Clone, PartialEq, Eq)]
5720#[non_exhaustive] pub struct FolderSharingInfo {
5722 pub read_only: bool,
5724 pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
5726 pub shared_folder_id: Option<crate::types::common::SharedFolderId>,
5729 pub traverse_only: bool,
5733 pub no_access: bool,
5735}
5736
5737impl FolderSharingInfo {
5738 pub fn new(read_only: bool) -> Self {
5739 FolderSharingInfo {
5740 read_only,
5741 parent_shared_folder_id: None,
5742 shared_folder_id: None,
5743 traverse_only: false,
5744 no_access: false,
5745 }
5746 }
5747
5748 pub fn with_parent_shared_folder_id(
5749 mut self,
5750 value: crate::types::common::SharedFolderId,
5751 ) -> Self {
5752 self.parent_shared_folder_id = Some(value);
5753 self
5754 }
5755
5756 pub fn with_shared_folder_id(mut self, value: crate::types::common::SharedFolderId) -> Self {
5757 self.shared_folder_id = Some(value);
5758 self
5759 }
5760
5761 pub fn with_traverse_only(mut self, value: bool) -> Self {
5762 self.traverse_only = value;
5763 self
5764 }
5765
5766 pub fn with_no_access(mut self, value: bool) -> Self {
5767 self.no_access = value;
5768 self
5769 }
5770}
5771
5772const FOLDER_SHARING_INFO_FIELDS: &[&str] = &["read_only",
5773 "parent_shared_folder_id",
5774 "shared_folder_id",
5775 "traverse_only",
5776 "no_access"];
5777impl FolderSharingInfo {
5778 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5779 map: V,
5780 ) -> Result<FolderSharingInfo, V::Error> {
5781 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5782 }
5783
5784 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5785 mut map: V,
5786 optional: bool,
5787 ) -> Result<Option<FolderSharingInfo>, V::Error> {
5788 let mut field_read_only = None;
5789 let mut field_parent_shared_folder_id = None;
5790 let mut field_shared_folder_id = None;
5791 let mut field_traverse_only = None;
5792 let mut field_no_access = None;
5793 let mut nothing = true;
5794 while let Some(key) = map.next_key::<&str>()? {
5795 nothing = false;
5796 match key {
5797 "read_only" => {
5798 if field_read_only.is_some() {
5799 return Err(::serde::de::Error::duplicate_field("read_only"));
5800 }
5801 field_read_only = Some(map.next_value()?);
5802 }
5803 "parent_shared_folder_id" => {
5804 if field_parent_shared_folder_id.is_some() {
5805 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5806 }
5807 field_parent_shared_folder_id = Some(map.next_value()?);
5808 }
5809 "shared_folder_id" => {
5810 if field_shared_folder_id.is_some() {
5811 return Err(::serde::de::Error::duplicate_field("shared_folder_id"));
5812 }
5813 field_shared_folder_id = Some(map.next_value()?);
5814 }
5815 "traverse_only" => {
5816 if field_traverse_only.is_some() {
5817 return Err(::serde::de::Error::duplicate_field("traverse_only"));
5818 }
5819 field_traverse_only = Some(map.next_value()?);
5820 }
5821 "no_access" => {
5822 if field_no_access.is_some() {
5823 return Err(::serde::de::Error::duplicate_field("no_access"));
5824 }
5825 field_no_access = Some(map.next_value()?);
5826 }
5827 _ => {
5828 map.next_value::<::serde_json::Value>()?;
5830 }
5831 }
5832 }
5833 if optional && nothing {
5834 return Ok(None);
5835 }
5836 let result = FolderSharingInfo {
5837 read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
5838 parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
5839 shared_folder_id: field_shared_folder_id.and_then(Option::flatten),
5840 traverse_only: field_traverse_only.unwrap_or(false),
5841 no_access: field_no_access.unwrap_or(false),
5842 };
5843 Ok(Some(result))
5844 }
5845
5846 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5847 &self,
5848 s: &mut S::SerializeStruct,
5849 ) -> Result<(), S::Error> {
5850 use serde::ser::SerializeStruct;
5851 s.serialize_field("read_only", &self.read_only)?;
5852 if let Some(val) = &self.parent_shared_folder_id {
5853 s.serialize_field("parent_shared_folder_id", val)?;
5854 }
5855 if let Some(val) = &self.shared_folder_id {
5856 s.serialize_field("shared_folder_id", val)?;
5857 }
5858 if self.traverse_only {
5859 s.serialize_field("traverse_only", &self.traverse_only)?;
5860 }
5861 if self.no_access {
5862 s.serialize_field("no_access", &self.no_access)?;
5863 }
5864 Ok(())
5865 }
5866}
5867
5868impl<'de> ::serde::de::Deserialize<'de> for FolderSharingInfo {
5869 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5870 use serde::de::{MapAccess, Visitor};
5872 struct StructVisitor;
5873 impl<'de> Visitor<'de> for StructVisitor {
5874 type Value = FolderSharingInfo;
5875 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5876 f.write_str("a FolderSharingInfo struct")
5877 }
5878 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5879 FolderSharingInfo::internal_deserialize(map)
5880 }
5881 }
5882 deserializer.deserialize_struct("FolderSharingInfo", FOLDER_SHARING_INFO_FIELDS, StructVisitor)
5883 }
5884}
5885
5886impl ::serde::ser::Serialize for FolderSharingInfo {
5887 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5888 use serde::ser::SerializeStruct;
5890 let mut s = serializer.serialize_struct("FolderSharingInfo", 5)?;
5891 self.internal_serialize::<S>(&mut s)?;
5892 s.end()
5893 }
5894}
5895
5896impl From<FolderSharingInfo> for SharingInfo {
5898 fn from(subtype: FolderSharingInfo) -> Self {
5899 Self {
5900 read_only: subtype.read_only,
5901 }
5902 }
5903}
5904#[derive(Debug, Clone, PartialEq, Eq)]
5905#[non_exhaustive] pub struct GetCopyReferenceArg {
5907 pub path: ReadPath,
5909}
5910
5911impl GetCopyReferenceArg {
5912 pub fn new(path: ReadPath) -> Self {
5913 GetCopyReferenceArg {
5914 path,
5915 }
5916 }
5917}
5918
5919const GET_COPY_REFERENCE_ARG_FIELDS: &[&str] = &["path"];
5920impl GetCopyReferenceArg {
5921 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5922 map: V,
5923 ) -> Result<GetCopyReferenceArg, V::Error> {
5924 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5925 }
5926
5927 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5928 mut map: V,
5929 optional: bool,
5930 ) -> Result<Option<GetCopyReferenceArg>, V::Error> {
5931 let mut field_path = None;
5932 let mut nothing = true;
5933 while let Some(key) = map.next_key::<&str>()? {
5934 nothing = false;
5935 match key {
5936 "path" => {
5937 if field_path.is_some() {
5938 return Err(::serde::de::Error::duplicate_field("path"));
5939 }
5940 field_path = Some(map.next_value()?);
5941 }
5942 _ => {
5943 map.next_value::<::serde_json::Value>()?;
5945 }
5946 }
5947 }
5948 if optional && nothing {
5949 return Ok(None);
5950 }
5951 let result = GetCopyReferenceArg {
5952 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
5953 };
5954 Ok(Some(result))
5955 }
5956
5957 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5958 &self,
5959 s: &mut S::SerializeStruct,
5960 ) -> Result<(), S::Error> {
5961 use serde::ser::SerializeStruct;
5962 s.serialize_field("path", &self.path)?;
5963 Ok(())
5964 }
5965}
5966
5967impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceArg {
5968 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5969 use serde::de::{MapAccess, Visitor};
5971 struct StructVisitor;
5972 impl<'de> Visitor<'de> for StructVisitor {
5973 type Value = GetCopyReferenceArg;
5974 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5975 f.write_str("a GetCopyReferenceArg struct")
5976 }
5977 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5978 GetCopyReferenceArg::internal_deserialize(map)
5979 }
5980 }
5981 deserializer.deserialize_struct("GetCopyReferenceArg", GET_COPY_REFERENCE_ARG_FIELDS, StructVisitor)
5982 }
5983}
5984
5985impl ::serde::ser::Serialize for GetCopyReferenceArg {
5986 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5987 use serde::ser::SerializeStruct;
5989 let mut s = serializer.serialize_struct("GetCopyReferenceArg", 1)?;
5990 self.internal_serialize::<S>(&mut s)?;
5991 s.end()
5992 }
5993}
5994
5995#[derive(Debug, Clone, PartialEq, Eq)]
5996#[non_exhaustive] pub enum GetCopyReferenceError {
5998 Path(LookupError),
5999 Other,
6002}
6003
6004impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceError {
6005 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6006 use serde::de::{self, MapAccess, Visitor};
6008 struct EnumVisitor;
6009 impl<'de> Visitor<'de> for EnumVisitor {
6010 type Value = GetCopyReferenceError;
6011 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6012 f.write_str("a GetCopyReferenceError structure")
6013 }
6014 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
6015 let tag: &str = match map.next_key()? {
6016 Some(".tag") => map.next_value()?,
6017 _ => return Err(de::Error::missing_field(".tag"))
6018 };
6019 let value = match tag {
6020 "path" => {
6021 match map.next_key()? {
6022 Some("path") => GetCopyReferenceError::Path(map.next_value()?),
6023 None => return Err(de::Error::missing_field("path")),
6024 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
6025 }
6026 }
6027 _ => GetCopyReferenceError::Other,
6028 };
6029 crate::eat_json_fields(&mut map)?;
6030 Ok(value)
6031 }
6032 }
6033 const VARIANTS: &[&str] = &["path",
6034 "other"];
6035 deserializer.deserialize_struct("GetCopyReferenceError", VARIANTS, EnumVisitor)
6036 }
6037}
6038
6039impl ::serde::ser::Serialize for GetCopyReferenceError {
6040 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6041 use serde::ser::SerializeStruct;
6043 match self {
6044 GetCopyReferenceError::Path(x) => {
6045 let mut s = serializer.serialize_struct("GetCopyReferenceError", 2)?;
6047 s.serialize_field(".tag", "path")?;
6048 s.serialize_field("path", x)?;
6049 s.end()
6050 }
6051 GetCopyReferenceError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
6052 }
6053 }
6054}
6055
6056impl ::std::error::Error for GetCopyReferenceError {
6057 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
6058 match self {
6059 GetCopyReferenceError::Path(inner) => Some(inner),
6060 _ => None,
6061 }
6062 }
6063}
6064
6065impl ::std::fmt::Display for GetCopyReferenceError {
6066 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6067 match self {
6068 GetCopyReferenceError::Path(inner) => write!(f, "GetCopyReferenceError: {}", inner),
6069 _ => write!(f, "{:?}", *self),
6070 }
6071 }
6072}
6073
6074#[derive(Debug, Clone, PartialEq)]
6075#[non_exhaustive] pub struct GetCopyReferenceResult {
6077 pub metadata: Metadata,
6079 pub copy_reference: String,
6081 pub expires: crate::types::common::DropboxTimestamp,
6084}
6085
6086impl GetCopyReferenceResult {
6087 pub fn new(
6088 metadata: Metadata,
6089 copy_reference: String,
6090 expires: crate::types::common::DropboxTimestamp,
6091 ) -> Self {
6092 GetCopyReferenceResult {
6093 metadata,
6094 copy_reference,
6095 expires,
6096 }
6097 }
6098}
6099
6100const GET_COPY_REFERENCE_RESULT_FIELDS: &[&str] = &["metadata",
6101 "copy_reference",
6102 "expires"];
6103impl GetCopyReferenceResult {
6104 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6105 map: V,
6106 ) -> Result<GetCopyReferenceResult, V::Error> {
6107 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6108 }
6109
6110 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6111 mut map: V,
6112 optional: bool,
6113 ) -> Result<Option<GetCopyReferenceResult>, V::Error> {
6114 let mut field_metadata = None;
6115 let mut field_copy_reference = None;
6116 let mut field_expires = None;
6117 let mut nothing = true;
6118 while let Some(key) = map.next_key::<&str>()? {
6119 nothing = false;
6120 match key {
6121 "metadata" => {
6122 if field_metadata.is_some() {
6123 return Err(::serde::de::Error::duplicate_field("metadata"));
6124 }
6125 field_metadata = Some(map.next_value()?);
6126 }
6127 "copy_reference" => {
6128 if field_copy_reference.is_some() {
6129 return Err(::serde::de::Error::duplicate_field("copy_reference"));
6130 }
6131 field_copy_reference = Some(map.next_value()?);
6132 }
6133 "expires" => {
6134 if field_expires.is_some() {
6135 return Err(::serde::de::Error::duplicate_field("expires"));
6136 }
6137 field_expires = Some(map.next_value()?);
6138 }
6139 _ => {
6140 map.next_value::<::serde_json::Value>()?;
6142 }
6143 }
6144 }
6145 if optional && nothing {
6146 return Ok(None);
6147 }
6148 let result = GetCopyReferenceResult {
6149 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
6150 copy_reference: field_copy_reference.ok_or_else(|| ::serde::de::Error::missing_field("copy_reference"))?,
6151 expires: field_expires.ok_or_else(|| ::serde::de::Error::missing_field("expires"))?,
6152 };
6153 Ok(Some(result))
6154 }
6155
6156 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6157 &self,
6158 s: &mut S::SerializeStruct,
6159 ) -> Result<(), S::Error> {
6160 use serde::ser::SerializeStruct;
6161 s.serialize_field("metadata", &self.metadata)?;
6162 s.serialize_field("copy_reference", &self.copy_reference)?;
6163 s.serialize_field("expires", &self.expires)?;
6164 Ok(())
6165 }
6166}
6167
6168impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceResult {
6169 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6170 use serde::de::{MapAccess, Visitor};
6172 struct StructVisitor;
6173 impl<'de> Visitor<'de> for StructVisitor {
6174 type Value = GetCopyReferenceResult;
6175 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6176 f.write_str("a GetCopyReferenceResult struct")
6177 }
6178 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6179 GetCopyReferenceResult::internal_deserialize(map)
6180 }
6181 }
6182 deserializer.deserialize_struct("GetCopyReferenceResult", GET_COPY_REFERENCE_RESULT_FIELDS, StructVisitor)
6183 }
6184}
6185
6186impl ::serde::ser::Serialize for GetCopyReferenceResult {
6187 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6188 use serde::ser::SerializeStruct;
6190 let mut s = serializer.serialize_struct("GetCopyReferenceResult", 3)?;
6191 self.internal_serialize::<S>(&mut s)?;
6192 s.end()
6193 }
6194}
6195
6196#[derive(Debug, Clone, PartialEq, Eq)]
6197#[non_exhaustive] pub struct GetMetadataArg {
6199 pub path: ReadPath,
6201 pub include_media_info: bool,
6203 pub include_deleted: bool,
6206 pub include_has_explicit_shared_members: bool,
6209 pub include_property_groups: Option<crate::types::file_properties::TemplateFilterBase>,
6212}
6213
6214impl GetMetadataArg {
6215 pub fn new(path: ReadPath) -> Self {
6216 GetMetadataArg {
6217 path,
6218 include_media_info: false,
6219 include_deleted: false,
6220 include_has_explicit_shared_members: false,
6221 include_property_groups: None,
6222 }
6223 }
6224
6225 pub fn with_include_media_info(mut self, value: bool) -> Self {
6226 self.include_media_info = value;
6227 self
6228 }
6229
6230 pub fn with_include_deleted(mut self, value: bool) -> Self {
6231 self.include_deleted = value;
6232 self
6233 }
6234
6235 pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
6236 self.include_has_explicit_shared_members = value;
6237 self
6238 }
6239
6240 pub fn with_include_property_groups(
6241 mut self,
6242 value: crate::types::file_properties::TemplateFilterBase,
6243 ) -> Self {
6244 self.include_property_groups = Some(value);
6245 self
6246 }
6247}
6248
6249const GET_METADATA_ARG_FIELDS: &[&str] = &["path",
6250 "include_media_info",
6251 "include_deleted",
6252 "include_has_explicit_shared_members",
6253 "include_property_groups"];
6254impl GetMetadataArg {
6255 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6256 map: V,
6257 ) -> Result<GetMetadataArg, V::Error> {
6258 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6259 }
6260
6261 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6262 mut map: V,
6263 optional: bool,
6264 ) -> Result<Option<GetMetadataArg>, V::Error> {
6265 let mut field_path = None;
6266 let mut field_include_media_info = None;
6267 let mut field_include_deleted = None;
6268 let mut field_include_has_explicit_shared_members = None;
6269 let mut field_include_property_groups = None;
6270 let mut nothing = true;
6271 while let Some(key) = map.next_key::<&str>()? {
6272 nothing = false;
6273 match key {
6274 "path" => {
6275 if field_path.is_some() {
6276 return Err(::serde::de::Error::duplicate_field("path"));
6277 }
6278 field_path = Some(map.next_value()?);
6279 }
6280 "include_media_info" => {
6281 if field_include_media_info.is_some() {
6282 return Err(::serde::de::Error::duplicate_field("include_media_info"));
6283 }
6284 field_include_media_info = Some(map.next_value()?);
6285 }
6286 "include_deleted" => {
6287 if field_include_deleted.is_some() {
6288 return Err(::serde::de::Error::duplicate_field("include_deleted"));
6289 }
6290 field_include_deleted = Some(map.next_value()?);
6291 }
6292 "include_has_explicit_shared_members" => {
6293 if field_include_has_explicit_shared_members.is_some() {
6294 return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
6295 }
6296 field_include_has_explicit_shared_members = Some(map.next_value()?);
6297 }
6298 "include_property_groups" => {
6299 if field_include_property_groups.is_some() {
6300 return Err(::serde::de::Error::duplicate_field("include_property_groups"));
6301 }
6302 field_include_property_groups = Some(map.next_value()?);
6303 }
6304 _ => {
6305 map.next_value::<::serde_json::Value>()?;
6307 }
6308 }
6309 }
6310 if optional && nothing {
6311 return Ok(None);
6312 }
6313 let result = GetMetadataArg {
6314 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
6315 include_media_info: field_include_media_info.unwrap_or(false),
6316 include_deleted: field_include_deleted.unwrap_or(false),
6317 include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
6318 include_property_groups: field_include_property_groups.and_then(Option::flatten),
6319 };
6320 Ok(Some(result))
6321 }
6322
6323 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6324 &self,
6325 s: &mut S::SerializeStruct,
6326 ) -> Result<(), S::Error> {
6327 use serde::ser::SerializeStruct;
6328 s.serialize_field("path", &self.path)?;
6329 if self.include_media_info {
6330 s.serialize_field("include_media_info", &self.include_media_info)?;
6331 }
6332 if self.include_deleted {
6333 s.serialize_field("include_deleted", &self.include_deleted)?;
6334 }
6335 if self.include_has_explicit_shared_members {
6336 s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
6337 }
6338 if let Some(val) = &self.include_property_groups {
6339 s.serialize_field("include_property_groups", val)?;
6340 }
6341 Ok(())
6342 }
6343}
6344
6345impl<'de> ::serde::de::Deserialize<'de> for GetMetadataArg {
6346 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6347 use serde::de::{MapAccess, Visitor};
6349 struct StructVisitor;
6350 impl<'de> Visitor<'de> for StructVisitor {
6351 type Value = GetMetadataArg;
6352 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6353 f.write_str("a GetMetadataArg struct")
6354 }
6355 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6356 GetMetadataArg::internal_deserialize(map)
6357 }
6358 }
6359 deserializer.deserialize_struct("GetMetadataArg", GET_METADATA_ARG_FIELDS, StructVisitor)
6360 }
6361}
6362
6363impl ::serde::ser::Serialize for GetMetadataArg {
6364 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6365 use serde::ser::SerializeStruct;
6367 let mut s = serializer.serialize_struct("GetMetadataArg", 5)?;
6368 self.internal_serialize::<S>(&mut s)?;
6369 s.end()
6370 }
6371}
6372
6373#[derive(Debug, Clone, PartialEq, Eq)]
6374pub enum GetMetadataError {
6375 Path(LookupError),
6376}
6377
6378impl<'de> ::serde::de::Deserialize<'de> for GetMetadataError {
6379 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6380 use serde::de::{self, MapAccess, Visitor};
6382 struct EnumVisitor;
6383 impl<'de> Visitor<'de> for EnumVisitor {
6384 type Value = GetMetadataError;
6385 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6386 f.write_str("a GetMetadataError structure")
6387 }
6388 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
6389 let tag: &str = match map.next_key()? {
6390 Some(".tag") => map.next_value()?,
6391 _ => return Err(de::Error::missing_field(".tag"))
6392 };
6393 let value = match tag {
6394 "path" => {
6395 match map.next_key()? {
6396 Some("path") => GetMetadataError::Path(map.next_value()?),
6397 None => return Err(de::Error::missing_field("path")),
6398 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
6399 }
6400 }
6401 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
6402 };
6403 crate::eat_json_fields(&mut map)?;
6404 Ok(value)
6405 }
6406 }
6407 const VARIANTS: &[&str] = &["path"];
6408 deserializer.deserialize_struct("GetMetadataError", VARIANTS, EnumVisitor)
6409 }
6410}
6411
6412impl ::serde::ser::Serialize for GetMetadataError {
6413 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6414 use serde::ser::SerializeStruct;
6416 match self {
6417 GetMetadataError::Path(x) => {
6418 let mut s = serializer.serialize_struct("GetMetadataError", 2)?;
6420 s.serialize_field(".tag", "path")?;
6421 s.serialize_field("path", x)?;
6422 s.end()
6423 }
6424 }
6425 }
6426}
6427
6428impl ::std::error::Error for GetMetadataError {
6429 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
6430 match self {
6431 GetMetadataError::Path(inner) => Some(inner),
6432 }
6433 }
6434}
6435
6436impl ::std::fmt::Display for GetMetadataError {
6437 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6438 match self {
6439 GetMetadataError::Path(inner) => write!(f, "GetMetadataError: {}", inner),
6440 }
6441 }
6442}
6443
6444#[derive(Debug, Clone, PartialEq, Eq)]
6445#[non_exhaustive] pub struct GetTagsArg {
6447 pub paths: Vec<Path>,
6449}
6450
6451impl GetTagsArg {
6452 pub fn new(paths: Vec<Path>) -> Self {
6453 GetTagsArg {
6454 paths,
6455 }
6456 }
6457}
6458
6459const GET_TAGS_ARG_FIELDS: &[&str] = &["paths"];
6460impl GetTagsArg {
6461 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6462 map: V,
6463 ) -> Result<GetTagsArg, V::Error> {
6464 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6465 }
6466
6467 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6468 mut map: V,
6469 optional: bool,
6470 ) -> Result<Option<GetTagsArg>, V::Error> {
6471 let mut field_paths = None;
6472 let mut nothing = true;
6473 while let Some(key) = map.next_key::<&str>()? {
6474 nothing = false;
6475 match key {
6476 "paths" => {
6477 if field_paths.is_some() {
6478 return Err(::serde::de::Error::duplicate_field("paths"));
6479 }
6480 field_paths = Some(map.next_value()?);
6481 }
6482 _ => {
6483 map.next_value::<::serde_json::Value>()?;
6485 }
6486 }
6487 }
6488 if optional && nothing {
6489 return Ok(None);
6490 }
6491 let result = GetTagsArg {
6492 paths: field_paths.ok_or_else(|| ::serde::de::Error::missing_field("paths"))?,
6493 };
6494 Ok(Some(result))
6495 }
6496
6497 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6498 &self,
6499 s: &mut S::SerializeStruct,
6500 ) -> Result<(), S::Error> {
6501 use serde::ser::SerializeStruct;
6502 s.serialize_field("paths", &self.paths)?;
6503 Ok(())
6504 }
6505}
6506
6507impl<'de> ::serde::de::Deserialize<'de> for GetTagsArg {
6508 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6509 use serde::de::{MapAccess, Visitor};
6511 struct StructVisitor;
6512 impl<'de> Visitor<'de> for StructVisitor {
6513 type Value = GetTagsArg;
6514 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6515 f.write_str("a GetTagsArg struct")
6516 }
6517 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6518 GetTagsArg::internal_deserialize(map)
6519 }
6520 }
6521 deserializer.deserialize_struct("GetTagsArg", GET_TAGS_ARG_FIELDS, StructVisitor)
6522 }
6523}
6524
6525impl ::serde::ser::Serialize for GetTagsArg {
6526 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6527 use serde::ser::SerializeStruct;
6529 let mut s = serializer.serialize_struct("GetTagsArg", 1)?;
6530 self.internal_serialize::<S>(&mut s)?;
6531 s.end()
6532 }
6533}
6534
6535#[derive(Debug, Clone, PartialEq, Eq)]
6536#[non_exhaustive] pub struct GetTagsResult {
6538 pub paths_to_tags: Vec<PathToTags>,
6540}
6541
6542impl GetTagsResult {
6543 pub fn new(paths_to_tags: Vec<PathToTags>) -> Self {
6544 GetTagsResult {
6545 paths_to_tags,
6546 }
6547 }
6548}
6549
6550const GET_TAGS_RESULT_FIELDS: &[&str] = &["paths_to_tags"];
6551impl GetTagsResult {
6552 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6553 map: V,
6554 ) -> Result<GetTagsResult, V::Error> {
6555 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6556 }
6557
6558 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6559 mut map: V,
6560 optional: bool,
6561 ) -> Result<Option<GetTagsResult>, V::Error> {
6562 let mut field_paths_to_tags = None;
6563 let mut nothing = true;
6564 while let Some(key) = map.next_key::<&str>()? {
6565 nothing = false;
6566 match key {
6567 "paths_to_tags" => {
6568 if field_paths_to_tags.is_some() {
6569 return Err(::serde::de::Error::duplicate_field("paths_to_tags"));
6570 }
6571 field_paths_to_tags = Some(map.next_value()?);
6572 }
6573 _ => {
6574 map.next_value::<::serde_json::Value>()?;
6576 }
6577 }
6578 }
6579 if optional && nothing {
6580 return Ok(None);
6581 }
6582 let result = GetTagsResult {
6583 paths_to_tags: field_paths_to_tags.ok_or_else(|| ::serde::de::Error::missing_field("paths_to_tags"))?,
6584 };
6585 Ok(Some(result))
6586 }
6587
6588 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6589 &self,
6590 s: &mut S::SerializeStruct,
6591 ) -> Result<(), S::Error> {
6592 use serde::ser::SerializeStruct;
6593 s.serialize_field("paths_to_tags", &self.paths_to_tags)?;
6594 Ok(())
6595 }
6596}
6597
6598impl<'de> ::serde::de::Deserialize<'de> for GetTagsResult {
6599 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6600 use serde::de::{MapAccess, Visitor};
6602 struct StructVisitor;
6603 impl<'de> Visitor<'de> for StructVisitor {
6604 type Value = GetTagsResult;
6605 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6606 f.write_str("a GetTagsResult struct")
6607 }
6608 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6609 GetTagsResult::internal_deserialize(map)
6610 }
6611 }
6612 deserializer.deserialize_struct("GetTagsResult", GET_TAGS_RESULT_FIELDS, StructVisitor)
6613 }
6614}
6615
6616impl ::serde::ser::Serialize for GetTagsResult {
6617 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6618 use serde::ser::SerializeStruct;
6620 let mut s = serializer.serialize_struct("GetTagsResult", 1)?;
6621 self.internal_serialize::<S>(&mut s)?;
6622 s.end()
6623 }
6624}
6625
6626#[derive(Debug, Clone, PartialEq, Eq)]
6627#[non_exhaustive] pub struct GetTemporaryLinkArg {
6629 pub path: ReadPath,
6631}
6632
6633impl GetTemporaryLinkArg {
6634 pub fn new(path: ReadPath) -> Self {
6635 GetTemporaryLinkArg {
6636 path,
6637 }
6638 }
6639}
6640
6641const GET_TEMPORARY_LINK_ARG_FIELDS: &[&str] = &["path"];
6642impl GetTemporaryLinkArg {
6643 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6644 map: V,
6645 ) -> Result<GetTemporaryLinkArg, V::Error> {
6646 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6647 }
6648
6649 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6650 mut map: V,
6651 optional: bool,
6652 ) -> Result<Option<GetTemporaryLinkArg>, V::Error> {
6653 let mut field_path = None;
6654 let mut nothing = true;
6655 while let Some(key) = map.next_key::<&str>()? {
6656 nothing = false;
6657 match key {
6658 "path" => {
6659 if field_path.is_some() {
6660 return Err(::serde::de::Error::duplicate_field("path"));
6661 }
6662 field_path = Some(map.next_value()?);
6663 }
6664 _ => {
6665 map.next_value::<::serde_json::Value>()?;
6667 }
6668 }
6669 }
6670 if optional && nothing {
6671 return Ok(None);
6672 }
6673 let result = GetTemporaryLinkArg {
6674 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
6675 };
6676 Ok(Some(result))
6677 }
6678
6679 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6680 &self,
6681 s: &mut S::SerializeStruct,
6682 ) -> Result<(), S::Error> {
6683 use serde::ser::SerializeStruct;
6684 s.serialize_field("path", &self.path)?;
6685 Ok(())
6686 }
6687}
6688
6689impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkArg {
6690 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6691 use serde::de::{MapAccess, Visitor};
6693 struct StructVisitor;
6694 impl<'de> Visitor<'de> for StructVisitor {
6695 type Value = GetTemporaryLinkArg;
6696 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6697 f.write_str("a GetTemporaryLinkArg struct")
6698 }
6699 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6700 GetTemporaryLinkArg::internal_deserialize(map)
6701 }
6702 }
6703 deserializer.deserialize_struct("GetTemporaryLinkArg", GET_TEMPORARY_LINK_ARG_FIELDS, StructVisitor)
6704 }
6705}
6706
6707impl ::serde::ser::Serialize for GetTemporaryLinkArg {
6708 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6709 use serde::ser::SerializeStruct;
6711 let mut s = serializer.serialize_struct("GetTemporaryLinkArg", 1)?;
6712 self.internal_serialize::<S>(&mut s)?;
6713 s.end()
6714 }
6715}
6716
6717#[derive(Debug, Clone, PartialEq, Eq)]
6718#[non_exhaustive] pub enum GetTemporaryLinkError {
6720 Path(LookupError),
6721 EmailNotVerified,
6725 UnsupportedFile,
6727 NotAllowed,
6731 Other,
6734}
6735
6736impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkError {
6737 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6738 use serde::de::{self, MapAccess, Visitor};
6740 struct EnumVisitor;
6741 impl<'de> Visitor<'de> for EnumVisitor {
6742 type Value = GetTemporaryLinkError;
6743 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6744 f.write_str("a GetTemporaryLinkError structure")
6745 }
6746 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
6747 let tag: &str = match map.next_key()? {
6748 Some(".tag") => map.next_value()?,
6749 _ => return Err(de::Error::missing_field(".tag"))
6750 };
6751 let value = match tag {
6752 "path" => {
6753 match map.next_key()? {
6754 Some("path") => GetTemporaryLinkError::Path(map.next_value()?),
6755 None => return Err(de::Error::missing_field("path")),
6756 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
6757 }
6758 }
6759 "email_not_verified" => GetTemporaryLinkError::EmailNotVerified,
6760 "unsupported_file" => GetTemporaryLinkError::UnsupportedFile,
6761 "not_allowed" => GetTemporaryLinkError::NotAllowed,
6762 _ => GetTemporaryLinkError::Other,
6763 };
6764 crate::eat_json_fields(&mut map)?;
6765 Ok(value)
6766 }
6767 }
6768 const VARIANTS: &[&str] = &["path",
6769 "email_not_verified",
6770 "unsupported_file",
6771 "not_allowed",
6772 "other"];
6773 deserializer.deserialize_struct("GetTemporaryLinkError", VARIANTS, EnumVisitor)
6774 }
6775}
6776
6777impl ::serde::ser::Serialize for GetTemporaryLinkError {
6778 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6779 use serde::ser::SerializeStruct;
6781 match self {
6782 GetTemporaryLinkError::Path(x) => {
6783 let mut s = serializer.serialize_struct("GetTemporaryLinkError", 2)?;
6785 s.serialize_field(".tag", "path")?;
6786 s.serialize_field("path", x)?;
6787 s.end()
6788 }
6789 GetTemporaryLinkError::EmailNotVerified => {
6790 let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
6792 s.serialize_field(".tag", "email_not_verified")?;
6793 s.end()
6794 }
6795 GetTemporaryLinkError::UnsupportedFile => {
6796 let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
6798 s.serialize_field(".tag", "unsupported_file")?;
6799 s.end()
6800 }
6801 GetTemporaryLinkError::NotAllowed => {
6802 let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
6804 s.serialize_field(".tag", "not_allowed")?;
6805 s.end()
6806 }
6807 GetTemporaryLinkError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
6808 }
6809 }
6810}
6811
6812impl ::std::error::Error for GetTemporaryLinkError {
6813 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
6814 match self {
6815 GetTemporaryLinkError::Path(inner) => Some(inner),
6816 _ => None,
6817 }
6818 }
6819}
6820
6821impl ::std::fmt::Display for GetTemporaryLinkError {
6822 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6823 match self {
6824 GetTemporaryLinkError::Path(inner) => write!(f, "GetTemporaryLinkError: {}", inner),
6825 _ => write!(f, "{:?}", *self),
6826 }
6827 }
6828}
6829
6830#[derive(Debug, Clone, PartialEq)]
6831#[non_exhaustive] pub struct GetTemporaryLinkResult {
6833 pub metadata: FileMetadata,
6835 pub link: String,
6837}
6838
6839impl GetTemporaryLinkResult {
6840 pub fn new(metadata: FileMetadata, link: String) -> Self {
6841 GetTemporaryLinkResult {
6842 metadata,
6843 link,
6844 }
6845 }
6846}
6847
6848const GET_TEMPORARY_LINK_RESULT_FIELDS: &[&str] = &["metadata",
6849 "link"];
6850impl GetTemporaryLinkResult {
6851 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6852 map: V,
6853 ) -> Result<GetTemporaryLinkResult, V::Error> {
6854 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6855 }
6856
6857 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6858 mut map: V,
6859 optional: bool,
6860 ) -> Result<Option<GetTemporaryLinkResult>, V::Error> {
6861 let mut field_metadata = None;
6862 let mut field_link = None;
6863 let mut nothing = true;
6864 while let Some(key) = map.next_key::<&str>()? {
6865 nothing = false;
6866 match key {
6867 "metadata" => {
6868 if field_metadata.is_some() {
6869 return Err(::serde::de::Error::duplicate_field("metadata"));
6870 }
6871 field_metadata = Some(map.next_value()?);
6872 }
6873 "link" => {
6874 if field_link.is_some() {
6875 return Err(::serde::de::Error::duplicate_field("link"));
6876 }
6877 field_link = Some(map.next_value()?);
6878 }
6879 _ => {
6880 map.next_value::<::serde_json::Value>()?;
6882 }
6883 }
6884 }
6885 if optional && nothing {
6886 return Ok(None);
6887 }
6888 let result = GetTemporaryLinkResult {
6889 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
6890 link: field_link.ok_or_else(|| ::serde::de::Error::missing_field("link"))?,
6891 };
6892 Ok(Some(result))
6893 }
6894
6895 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6896 &self,
6897 s: &mut S::SerializeStruct,
6898 ) -> Result<(), S::Error> {
6899 use serde::ser::SerializeStruct;
6900 s.serialize_field("metadata", &self.metadata)?;
6901 s.serialize_field("link", &self.link)?;
6902 Ok(())
6903 }
6904}
6905
6906impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkResult {
6907 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6908 use serde::de::{MapAccess, Visitor};
6910 struct StructVisitor;
6911 impl<'de> Visitor<'de> for StructVisitor {
6912 type Value = GetTemporaryLinkResult;
6913 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6914 f.write_str("a GetTemporaryLinkResult struct")
6915 }
6916 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6917 GetTemporaryLinkResult::internal_deserialize(map)
6918 }
6919 }
6920 deserializer.deserialize_struct("GetTemporaryLinkResult", GET_TEMPORARY_LINK_RESULT_FIELDS, StructVisitor)
6921 }
6922}
6923
6924impl ::serde::ser::Serialize for GetTemporaryLinkResult {
6925 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6926 use serde::ser::SerializeStruct;
6928 let mut s = serializer.serialize_struct("GetTemporaryLinkResult", 2)?;
6929 self.internal_serialize::<S>(&mut s)?;
6930 s.end()
6931 }
6932}
6933
6934#[derive(Debug, Clone, PartialEq)]
6935#[non_exhaustive] pub struct GetTemporaryUploadLinkArg {
6937 pub commit_info: CommitInfo,
6940 pub duration: f64,
6943}
6944
6945impl GetTemporaryUploadLinkArg {
6946 pub fn new(commit_info: CommitInfo) -> Self {
6947 GetTemporaryUploadLinkArg {
6948 commit_info,
6949 duration: 14400.0,
6950 }
6951 }
6952
6953 pub fn with_duration(mut self, value: f64) -> Self {
6954 self.duration = value;
6955 self
6956 }
6957}
6958
6959const GET_TEMPORARY_UPLOAD_LINK_ARG_FIELDS: &[&str] = &["commit_info",
6960 "duration"];
6961impl GetTemporaryUploadLinkArg {
6962 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6963 map: V,
6964 ) -> Result<GetTemporaryUploadLinkArg, V::Error> {
6965 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6966 }
6967
6968 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6969 mut map: V,
6970 optional: bool,
6971 ) -> Result<Option<GetTemporaryUploadLinkArg>, V::Error> {
6972 let mut field_commit_info = None;
6973 let mut field_duration = None;
6974 let mut nothing = true;
6975 while let Some(key) = map.next_key::<&str>()? {
6976 nothing = false;
6977 match key {
6978 "commit_info" => {
6979 if field_commit_info.is_some() {
6980 return Err(::serde::de::Error::duplicate_field("commit_info"));
6981 }
6982 field_commit_info = Some(map.next_value()?);
6983 }
6984 "duration" => {
6985 if field_duration.is_some() {
6986 return Err(::serde::de::Error::duplicate_field("duration"));
6987 }
6988 field_duration = Some(map.next_value()?);
6989 }
6990 _ => {
6991 map.next_value::<::serde_json::Value>()?;
6993 }
6994 }
6995 }
6996 if optional && nothing {
6997 return Ok(None);
6998 }
6999 let result = GetTemporaryUploadLinkArg {
7000 commit_info: field_commit_info.ok_or_else(|| ::serde::de::Error::missing_field("commit_info"))?,
7001 duration: field_duration.unwrap_or(14400.0),
7002 };
7003 Ok(Some(result))
7004 }
7005
7006 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7007 &self,
7008 s: &mut S::SerializeStruct,
7009 ) -> Result<(), S::Error> {
7010 use serde::ser::SerializeStruct;
7011 s.serialize_field("commit_info", &self.commit_info)?;
7012 if self.duration != 14400.0 {
7013 s.serialize_field("duration", &self.duration)?;
7014 }
7015 Ok(())
7016 }
7017}
7018
7019impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryUploadLinkArg {
7020 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7021 use serde::de::{MapAccess, Visitor};
7023 struct StructVisitor;
7024 impl<'de> Visitor<'de> for StructVisitor {
7025 type Value = GetTemporaryUploadLinkArg;
7026 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7027 f.write_str("a GetTemporaryUploadLinkArg struct")
7028 }
7029 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7030 GetTemporaryUploadLinkArg::internal_deserialize(map)
7031 }
7032 }
7033 deserializer.deserialize_struct("GetTemporaryUploadLinkArg", GET_TEMPORARY_UPLOAD_LINK_ARG_FIELDS, StructVisitor)
7034 }
7035}
7036
7037impl ::serde::ser::Serialize for GetTemporaryUploadLinkArg {
7038 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7039 use serde::ser::SerializeStruct;
7041 let mut s = serializer.serialize_struct("GetTemporaryUploadLinkArg", 2)?;
7042 self.internal_serialize::<S>(&mut s)?;
7043 s.end()
7044 }
7045}
7046
7047#[derive(Debug, Clone, PartialEq, Eq)]
7048#[non_exhaustive] pub struct GetTemporaryUploadLinkResult {
7050 pub link: String,
7052}
7053
7054impl GetTemporaryUploadLinkResult {
7055 pub fn new(link: String) -> Self {
7056 GetTemporaryUploadLinkResult {
7057 link,
7058 }
7059 }
7060}
7061
7062const GET_TEMPORARY_UPLOAD_LINK_RESULT_FIELDS: &[&str] = &["link"];
7063impl GetTemporaryUploadLinkResult {
7064 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7065 map: V,
7066 ) -> Result<GetTemporaryUploadLinkResult, V::Error> {
7067 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7068 }
7069
7070 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7071 mut map: V,
7072 optional: bool,
7073 ) -> Result<Option<GetTemporaryUploadLinkResult>, V::Error> {
7074 let mut field_link = None;
7075 let mut nothing = true;
7076 while let Some(key) = map.next_key::<&str>()? {
7077 nothing = false;
7078 match key {
7079 "link" => {
7080 if field_link.is_some() {
7081 return Err(::serde::de::Error::duplicate_field("link"));
7082 }
7083 field_link = Some(map.next_value()?);
7084 }
7085 _ => {
7086 map.next_value::<::serde_json::Value>()?;
7088 }
7089 }
7090 }
7091 if optional && nothing {
7092 return Ok(None);
7093 }
7094 let result = GetTemporaryUploadLinkResult {
7095 link: field_link.ok_or_else(|| ::serde::de::Error::missing_field("link"))?,
7096 };
7097 Ok(Some(result))
7098 }
7099
7100 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7101 &self,
7102 s: &mut S::SerializeStruct,
7103 ) -> Result<(), S::Error> {
7104 use serde::ser::SerializeStruct;
7105 s.serialize_field("link", &self.link)?;
7106 Ok(())
7107 }
7108}
7109
7110impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryUploadLinkResult {
7111 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7112 use serde::de::{MapAccess, Visitor};
7114 struct StructVisitor;
7115 impl<'de> Visitor<'de> for StructVisitor {
7116 type Value = GetTemporaryUploadLinkResult;
7117 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7118 f.write_str("a GetTemporaryUploadLinkResult struct")
7119 }
7120 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7121 GetTemporaryUploadLinkResult::internal_deserialize(map)
7122 }
7123 }
7124 deserializer.deserialize_struct("GetTemporaryUploadLinkResult", GET_TEMPORARY_UPLOAD_LINK_RESULT_FIELDS, StructVisitor)
7125 }
7126}
7127
7128impl ::serde::ser::Serialize for GetTemporaryUploadLinkResult {
7129 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7130 use serde::ser::SerializeStruct;
7132 let mut s = serializer.serialize_struct("GetTemporaryUploadLinkResult", 1)?;
7133 self.internal_serialize::<S>(&mut s)?;
7134 s.end()
7135 }
7136}
7137
7138#[derive(Debug, Clone, PartialEq, Eq)]
7140#[non_exhaustive] pub struct GetThumbnailBatchArg {
7142 pub entries: Vec<ThumbnailArg>,
7144}
7145
7146impl GetThumbnailBatchArg {
7147 pub fn new(entries: Vec<ThumbnailArg>) -> Self {
7148 GetThumbnailBatchArg {
7149 entries,
7150 }
7151 }
7152}
7153
7154const GET_THUMBNAIL_BATCH_ARG_FIELDS: &[&str] = &["entries"];
7155impl GetThumbnailBatchArg {
7156 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7157 map: V,
7158 ) -> Result<GetThumbnailBatchArg, V::Error> {
7159 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7160 }
7161
7162 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7163 mut map: V,
7164 optional: bool,
7165 ) -> Result<Option<GetThumbnailBatchArg>, V::Error> {
7166 let mut field_entries = None;
7167 let mut nothing = true;
7168 while let Some(key) = map.next_key::<&str>()? {
7169 nothing = false;
7170 match key {
7171 "entries" => {
7172 if field_entries.is_some() {
7173 return Err(::serde::de::Error::duplicate_field("entries"));
7174 }
7175 field_entries = Some(map.next_value()?);
7176 }
7177 _ => {
7178 map.next_value::<::serde_json::Value>()?;
7180 }
7181 }
7182 }
7183 if optional && nothing {
7184 return Ok(None);
7185 }
7186 let result = GetThumbnailBatchArg {
7187 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
7188 };
7189 Ok(Some(result))
7190 }
7191
7192 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7193 &self,
7194 s: &mut S::SerializeStruct,
7195 ) -> Result<(), S::Error> {
7196 use serde::ser::SerializeStruct;
7197 s.serialize_field("entries", &self.entries)?;
7198 Ok(())
7199 }
7200}
7201
7202impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchArg {
7203 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7204 use serde::de::{MapAccess, Visitor};
7206 struct StructVisitor;
7207 impl<'de> Visitor<'de> for StructVisitor {
7208 type Value = GetThumbnailBatchArg;
7209 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7210 f.write_str("a GetThumbnailBatchArg struct")
7211 }
7212 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7213 GetThumbnailBatchArg::internal_deserialize(map)
7214 }
7215 }
7216 deserializer.deserialize_struct("GetThumbnailBatchArg", GET_THUMBNAIL_BATCH_ARG_FIELDS, StructVisitor)
7217 }
7218}
7219
7220impl ::serde::ser::Serialize for GetThumbnailBatchArg {
7221 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7222 use serde::ser::SerializeStruct;
7224 let mut s = serializer.serialize_struct("GetThumbnailBatchArg", 1)?;
7225 self.internal_serialize::<S>(&mut s)?;
7226 s.end()
7227 }
7228}
7229
7230#[derive(Debug, Clone, PartialEq, Eq)]
7231#[non_exhaustive] pub enum GetThumbnailBatchError {
7233 TooManyFiles,
7235 Other,
7238}
7239
7240impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchError {
7241 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7242 use serde::de::{self, MapAccess, Visitor};
7244 struct EnumVisitor;
7245 impl<'de> Visitor<'de> for EnumVisitor {
7246 type Value = GetThumbnailBatchError;
7247 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7248 f.write_str("a GetThumbnailBatchError structure")
7249 }
7250 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
7251 let tag: &str = match map.next_key()? {
7252 Some(".tag") => map.next_value()?,
7253 _ => return Err(de::Error::missing_field(".tag"))
7254 };
7255 let value = match tag {
7256 "too_many_files" => GetThumbnailBatchError::TooManyFiles,
7257 _ => GetThumbnailBatchError::Other,
7258 };
7259 crate::eat_json_fields(&mut map)?;
7260 Ok(value)
7261 }
7262 }
7263 const VARIANTS: &[&str] = &["too_many_files",
7264 "other"];
7265 deserializer.deserialize_struct("GetThumbnailBatchError", VARIANTS, EnumVisitor)
7266 }
7267}
7268
7269impl ::serde::ser::Serialize for GetThumbnailBatchError {
7270 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7271 use serde::ser::SerializeStruct;
7273 match self {
7274 GetThumbnailBatchError::TooManyFiles => {
7275 let mut s = serializer.serialize_struct("GetThumbnailBatchError", 1)?;
7277 s.serialize_field(".tag", "too_many_files")?;
7278 s.end()
7279 }
7280 GetThumbnailBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
7281 }
7282 }
7283}
7284
7285impl ::std::error::Error for GetThumbnailBatchError {
7286}
7287
7288impl ::std::fmt::Display for GetThumbnailBatchError {
7289 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7290 match self {
7291 GetThumbnailBatchError::TooManyFiles => f.write_str("The operation involves more than 25 files."),
7292 _ => write!(f, "{:?}", *self),
7293 }
7294 }
7295}
7296
7297#[derive(Debug, Clone, PartialEq)]
7298#[non_exhaustive] pub struct GetThumbnailBatchResult {
7300 pub entries: Vec<GetThumbnailBatchResultEntry>,
7302}
7303
7304impl GetThumbnailBatchResult {
7305 pub fn new(entries: Vec<GetThumbnailBatchResultEntry>) -> Self {
7306 GetThumbnailBatchResult {
7307 entries,
7308 }
7309 }
7310}
7311
7312const GET_THUMBNAIL_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
7313impl GetThumbnailBatchResult {
7314 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7315 map: V,
7316 ) -> Result<GetThumbnailBatchResult, V::Error> {
7317 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7318 }
7319
7320 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7321 mut map: V,
7322 optional: bool,
7323 ) -> Result<Option<GetThumbnailBatchResult>, V::Error> {
7324 let mut field_entries = None;
7325 let mut nothing = true;
7326 while let Some(key) = map.next_key::<&str>()? {
7327 nothing = false;
7328 match key {
7329 "entries" => {
7330 if field_entries.is_some() {
7331 return Err(::serde::de::Error::duplicate_field("entries"));
7332 }
7333 field_entries = Some(map.next_value()?);
7334 }
7335 _ => {
7336 map.next_value::<::serde_json::Value>()?;
7338 }
7339 }
7340 }
7341 if optional && nothing {
7342 return Ok(None);
7343 }
7344 let result = GetThumbnailBatchResult {
7345 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
7346 };
7347 Ok(Some(result))
7348 }
7349
7350 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7351 &self,
7352 s: &mut S::SerializeStruct,
7353 ) -> Result<(), S::Error> {
7354 use serde::ser::SerializeStruct;
7355 s.serialize_field("entries", &self.entries)?;
7356 Ok(())
7357 }
7358}
7359
7360impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResult {
7361 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7362 use serde::de::{MapAccess, Visitor};
7364 struct StructVisitor;
7365 impl<'de> Visitor<'de> for StructVisitor {
7366 type Value = GetThumbnailBatchResult;
7367 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7368 f.write_str("a GetThumbnailBatchResult struct")
7369 }
7370 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7371 GetThumbnailBatchResult::internal_deserialize(map)
7372 }
7373 }
7374 deserializer.deserialize_struct("GetThumbnailBatchResult", GET_THUMBNAIL_BATCH_RESULT_FIELDS, StructVisitor)
7375 }
7376}
7377
7378impl ::serde::ser::Serialize for GetThumbnailBatchResult {
7379 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7380 use serde::ser::SerializeStruct;
7382 let mut s = serializer.serialize_struct("GetThumbnailBatchResult", 1)?;
7383 self.internal_serialize::<S>(&mut s)?;
7384 s.end()
7385 }
7386}
7387
7388#[derive(Debug, Clone, PartialEq)]
7389#[non_exhaustive] pub struct GetThumbnailBatchResultData {
7391 pub metadata: FileMetadata,
7392 pub thumbnail: String,
7394}
7395
7396impl GetThumbnailBatchResultData {
7397 pub fn new(metadata: FileMetadata, thumbnail: String) -> Self {
7398 GetThumbnailBatchResultData {
7399 metadata,
7400 thumbnail,
7401 }
7402 }
7403}
7404
7405const GET_THUMBNAIL_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata",
7406 "thumbnail"];
7407impl GetThumbnailBatchResultData {
7408 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7409 map: V,
7410 ) -> Result<GetThumbnailBatchResultData, V::Error> {
7411 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7412 }
7413
7414 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7415 mut map: V,
7416 optional: bool,
7417 ) -> Result<Option<GetThumbnailBatchResultData>, V::Error> {
7418 let mut field_metadata = None;
7419 let mut field_thumbnail = None;
7420 let mut nothing = true;
7421 while let Some(key) = map.next_key::<&str>()? {
7422 nothing = false;
7423 match key {
7424 "metadata" => {
7425 if field_metadata.is_some() {
7426 return Err(::serde::de::Error::duplicate_field("metadata"));
7427 }
7428 field_metadata = Some(map.next_value()?);
7429 }
7430 "thumbnail" => {
7431 if field_thumbnail.is_some() {
7432 return Err(::serde::de::Error::duplicate_field("thumbnail"));
7433 }
7434 field_thumbnail = Some(map.next_value()?);
7435 }
7436 _ => {
7437 map.next_value::<::serde_json::Value>()?;
7439 }
7440 }
7441 }
7442 if optional && nothing {
7443 return Ok(None);
7444 }
7445 let result = GetThumbnailBatchResultData {
7446 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
7447 thumbnail: field_thumbnail.ok_or_else(|| ::serde::de::Error::missing_field("thumbnail"))?,
7448 };
7449 Ok(Some(result))
7450 }
7451
7452 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7453 &self,
7454 s: &mut S::SerializeStruct,
7455 ) -> Result<(), S::Error> {
7456 use serde::ser::SerializeStruct;
7457 s.serialize_field("metadata", &self.metadata)?;
7458 s.serialize_field("thumbnail", &self.thumbnail)?;
7459 Ok(())
7460 }
7461}
7462
7463impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResultData {
7464 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7465 use serde::de::{MapAccess, Visitor};
7467 struct StructVisitor;
7468 impl<'de> Visitor<'de> for StructVisitor {
7469 type Value = GetThumbnailBatchResultData;
7470 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7471 f.write_str("a GetThumbnailBatchResultData struct")
7472 }
7473 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7474 GetThumbnailBatchResultData::internal_deserialize(map)
7475 }
7476 }
7477 deserializer.deserialize_struct("GetThumbnailBatchResultData", GET_THUMBNAIL_BATCH_RESULT_DATA_FIELDS, StructVisitor)
7478 }
7479}
7480
7481impl ::serde::ser::Serialize for GetThumbnailBatchResultData {
7482 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7483 use serde::ser::SerializeStruct;
7485 let mut s = serializer.serialize_struct("GetThumbnailBatchResultData", 2)?;
7486 self.internal_serialize::<S>(&mut s)?;
7487 s.end()
7488 }
7489}
7490
7491#[derive(Debug, Clone, PartialEq)]
7492#[non_exhaustive] pub enum GetThumbnailBatchResultEntry {
7494 Success(GetThumbnailBatchResultData),
7495 Failure(ThumbnailError),
7497 Other,
7500}
7501
7502impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResultEntry {
7503 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7504 use serde::de::{self, MapAccess, Visitor};
7506 struct EnumVisitor;
7507 impl<'de> Visitor<'de> for EnumVisitor {
7508 type Value = GetThumbnailBatchResultEntry;
7509 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7510 f.write_str("a GetThumbnailBatchResultEntry structure")
7511 }
7512 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
7513 let tag: &str = match map.next_key()? {
7514 Some(".tag") => map.next_value()?,
7515 _ => return Err(de::Error::missing_field(".tag"))
7516 };
7517 let value = match tag {
7518 "success" => GetThumbnailBatchResultEntry::Success(GetThumbnailBatchResultData::internal_deserialize(&mut map)?),
7519 "failure" => {
7520 match map.next_key()? {
7521 Some("failure") => GetThumbnailBatchResultEntry::Failure(map.next_value()?),
7522 None => return Err(de::Error::missing_field("failure")),
7523 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
7524 }
7525 }
7526 _ => GetThumbnailBatchResultEntry::Other,
7527 };
7528 crate::eat_json_fields(&mut map)?;
7529 Ok(value)
7530 }
7531 }
7532 const VARIANTS: &[&str] = &["success",
7533 "failure",
7534 "other"];
7535 deserializer.deserialize_struct("GetThumbnailBatchResultEntry", VARIANTS, EnumVisitor)
7536 }
7537}
7538
7539impl ::serde::ser::Serialize for GetThumbnailBatchResultEntry {
7540 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7541 use serde::ser::SerializeStruct;
7543 match self {
7544 GetThumbnailBatchResultEntry::Success(x) => {
7545 let mut s = serializer.serialize_struct("GetThumbnailBatchResultEntry", 3)?;
7547 s.serialize_field(".tag", "success")?;
7548 x.internal_serialize::<S>(&mut s)?;
7549 s.end()
7550 }
7551 GetThumbnailBatchResultEntry::Failure(x) => {
7552 let mut s = serializer.serialize_struct("GetThumbnailBatchResultEntry", 2)?;
7554 s.serialize_field(".tag", "failure")?;
7555 s.serialize_field("failure", x)?;
7556 s.end()
7557 }
7558 GetThumbnailBatchResultEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
7559 }
7560 }
7561}
7562
7563#[derive(Debug, Clone, PartialEq)]
7565#[non_exhaustive] pub struct GpsCoordinates {
7567 pub latitude: f64,
7569 pub longitude: f64,
7571}
7572
7573impl GpsCoordinates {
7574 pub fn new(latitude: f64, longitude: f64) -> Self {
7575 GpsCoordinates {
7576 latitude,
7577 longitude,
7578 }
7579 }
7580}
7581
7582const GPS_COORDINATES_FIELDS: &[&str] = &["latitude",
7583 "longitude"];
7584impl GpsCoordinates {
7585 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7586 map: V,
7587 ) -> Result<GpsCoordinates, V::Error> {
7588 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7589 }
7590
7591 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7592 mut map: V,
7593 optional: bool,
7594 ) -> Result<Option<GpsCoordinates>, V::Error> {
7595 let mut field_latitude = None;
7596 let mut field_longitude = None;
7597 let mut nothing = true;
7598 while let Some(key) = map.next_key::<&str>()? {
7599 nothing = false;
7600 match key {
7601 "latitude" => {
7602 if field_latitude.is_some() {
7603 return Err(::serde::de::Error::duplicate_field("latitude"));
7604 }
7605 field_latitude = Some(map.next_value()?);
7606 }
7607 "longitude" => {
7608 if field_longitude.is_some() {
7609 return Err(::serde::de::Error::duplicate_field("longitude"));
7610 }
7611 field_longitude = Some(map.next_value()?);
7612 }
7613 _ => {
7614 map.next_value::<::serde_json::Value>()?;
7616 }
7617 }
7618 }
7619 if optional && nothing {
7620 return Ok(None);
7621 }
7622 let result = GpsCoordinates {
7623 latitude: field_latitude.ok_or_else(|| ::serde::de::Error::missing_field("latitude"))?,
7624 longitude: field_longitude.ok_or_else(|| ::serde::de::Error::missing_field("longitude"))?,
7625 };
7626 Ok(Some(result))
7627 }
7628
7629 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7630 &self,
7631 s: &mut S::SerializeStruct,
7632 ) -> Result<(), S::Error> {
7633 use serde::ser::SerializeStruct;
7634 s.serialize_field("latitude", &self.latitude)?;
7635 s.serialize_field("longitude", &self.longitude)?;
7636 Ok(())
7637 }
7638}
7639
7640impl<'de> ::serde::de::Deserialize<'de> for GpsCoordinates {
7641 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7642 use serde::de::{MapAccess, Visitor};
7644 struct StructVisitor;
7645 impl<'de> Visitor<'de> for StructVisitor {
7646 type Value = GpsCoordinates;
7647 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7648 f.write_str("a GpsCoordinates struct")
7649 }
7650 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7651 GpsCoordinates::internal_deserialize(map)
7652 }
7653 }
7654 deserializer.deserialize_struct("GpsCoordinates", GPS_COORDINATES_FIELDS, StructVisitor)
7655 }
7656}
7657
7658impl ::serde::ser::Serialize for GpsCoordinates {
7659 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7660 use serde::ser::SerializeStruct;
7662 let mut s = serializer.serialize_struct("GpsCoordinates", 2)?;
7663 self.internal_serialize::<S>(&mut s)?;
7664 s.end()
7665 }
7666}
7667
7668#[derive(Debug, Clone, PartialEq, Eq)]
7669#[non_exhaustive] pub struct HighlightSpan {
7671 pub highlight_str: String,
7673 pub is_highlighted: bool,
7675}
7676
7677impl HighlightSpan {
7678 pub fn new(highlight_str: String, is_highlighted: bool) -> Self {
7679 HighlightSpan {
7680 highlight_str,
7681 is_highlighted,
7682 }
7683 }
7684}
7685
7686const HIGHLIGHT_SPAN_FIELDS: &[&str] = &["highlight_str",
7687 "is_highlighted"];
7688impl HighlightSpan {
7689 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7690 map: V,
7691 ) -> Result<HighlightSpan, V::Error> {
7692 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7693 }
7694
7695 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7696 mut map: V,
7697 optional: bool,
7698 ) -> Result<Option<HighlightSpan>, V::Error> {
7699 let mut field_highlight_str = None;
7700 let mut field_is_highlighted = None;
7701 let mut nothing = true;
7702 while let Some(key) = map.next_key::<&str>()? {
7703 nothing = false;
7704 match key {
7705 "highlight_str" => {
7706 if field_highlight_str.is_some() {
7707 return Err(::serde::de::Error::duplicate_field("highlight_str"));
7708 }
7709 field_highlight_str = Some(map.next_value()?);
7710 }
7711 "is_highlighted" => {
7712 if field_is_highlighted.is_some() {
7713 return Err(::serde::de::Error::duplicate_field("is_highlighted"));
7714 }
7715 field_is_highlighted = Some(map.next_value()?);
7716 }
7717 _ => {
7718 map.next_value::<::serde_json::Value>()?;
7720 }
7721 }
7722 }
7723 if optional && nothing {
7724 return Ok(None);
7725 }
7726 let result = HighlightSpan {
7727 highlight_str: field_highlight_str.ok_or_else(|| ::serde::de::Error::missing_field("highlight_str"))?,
7728 is_highlighted: field_is_highlighted.ok_or_else(|| ::serde::de::Error::missing_field("is_highlighted"))?,
7729 };
7730 Ok(Some(result))
7731 }
7732
7733 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7734 &self,
7735 s: &mut S::SerializeStruct,
7736 ) -> Result<(), S::Error> {
7737 use serde::ser::SerializeStruct;
7738 s.serialize_field("highlight_str", &self.highlight_str)?;
7739 s.serialize_field("is_highlighted", &self.is_highlighted)?;
7740 Ok(())
7741 }
7742}
7743
7744impl<'de> ::serde::de::Deserialize<'de> for HighlightSpan {
7745 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7746 use serde::de::{MapAccess, Visitor};
7748 struct StructVisitor;
7749 impl<'de> Visitor<'de> for StructVisitor {
7750 type Value = HighlightSpan;
7751 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7752 f.write_str("a HighlightSpan struct")
7753 }
7754 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7755 HighlightSpan::internal_deserialize(map)
7756 }
7757 }
7758 deserializer.deserialize_struct("HighlightSpan", HIGHLIGHT_SPAN_FIELDS, StructVisitor)
7759 }
7760}
7761
7762impl ::serde::ser::Serialize for HighlightSpan {
7763 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7764 use serde::ser::SerializeStruct;
7766 let mut s = serializer.serialize_struct("HighlightSpan", 2)?;
7767 self.internal_serialize::<S>(&mut s)?;
7768 s.end()
7769 }
7770}
7771
7772#[derive(Debug, Clone, PartialEq, Eq)]
7774#[non_exhaustive] pub enum ImportFormat {
7776 Html,
7778 Markdown,
7780 PlainText,
7782 Other,
7785}
7786
7787impl<'de> ::serde::de::Deserialize<'de> for ImportFormat {
7788 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7789 use serde::de::{self, MapAccess, Visitor};
7791 struct EnumVisitor;
7792 impl<'de> Visitor<'de> for EnumVisitor {
7793 type Value = ImportFormat;
7794 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7795 f.write_str("a ImportFormat structure")
7796 }
7797 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
7798 let tag: &str = match map.next_key()? {
7799 Some(".tag") => map.next_value()?,
7800 _ => return Err(de::Error::missing_field(".tag"))
7801 };
7802 let value = match tag {
7803 "html" => ImportFormat::Html,
7804 "markdown" => ImportFormat::Markdown,
7805 "plain_text" => ImportFormat::PlainText,
7806 _ => ImportFormat::Other,
7807 };
7808 crate::eat_json_fields(&mut map)?;
7809 Ok(value)
7810 }
7811 }
7812 const VARIANTS: &[&str] = &["html",
7813 "markdown",
7814 "plain_text",
7815 "other"];
7816 deserializer.deserialize_struct("ImportFormat", VARIANTS, EnumVisitor)
7817 }
7818}
7819
7820impl ::serde::ser::Serialize for ImportFormat {
7821 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7822 use serde::ser::SerializeStruct;
7824 match self {
7825 ImportFormat::Html => {
7826 let mut s = serializer.serialize_struct("ImportFormat", 1)?;
7828 s.serialize_field(".tag", "html")?;
7829 s.end()
7830 }
7831 ImportFormat::Markdown => {
7832 let mut s = serializer.serialize_struct("ImportFormat", 1)?;
7834 s.serialize_field(".tag", "markdown")?;
7835 s.end()
7836 }
7837 ImportFormat::PlainText => {
7838 let mut s = serializer.serialize_struct("ImportFormat", 1)?;
7840 s.serialize_field(".tag", "plain_text")?;
7841 s.end()
7842 }
7843 ImportFormat::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
7844 }
7845 }
7846}
7847
7848#[derive(Debug, Clone, PartialEq, Eq)]
7849#[non_exhaustive] pub struct ListFolderArg {
7851 pub path: PathROrId,
7853 pub recursive: bool,
7860 pub include_media_info: bool,
7863 pub include_deleted: bool,
7866 pub include_has_explicit_shared_members: bool,
7869 pub include_mounted_folders: bool,
7872 pub limit: Option<u32>,
7875 pub shared_link: Option<SharedLink>,
7879 pub include_property_groups: Option<crate::types::file_properties::TemplateFilterBase>,
7882 pub include_non_downloadable_files: bool,
7884}
7885
7886impl ListFolderArg {
7887 pub fn new(path: PathROrId) -> Self {
7888 ListFolderArg {
7889 path,
7890 recursive: false,
7891 include_media_info: false,
7892 include_deleted: false,
7893 include_has_explicit_shared_members: false,
7894 include_mounted_folders: true,
7895 limit: None,
7896 shared_link: None,
7897 include_property_groups: None,
7898 include_non_downloadable_files: true,
7899 }
7900 }
7901
7902 pub fn with_recursive(mut self, value: bool) -> Self {
7903 self.recursive = value;
7904 self
7905 }
7906
7907 pub fn with_include_media_info(mut self, value: bool) -> Self {
7908 self.include_media_info = value;
7909 self
7910 }
7911
7912 pub fn with_include_deleted(mut self, value: bool) -> Self {
7913 self.include_deleted = value;
7914 self
7915 }
7916
7917 pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
7918 self.include_has_explicit_shared_members = value;
7919 self
7920 }
7921
7922 pub fn with_include_mounted_folders(mut self, value: bool) -> Self {
7923 self.include_mounted_folders = value;
7924 self
7925 }
7926
7927 pub fn with_limit(mut self, value: u32) -> Self {
7928 self.limit = Some(value);
7929 self
7930 }
7931
7932 pub fn with_shared_link(mut self, value: SharedLink) -> Self {
7933 self.shared_link = Some(value);
7934 self
7935 }
7936
7937 pub fn with_include_property_groups(
7938 mut self,
7939 value: crate::types::file_properties::TemplateFilterBase,
7940 ) -> Self {
7941 self.include_property_groups = Some(value);
7942 self
7943 }
7944
7945 pub fn with_include_non_downloadable_files(mut self, value: bool) -> Self {
7946 self.include_non_downloadable_files = value;
7947 self
7948 }
7949}
7950
7951const LIST_FOLDER_ARG_FIELDS: &[&str] = &["path",
7952 "recursive",
7953 "include_media_info",
7954 "include_deleted",
7955 "include_has_explicit_shared_members",
7956 "include_mounted_folders",
7957 "limit",
7958 "shared_link",
7959 "include_property_groups",
7960 "include_non_downloadable_files"];
7961impl ListFolderArg {
7962 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7963 map: V,
7964 ) -> Result<ListFolderArg, V::Error> {
7965 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7966 }
7967
7968 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7969 mut map: V,
7970 optional: bool,
7971 ) -> Result<Option<ListFolderArg>, V::Error> {
7972 let mut field_path = None;
7973 let mut field_recursive = None;
7974 let mut field_include_media_info = None;
7975 let mut field_include_deleted = None;
7976 let mut field_include_has_explicit_shared_members = None;
7977 let mut field_include_mounted_folders = None;
7978 let mut field_limit = None;
7979 let mut field_shared_link = None;
7980 let mut field_include_property_groups = None;
7981 let mut field_include_non_downloadable_files = None;
7982 let mut nothing = true;
7983 while let Some(key) = map.next_key::<&str>()? {
7984 nothing = false;
7985 match key {
7986 "path" => {
7987 if field_path.is_some() {
7988 return Err(::serde::de::Error::duplicate_field("path"));
7989 }
7990 field_path = Some(map.next_value()?);
7991 }
7992 "recursive" => {
7993 if field_recursive.is_some() {
7994 return Err(::serde::de::Error::duplicate_field("recursive"));
7995 }
7996 field_recursive = Some(map.next_value()?);
7997 }
7998 "include_media_info" => {
7999 if field_include_media_info.is_some() {
8000 return Err(::serde::de::Error::duplicate_field("include_media_info"));
8001 }
8002 field_include_media_info = Some(map.next_value()?);
8003 }
8004 "include_deleted" => {
8005 if field_include_deleted.is_some() {
8006 return Err(::serde::de::Error::duplicate_field("include_deleted"));
8007 }
8008 field_include_deleted = Some(map.next_value()?);
8009 }
8010 "include_has_explicit_shared_members" => {
8011 if field_include_has_explicit_shared_members.is_some() {
8012 return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
8013 }
8014 field_include_has_explicit_shared_members = Some(map.next_value()?);
8015 }
8016 "include_mounted_folders" => {
8017 if field_include_mounted_folders.is_some() {
8018 return Err(::serde::de::Error::duplicate_field("include_mounted_folders"));
8019 }
8020 field_include_mounted_folders = Some(map.next_value()?);
8021 }
8022 "limit" => {
8023 if field_limit.is_some() {
8024 return Err(::serde::de::Error::duplicate_field("limit"));
8025 }
8026 field_limit = Some(map.next_value()?);
8027 }
8028 "shared_link" => {
8029 if field_shared_link.is_some() {
8030 return Err(::serde::de::Error::duplicate_field("shared_link"));
8031 }
8032 field_shared_link = Some(map.next_value()?);
8033 }
8034 "include_property_groups" => {
8035 if field_include_property_groups.is_some() {
8036 return Err(::serde::de::Error::duplicate_field("include_property_groups"));
8037 }
8038 field_include_property_groups = Some(map.next_value()?);
8039 }
8040 "include_non_downloadable_files" => {
8041 if field_include_non_downloadable_files.is_some() {
8042 return Err(::serde::de::Error::duplicate_field("include_non_downloadable_files"));
8043 }
8044 field_include_non_downloadable_files = Some(map.next_value()?);
8045 }
8046 _ => {
8047 map.next_value::<::serde_json::Value>()?;
8049 }
8050 }
8051 }
8052 if optional && nothing {
8053 return Ok(None);
8054 }
8055 let result = ListFolderArg {
8056 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
8057 recursive: field_recursive.unwrap_or(false),
8058 include_media_info: field_include_media_info.unwrap_or(false),
8059 include_deleted: field_include_deleted.unwrap_or(false),
8060 include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
8061 include_mounted_folders: field_include_mounted_folders.unwrap_or(true),
8062 limit: field_limit.and_then(Option::flatten),
8063 shared_link: field_shared_link.and_then(Option::flatten),
8064 include_property_groups: field_include_property_groups.and_then(Option::flatten),
8065 include_non_downloadable_files: field_include_non_downloadable_files.unwrap_or(true),
8066 };
8067 Ok(Some(result))
8068 }
8069
8070 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8071 &self,
8072 s: &mut S::SerializeStruct,
8073 ) -> Result<(), S::Error> {
8074 use serde::ser::SerializeStruct;
8075 s.serialize_field("path", &self.path)?;
8076 if self.recursive {
8077 s.serialize_field("recursive", &self.recursive)?;
8078 }
8079 if self.include_media_info {
8080 s.serialize_field("include_media_info", &self.include_media_info)?;
8081 }
8082 if self.include_deleted {
8083 s.serialize_field("include_deleted", &self.include_deleted)?;
8084 }
8085 if self.include_has_explicit_shared_members {
8086 s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
8087 }
8088 if !self.include_mounted_folders {
8089 s.serialize_field("include_mounted_folders", &self.include_mounted_folders)?;
8090 }
8091 if let Some(val) = &self.limit {
8092 s.serialize_field("limit", val)?;
8093 }
8094 if let Some(val) = &self.shared_link {
8095 s.serialize_field("shared_link", val)?;
8096 }
8097 if let Some(val) = &self.include_property_groups {
8098 s.serialize_field("include_property_groups", val)?;
8099 }
8100 if !self.include_non_downloadable_files {
8101 s.serialize_field("include_non_downloadable_files", &self.include_non_downloadable_files)?;
8102 }
8103 Ok(())
8104 }
8105}
8106
8107impl<'de> ::serde::de::Deserialize<'de> for ListFolderArg {
8108 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8109 use serde::de::{MapAccess, Visitor};
8111 struct StructVisitor;
8112 impl<'de> Visitor<'de> for StructVisitor {
8113 type Value = ListFolderArg;
8114 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8115 f.write_str("a ListFolderArg struct")
8116 }
8117 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8118 ListFolderArg::internal_deserialize(map)
8119 }
8120 }
8121 deserializer.deserialize_struct("ListFolderArg", LIST_FOLDER_ARG_FIELDS, StructVisitor)
8122 }
8123}
8124
8125impl ::serde::ser::Serialize for ListFolderArg {
8126 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8127 use serde::ser::SerializeStruct;
8129 let mut s = serializer.serialize_struct("ListFolderArg", 10)?;
8130 self.internal_serialize::<S>(&mut s)?;
8131 s.end()
8132 }
8133}
8134
8135#[derive(Debug, Clone, PartialEq, Eq)]
8136#[non_exhaustive] pub struct ListFolderContinueArg {
8138 pub cursor: ListFolderCursor,
8141}
8142
8143impl ListFolderContinueArg {
8144 pub fn new(cursor: ListFolderCursor) -> Self {
8145 ListFolderContinueArg {
8146 cursor,
8147 }
8148 }
8149}
8150
8151const LIST_FOLDER_CONTINUE_ARG_FIELDS: &[&str] = &["cursor"];
8152impl ListFolderContinueArg {
8153 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8154 map: V,
8155 ) -> Result<ListFolderContinueArg, V::Error> {
8156 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8157 }
8158
8159 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8160 mut map: V,
8161 optional: bool,
8162 ) -> Result<Option<ListFolderContinueArg>, V::Error> {
8163 let mut field_cursor = None;
8164 let mut nothing = true;
8165 while let Some(key) = map.next_key::<&str>()? {
8166 nothing = false;
8167 match key {
8168 "cursor" => {
8169 if field_cursor.is_some() {
8170 return Err(::serde::de::Error::duplicate_field("cursor"));
8171 }
8172 field_cursor = Some(map.next_value()?);
8173 }
8174 _ => {
8175 map.next_value::<::serde_json::Value>()?;
8177 }
8178 }
8179 }
8180 if optional && nothing {
8181 return Ok(None);
8182 }
8183 let result = ListFolderContinueArg {
8184 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8185 };
8186 Ok(Some(result))
8187 }
8188
8189 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8190 &self,
8191 s: &mut S::SerializeStruct,
8192 ) -> Result<(), S::Error> {
8193 use serde::ser::SerializeStruct;
8194 s.serialize_field("cursor", &self.cursor)?;
8195 Ok(())
8196 }
8197}
8198
8199impl<'de> ::serde::de::Deserialize<'de> for ListFolderContinueArg {
8200 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8201 use serde::de::{MapAccess, Visitor};
8203 struct StructVisitor;
8204 impl<'de> Visitor<'de> for StructVisitor {
8205 type Value = ListFolderContinueArg;
8206 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8207 f.write_str("a ListFolderContinueArg struct")
8208 }
8209 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8210 ListFolderContinueArg::internal_deserialize(map)
8211 }
8212 }
8213 deserializer.deserialize_struct("ListFolderContinueArg", LIST_FOLDER_CONTINUE_ARG_FIELDS, StructVisitor)
8214 }
8215}
8216
8217impl ::serde::ser::Serialize for ListFolderContinueArg {
8218 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8219 use serde::ser::SerializeStruct;
8221 let mut s = serializer.serialize_struct("ListFolderContinueArg", 1)?;
8222 self.internal_serialize::<S>(&mut s)?;
8223 s.end()
8224 }
8225}
8226
8227#[derive(Debug, Clone, PartialEq, Eq)]
8228#[non_exhaustive] pub enum ListFolderContinueError {
8230 Path(LookupError),
8231 Reset,
8234 Other,
8237}
8238
8239impl<'de> ::serde::de::Deserialize<'de> for ListFolderContinueError {
8240 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8241 use serde::de::{self, MapAccess, Visitor};
8243 struct EnumVisitor;
8244 impl<'de> Visitor<'de> for EnumVisitor {
8245 type Value = ListFolderContinueError;
8246 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8247 f.write_str("a ListFolderContinueError structure")
8248 }
8249 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
8250 let tag: &str = match map.next_key()? {
8251 Some(".tag") => map.next_value()?,
8252 _ => return Err(de::Error::missing_field(".tag"))
8253 };
8254 let value = match tag {
8255 "path" => {
8256 match map.next_key()? {
8257 Some("path") => ListFolderContinueError::Path(map.next_value()?),
8258 None => return Err(de::Error::missing_field("path")),
8259 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
8260 }
8261 }
8262 "reset" => ListFolderContinueError::Reset,
8263 _ => ListFolderContinueError::Other,
8264 };
8265 crate::eat_json_fields(&mut map)?;
8266 Ok(value)
8267 }
8268 }
8269 const VARIANTS: &[&str] = &["path",
8270 "reset",
8271 "other"];
8272 deserializer.deserialize_struct("ListFolderContinueError", VARIANTS, EnumVisitor)
8273 }
8274}
8275
8276impl ::serde::ser::Serialize for ListFolderContinueError {
8277 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8278 use serde::ser::SerializeStruct;
8280 match self {
8281 ListFolderContinueError::Path(x) => {
8282 let mut s = serializer.serialize_struct("ListFolderContinueError", 2)?;
8284 s.serialize_field(".tag", "path")?;
8285 s.serialize_field("path", x)?;
8286 s.end()
8287 }
8288 ListFolderContinueError::Reset => {
8289 let mut s = serializer.serialize_struct("ListFolderContinueError", 1)?;
8291 s.serialize_field(".tag", "reset")?;
8292 s.end()
8293 }
8294 ListFolderContinueError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
8295 }
8296 }
8297}
8298
8299impl ::std::error::Error for ListFolderContinueError {
8300 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
8301 match self {
8302 ListFolderContinueError::Path(inner) => Some(inner),
8303 _ => None,
8304 }
8305 }
8306}
8307
8308impl ::std::fmt::Display for ListFolderContinueError {
8309 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8310 match self {
8311 ListFolderContinueError::Path(inner) => write!(f, "ListFolderContinueError: {}", inner),
8312 _ => write!(f, "{:?}", *self),
8313 }
8314 }
8315}
8316
8317#[derive(Debug, Clone, PartialEq, Eq)]
8318#[non_exhaustive] pub enum ListFolderError {
8320 Path(LookupError),
8321 TemplateError(crate::types::file_properties::TemplateError),
8322 Other,
8325}
8326
8327impl<'de> ::serde::de::Deserialize<'de> for ListFolderError {
8328 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8329 use serde::de::{self, MapAccess, Visitor};
8331 struct EnumVisitor;
8332 impl<'de> Visitor<'de> for EnumVisitor {
8333 type Value = ListFolderError;
8334 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8335 f.write_str("a ListFolderError structure")
8336 }
8337 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
8338 let tag: &str = match map.next_key()? {
8339 Some(".tag") => map.next_value()?,
8340 _ => return Err(de::Error::missing_field(".tag"))
8341 };
8342 let value = match tag {
8343 "path" => {
8344 match map.next_key()? {
8345 Some("path") => ListFolderError::Path(map.next_value()?),
8346 None => return Err(de::Error::missing_field("path")),
8347 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
8348 }
8349 }
8350 "template_error" => {
8351 match map.next_key()? {
8352 Some("template_error") => ListFolderError::TemplateError(map.next_value()?),
8353 None => return Err(de::Error::missing_field("template_error")),
8354 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
8355 }
8356 }
8357 _ => ListFolderError::Other,
8358 };
8359 crate::eat_json_fields(&mut map)?;
8360 Ok(value)
8361 }
8362 }
8363 const VARIANTS: &[&str] = &["path",
8364 "template_error",
8365 "other"];
8366 deserializer.deserialize_struct("ListFolderError", VARIANTS, EnumVisitor)
8367 }
8368}
8369
8370impl ::serde::ser::Serialize for ListFolderError {
8371 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8372 use serde::ser::SerializeStruct;
8374 match self {
8375 ListFolderError::Path(x) => {
8376 let mut s = serializer.serialize_struct("ListFolderError", 2)?;
8378 s.serialize_field(".tag", "path")?;
8379 s.serialize_field("path", x)?;
8380 s.end()
8381 }
8382 ListFolderError::TemplateError(x) => {
8383 let mut s = serializer.serialize_struct("ListFolderError", 2)?;
8385 s.serialize_field(".tag", "template_error")?;
8386 s.serialize_field("template_error", x)?;
8387 s.end()
8388 }
8389 ListFolderError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
8390 }
8391 }
8392}
8393
8394impl ::std::error::Error for ListFolderError {
8395 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
8396 match self {
8397 ListFolderError::Path(inner) => Some(inner),
8398 ListFolderError::TemplateError(inner) => Some(inner),
8399 _ => None,
8400 }
8401 }
8402}
8403
8404impl ::std::fmt::Display for ListFolderError {
8405 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8406 match self {
8407 ListFolderError::Path(inner) => write!(f, "ListFolderError: {}", inner),
8408 ListFolderError::TemplateError(inner) => write!(f, "ListFolderError: {}", inner),
8409 _ => write!(f, "{:?}", *self),
8410 }
8411 }
8412}
8413
8414#[derive(Debug, Clone, PartialEq, Eq)]
8415#[non_exhaustive] pub struct ListFolderGetLatestCursorResult {
8417 pub cursor: ListFolderCursor,
8420}
8421
8422impl ListFolderGetLatestCursorResult {
8423 pub fn new(cursor: ListFolderCursor) -> Self {
8424 ListFolderGetLatestCursorResult {
8425 cursor,
8426 }
8427 }
8428}
8429
8430const LIST_FOLDER_GET_LATEST_CURSOR_RESULT_FIELDS: &[&str] = &["cursor"];
8431impl ListFolderGetLatestCursorResult {
8432 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8433 map: V,
8434 ) -> Result<ListFolderGetLatestCursorResult, V::Error> {
8435 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8436 }
8437
8438 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8439 mut map: V,
8440 optional: bool,
8441 ) -> Result<Option<ListFolderGetLatestCursorResult>, V::Error> {
8442 let mut field_cursor = None;
8443 let mut nothing = true;
8444 while let Some(key) = map.next_key::<&str>()? {
8445 nothing = false;
8446 match key {
8447 "cursor" => {
8448 if field_cursor.is_some() {
8449 return Err(::serde::de::Error::duplicate_field("cursor"));
8450 }
8451 field_cursor = Some(map.next_value()?);
8452 }
8453 _ => {
8454 map.next_value::<::serde_json::Value>()?;
8456 }
8457 }
8458 }
8459 if optional && nothing {
8460 return Ok(None);
8461 }
8462 let result = ListFolderGetLatestCursorResult {
8463 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8464 };
8465 Ok(Some(result))
8466 }
8467
8468 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8469 &self,
8470 s: &mut S::SerializeStruct,
8471 ) -> Result<(), S::Error> {
8472 use serde::ser::SerializeStruct;
8473 s.serialize_field("cursor", &self.cursor)?;
8474 Ok(())
8475 }
8476}
8477
8478impl<'de> ::serde::de::Deserialize<'de> for ListFolderGetLatestCursorResult {
8479 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8480 use serde::de::{MapAccess, Visitor};
8482 struct StructVisitor;
8483 impl<'de> Visitor<'de> for StructVisitor {
8484 type Value = ListFolderGetLatestCursorResult;
8485 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8486 f.write_str("a ListFolderGetLatestCursorResult struct")
8487 }
8488 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8489 ListFolderGetLatestCursorResult::internal_deserialize(map)
8490 }
8491 }
8492 deserializer.deserialize_struct("ListFolderGetLatestCursorResult", LIST_FOLDER_GET_LATEST_CURSOR_RESULT_FIELDS, StructVisitor)
8493 }
8494}
8495
8496impl ::serde::ser::Serialize for ListFolderGetLatestCursorResult {
8497 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8498 use serde::ser::SerializeStruct;
8500 let mut s = serializer.serialize_struct("ListFolderGetLatestCursorResult", 1)?;
8501 self.internal_serialize::<S>(&mut s)?;
8502 s.end()
8503 }
8504}
8505
8506#[derive(Debug, Clone, PartialEq, Eq)]
8507#[non_exhaustive] pub struct ListFolderLongpollArg {
8509 pub cursor: ListFolderCursor,
8513 pub timeout: u64,
8517}
8518
8519impl ListFolderLongpollArg {
8520 pub fn new(cursor: ListFolderCursor) -> Self {
8521 ListFolderLongpollArg {
8522 cursor,
8523 timeout: 30,
8524 }
8525 }
8526
8527 pub fn with_timeout(mut self, value: u64) -> Self {
8528 self.timeout = value;
8529 self
8530 }
8531}
8532
8533const LIST_FOLDER_LONGPOLL_ARG_FIELDS: &[&str] = &["cursor",
8534 "timeout"];
8535impl ListFolderLongpollArg {
8536 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8537 map: V,
8538 ) -> Result<ListFolderLongpollArg, V::Error> {
8539 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8540 }
8541
8542 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8543 mut map: V,
8544 optional: bool,
8545 ) -> Result<Option<ListFolderLongpollArg>, V::Error> {
8546 let mut field_cursor = None;
8547 let mut field_timeout = None;
8548 let mut nothing = true;
8549 while let Some(key) = map.next_key::<&str>()? {
8550 nothing = false;
8551 match key {
8552 "cursor" => {
8553 if field_cursor.is_some() {
8554 return Err(::serde::de::Error::duplicate_field("cursor"));
8555 }
8556 field_cursor = Some(map.next_value()?);
8557 }
8558 "timeout" => {
8559 if field_timeout.is_some() {
8560 return Err(::serde::de::Error::duplicate_field("timeout"));
8561 }
8562 field_timeout = Some(map.next_value()?);
8563 }
8564 _ => {
8565 map.next_value::<::serde_json::Value>()?;
8567 }
8568 }
8569 }
8570 if optional && nothing {
8571 return Ok(None);
8572 }
8573 let result = ListFolderLongpollArg {
8574 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8575 timeout: field_timeout.unwrap_or(30),
8576 };
8577 Ok(Some(result))
8578 }
8579
8580 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8581 &self,
8582 s: &mut S::SerializeStruct,
8583 ) -> Result<(), S::Error> {
8584 use serde::ser::SerializeStruct;
8585 s.serialize_field("cursor", &self.cursor)?;
8586 if self.timeout != 30 {
8587 s.serialize_field("timeout", &self.timeout)?;
8588 }
8589 Ok(())
8590 }
8591}
8592
8593impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollArg {
8594 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8595 use serde::de::{MapAccess, Visitor};
8597 struct StructVisitor;
8598 impl<'de> Visitor<'de> for StructVisitor {
8599 type Value = ListFolderLongpollArg;
8600 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8601 f.write_str("a ListFolderLongpollArg struct")
8602 }
8603 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8604 ListFolderLongpollArg::internal_deserialize(map)
8605 }
8606 }
8607 deserializer.deserialize_struct("ListFolderLongpollArg", LIST_FOLDER_LONGPOLL_ARG_FIELDS, StructVisitor)
8608 }
8609}
8610
8611impl ::serde::ser::Serialize for ListFolderLongpollArg {
8612 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8613 use serde::ser::SerializeStruct;
8615 let mut s = serializer.serialize_struct("ListFolderLongpollArg", 2)?;
8616 self.internal_serialize::<S>(&mut s)?;
8617 s.end()
8618 }
8619}
8620
8621#[derive(Debug, Clone, PartialEq, Eq)]
8622#[non_exhaustive] pub enum ListFolderLongpollError {
8624 Reset,
8627 Other,
8630}
8631
8632impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollError {
8633 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8634 use serde::de::{self, MapAccess, Visitor};
8636 struct EnumVisitor;
8637 impl<'de> Visitor<'de> for EnumVisitor {
8638 type Value = ListFolderLongpollError;
8639 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8640 f.write_str("a ListFolderLongpollError structure")
8641 }
8642 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
8643 let tag: &str = match map.next_key()? {
8644 Some(".tag") => map.next_value()?,
8645 _ => return Err(de::Error::missing_field(".tag"))
8646 };
8647 let value = match tag {
8648 "reset" => ListFolderLongpollError::Reset,
8649 _ => ListFolderLongpollError::Other,
8650 };
8651 crate::eat_json_fields(&mut map)?;
8652 Ok(value)
8653 }
8654 }
8655 const VARIANTS: &[&str] = &["reset",
8656 "other"];
8657 deserializer.deserialize_struct("ListFolderLongpollError", VARIANTS, EnumVisitor)
8658 }
8659}
8660
8661impl ::serde::ser::Serialize for ListFolderLongpollError {
8662 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8663 use serde::ser::SerializeStruct;
8665 match self {
8666 ListFolderLongpollError::Reset => {
8667 let mut s = serializer.serialize_struct("ListFolderLongpollError", 1)?;
8669 s.serialize_field(".tag", "reset")?;
8670 s.end()
8671 }
8672 ListFolderLongpollError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
8673 }
8674 }
8675}
8676
8677impl ::std::error::Error for ListFolderLongpollError {
8678}
8679
8680impl ::std::fmt::Display for ListFolderLongpollError {
8681 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8682 write!(f, "{:?}", *self)
8683 }
8684}
8685
8686#[derive(Debug, Clone, PartialEq, Eq)]
8687#[non_exhaustive] pub struct ListFolderLongpollResult {
8689 pub changes: bool,
8692 pub backoff: Option<u64>,
8695}
8696
8697impl ListFolderLongpollResult {
8698 pub fn new(changes: bool) -> Self {
8699 ListFolderLongpollResult {
8700 changes,
8701 backoff: None,
8702 }
8703 }
8704
8705 pub fn with_backoff(mut self, value: u64) -> Self {
8706 self.backoff = Some(value);
8707 self
8708 }
8709}
8710
8711const LIST_FOLDER_LONGPOLL_RESULT_FIELDS: &[&str] = &["changes",
8712 "backoff"];
8713impl ListFolderLongpollResult {
8714 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8715 map: V,
8716 ) -> Result<ListFolderLongpollResult, V::Error> {
8717 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8718 }
8719
8720 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8721 mut map: V,
8722 optional: bool,
8723 ) -> Result<Option<ListFolderLongpollResult>, V::Error> {
8724 let mut field_changes = None;
8725 let mut field_backoff = None;
8726 let mut nothing = true;
8727 while let Some(key) = map.next_key::<&str>()? {
8728 nothing = false;
8729 match key {
8730 "changes" => {
8731 if field_changes.is_some() {
8732 return Err(::serde::de::Error::duplicate_field("changes"));
8733 }
8734 field_changes = Some(map.next_value()?);
8735 }
8736 "backoff" => {
8737 if field_backoff.is_some() {
8738 return Err(::serde::de::Error::duplicate_field("backoff"));
8739 }
8740 field_backoff = Some(map.next_value()?);
8741 }
8742 _ => {
8743 map.next_value::<::serde_json::Value>()?;
8745 }
8746 }
8747 }
8748 if optional && nothing {
8749 return Ok(None);
8750 }
8751 let result = ListFolderLongpollResult {
8752 changes: field_changes.ok_or_else(|| ::serde::de::Error::missing_field("changes"))?,
8753 backoff: field_backoff.and_then(Option::flatten),
8754 };
8755 Ok(Some(result))
8756 }
8757
8758 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8759 &self,
8760 s: &mut S::SerializeStruct,
8761 ) -> Result<(), S::Error> {
8762 use serde::ser::SerializeStruct;
8763 s.serialize_field("changes", &self.changes)?;
8764 if let Some(val) = &self.backoff {
8765 s.serialize_field("backoff", val)?;
8766 }
8767 Ok(())
8768 }
8769}
8770
8771impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollResult {
8772 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8773 use serde::de::{MapAccess, Visitor};
8775 struct StructVisitor;
8776 impl<'de> Visitor<'de> for StructVisitor {
8777 type Value = ListFolderLongpollResult;
8778 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8779 f.write_str("a ListFolderLongpollResult struct")
8780 }
8781 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8782 ListFolderLongpollResult::internal_deserialize(map)
8783 }
8784 }
8785 deserializer.deserialize_struct("ListFolderLongpollResult", LIST_FOLDER_LONGPOLL_RESULT_FIELDS, StructVisitor)
8786 }
8787}
8788
8789impl ::serde::ser::Serialize for ListFolderLongpollResult {
8790 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8791 use serde::ser::SerializeStruct;
8793 let mut s = serializer.serialize_struct("ListFolderLongpollResult", 2)?;
8794 self.internal_serialize::<S>(&mut s)?;
8795 s.end()
8796 }
8797}
8798
8799#[derive(Debug, Clone, PartialEq)]
8800#[non_exhaustive] pub struct ListFolderResult {
8802 pub entries: Vec<Metadata>,
8804 pub cursor: ListFolderCursor,
8807 pub has_more: bool,
8810}
8811
8812impl ListFolderResult {
8813 pub fn new(entries: Vec<Metadata>, cursor: ListFolderCursor, has_more: bool) -> Self {
8814 ListFolderResult {
8815 entries,
8816 cursor,
8817 has_more,
8818 }
8819 }
8820}
8821
8822const LIST_FOLDER_RESULT_FIELDS: &[&str] = &["entries",
8823 "cursor",
8824 "has_more"];
8825impl ListFolderResult {
8826 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8827 map: V,
8828 ) -> Result<ListFolderResult, V::Error> {
8829 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8830 }
8831
8832 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8833 mut map: V,
8834 optional: bool,
8835 ) -> Result<Option<ListFolderResult>, V::Error> {
8836 let mut field_entries = None;
8837 let mut field_cursor = None;
8838 let mut field_has_more = None;
8839 let mut nothing = true;
8840 while let Some(key) = map.next_key::<&str>()? {
8841 nothing = false;
8842 match key {
8843 "entries" => {
8844 if field_entries.is_some() {
8845 return Err(::serde::de::Error::duplicate_field("entries"));
8846 }
8847 field_entries = Some(map.next_value()?);
8848 }
8849 "cursor" => {
8850 if field_cursor.is_some() {
8851 return Err(::serde::de::Error::duplicate_field("cursor"));
8852 }
8853 field_cursor = Some(map.next_value()?);
8854 }
8855 "has_more" => {
8856 if field_has_more.is_some() {
8857 return Err(::serde::de::Error::duplicate_field("has_more"));
8858 }
8859 field_has_more = Some(map.next_value()?);
8860 }
8861 _ => {
8862 map.next_value::<::serde_json::Value>()?;
8864 }
8865 }
8866 }
8867 if optional && nothing {
8868 return Ok(None);
8869 }
8870 let result = ListFolderResult {
8871 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
8872 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8873 has_more: field_has_more.ok_or_else(|| ::serde::de::Error::missing_field("has_more"))?,
8874 };
8875 Ok(Some(result))
8876 }
8877
8878 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8879 &self,
8880 s: &mut S::SerializeStruct,
8881 ) -> Result<(), S::Error> {
8882 use serde::ser::SerializeStruct;
8883 s.serialize_field("entries", &self.entries)?;
8884 s.serialize_field("cursor", &self.cursor)?;
8885 s.serialize_field("has_more", &self.has_more)?;
8886 Ok(())
8887 }
8888}
8889
8890impl<'de> ::serde::de::Deserialize<'de> for ListFolderResult {
8891 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8892 use serde::de::{MapAccess, Visitor};
8894 struct StructVisitor;
8895 impl<'de> Visitor<'de> for StructVisitor {
8896 type Value = ListFolderResult;
8897 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8898 f.write_str("a ListFolderResult struct")
8899 }
8900 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8901 ListFolderResult::internal_deserialize(map)
8902 }
8903 }
8904 deserializer.deserialize_struct("ListFolderResult", LIST_FOLDER_RESULT_FIELDS, StructVisitor)
8905 }
8906}
8907
8908impl ::serde::ser::Serialize for ListFolderResult {
8909 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8910 use serde::ser::SerializeStruct;
8912 let mut s = serializer.serialize_struct("ListFolderResult", 3)?;
8913 self.internal_serialize::<S>(&mut s)?;
8914 s.end()
8915 }
8916}
8917
8918#[derive(Debug, Clone, PartialEq, Eq)]
8919#[non_exhaustive] pub struct ListRevisionsArg {
8921 pub path: PathOrId,
8923 pub mode: ListRevisionsMode,
8925 pub limit: u64,
8927 pub before_rev: Option<Rev>,
8931}
8932
8933impl ListRevisionsArg {
8934 pub fn new(path: PathOrId) -> Self {
8935 ListRevisionsArg {
8936 path,
8937 mode: ListRevisionsMode::Path,
8938 limit: 10,
8939 before_rev: None,
8940 }
8941 }
8942
8943 pub fn with_mode(mut self, value: ListRevisionsMode) -> Self {
8944 self.mode = value;
8945 self
8946 }
8947
8948 pub fn with_limit(mut self, value: u64) -> Self {
8949 self.limit = value;
8950 self
8951 }
8952
8953 pub fn with_before_rev(mut self, value: Rev) -> Self {
8954 self.before_rev = Some(value);
8955 self
8956 }
8957}
8958
8959const LIST_REVISIONS_ARG_FIELDS: &[&str] = &["path",
8960 "mode",
8961 "limit",
8962 "before_rev"];
8963impl ListRevisionsArg {
8964 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8965 map: V,
8966 ) -> Result<ListRevisionsArg, V::Error> {
8967 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8968 }
8969
8970 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8971 mut map: V,
8972 optional: bool,
8973 ) -> Result<Option<ListRevisionsArg>, V::Error> {
8974 let mut field_path = None;
8975 let mut field_mode = None;
8976 let mut field_limit = None;
8977 let mut field_before_rev = None;
8978 let mut nothing = true;
8979 while let Some(key) = map.next_key::<&str>()? {
8980 nothing = false;
8981 match key {
8982 "path" => {
8983 if field_path.is_some() {
8984 return Err(::serde::de::Error::duplicate_field("path"));
8985 }
8986 field_path = Some(map.next_value()?);
8987 }
8988 "mode" => {
8989 if field_mode.is_some() {
8990 return Err(::serde::de::Error::duplicate_field("mode"));
8991 }
8992 field_mode = Some(map.next_value()?);
8993 }
8994 "limit" => {
8995 if field_limit.is_some() {
8996 return Err(::serde::de::Error::duplicate_field("limit"));
8997 }
8998 field_limit = Some(map.next_value()?);
8999 }
9000 "before_rev" => {
9001 if field_before_rev.is_some() {
9002 return Err(::serde::de::Error::duplicate_field("before_rev"));
9003 }
9004 field_before_rev = Some(map.next_value()?);
9005 }
9006 _ => {
9007 map.next_value::<::serde_json::Value>()?;
9009 }
9010 }
9011 }
9012 if optional && nothing {
9013 return Ok(None);
9014 }
9015 let result = ListRevisionsArg {
9016 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
9017 mode: field_mode.unwrap_or(ListRevisionsMode::Path),
9018 limit: field_limit.unwrap_or(10),
9019 before_rev: field_before_rev.and_then(Option::flatten),
9020 };
9021 Ok(Some(result))
9022 }
9023
9024 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9025 &self,
9026 s: &mut S::SerializeStruct,
9027 ) -> Result<(), S::Error> {
9028 use serde::ser::SerializeStruct;
9029 s.serialize_field("path", &self.path)?;
9030 if self.mode != ListRevisionsMode::Path {
9031 s.serialize_field("mode", &self.mode)?;
9032 }
9033 if self.limit != 10 {
9034 s.serialize_field("limit", &self.limit)?;
9035 }
9036 if let Some(val) = &self.before_rev {
9037 s.serialize_field("before_rev", val)?;
9038 }
9039 Ok(())
9040 }
9041}
9042
9043impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsArg {
9044 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9045 use serde::de::{MapAccess, Visitor};
9047 struct StructVisitor;
9048 impl<'de> Visitor<'de> for StructVisitor {
9049 type Value = ListRevisionsArg;
9050 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9051 f.write_str("a ListRevisionsArg struct")
9052 }
9053 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9054 ListRevisionsArg::internal_deserialize(map)
9055 }
9056 }
9057 deserializer.deserialize_struct("ListRevisionsArg", LIST_REVISIONS_ARG_FIELDS, StructVisitor)
9058 }
9059}
9060
9061impl ::serde::ser::Serialize for ListRevisionsArg {
9062 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9063 use serde::ser::SerializeStruct;
9065 let mut s = serializer.serialize_struct("ListRevisionsArg", 4)?;
9066 self.internal_serialize::<S>(&mut s)?;
9067 s.end()
9068 }
9069}
9070
9071#[derive(Debug, Clone, PartialEq, Eq)]
9072#[non_exhaustive] pub enum ListRevisionsError {
9074 Path(LookupError),
9075 InvalidBeforeRev,
9077 BeforeRevNotSupported,
9079 Other,
9082}
9083
9084impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsError {
9085 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9086 use serde::de::{self, MapAccess, Visitor};
9088 struct EnumVisitor;
9089 impl<'de> Visitor<'de> for EnumVisitor {
9090 type Value = ListRevisionsError;
9091 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9092 f.write_str("a ListRevisionsError structure")
9093 }
9094 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
9095 let tag: &str = match map.next_key()? {
9096 Some(".tag") => map.next_value()?,
9097 _ => return Err(de::Error::missing_field(".tag"))
9098 };
9099 let value = match tag {
9100 "path" => {
9101 match map.next_key()? {
9102 Some("path") => ListRevisionsError::Path(map.next_value()?),
9103 None => return Err(de::Error::missing_field("path")),
9104 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
9105 }
9106 }
9107 "invalid_before_rev" => ListRevisionsError::InvalidBeforeRev,
9108 "before_rev_not_supported" => ListRevisionsError::BeforeRevNotSupported,
9109 _ => ListRevisionsError::Other,
9110 };
9111 crate::eat_json_fields(&mut map)?;
9112 Ok(value)
9113 }
9114 }
9115 const VARIANTS: &[&str] = &["path",
9116 "invalid_before_rev",
9117 "before_rev_not_supported",
9118 "other"];
9119 deserializer.deserialize_struct("ListRevisionsError", VARIANTS, EnumVisitor)
9120 }
9121}
9122
9123impl ::serde::ser::Serialize for ListRevisionsError {
9124 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9125 use serde::ser::SerializeStruct;
9127 match self {
9128 ListRevisionsError::Path(x) => {
9129 let mut s = serializer.serialize_struct("ListRevisionsError", 2)?;
9131 s.serialize_field(".tag", "path")?;
9132 s.serialize_field("path", x)?;
9133 s.end()
9134 }
9135 ListRevisionsError::InvalidBeforeRev => {
9136 let mut s = serializer.serialize_struct("ListRevisionsError", 1)?;
9138 s.serialize_field(".tag", "invalid_before_rev")?;
9139 s.end()
9140 }
9141 ListRevisionsError::BeforeRevNotSupported => {
9142 let mut s = serializer.serialize_struct("ListRevisionsError", 1)?;
9144 s.serialize_field(".tag", "before_rev_not_supported")?;
9145 s.end()
9146 }
9147 ListRevisionsError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
9148 }
9149 }
9150}
9151
9152impl ::std::error::Error for ListRevisionsError {
9153 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
9154 match self {
9155 ListRevisionsError::Path(inner) => Some(inner),
9156 _ => None,
9157 }
9158 }
9159}
9160
9161impl ::std::fmt::Display for ListRevisionsError {
9162 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9163 match self {
9164 ListRevisionsError::Path(inner) => write!(f, "ListRevisionsError: {}", inner),
9165 ListRevisionsError::InvalidBeforeRev => f.write_str("The revision in before_rev is invalid."),
9166 ListRevisionsError::BeforeRevNotSupported => f.write_str("The before_rev argument is only supported in path mode."),
9167 _ => write!(f, "{:?}", *self),
9168 }
9169 }
9170}
9171
9172#[derive(Debug, Clone, PartialEq, Eq)]
9173#[non_exhaustive] pub enum ListRevisionsMode {
9175 Path,
9178 Id,
9181 Other,
9184}
9185
9186impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsMode {
9187 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9188 use serde::de::{self, MapAccess, Visitor};
9190 struct EnumVisitor;
9191 impl<'de> Visitor<'de> for EnumVisitor {
9192 type Value = ListRevisionsMode;
9193 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9194 f.write_str("a ListRevisionsMode structure")
9195 }
9196 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
9197 let tag: &str = match map.next_key()? {
9198 Some(".tag") => map.next_value()?,
9199 _ => return Err(de::Error::missing_field(".tag"))
9200 };
9201 let value = match tag {
9202 "path" => ListRevisionsMode::Path,
9203 "id" => ListRevisionsMode::Id,
9204 _ => ListRevisionsMode::Other,
9205 };
9206 crate::eat_json_fields(&mut map)?;
9207 Ok(value)
9208 }
9209 }
9210 const VARIANTS: &[&str] = &["path",
9211 "id",
9212 "other"];
9213 deserializer.deserialize_struct("ListRevisionsMode", VARIANTS, EnumVisitor)
9214 }
9215}
9216
9217impl ::serde::ser::Serialize for ListRevisionsMode {
9218 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9219 use serde::ser::SerializeStruct;
9221 match self {
9222 ListRevisionsMode::Path => {
9223 let mut s = serializer.serialize_struct("ListRevisionsMode", 1)?;
9225 s.serialize_field(".tag", "path")?;
9226 s.end()
9227 }
9228 ListRevisionsMode::Id => {
9229 let mut s = serializer.serialize_struct("ListRevisionsMode", 1)?;
9231 s.serialize_field(".tag", "id")?;
9232 s.end()
9233 }
9234 ListRevisionsMode::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
9235 }
9236 }
9237}
9238
9239#[derive(Debug, Clone, PartialEq)]
9240#[non_exhaustive] pub struct ListRevisionsResult {
9242 pub is_deleted: bool,
9245 pub entries: Vec<FileMetadata>,
9247 pub has_more: bool,
9250 pub server_deleted: Option<crate::types::common::DropboxTimestamp>,
9252}
9253
9254impl ListRevisionsResult {
9255 pub fn new(is_deleted: bool, entries: Vec<FileMetadata>, has_more: bool) -> Self {
9256 ListRevisionsResult {
9257 is_deleted,
9258 entries,
9259 has_more,
9260 server_deleted: None,
9261 }
9262 }
9263
9264 pub fn with_server_deleted(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
9265 self.server_deleted = Some(value);
9266 self
9267 }
9268}
9269
9270const LIST_REVISIONS_RESULT_FIELDS: &[&str] = &["is_deleted",
9271 "entries",
9272 "has_more",
9273 "server_deleted"];
9274impl ListRevisionsResult {
9275 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9276 map: V,
9277 ) -> Result<ListRevisionsResult, V::Error> {
9278 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9279 }
9280
9281 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9282 mut map: V,
9283 optional: bool,
9284 ) -> Result<Option<ListRevisionsResult>, V::Error> {
9285 let mut field_is_deleted = None;
9286 let mut field_entries = None;
9287 let mut field_has_more = None;
9288 let mut field_server_deleted = None;
9289 let mut nothing = true;
9290 while let Some(key) = map.next_key::<&str>()? {
9291 nothing = false;
9292 match key {
9293 "is_deleted" => {
9294 if field_is_deleted.is_some() {
9295 return Err(::serde::de::Error::duplicate_field("is_deleted"));
9296 }
9297 field_is_deleted = Some(map.next_value()?);
9298 }
9299 "entries" => {
9300 if field_entries.is_some() {
9301 return Err(::serde::de::Error::duplicate_field("entries"));
9302 }
9303 field_entries = Some(map.next_value()?);
9304 }
9305 "has_more" => {
9306 if field_has_more.is_some() {
9307 return Err(::serde::de::Error::duplicate_field("has_more"));
9308 }
9309 field_has_more = Some(map.next_value()?);
9310 }
9311 "server_deleted" => {
9312 if field_server_deleted.is_some() {
9313 return Err(::serde::de::Error::duplicate_field("server_deleted"));
9314 }
9315 field_server_deleted = Some(map.next_value()?);
9316 }
9317 _ => {
9318 map.next_value::<::serde_json::Value>()?;
9320 }
9321 }
9322 }
9323 if optional && nothing {
9324 return Ok(None);
9325 }
9326 let result = ListRevisionsResult {
9327 is_deleted: field_is_deleted.ok_or_else(|| ::serde::de::Error::missing_field("is_deleted"))?,
9328 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
9329 has_more: field_has_more.ok_or_else(|| ::serde::de::Error::missing_field("has_more"))?,
9330 server_deleted: field_server_deleted.and_then(Option::flatten),
9331 };
9332 Ok(Some(result))
9333 }
9334
9335 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9336 &self,
9337 s: &mut S::SerializeStruct,
9338 ) -> Result<(), S::Error> {
9339 use serde::ser::SerializeStruct;
9340 s.serialize_field("is_deleted", &self.is_deleted)?;
9341 s.serialize_field("entries", &self.entries)?;
9342 s.serialize_field("has_more", &self.has_more)?;
9343 if let Some(val) = &self.server_deleted {
9344 s.serialize_field("server_deleted", val)?;
9345 }
9346 Ok(())
9347 }
9348}
9349
9350impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsResult {
9351 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9352 use serde::de::{MapAccess, Visitor};
9354 struct StructVisitor;
9355 impl<'de> Visitor<'de> for StructVisitor {
9356 type Value = ListRevisionsResult;
9357 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9358 f.write_str("a ListRevisionsResult struct")
9359 }
9360 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9361 ListRevisionsResult::internal_deserialize(map)
9362 }
9363 }
9364 deserializer.deserialize_struct("ListRevisionsResult", LIST_REVISIONS_RESULT_FIELDS, StructVisitor)
9365 }
9366}
9367
9368impl ::serde::ser::Serialize for ListRevisionsResult {
9369 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9370 use serde::ser::SerializeStruct;
9372 let mut s = serializer.serialize_struct("ListRevisionsResult", 4)?;
9373 self.internal_serialize::<S>(&mut s)?;
9374 s.end()
9375 }
9376}
9377
9378#[derive(Debug, Clone, PartialEq, Eq)]
9379#[non_exhaustive] pub struct LockConflictError {
9381 pub lock: FileLock,
9383}
9384
9385impl LockConflictError {
9386 pub fn new(lock: FileLock) -> Self {
9387 LockConflictError {
9388 lock,
9389 }
9390 }
9391}
9392
9393const LOCK_CONFLICT_ERROR_FIELDS: &[&str] = &["lock"];
9394impl LockConflictError {
9395 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9396 map: V,
9397 ) -> Result<LockConflictError, V::Error> {
9398 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9399 }
9400
9401 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9402 mut map: V,
9403 optional: bool,
9404 ) -> Result<Option<LockConflictError>, V::Error> {
9405 let mut field_lock = None;
9406 let mut nothing = true;
9407 while let Some(key) = map.next_key::<&str>()? {
9408 nothing = false;
9409 match key {
9410 "lock" => {
9411 if field_lock.is_some() {
9412 return Err(::serde::de::Error::duplicate_field("lock"));
9413 }
9414 field_lock = Some(map.next_value()?);
9415 }
9416 _ => {
9417 map.next_value::<::serde_json::Value>()?;
9419 }
9420 }
9421 }
9422 if optional && nothing {
9423 return Ok(None);
9424 }
9425 let result = LockConflictError {
9426 lock: field_lock.ok_or_else(|| ::serde::de::Error::missing_field("lock"))?,
9427 };
9428 Ok(Some(result))
9429 }
9430
9431 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9432 &self,
9433 s: &mut S::SerializeStruct,
9434 ) -> Result<(), S::Error> {
9435 use serde::ser::SerializeStruct;
9436 s.serialize_field("lock", &self.lock)?;
9437 Ok(())
9438 }
9439}
9440
9441impl<'de> ::serde::de::Deserialize<'de> for LockConflictError {
9442 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9443 use serde::de::{MapAccess, Visitor};
9445 struct StructVisitor;
9446 impl<'de> Visitor<'de> for StructVisitor {
9447 type Value = LockConflictError;
9448 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9449 f.write_str("a LockConflictError struct")
9450 }
9451 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9452 LockConflictError::internal_deserialize(map)
9453 }
9454 }
9455 deserializer.deserialize_struct("LockConflictError", LOCK_CONFLICT_ERROR_FIELDS, StructVisitor)
9456 }
9457}
9458
9459impl ::serde::ser::Serialize for LockConflictError {
9460 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9461 use serde::ser::SerializeStruct;
9463 let mut s = serializer.serialize_struct("LockConflictError", 1)?;
9464 self.internal_serialize::<S>(&mut s)?;
9465 s.end()
9466 }
9467}
9468
9469#[derive(Debug, Clone, PartialEq, Eq)]
9470#[non_exhaustive] pub struct LockFileArg {
9472 pub path: WritePathOrId,
9474}
9475
9476impl LockFileArg {
9477 pub fn new(path: WritePathOrId) -> Self {
9478 LockFileArg {
9479 path,
9480 }
9481 }
9482}
9483
9484const LOCK_FILE_ARG_FIELDS: &[&str] = &["path"];
9485impl LockFileArg {
9486 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9487 map: V,
9488 ) -> Result<LockFileArg, V::Error> {
9489 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9490 }
9491
9492 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9493 mut map: V,
9494 optional: bool,
9495 ) -> Result<Option<LockFileArg>, V::Error> {
9496 let mut field_path = None;
9497 let mut nothing = true;
9498 while let Some(key) = map.next_key::<&str>()? {
9499 nothing = false;
9500 match key {
9501 "path" => {
9502 if field_path.is_some() {
9503 return Err(::serde::de::Error::duplicate_field("path"));
9504 }
9505 field_path = Some(map.next_value()?);
9506 }
9507 _ => {
9508 map.next_value::<::serde_json::Value>()?;
9510 }
9511 }
9512 }
9513 if optional && nothing {
9514 return Ok(None);
9515 }
9516 let result = LockFileArg {
9517 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
9518 };
9519 Ok(Some(result))
9520 }
9521
9522 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9523 &self,
9524 s: &mut S::SerializeStruct,
9525 ) -> Result<(), S::Error> {
9526 use serde::ser::SerializeStruct;
9527 s.serialize_field("path", &self.path)?;
9528 Ok(())
9529 }
9530}
9531
9532impl<'de> ::serde::de::Deserialize<'de> for LockFileArg {
9533 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9534 use serde::de::{MapAccess, Visitor};
9536 struct StructVisitor;
9537 impl<'de> Visitor<'de> for StructVisitor {
9538 type Value = LockFileArg;
9539 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9540 f.write_str("a LockFileArg struct")
9541 }
9542 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9543 LockFileArg::internal_deserialize(map)
9544 }
9545 }
9546 deserializer.deserialize_struct("LockFileArg", LOCK_FILE_ARG_FIELDS, StructVisitor)
9547 }
9548}
9549
9550impl ::serde::ser::Serialize for LockFileArg {
9551 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9552 use serde::ser::SerializeStruct;
9554 let mut s = serializer.serialize_struct("LockFileArg", 1)?;
9555 self.internal_serialize::<S>(&mut s)?;
9556 s.end()
9557 }
9558}
9559
9560#[derive(Debug, Clone, PartialEq, Eq)]
9561#[non_exhaustive] pub struct LockFileBatchArg {
9563 pub entries: Vec<LockFileArg>,
9566}
9567
9568impl LockFileBatchArg {
9569 pub fn new(entries: Vec<LockFileArg>) -> Self {
9570 LockFileBatchArg {
9571 entries,
9572 }
9573 }
9574}
9575
9576const LOCK_FILE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
9577impl LockFileBatchArg {
9578 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9579 map: V,
9580 ) -> Result<LockFileBatchArg, V::Error> {
9581 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9582 }
9583
9584 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9585 mut map: V,
9586 optional: bool,
9587 ) -> Result<Option<LockFileBatchArg>, V::Error> {
9588 let mut field_entries = None;
9589 let mut nothing = true;
9590 while let Some(key) = map.next_key::<&str>()? {
9591 nothing = false;
9592 match key {
9593 "entries" => {
9594 if field_entries.is_some() {
9595 return Err(::serde::de::Error::duplicate_field("entries"));
9596 }
9597 field_entries = Some(map.next_value()?);
9598 }
9599 _ => {
9600 map.next_value::<::serde_json::Value>()?;
9602 }
9603 }
9604 }
9605 if optional && nothing {
9606 return Ok(None);
9607 }
9608 let result = LockFileBatchArg {
9609 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
9610 };
9611 Ok(Some(result))
9612 }
9613
9614 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9615 &self,
9616 s: &mut S::SerializeStruct,
9617 ) -> Result<(), S::Error> {
9618 use serde::ser::SerializeStruct;
9619 s.serialize_field("entries", &self.entries)?;
9620 Ok(())
9621 }
9622}
9623
9624impl<'de> ::serde::de::Deserialize<'de> for LockFileBatchArg {
9625 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9626 use serde::de::{MapAccess, Visitor};
9628 struct StructVisitor;
9629 impl<'de> Visitor<'de> for StructVisitor {
9630 type Value = LockFileBatchArg;
9631 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9632 f.write_str("a LockFileBatchArg struct")
9633 }
9634 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9635 LockFileBatchArg::internal_deserialize(map)
9636 }
9637 }
9638 deserializer.deserialize_struct("LockFileBatchArg", LOCK_FILE_BATCH_ARG_FIELDS, StructVisitor)
9639 }
9640}
9641
9642impl ::serde::ser::Serialize for LockFileBatchArg {
9643 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9644 use serde::ser::SerializeStruct;
9646 let mut s = serializer.serialize_struct("LockFileBatchArg", 1)?;
9647 self.internal_serialize::<S>(&mut s)?;
9648 s.end()
9649 }
9650}
9651
9652#[derive(Debug, Clone, PartialEq)]
9653#[non_exhaustive] pub struct LockFileBatchResult {
9655 pub entries: Vec<LockFileResultEntry>,
9658}
9659
9660impl LockFileBatchResult {
9661 pub fn new(entries: Vec<LockFileResultEntry>) -> Self {
9662 LockFileBatchResult {
9663 entries,
9664 }
9665 }
9666}
9667
9668const LOCK_FILE_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
9669impl LockFileBatchResult {
9670 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9671 map: V,
9672 ) -> Result<LockFileBatchResult, V::Error> {
9673 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9674 }
9675
9676 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9677 mut map: V,
9678 optional: bool,
9679 ) -> Result<Option<LockFileBatchResult>, V::Error> {
9680 let mut field_entries = None;
9681 let mut nothing = true;
9682 while let Some(key) = map.next_key::<&str>()? {
9683 nothing = false;
9684 match key {
9685 "entries" => {
9686 if field_entries.is_some() {
9687 return Err(::serde::de::Error::duplicate_field("entries"));
9688 }
9689 field_entries = Some(map.next_value()?);
9690 }
9691 _ => {
9692 map.next_value::<::serde_json::Value>()?;
9694 }
9695 }
9696 }
9697 if optional && nothing {
9698 return Ok(None);
9699 }
9700 let result = LockFileBatchResult {
9701 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
9702 };
9703 Ok(Some(result))
9704 }
9705
9706 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9707 &self,
9708 s: &mut S::SerializeStruct,
9709 ) -> Result<(), S::Error> {
9710 use serde::ser::SerializeStruct;
9711 s.serialize_field("entries", &self.entries)?;
9712 Ok(())
9713 }
9714}
9715
9716impl<'de> ::serde::de::Deserialize<'de> for LockFileBatchResult {
9717 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9718 use serde::de::{MapAccess, Visitor};
9720 struct StructVisitor;
9721 impl<'de> Visitor<'de> for StructVisitor {
9722 type Value = LockFileBatchResult;
9723 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9724 f.write_str("a LockFileBatchResult struct")
9725 }
9726 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9727 LockFileBatchResult::internal_deserialize(map)
9728 }
9729 }
9730 deserializer.deserialize_struct("LockFileBatchResult", LOCK_FILE_BATCH_RESULT_FIELDS, StructVisitor)
9731 }
9732}
9733
9734impl ::serde::ser::Serialize for LockFileBatchResult {
9735 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9736 use serde::ser::SerializeStruct;
9738 let mut s = serializer.serialize_struct("LockFileBatchResult", 1)?;
9739 self.internal_serialize::<S>(&mut s)?;
9740 s.end()
9741 }
9742}
9743
9744impl From<LockFileBatchResult> for FileOpsResult {
9746 fn from(_: LockFileBatchResult) -> Self {
9747 Self {}
9748 }
9749}
9750#[derive(Debug, Clone, PartialEq, Eq)]
9751#[non_exhaustive] pub enum LockFileError {
9753 PathLookup(LookupError),
9755 TooManyWriteOperations,
9757 TooManyFiles,
9759 NoWritePermission,
9761 CannotBeLocked,
9763 FileNotShared,
9765 LockConflict(LockConflictError),
9767 InternalError,
9770 Other,
9773}
9774
9775impl<'de> ::serde::de::Deserialize<'de> for LockFileError {
9776 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9777 use serde::de::{self, MapAccess, Visitor};
9779 struct EnumVisitor;
9780 impl<'de> Visitor<'de> for EnumVisitor {
9781 type Value = LockFileError;
9782 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9783 f.write_str("a LockFileError structure")
9784 }
9785 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
9786 let tag: &str = match map.next_key()? {
9787 Some(".tag") => map.next_value()?,
9788 _ => return Err(de::Error::missing_field(".tag"))
9789 };
9790 let value = match tag {
9791 "path_lookup" => {
9792 match map.next_key()? {
9793 Some("path_lookup") => LockFileError::PathLookup(map.next_value()?),
9794 None => return Err(de::Error::missing_field("path_lookup")),
9795 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
9796 }
9797 }
9798 "too_many_write_operations" => LockFileError::TooManyWriteOperations,
9799 "too_many_files" => LockFileError::TooManyFiles,
9800 "no_write_permission" => LockFileError::NoWritePermission,
9801 "cannot_be_locked" => LockFileError::CannotBeLocked,
9802 "file_not_shared" => LockFileError::FileNotShared,
9803 "lock_conflict" => LockFileError::LockConflict(LockConflictError::internal_deserialize(&mut map)?),
9804 "internal_error" => LockFileError::InternalError,
9805 _ => LockFileError::Other,
9806 };
9807 crate::eat_json_fields(&mut map)?;
9808 Ok(value)
9809 }
9810 }
9811 const VARIANTS: &[&str] = &["path_lookup",
9812 "too_many_write_operations",
9813 "too_many_files",
9814 "no_write_permission",
9815 "cannot_be_locked",
9816 "file_not_shared",
9817 "lock_conflict",
9818 "internal_error",
9819 "other"];
9820 deserializer.deserialize_struct("LockFileError", VARIANTS, EnumVisitor)
9821 }
9822}
9823
9824impl ::serde::ser::Serialize for LockFileError {
9825 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9826 use serde::ser::SerializeStruct;
9828 match self {
9829 LockFileError::PathLookup(x) => {
9830 let mut s = serializer.serialize_struct("LockFileError", 2)?;
9832 s.serialize_field(".tag", "path_lookup")?;
9833 s.serialize_field("path_lookup", x)?;
9834 s.end()
9835 }
9836 LockFileError::TooManyWriteOperations => {
9837 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9839 s.serialize_field(".tag", "too_many_write_operations")?;
9840 s.end()
9841 }
9842 LockFileError::TooManyFiles => {
9843 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9845 s.serialize_field(".tag", "too_many_files")?;
9846 s.end()
9847 }
9848 LockFileError::NoWritePermission => {
9849 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9851 s.serialize_field(".tag", "no_write_permission")?;
9852 s.end()
9853 }
9854 LockFileError::CannotBeLocked => {
9855 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9857 s.serialize_field(".tag", "cannot_be_locked")?;
9858 s.end()
9859 }
9860 LockFileError::FileNotShared => {
9861 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9863 s.serialize_field(".tag", "file_not_shared")?;
9864 s.end()
9865 }
9866 LockFileError::LockConflict(x) => {
9867 let mut s = serializer.serialize_struct("LockFileError", 2)?;
9869 s.serialize_field(".tag", "lock_conflict")?;
9870 x.internal_serialize::<S>(&mut s)?;
9871 s.end()
9872 }
9873 LockFileError::InternalError => {
9874 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9876 s.serialize_field(".tag", "internal_error")?;
9877 s.end()
9878 }
9879 LockFileError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
9880 }
9881 }
9882}
9883
9884impl ::std::error::Error for LockFileError {
9885 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
9886 match self {
9887 LockFileError::PathLookup(inner) => Some(inner),
9888 _ => None,
9889 }
9890 }
9891}
9892
9893impl ::std::fmt::Display for LockFileError {
9894 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9895 match self {
9896 LockFileError::PathLookup(inner) => write!(f, "Could not find the specified resource: {}", inner),
9897 LockFileError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
9898 LockFileError::TooManyFiles => f.write_str("There are too many files in one request. Please retry with fewer files."),
9899 LockFileError::NoWritePermission => f.write_str("The user does not have permissions to change the lock state or access the file."),
9900 LockFileError::CannotBeLocked => f.write_str("Item is a type that cannot be locked."),
9901 LockFileError::FileNotShared => f.write_str("Requested file is not currently shared."),
9902 LockFileError::LockConflict(inner) => write!(f, "The user action conflicts with an existing lock on the file: {:?}", inner),
9903 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."),
9904 _ => write!(f, "{:?}", *self),
9905 }
9906 }
9907}
9908
9909#[derive(Debug, Clone, PartialEq)]
9910#[non_exhaustive] pub struct LockFileResult {
9912 pub metadata: Metadata,
9914 pub lock: FileLock,
9916}
9917
9918impl LockFileResult {
9919 pub fn new(metadata: Metadata, lock: FileLock) -> Self {
9920 LockFileResult {
9921 metadata,
9922 lock,
9923 }
9924 }
9925}
9926
9927const LOCK_FILE_RESULT_FIELDS: &[&str] = &["metadata",
9928 "lock"];
9929impl LockFileResult {
9930 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9931 map: V,
9932 ) -> Result<LockFileResult, V::Error> {
9933 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9934 }
9935
9936 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9937 mut map: V,
9938 optional: bool,
9939 ) -> Result<Option<LockFileResult>, V::Error> {
9940 let mut field_metadata = None;
9941 let mut field_lock = None;
9942 let mut nothing = true;
9943 while let Some(key) = map.next_key::<&str>()? {
9944 nothing = false;
9945 match key {
9946 "metadata" => {
9947 if field_metadata.is_some() {
9948 return Err(::serde::de::Error::duplicate_field("metadata"));
9949 }
9950 field_metadata = Some(map.next_value()?);
9951 }
9952 "lock" => {
9953 if field_lock.is_some() {
9954 return Err(::serde::de::Error::duplicate_field("lock"));
9955 }
9956 field_lock = Some(map.next_value()?);
9957 }
9958 _ => {
9959 map.next_value::<::serde_json::Value>()?;
9961 }
9962 }
9963 }
9964 if optional && nothing {
9965 return Ok(None);
9966 }
9967 let result = LockFileResult {
9968 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
9969 lock: field_lock.ok_or_else(|| ::serde::de::Error::missing_field("lock"))?,
9970 };
9971 Ok(Some(result))
9972 }
9973
9974 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9975 &self,
9976 s: &mut S::SerializeStruct,
9977 ) -> Result<(), S::Error> {
9978 use serde::ser::SerializeStruct;
9979 s.serialize_field("metadata", &self.metadata)?;
9980 s.serialize_field("lock", &self.lock)?;
9981 Ok(())
9982 }
9983}
9984
9985impl<'de> ::serde::de::Deserialize<'de> for LockFileResult {
9986 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9987 use serde::de::{MapAccess, Visitor};
9989 struct StructVisitor;
9990 impl<'de> Visitor<'de> for StructVisitor {
9991 type Value = LockFileResult;
9992 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9993 f.write_str("a LockFileResult struct")
9994 }
9995 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9996 LockFileResult::internal_deserialize(map)
9997 }
9998 }
9999 deserializer.deserialize_struct("LockFileResult", LOCK_FILE_RESULT_FIELDS, StructVisitor)
10000 }
10001}
10002
10003impl ::serde::ser::Serialize for LockFileResult {
10004 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10005 use serde::ser::SerializeStruct;
10007 let mut s = serializer.serialize_struct("LockFileResult", 2)?;
10008 self.internal_serialize::<S>(&mut s)?;
10009 s.end()
10010 }
10011}
10012
10013#[derive(Debug, Clone, PartialEq)]
10014pub enum LockFileResultEntry {
10015 Success(LockFileResult),
10016 Failure(LockFileError),
10017}
10018
10019impl<'de> ::serde::de::Deserialize<'de> for LockFileResultEntry {
10020 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10021 use serde::de::{self, MapAccess, Visitor};
10023 struct EnumVisitor;
10024 impl<'de> Visitor<'de> for EnumVisitor {
10025 type Value = LockFileResultEntry;
10026 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10027 f.write_str("a LockFileResultEntry structure")
10028 }
10029 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10030 let tag: &str = match map.next_key()? {
10031 Some(".tag") => map.next_value()?,
10032 _ => return Err(de::Error::missing_field(".tag"))
10033 };
10034 let value = match tag {
10035 "success" => LockFileResultEntry::Success(LockFileResult::internal_deserialize(&mut map)?),
10036 "failure" => {
10037 match map.next_key()? {
10038 Some("failure") => LockFileResultEntry::Failure(map.next_value()?),
10039 None => return Err(de::Error::missing_field("failure")),
10040 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10041 }
10042 }
10043 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
10044 };
10045 crate::eat_json_fields(&mut map)?;
10046 Ok(value)
10047 }
10048 }
10049 const VARIANTS: &[&str] = &["success",
10050 "failure"];
10051 deserializer.deserialize_struct("LockFileResultEntry", VARIANTS, EnumVisitor)
10052 }
10053}
10054
10055impl ::serde::ser::Serialize for LockFileResultEntry {
10056 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10057 use serde::ser::SerializeStruct;
10059 match self {
10060 LockFileResultEntry::Success(x) => {
10061 let mut s = serializer.serialize_struct("LockFileResultEntry", 3)?;
10063 s.serialize_field(".tag", "success")?;
10064 x.internal_serialize::<S>(&mut s)?;
10065 s.end()
10066 }
10067 LockFileResultEntry::Failure(x) => {
10068 let mut s = serializer.serialize_struct("LockFileResultEntry", 2)?;
10070 s.serialize_field(".tag", "failure")?;
10071 s.serialize_field("failure", x)?;
10072 s.end()
10073 }
10074 }
10075 }
10076}
10077
10078#[derive(Debug, Clone, PartialEq, Eq)]
10079#[non_exhaustive] pub enum LookupError {
10081 MalformedPath(MalformedPathError),
10085 NotFound,
10087 NotFile,
10089 NotFolder,
10091 RestrictedContent,
10094 UnsupportedContentType,
10096 Locked,
10098 Other,
10101}
10102
10103impl<'de> ::serde::de::Deserialize<'de> for LookupError {
10104 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10105 use serde::de::{self, MapAccess, Visitor};
10107 struct EnumVisitor;
10108 impl<'de> Visitor<'de> for EnumVisitor {
10109 type Value = LookupError;
10110 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10111 f.write_str("a LookupError structure")
10112 }
10113 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10114 let tag: &str = match map.next_key()? {
10115 Some(".tag") => map.next_value()?,
10116 _ => return Err(de::Error::missing_field(".tag"))
10117 };
10118 let value = match tag {
10119 "malformed_path" => {
10120 match map.next_key()? {
10121 Some("malformed_path") => LookupError::MalformedPath(map.next_value()?),
10122 None => LookupError::MalformedPath(None),
10123 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10124 }
10125 }
10126 "not_found" => LookupError::NotFound,
10127 "not_file" => LookupError::NotFile,
10128 "not_folder" => LookupError::NotFolder,
10129 "restricted_content" => LookupError::RestrictedContent,
10130 "unsupported_content_type" => LookupError::UnsupportedContentType,
10131 "locked" => LookupError::Locked,
10132 _ => LookupError::Other,
10133 };
10134 crate::eat_json_fields(&mut map)?;
10135 Ok(value)
10136 }
10137 }
10138 const VARIANTS: &[&str] = &["malformed_path",
10139 "not_found",
10140 "not_file",
10141 "not_folder",
10142 "restricted_content",
10143 "unsupported_content_type",
10144 "locked",
10145 "other"];
10146 deserializer.deserialize_struct("LookupError", VARIANTS, EnumVisitor)
10147 }
10148}
10149
10150impl ::serde::ser::Serialize for LookupError {
10151 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10152 use serde::ser::SerializeStruct;
10154 match self {
10155 LookupError::MalformedPath(x) => {
10156 let n = if x.is_some() { 2 } else { 1 };
10158 let mut s = serializer.serialize_struct("LookupError", n)?;
10159 s.serialize_field(".tag", "malformed_path")?;
10160 if let Some(x) = x {
10161 s.serialize_field("malformed_path", &x)?;
10162 }
10163 s.end()
10164 }
10165 LookupError::NotFound => {
10166 let mut s = serializer.serialize_struct("LookupError", 1)?;
10168 s.serialize_field(".tag", "not_found")?;
10169 s.end()
10170 }
10171 LookupError::NotFile => {
10172 let mut s = serializer.serialize_struct("LookupError", 1)?;
10174 s.serialize_field(".tag", "not_file")?;
10175 s.end()
10176 }
10177 LookupError::NotFolder => {
10178 let mut s = serializer.serialize_struct("LookupError", 1)?;
10180 s.serialize_field(".tag", "not_folder")?;
10181 s.end()
10182 }
10183 LookupError::RestrictedContent => {
10184 let mut s = serializer.serialize_struct("LookupError", 1)?;
10186 s.serialize_field(".tag", "restricted_content")?;
10187 s.end()
10188 }
10189 LookupError::UnsupportedContentType => {
10190 let mut s = serializer.serialize_struct("LookupError", 1)?;
10192 s.serialize_field(".tag", "unsupported_content_type")?;
10193 s.end()
10194 }
10195 LookupError::Locked => {
10196 let mut s = serializer.serialize_struct("LookupError", 1)?;
10198 s.serialize_field(".tag", "locked")?;
10199 s.end()
10200 }
10201 LookupError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10202 }
10203 }
10204}
10205
10206impl ::std::error::Error for LookupError {
10207}
10208
10209impl ::std::fmt::Display for LookupError {
10210 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10211 match self {
10212 LookupError::MalformedPath(inner) => write!(f, "malformed_path: {:?}", inner),
10213 LookupError::NotFound => f.write_str("There is nothing at the given path."),
10214 LookupError::NotFile => f.write_str("We were expecting a file, but the given path refers to something that isn't a file."),
10215 LookupError::NotFolder => f.write_str("We were expecting a folder, but the given path refers to something that isn't a folder."),
10216 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."),
10217 LookupError::UnsupportedContentType => f.write_str("This operation is not supported for this content type."),
10218 LookupError::Locked => f.write_str("The given path is locked."),
10219 _ => write!(f, "{:?}", *self),
10220 }
10221 }
10222}
10223
10224#[derive(Debug, Clone, PartialEq)]
10225pub enum MediaInfo {
10226 Pending,
10228 Metadata(MediaMetadata),
10231}
10232
10233impl<'de> ::serde::de::Deserialize<'de> for MediaInfo {
10234 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10235 use serde::de::{self, MapAccess, Visitor};
10237 struct EnumVisitor;
10238 impl<'de> Visitor<'de> for EnumVisitor {
10239 type Value = MediaInfo;
10240 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10241 f.write_str("a MediaInfo structure")
10242 }
10243 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10244 let tag: &str = match map.next_key()? {
10245 Some(".tag") => map.next_value()?,
10246 _ => return Err(de::Error::missing_field(".tag"))
10247 };
10248 let value = match tag {
10249 "pending" => MediaInfo::Pending,
10250 "metadata" => {
10251 match map.next_key()? {
10252 Some("metadata") => MediaInfo::Metadata(map.next_value()?),
10253 None => return Err(de::Error::missing_field("metadata")),
10254 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10255 }
10256 }
10257 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
10258 };
10259 crate::eat_json_fields(&mut map)?;
10260 Ok(value)
10261 }
10262 }
10263 const VARIANTS: &[&str] = &["pending",
10264 "metadata"];
10265 deserializer.deserialize_struct("MediaInfo", VARIANTS, EnumVisitor)
10266 }
10267}
10268
10269impl ::serde::ser::Serialize for MediaInfo {
10270 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10271 use serde::ser::SerializeStruct;
10273 match self {
10274 MediaInfo::Pending => {
10275 let mut s = serializer.serialize_struct("MediaInfo", 1)?;
10277 s.serialize_field(".tag", "pending")?;
10278 s.end()
10279 }
10280 MediaInfo::Metadata(x) => {
10281 let mut s = serializer.serialize_struct("MediaInfo", 2)?;
10283 s.serialize_field(".tag", "metadata")?;
10284 s.serialize_field("metadata", x)?;
10285 s.end()
10286 }
10287 }
10288 }
10289}
10290
10291#[derive(Debug, Clone, PartialEq)]
10293pub enum MediaMetadata {
10294 Photo(PhotoMetadata),
10295 Video(VideoMetadata),
10296}
10297
10298impl<'de> ::serde::de::Deserialize<'de> for MediaMetadata {
10299 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10300 use serde::de::{self, MapAccess, Visitor};
10302 struct EnumVisitor;
10303 impl<'de> Visitor<'de> for EnumVisitor {
10304 type Value = MediaMetadata;
10305 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10306 f.write_str("a MediaMetadata structure")
10307 }
10308 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10309 let tag = match map.next_key()? {
10310 Some(".tag") => map.next_value()?,
10311 _ => return Err(de::Error::missing_field(".tag"))
10312 };
10313 match tag {
10314 "photo" => Ok(MediaMetadata::Photo(PhotoMetadata::internal_deserialize(map)?)),
10315 "video" => Ok(MediaMetadata::Video(VideoMetadata::internal_deserialize(map)?)),
10316 _ => Err(de::Error::unknown_variant(tag, VARIANTS))
10317 }
10318 }
10319 }
10320 const VARIANTS: &[&str] = &["photo",
10321 "video"];
10322 deserializer.deserialize_struct("MediaMetadata", VARIANTS, EnumVisitor)
10323 }
10324}
10325
10326impl ::serde::ser::Serialize for MediaMetadata {
10327 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10328 use serde::ser::SerializeStruct;
10330 match self {
10331 MediaMetadata::Photo(x) => {
10332 let mut s = serializer.serialize_struct("MediaMetadata", 4)?;
10333 s.serialize_field(".tag", "photo")?;
10334 x.internal_serialize::<S>(&mut s)?;
10335 s.end()
10336 }
10337 MediaMetadata::Video(x) => {
10338 let mut s = serializer.serialize_struct("MediaMetadata", 5)?;
10339 s.serialize_field(".tag", "video")?;
10340 x.internal_serialize::<S>(&mut s)?;
10341 s.end()
10342 }
10343 }
10344 }
10345}
10346
10347#[derive(Debug, Clone, PartialEq)]
10349pub enum Metadata {
10350 File(FileMetadata),
10351 Folder(FolderMetadata),
10352 Deleted(DeletedMetadata),
10353}
10354
10355impl<'de> ::serde::de::Deserialize<'de> for Metadata {
10356 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10357 use serde::de::{self, MapAccess, Visitor};
10359 struct EnumVisitor;
10360 impl<'de> Visitor<'de> for EnumVisitor {
10361 type Value = Metadata;
10362 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10363 f.write_str("a Metadata structure")
10364 }
10365 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10366 let tag = match map.next_key()? {
10367 Some(".tag") => map.next_value()?,
10368 _ => return Err(de::Error::missing_field(".tag"))
10369 };
10370 match tag {
10371 "file" => Ok(Metadata::File(FileMetadata::internal_deserialize(map)?)),
10372 "folder" => Ok(Metadata::Folder(FolderMetadata::internal_deserialize(map)?)),
10373 "deleted" => Ok(Metadata::Deleted(DeletedMetadata::internal_deserialize(map)?)),
10374 _ => Err(de::Error::unknown_variant(tag, VARIANTS))
10375 }
10376 }
10377 }
10378 const VARIANTS: &[&str] = &["file",
10379 "folder",
10380 "deleted"];
10381 deserializer.deserialize_struct("Metadata", VARIANTS, EnumVisitor)
10382 }
10383}
10384
10385impl ::serde::ser::Serialize for Metadata {
10386 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10387 use serde::ser::SerializeStruct;
10389 match self {
10390 Metadata::File(x) => {
10391 let mut s = serializer.serialize_struct("Metadata", 20)?;
10392 s.serialize_field(".tag", "file")?;
10393 x.internal_serialize::<S>(&mut s)?;
10394 s.end()
10395 }
10396 Metadata::Folder(x) => {
10397 let mut s = serializer.serialize_struct("Metadata", 10)?;
10398 s.serialize_field(".tag", "folder")?;
10399 x.internal_serialize::<S>(&mut s)?;
10400 s.end()
10401 }
10402 Metadata::Deleted(x) => {
10403 let mut s = serializer.serialize_struct("Metadata", 6)?;
10404 s.serialize_field(".tag", "deleted")?;
10405 x.internal_serialize::<S>(&mut s)?;
10406 s.end()
10407 }
10408 }
10409 }
10410}
10411
10412#[derive(Debug, Clone, PartialEq)]
10414#[non_exhaustive] pub enum MetadataV2 {
10416 Metadata(Metadata),
10417 Other,
10420}
10421
10422impl<'de> ::serde::de::Deserialize<'de> for MetadataV2 {
10423 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10424 use serde::de::{self, MapAccess, Visitor};
10426 struct EnumVisitor;
10427 impl<'de> Visitor<'de> for EnumVisitor {
10428 type Value = MetadataV2;
10429 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10430 f.write_str("a MetadataV2 structure")
10431 }
10432 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10433 let tag: &str = match map.next_key()? {
10434 Some(".tag") => map.next_value()?,
10435 _ => return Err(de::Error::missing_field(".tag"))
10436 };
10437 let value = match tag {
10438 "metadata" => {
10439 match map.next_key()? {
10440 Some("metadata") => MetadataV2::Metadata(map.next_value()?),
10441 None => return Err(de::Error::missing_field("metadata")),
10442 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10443 }
10444 }
10445 _ => MetadataV2::Other,
10446 };
10447 crate::eat_json_fields(&mut map)?;
10448 Ok(value)
10449 }
10450 }
10451 const VARIANTS: &[&str] = &["metadata",
10452 "other"];
10453 deserializer.deserialize_struct("MetadataV2", VARIANTS, EnumVisitor)
10454 }
10455}
10456
10457impl ::serde::ser::Serialize for MetadataV2 {
10458 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10459 use serde::ser::SerializeStruct;
10461 match self {
10462 MetadataV2::Metadata(x) => {
10463 let mut s = serializer.serialize_struct("MetadataV2", 2)?;
10465 s.serialize_field(".tag", "metadata")?;
10466 s.serialize_field("metadata", x)?;
10467 s.end()
10468 }
10469 MetadataV2::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10470 }
10471 }
10472}
10473
10474#[derive(Debug, Clone, PartialEq, Eq)]
10475#[non_exhaustive] pub struct MinimalFileLinkMetadata {
10477 pub url: String,
10479 pub rev: Rev,
10482 pub id: Option<Id>,
10484 pub path: Option<String>,
10487}
10488
10489impl MinimalFileLinkMetadata {
10490 pub fn new(url: String, rev: Rev) -> Self {
10491 MinimalFileLinkMetadata {
10492 url,
10493 rev,
10494 id: None,
10495 path: None,
10496 }
10497 }
10498
10499 pub fn with_id(mut self, value: Id) -> Self {
10500 self.id = Some(value);
10501 self
10502 }
10503
10504 pub fn with_path(mut self, value: String) -> Self {
10505 self.path = Some(value);
10506 self
10507 }
10508}
10509
10510const MINIMAL_FILE_LINK_METADATA_FIELDS: &[&str] = &["url",
10511 "rev",
10512 "id",
10513 "path"];
10514impl MinimalFileLinkMetadata {
10515 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
10516 map: V,
10517 ) -> Result<MinimalFileLinkMetadata, V::Error> {
10518 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
10519 }
10520
10521 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
10522 mut map: V,
10523 optional: bool,
10524 ) -> Result<Option<MinimalFileLinkMetadata>, V::Error> {
10525 let mut field_url = None;
10526 let mut field_rev = None;
10527 let mut field_id = None;
10528 let mut field_path = None;
10529 let mut nothing = true;
10530 while let Some(key) = map.next_key::<&str>()? {
10531 nothing = false;
10532 match key {
10533 "url" => {
10534 if field_url.is_some() {
10535 return Err(::serde::de::Error::duplicate_field("url"));
10536 }
10537 field_url = Some(map.next_value()?);
10538 }
10539 "rev" => {
10540 if field_rev.is_some() {
10541 return Err(::serde::de::Error::duplicate_field("rev"));
10542 }
10543 field_rev = Some(map.next_value()?);
10544 }
10545 "id" => {
10546 if field_id.is_some() {
10547 return Err(::serde::de::Error::duplicate_field("id"));
10548 }
10549 field_id = Some(map.next_value()?);
10550 }
10551 "path" => {
10552 if field_path.is_some() {
10553 return Err(::serde::de::Error::duplicate_field("path"));
10554 }
10555 field_path = Some(map.next_value()?);
10556 }
10557 _ => {
10558 map.next_value::<::serde_json::Value>()?;
10560 }
10561 }
10562 }
10563 if optional && nothing {
10564 return Ok(None);
10565 }
10566 let result = MinimalFileLinkMetadata {
10567 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
10568 rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
10569 id: field_id.and_then(Option::flatten),
10570 path: field_path.and_then(Option::flatten),
10571 };
10572 Ok(Some(result))
10573 }
10574
10575 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
10576 &self,
10577 s: &mut S::SerializeStruct,
10578 ) -> Result<(), S::Error> {
10579 use serde::ser::SerializeStruct;
10580 s.serialize_field("url", &self.url)?;
10581 s.serialize_field("rev", &self.rev)?;
10582 if let Some(val) = &self.id {
10583 s.serialize_field("id", val)?;
10584 }
10585 if let Some(val) = &self.path {
10586 s.serialize_field("path", val)?;
10587 }
10588 Ok(())
10589 }
10590}
10591
10592impl<'de> ::serde::de::Deserialize<'de> for MinimalFileLinkMetadata {
10593 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10594 use serde::de::{MapAccess, Visitor};
10596 struct StructVisitor;
10597 impl<'de> Visitor<'de> for StructVisitor {
10598 type Value = MinimalFileLinkMetadata;
10599 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10600 f.write_str("a MinimalFileLinkMetadata struct")
10601 }
10602 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
10603 MinimalFileLinkMetadata::internal_deserialize(map)
10604 }
10605 }
10606 deserializer.deserialize_struct("MinimalFileLinkMetadata", MINIMAL_FILE_LINK_METADATA_FIELDS, StructVisitor)
10607 }
10608}
10609
10610impl ::serde::ser::Serialize for MinimalFileLinkMetadata {
10611 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10612 use serde::ser::SerializeStruct;
10614 let mut s = serializer.serialize_struct("MinimalFileLinkMetadata", 4)?;
10615 self.internal_serialize::<S>(&mut s)?;
10616 s.end()
10617 }
10618}
10619
10620#[derive(Debug, Clone, PartialEq, Eq)]
10621#[non_exhaustive] pub struct MoveBatchArg {
10623 pub entries: Vec<RelocationPath>,
10625 pub autorename: bool,
10628 pub allow_ownership_transfer: bool,
10631}
10632
10633impl MoveBatchArg {
10634 pub fn new(entries: Vec<RelocationPath>) -> Self {
10635 MoveBatchArg {
10636 entries,
10637 autorename: false,
10638 allow_ownership_transfer: false,
10639 }
10640 }
10641
10642 pub fn with_autorename(mut self, value: bool) -> Self {
10643 self.autorename = value;
10644 self
10645 }
10646
10647 pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
10648 self.allow_ownership_transfer = value;
10649 self
10650 }
10651}
10652
10653const MOVE_BATCH_ARG_FIELDS: &[&str] = &["entries",
10654 "autorename",
10655 "allow_ownership_transfer"];
10656impl MoveBatchArg {
10657 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
10658 map: V,
10659 ) -> Result<MoveBatchArg, V::Error> {
10660 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
10661 }
10662
10663 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
10664 mut map: V,
10665 optional: bool,
10666 ) -> Result<Option<MoveBatchArg>, V::Error> {
10667 let mut field_entries = None;
10668 let mut field_autorename = None;
10669 let mut field_allow_ownership_transfer = None;
10670 let mut nothing = true;
10671 while let Some(key) = map.next_key::<&str>()? {
10672 nothing = false;
10673 match key {
10674 "entries" => {
10675 if field_entries.is_some() {
10676 return Err(::serde::de::Error::duplicate_field("entries"));
10677 }
10678 field_entries = Some(map.next_value()?);
10679 }
10680 "autorename" => {
10681 if field_autorename.is_some() {
10682 return Err(::serde::de::Error::duplicate_field("autorename"));
10683 }
10684 field_autorename = Some(map.next_value()?);
10685 }
10686 "allow_ownership_transfer" => {
10687 if field_allow_ownership_transfer.is_some() {
10688 return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
10689 }
10690 field_allow_ownership_transfer = Some(map.next_value()?);
10691 }
10692 _ => {
10693 map.next_value::<::serde_json::Value>()?;
10695 }
10696 }
10697 }
10698 if optional && nothing {
10699 return Ok(None);
10700 }
10701 let result = MoveBatchArg {
10702 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
10703 autorename: field_autorename.unwrap_or(false),
10704 allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
10705 };
10706 Ok(Some(result))
10707 }
10708
10709 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
10710 &self,
10711 s: &mut S::SerializeStruct,
10712 ) -> Result<(), S::Error> {
10713 use serde::ser::SerializeStruct;
10714 s.serialize_field("entries", &self.entries)?;
10715 if self.autorename {
10716 s.serialize_field("autorename", &self.autorename)?;
10717 }
10718 if self.allow_ownership_transfer {
10719 s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
10720 }
10721 Ok(())
10722 }
10723}
10724
10725impl<'de> ::serde::de::Deserialize<'de> for MoveBatchArg {
10726 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10727 use serde::de::{MapAccess, Visitor};
10729 struct StructVisitor;
10730 impl<'de> Visitor<'de> for StructVisitor {
10731 type Value = MoveBatchArg;
10732 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10733 f.write_str("a MoveBatchArg struct")
10734 }
10735 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
10736 MoveBatchArg::internal_deserialize(map)
10737 }
10738 }
10739 deserializer.deserialize_struct("MoveBatchArg", MOVE_BATCH_ARG_FIELDS, StructVisitor)
10740 }
10741}
10742
10743impl ::serde::ser::Serialize for MoveBatchArg {
10744 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10745 use serde::ser::SerializeStruct;
10747 let mut s = serializer.serialize_struct("MoveBatchArg", 3)?;
10748 self.internal_serialize::<S>(&mut s)?;
10749 s.end()
10750 }
10751}
10752
10753impl From<MoveBatchArg> for RelocationBatchArgBase {
10755 fn from(subtype: MoveBatchArg) -> Self {
10756 Self {
10757 entries: subtype.entries,
10758 autorename: subtype.autorename,
10759 }
10760 }
10761}
10762#[derive(Debug, Clone, PartialEq, Eq)]
10763#[non_exhaustive] pub enum MoveIntoFamilyError {
10765 IsSharedFolder,
10767 Other,
10770}
10771
10772impl<'de> ::serde::de::Deserialize<'de> for MoveIntoFamilyError {
10773 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10774 use serde::de::{self, MapAccess, Visitor};
10776 struct EnumVisitor;
10777 impl<'de> Visitor<'de> for EnumVisitor {
10778 type Value = MoveIntoFamilyError;
10779 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10780 f.write_str("a MoveIntoFamilyError structure")
10781 }
10782 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10783 let tag: &str = match map.next_key()? {
10784 Some(".tag") => map.next_value()?,
10785 _ => return Err(de::Error::missing_field(".tag"))
10786 };
10787 let value = match tag {
10788 "is_shared_folder" => MoveIntoFamilyError::IsSharedFolder,
10789 _ => MoveIntoFamilyError::Other,
10790 };
10791 crate::eat_json_fields(&mut map)?;
10792 Ok(value)
10793 }
10794 }
10795 const VARIANTS: &[&str] = &["is_shared_folder",
10796 "other"];
10797 deserializer.deserialize_struct("MoveIntoFamilyError", VARIANTS, EnumVisitor)
10798 }
10799}
10800
10801impl ::serde::ser::Serialize for MoveIntoFamilyError {
10802 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10803 use serde::ser::SerializeStruct;
10805 match self {
10806 MoveIntoFamilyError::IsSharedFolder => {
10807 let mut s = serializer.serialize_struct("MoveIntoFamilyError", 1)?;
10809 s.serialize_field(".tag", "is_shared_folder")?;
10810 s.end()
10811 }
10812 MoveIntoFamilyError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10813 }
10814 }
10815}
10816
10817impl ::std::error::Error for MoveIntoFamilyError {
10818}
10819
10820impl ::std::fmt::Display for MoveIntoFamilyError {
10821 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10822 match self {
10823 MoveIntoFamilyError::IsSharedFolder => f.write_str("Moving shared folder into Family Room folder is not allowed."),
10824 _ => write!(f, "{:?}", *self),
10825 }
10826 }
10827}
10828
10829#[derive(Debug, Clone, PartialEq, Eq)]
10830#[non_exhaustive] pub enum MoveIntoVaultError {
10832 IsSharedFolder,
10834 Other,
10837}
10838
10839impl<'de> ::serde::de::Deserialize<'de> for MoveIntoVaultError {
10840 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10841 use serde::de::{self, MapAccess, Visitor};
10843 struct EnumVisitor;
10844 impl<'de> Visitor<'de> for EnumVisitor {
10845 type Value = MoveIntoVaultError;
10846 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10847 f.write_str("a MoveIntoVaultError structure")
10848 }
10849 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10850 let tag: &str = match map.next_key()? {
10851 Some(".tag") => map.next_value()?,
10852 _ => return Err(de::Error::missing_field(".tag"))
10853 };
10854 let value = match tag {
10855 "is_shared_folder" => MoveIntoVaultError::IsSharedFolder,
10856 _ => MoveIntoVaultError::Other,
10857 };
10858 crate::eat_json_fields(&mut map)?;
10859 Ok(value)
10860 }
10861 }
10862 const VARIANTS: &[&str] = &["is_shared_folder",
10863 "other"];
10864 deserializer.deserialize_struct("MoveIntoVaultError", VARIANTS, EnumVisitor)
10865 }
10866}
10867
10868impl ::serde::ser::Serialize for MoveIntoVaultError {
10869 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10870 use serde::ser::SerializeStruct;
10872 match self {
10873 MoveIntoVaultError::IsSharedFolder => {
10874 let mut s = serializer.serialize_struct("MoveIntoVaultError", 1)?;
10876 s.serialize_field(".tag", "is_shared_folder")?;
10877 s.end()
10878 }
10879 MoveIntoVaultError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10880 }
10881 }
10882}
10883
10884impl ::std::error::Error for MoveIntoVaultError {
10885}
10886
10887impl ::std::fmt::Display for MoveIntoVaultError {
10888 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10889 match self {
10890 MoveIntoVaultError::IsSharedFolder => f.write_str("Moving shared folder into Vault is not allowed."),
10891 _ => write!(f, "{:?}", *self),
10892 }
10893 }
10894}
10895
10896#[derive(Debug, Clone, PartialEq, Eq)]
10897#[non_exhaustive] pub enum PaperContentError {
10899 InsufficientPermissions,
10901 ContentMalformed,
10903 DocLengthExceeded,
10905 ImageSizeExceeded,
10908 Other,
10911}
10912
10913impl<'de> ::serde::de::Deserialize<'de> for PaperContentError {
10914 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10915 use serde::de::{self, MapAccess, Visitor};
10917 struct EnumVisitor;
10918 impl<'de> Visitor<'de> for EnumVisitor {
10919 type Value = PaperContentError;
10920 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10921 f.write_str("a PaperContentError structure")
10922 }
10923 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10924 let tag: &str = match map.next_key()? {
10925 Some(".tag") => map.next_value()?,
10926 _ => return Err(de::Error::missing_field(".tag"))
10927 };
10928 let value = match tag {
10929 "insufficient_permissions" => PaperContentError::InsufficientPermissions,
10930 "content_malformed" => PaperContentError::ContentMalformed,
10931 "doc_length_exceeded" => PaperContentError::DocLengthExceeded,
10932 "image_size_exceeded" => PaperContentError::ImageSizeExceeded,
10933 _ => PaperContentError::Other,
10934 };
10935 crate::eat_json_fields(&mut map)?;
10936 Ok(value)
10937 }
10938 }
10939 const VARIANTS: &[&str] = &["insufficient_permissions",
10940 "content_malformed",
10941 "doc_length_exceeded",
10942 "image_size_exceeded",
10943 "other"];
10944 deserializer.deserialize_struct("PaperContentError", VARIANTS, EnumVisitor)
10945 }
10946}
10947
10948impl ::serde::ser::Serialize for PaperContentError {
10949 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10950 use serde::ser::SerializeStruct;
10952 match self {
10953 PaperContentError::InsufficientPermissions => {
10954 let mut s = serializer.serialize_struct("PaperContentError", 1)?;
10956 s.serialize_field(".tag", "insufficient_permissions")?;
10957 s.end()
10958 }
10959 PaperContentError::ContentMalformed => {
10960 let mut s = serializer.serialize_struct("PaperContentError", 1)?;
10962 s.serialize_field(".tag", "content_malformed")?;
10963 s.end()
10964 }
10965 PaperContentError::DocLengthExceeded => {
10966 let mut s = serializer.serialize_struct("PaperContentError", 1)?;
10968 s.serialize_field(".tag", "doc_length_exceeded")?;
10969 s.end()
10970 }
10971 PaperContentError::ImageSizeExceeded => {
10972 let mut s = serializer.serialize_struct("PaperContentError", 1)?;
10974 s.serialize_field(".tag", "image_size_exceeded")?;
10975 s.end()
10976 }
10977 PaperContentError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10978 }
10979 }
10980}
10981
10982impl ::std::error::Error for PaperContentError {
10983}
10984
10985impl ::std::fmt::Display for PaperContentError {
10986 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10987 match self {
10988 PaperContentError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
10989 PaperContentError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
10990 PaperContentError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
10991 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."),
10992 _ => write!(f, "{:?}", *self),
10993 }
10994 }
10995}
10996
10997#[derive(Debug, Clone, PartialEq, Eq)]
10998#[non_exhaustive] pub struct PaperCreateArg {
11000 pub path: Path,
11003 pub import_format: ImportFormat,
11005}
11006
11007impl PaperCreateArg {
11008 pub fn new(path: Path, import_format: ImportFormat) -> Self {
11009 PaperCreateArg {
11010 path,
11011 import_format,
11012 }
11013 }
11014}
11015
11016const PAPER_CREATE_ARG_FIELDS: &[&str] = &["path",
11017 "import_format"];
11018impl PaperCreateArg {
11019 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11020 map: V,
11021 ) -> Result<PaperCreateArg, V::Error> {
11022 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11023 }
11024
11025 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11026 mut map: V,
11027 optional: bool,
11028 ) -> Result<Option<PaperCreateArg>, V::Error> {
11029 let mut field_path = None;
11030 let mut field_import_format = None;
11031 let mut nothing = true;
11032 while let Some(key) = map.next_key::<&str>()? {
11033 nothing = false;
11034 match key {
11035 "path" => {
11036 if field_path.is_some() {
11037 return Err(::serde::de::Error::duplicate_field("path"));
11038 }
11039 field_path = Some(map.next_value()?);
11040 }
11041 "import_format" => {
11042 if field_import_format.is_some() {
11043 return Err(::serde::de::Error::duplicate_field("import_format"));
11044 }
11045 field_import_format = Some(map.next_value()?);
11046 }
11047 _ => {
11048 map.next_value::<::serde_json::Value>()?;
11050 }
11051 }
11052 }
11053 if optional && nothing {
11054 return Ok(None);
11055 }
11056 let result = PaperCreateArg {
11057 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
11058 import_format: field_import_format.ok_or_else(|| ::serde::de::Error::missing_field("import_format"))?,
11059 };
11060 Ok(Some(result))
11061 }
11062
11063 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11064 &self,
11065 s: &mut S::SerializeStruct,
11066 ) -> Result<(), S::Error> {
11067 use serde::ser::SerializeStruct;
11068 s.serialize_field("path", &self.path)?;
11069 s.serialize_field("import_format", &self.import_format)?;
11070 Ok(())
11071 }
11072}
11073
11074impl<'de> ::serde::de::Deserialize<'de> for PaperCreateArg {
11075 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11076 use serde::de::{MapAccess, Visitor};
11078 struct StructVisitor;
11079 impl<'de> Visitor<'de> for StructVisitor {
11080 type Value = PaperCreateArg;
11081 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11082 f.write_str("a PaperCreateArg struct")
11083 }
11084 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11085 PaperCreateArg::internal_deserialize(map)
11086 }
11087 }
11088 deserializer.deserialize_struct("PaperCreateArg", PAPER_CREATE_ARG_FIELDS, StructVisitor)
11089 }
11090}
11091
11092impl ::serde::ser::Serialize for PaperCreateArg {
11093 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11094 use serde::ser::SerializeStruct;
11096 let mut s = serializer.serialize_struct("PaperCreateArg", 2)?;
11097 self.internal_serialize::<S>(&mut s)?;
11098 s.end()
11099 }
11100}
11101
11102#[derive(Debug, Clone, PartialEq, Eq)]
11103#[non_exhaustive] pub enum PaperCreateError {
11105 InsufficientPermissions,
11107 ContentMalformed,
11109 DocLengthExceeded,
11111 ImageSizeExceeded,
11114 InvalidPath,
11116 EmailUnverified,
11118 InvalidFileExtension,
11120 PaperDisabled,
11122 Other,
11125}
11126
11127impl<'de> ::serde::de::Deserialize<'de> for PaperCreateError {
11128 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11129 use serde::de::{self, MapAccess, Visitor};
11131 struct EnumVisitor;
11132 impl<'de> Visitor<'de> for EnumVisitor {
11133 type Value = PaperCreateError;
11134 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11135 f.write_str("a PaperCreateError structure")
11136 }
11137 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11138 let tag: &str = match map.next_key()? {
11139 Some(".tag") => map.next_value()?,
11140 _ => return Err(de::Error::missing_field(".tag"))
11141 };
11142 let value = match tag {
11143 "insufficient_permissions" => PaperCreateError::InsufficientPermissions,
11144 "content_malformed" => PaperCreateError::ContentMalformed,
11145 "doc_length_exceeded" => PaperCreateError::DocLengthExceeded,
11146 "image_size_exceeded" => PaperCreateError::ImageSizeExceeded,
11147 "invalid_path" => PaperCreateError::InvalidPath,
11148 "email_unverified" => PaperCreateError::EmailUnverified,
11149 "invalid_file_extension" => PaperCreateError::InvalidFileExtension,
11150 "paper_disabled" => PaperCreateError::PaperDisabled,
11151 _ => PaperCreateError::Other,
11152 };
11153 crate::eat_json_fields(&mut map)?;
11154 Ok(value)
11155 }
11156 }
11157 const VARIANTS: &[&str] = &["insufficient_permissions",
11158 "content_malformed",
11159 "doc_length_exceeded",
11160 "image_size_exceeded",
11161 "other",
11162 "invalid_path",
11163 "email_unverified",
11164 "invalid_file_extension",
11165 "paper_disabled"];
11166 deserializer.deserialize_struct("PaperCreateError", VARIANTS, EnumVisitor)
11167 }
11168}
11169
11170impl ::serde::ser::Serialize for PaperCreateError {
11171 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11172 use serde::ser::SerializeStruct;
11174 match self {
11175 PaperCreateError::InsufficientPermissions => {
11176 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11178 s.serialize_field(".tag", "insufficient_permissions")?;
11179 s.end()
11180 }
11181 PaperCreateError::ContentMalformed => {
11182 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11184 s.serialize_field(".tag", "content_malformed")?;
11185 s.end()
11186 }
11187 PaperCreateError::DocLengthExceeded => {
11188 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11190 s.serialize_field(".tag", "doc_length_exceeded")?;
11191 s.end()
11192 }
11193 PaperCreateError::ImageSizeExceeded => {
11194 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11196 s.serialize_field(".tag", "image_size_exceeded")?;
11197 s.end()
11198 }
11199 PaperCreateError::InvalidPath => {
11200 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11202 s.serialize_field(".tag", "invalid_path")?;
11203 s.end()
11204 }
11205 PaperCreateError::EmailUnverified => {
11206 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11208 s.serialize_field(".tag", "email_unverified")?;
11209 s.end()
11210 }
11211 PaperCreateError::InvalidFileExtension => {
11212 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11214 s.serialize_field(".tag", "invalid_file_extension")?;
11215 s.end()
11216 }
11217 PaperCreateError::PaperDisabled => {
11218 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11220 s.serialize_field(".tag", "paper_disabled")?;
11221 s.end()
11222 }
11223 PaperCreateError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11224 }
11225 }
11226}
11227
11228impl ::std::error::Error for PaperCreateError {
11229}
11230
11231impl ::std::fmt::Display for PaperCreateError {
11232 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11233 match self {
11234 PaperCreateError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
11235 PaperCreateError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
11236 PaperCreateError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
11237 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."),
11238 PaperCreateError::InvalidPath => f.write_str("The file could not be saved to the specified location."),
11239 PaperCreateError::EmailUnverified => f.write_str("The user's email must be verified to create Paper docs."),
11240 PaperCreateError::InvalidFileExtension => f.write_str("The file path must end in .paper."),
11241 PaperCreateError::PaperDisabled => f.write_str("Paper is disabled for your team."),
11242 _ => write!(f, "{:?}", *self),
11243 }
11244 }
11245}
11246
11247impl From<PaperContentError> for PaperCreateError {
11249 fn from(parent: PaperContentError) -> Self {
11250 match parent {
11251 PaperContentError::InsufficientPermissions => PaperCreateError::InsufficientPermissions,
11252 PaperContentError::ContentMalformed => PaperCreateError::ContentMalformed,
11253 PaperContentError::DocLengthExceeded => PaperCreateError::DocLengthExceeded,
11254 PaperContentError::ImageSizeExceeded => PaperCreateError::ImageSizeExceeded,
11255 PaperContentError::Other => PaperCreateError::Other,
11256 }
11257 }
11258}
11259#[derive(Debug, Clone, PartialEq, Eq)]
11260#[non_exhaustive] pub struct PaperCreateResult {
11262 pub url: String,
11264 pub result_path: String,
11266 pub file_id: FileId,
11268 pub paper_revision: i64,
11270}
11271
11272impl PaperCreateResult {
11273 pub fn new(url: String, result_path: String, file_id: FileId, paper_revision: i64) -> Self {
11274 PaperCreateResult {
11275 url,
11276 result_path,
11277 file_id,
11278 paper_revision,
11279 }
11280 }
11281}
11282
11283const PAPER_CREATE_RESULT_FIELDS: &[&str] = &["url",
11284 "result_path",
11285 "file_id",
11286 "paper_revision"];
11287impl PaperCreateResult {
11288 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11289 map: V,
11290 ) -> Result<PaperCreateResult, V::Error> {
11291 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11292 }
11293
11294 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11295 mut map: V,
11296 optional: bool,
11297 ) -> Result<Option<PaperCreateResult>, V::Error> {
11298 let mut field_url = None;
11299 let mut field_result_path = None;
11300 let mut field_file_id = None;
11301 let mut field_paper_revision = None;
11302 let mut nothing = true;
11303 while let Some(key) = map.next_key::<&str>()? {
11304 nothing = false;
11305 match key {
11306 "url" => {
11307 if field_url.is_some() {
11308 return Err(::serde::de::Error::duplicate_field("url"));
11309 }
11310 field_url = Some(map.next_value()?);
11311 }
11312 "result_path" => {
11313 if field_result_path.is_some() {
11314 return Err(::serde::de::Error::duplicate_field("result_path"));
11315 }
11316 field_result_path = Some(map.next_value()?);
11317 }
11318 "file_id" => {
11319 if field_file_id.is_some() {
11320 return Err(::serde::de::Error::duplicate_field("file_id"));
11321 }
11322 field_file_id = Some(map.next_value()?);
11323 }
11324 "paper_revision" => {
11325 if field_paper_revision.is_some() {
11326 return Err(::serde::de::Error::duplicate_field("paper_revision"));
11327 }
11328 field_paper_revision = Some(map.next_value()?);
11329 }
11330 _ => {
11331 map.next_value::<::serde_json::Value>()?;
11333 }
11334 }
11335 }
11336 if optional && nothing {
11337 return Ok(None);
11338 }
11339 let result = PaperCreateResult {
11340 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
11341 result_path: field_result_path.ok_or_else(|| ::serde::de::Error::missing_field("result_path"))?,
11342 file_id: field_file_id.ok_or_else(|| ::serde::de::Error::missing_field("file_id"))?,
11343 paper_revision: field_paper_revision.ok_or_else(|| ::serde::de::Error::missing_field("paper_revision"))?,
11344 };
11345 Ok(Some(result))
11346 }
11347
11348 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11349 &self,
11350 s: &mut S::SerializeStruct,
11351 ) -> Result<(), S::Error> {
11352 use serde::ser::SerializeStruct;
11353 s.serialize_field("url", &self.url)?;
11354 s.serialize_field("result_path", &self.result_path)?;
11355 s.serialize_field("file_id", &self.file_id)?;
11356 s.serialize_field("paper_revision", &self.paper_revision)?;
11357 Ok(())
11358 }
11359}
11360
11361impl<'de> ::serde::de::Deserialize<'de> for PaperCreateResult {
11362 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11363 use serde::de::{MapAccess, Visitor};
11365 struct StructVisitor;
11366 impl<'de> Visitor<'de> for StructVisitor {
11367 type Value = PaperCreateResult;
11368 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11369 f.write_str("a PaperCreateResult struct")
11370 }
11371 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11372 PaperCreateResult::internal_deserialize(map)
11373 }
11374 }
11375 deserializer.deserialize_struct("PaperCreateResult", PAPER_CREATE_RESULT_FIELDS, StructVisitor)
11376 }
11377}
11378
11379impl ::serde::ser::Serialize for PaperCreateResult {
11380 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11381 use serde::ser::SerializeStruct;
11383 let mut s = serializer.serialize_struct("PaperCreateResult", 4)?;
11384 self.internal_serialize::<S>(&mut s)?;
11385 s.end()
11386 }
11387}
11388
11389#[derive(Debug, Clone, PartialEq, Eq)]
11390#[non_exhaustive] pub enum PaperDocUpdatePolicy {
11392 Update,
11395 Overwrite,
11397 Prepend,
11399 Append,
11401 Other,
11404}
11405
11406impl<'de> ::serde::de::Deserialize<'de> for PaperDocUpdatePolicy {
11407 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11408 use serde::de::{self, MapAccess, Visitor};
11410 struct EnumVisitor;
11411 impl<'de> Visitor<'de> for EnumVisitor {
11412 type Value = PaperDocUpdatePolicy;
11413 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11414 f.write_str("a PaperDocUpdatePolicy structure")
11415 }
11416 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11417 let tag: &str = match map.next_key()? {
11418 Some(".tag") => map.next_value()?,
11419 _ => return Err(de::Error::missing_field(".tag"))
11420 };
11421 let value = match tag {
11422 "update" => PaperDocUpdatePolicy::Update,
11423 "overwrite" => PaperDocUpdatePolicy::Overwrite,
11424 "prepend" => PaperDocUpdatePolicy::Prepend,
11425 "append" => PaperDocUpdatePolicy::Append,
11426 _ => PaperDocUpdatePolicy::Other,
11427 };
11428 crate::eat_json_fields(&mut map)?;
11429 Ok(value)
11430 }
11431 }
11432 const VARIANTS: &[&str] = &["update",
11433 "overwrite",
11434 "prepend",
11435 "append",
11436 "other"];
11437 deserializer.deserialize_struct("PaperDocUpdatePolicy", VARIANTS, EnumVisitor)
11438 }
11439}
11440
11441impl ::serde::ser::Serialize for PaperDocUpdatePolicy {
11442 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11443 use serde::ser::SerializeStruct;
11445 match self {
11446 PaperDocUpdatePolicy::Update => {
11447 let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11449 s.serialize_field(".tag", "update")?;
11450 s.end()
11451 }
11452 PaperDocUpdatePolicy::Overwrite => {
11453 let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11455 s.serialize_field(".tag", "overwrite")?;
11456 s.end()
11457 }
11458 PaperDocUpdatePolicy::Prepend => {
11459 let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11461 s.serialize_field(".tag", "prepend")?;
11462 s.end()
11463 }
11464 PaperDocUpdatePolicy::Append => {
11465 let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11467 s.serialize_field(".tag", "append")?;
11468 s.end()
11469 }
11470 PaperDocUpdatePolicy::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11471 }
11472 }
11473}
11474
11475#[derive(Debug, Clone, PartialEq, Eq)]
11476#[non_exhaustive] pub struct PaperUpdateArg {
11478 pub path: WritePathOrId,
11481 pub import_format: ImportFormat,
11483 pub doc_update_policy: PaperDocUpdatePolicy,
11485 pub paper_revision: Option<i64>,
11488}
11489
11490impl PaperUpdateArg {
11491 pub fn new(
11492 path: WritePathOrId,
11493 import_format: ImportFormat,
11494 doc_update_policy: PaperDocUpdatePolicy,
11495 ) -> Self {
11496 PaperUpdateArg {
11497 path,
11498 import_format,
11499 doc_update_policy,
11500 paper_revision: None,
11501 }
11502 }
11503
11504 pub fn with_paper_revision(mut self, value: i64) -> Self {
11505 self.paper_revision = Some(value);
11506 self
11507 }
11508}
11509
11510const PAPER_UPDATE_ARG_FIELDS: &[&str] = &["path",
11511 "import_format",
11512 "doc_update_policy",
11513 "paper_revision"];
11514impl PaperUpdateArg {
11515 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11516 map: V,
11517 ) -> Result<PaperUpdateArg, V::Error> {
11518 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11519 }
11520
11521 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11522 mut map: V,
11523 optional: bool,
11524 ) -> Result<Option<PaperUpdateArg>, V::Error> {
11525 let mut field_path = None;
11526 let mut field_import_format = None;
11527 let mut field_doc_update_policy = None;
11528 let mut field_paper_revision = None;
11529 let mut nothing = true;
11530 while let Some(key) = map.next_key::<&str>()? {
11531 nothing = false;
11532 match key {
11533 "path" => {
11534 if field_path.is_some() {
11535 return Err(::serde::de::Error::duplicate_field("path"));
11536 }
11537 field_path = Some(map.next_value()?);
11538 }
11539 "import_format" => {
11540 if field_import_format.is_some() {
11541 return Err(::serde::de::Error::duplicate_field("import_format"));
11542 }
11543 field_import_format = Some(map.next_value()?);
11544 }
11545 "doc_update_policy" => {
11546 if field_doc_update_policy.is_some() {
11547 return Err(::serde::de::Error::duplicate_field("doc_update_policy"));
11548 }
11549 field_doc_update_policy = Some(map.next_value()?);
11550 }
11551 "paper_revision" => {
11552 if field_paper_revision.is_some() {
11553 return Err(::serde::de::Error::duplicate_field("paper_revision"));
11554 }
11555 field_paper_revision = Some(map.next_value()?);
11556 }
11557 _ => {
11558 map.next_value::<::serde_json::Value>()?;
11560 }
11561 }
11562 }
11563 if optional && nothing {
11564 return Ok(None);
11565 }
11566 let result = PaperUpdateArg {
11567 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
11568 import_format: field_import_format.ok_or_else(|| ::serde::de::Error::missing_field("import_format"))?,
11569 doc_update_policy: field_doc_update_policy.ok_or_else(|| ::serde::de::Error::missing_field("doc_update_policy"))?,
11570 paper_revision: field_paper_revision.and_then(Option::flatten),
11571 };
11572 Ok(Some(result))
11573 }
11574
11575 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11576 &self,
11577 s: &mut S::SerializeStruct,
11578 ) -> Result<(), S::Error> {
11579 use serde::ser::SerializeStruct;
11580 s.serialize_field("path", &self.path)?;
11581 s.serialize_field("import_format", &self.import_format)?;
11582 s.serialize_field("doc_update_policy", &self.doc_update_policy)?;
11583 if let Some(val) = &self.paper_revision {
11584 s.serialize_field("paper_revision", val)?;
11585 }
11586 Ok(())
11587 }
11588}
11589
11590impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateArg {
11591 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11592 use serde::de::{MapAccess, Visitor};
11594 struct StructVisitor;
11595 impl<'de> Visitor<'de> for StructVisitor {
11596 type Value = PaperUpdateArg;
11597 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11598 f.write_str("a PaperUpdateArg struct")
11599 }
11600 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11601 PaperUpdateArg::internal_deserialize(map)
11602 }
11603 }
11604 deserializer.deserialize_struct("PaperUpdateArg", PAPER_UPDATE_ARG_FIELDS, StructVisitor)
11605 }
11606}
11607
11608impl ::serde::ser::Serialize for PaperUpdateArg {
11609 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11610 use serde::ser::SerializeStruct;
11612 let mut s = serializer.serialize_struct("PaperUpdateArg", 4)?;
11613 self.internal_serialize::<S>(&mut s)?;
11614 s.end()
11615 }
11616}
11617
11618#[derive(Debug, Clone, PartialEq, Eq)]
11619#[non_exhaustive] pub enum PaperUpdateError {
11621 InsufficientPermissions,
11623 ContentMalformed,
11625 DocLengthExceeded,
11627 ImageSizeExceeded,
11630 Path(LookupError),
11631 RevisionMismatch,
11633 DocArchived,
11635 DocDeleted,
11637 Other,
11640}
11641
11642impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateError {
11643 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11644 use serde::de::{self, MapAccess, Visitor};
11646 struct EnumVisitor;
11647 impl<'de> Visitor<'de> for EnumVisitor {
11648 type Value = PaperUpdateError;
11649 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11650 f.write_str("a PaperUpdateError structure")
11651 }
11652 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11653 let tag: &str = match map.next_key()? {
11654 Some(".tag") => map.next_value()?,
11655 _ => return Err(de::Error::missing_field(".tag"))
11656 };
11657 let value = match tag {
11658 "insufficient_permissions" => PaperUpdateError::InsufficientPermissions,
11659 "content_malformed" => PaperUpdateError::ContentMalformed,
11660 "doc_length_exceeded" => PaperUpdateError::DocLengthExceeded,
11661 "image_size_exceeded" => PaperUpdateError::ImageSizeExceeded,
11662 "path" => {
11663 match map.next_key()? {
11664 Some("path") => PaperUpdateError::Path(map.next_value()?),
11665 None => return Err(de::Error::missing_field("path")),
11666 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
11667 }
11668 }
11669 "revision_mismatch" => PaperUpdateError::RevisionMismatch,
11670 "doc_archived" => PaperUpdateError::DocArchived,
11671 "doc_deleted" => PaperUpdateError::DocDeleted,
11672 _ => PaperUpdateError::Other,
11673 };
11674 crate::eat_json_fields(&mut map)?;
11675 Ok(value)
11676 }
11677 }
11678 const VARIANTS: &[&str] = &["insufficient_permissions",
11679 "content_malformed",
11680 "doc_length_exceeded",
11681 "image_size_exceeded",
11682 "other",
11683 "path",
11684 "revision_mismatch",
11685 "doc_archived",
11686 "doc_deleted"];
11687 deserializer.deserialize_struct("PaperUpdateError", VARIANTS, EnumVisitor)
11688 }
11689}
11690
11691impl ::serde::ser::Serialize for PaperUpdateError {
11692 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11693 use serde::ser::SerializeStruct;
11695 match self {
11696 PaperUpdateError::InsufficientPermissions => {
11697 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11699 s.serialize_field(".tag", "insufficient_permissions")?;
11700 s.end()
11701 }
11702 PaperUpdateError::ContentMalformed => {
11703 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11705 s.serialize_field(".tag", "content_malformed")?;
11706 s.end()
11707 }
11708 PaperUpdateError::DocLengthExceeded => {
11709 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11711 s.serialize_field(".tag", "doc_length_exceeded")?;
11712 s.end()
11713 }
11714 PaperUpdateError::ImageSizeExceeded => {
11715 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11717 s.serialize_field(".tag", "image_size_exceeded")?;
11718 s.end()
11719 }
11720 PaperUpdateError::Path(x) => {
11721 let mut s = serializer.serialize_struct("PaperUpdateError", 2)?;
11723 s.serialize_field(".tag", "path")?;
11724 s.serialize_field("path", x)?;
11725 s.end()
11726 }
11727 PaperUpdateError::RevisionMismatch => {
11728 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11730 s.serialize_field(".tag", "revision_mismatch")?;
11731 s.end()
11732 }
11733 PaperUpdateError::DocArchived => {
11734 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11736 s.serialize_field(".tag", "doc_archived")?;
11737 s.end()
11738 }
11739 PaperUpdateError::DocDeleted => {
11740 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11742 s.serialize_field(".tag", "doc_deleted")?;
11743 s.end()
11744 }
11745 PaperUpdateError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11746 }
11747 }
11748}
11749
11750impl ::std::error::Error for PaperUpdateError {
11751 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
11752 match self {
11753 PaperUpdateError::Path(inner) => Some(inner),
11754 _ => None,
11755 }
11756 }
11757}
11758
11759impl ::std::fmt::Display for PaperUpdateError {
11760 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11761 match self {
11762 PaperUpdateError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
11763 PaperUpdateError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
11764 PaperUpdateError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
11765 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."),
11766 PaperUpdateError::Path(inner) => write!(f, "PaperUpdateError: {}", inner),
11767 PaperUpdateError::RevisionMismatch => f.write_str("The provided revision does not match the document head."),
11768 PaperUpdateError::DocArchived => f.write_str("This operation is not allowed on archived Paper docs."),
11769 PaperUpdateError::DocDeleted => f.write_str("This operation is not allowed on deleted Paper docs."),
11770 _ => write!(f, "{:?}", *self),
11771 }
11772 }
11773}
11774
11775impl From<PaperContentError> for PaperUpdateError {
11777 fn from(parent: PaperContentError) -> Self {
11778 match parent {
11779 PaperContentError::InsufficientPermissions => PaperUpdateError::InsufficientPermissions,
11780 PaperContentError::ContentMalformed => PaperUpdateError::ContentMalformed,
11781 PaperContentError::DocLengthExceeded => PaperUpdateError::DocLengthExceeded,
11782 PaperContentError::ImageSizeExceeded => PaperUpdateError::ImageSizeExceeded,
11783 PaperContentError::Other => PaperUpdateError::Other,
11784 }
11785 }
11786}
11787#[derive(Debug, Clone, PartialEq, Eq)]
11788#[non_exhaustive] pub struct PaperUpdateResult {
11790 pub paper_revision: i64,
11792}
11793
11794impl PaperUpdateResult {
11795 pub fn new(paper_revision: i64) -> Self {
11796 PaperUpdateResult {
11797 paper_revision,
11798 }
11799 }
11800}
11801
11802const PAPER_UPDATE_RESULT_FIELDS: &[&str] = &["paper_revision"];
11803impl PaperUpdateResult {
11804 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11805 map: V,
11806 ) -> Result<PaperUpdateResult, V::Error> {
11807 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11808 }
11809
11810 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11811 mut map: V,
11812 optional: bool,
11813 ) -> Result<Option<PaperUpdateResult>, V::Error> {
11814 let mut field_paper_revision = None;
11815 let mut nothing = true;
11816 while let Some(key) = map.next_key::<&str>()? {
11817 nothing = false;
11818 match key {
11819 "paper_revision" => {
11820 if field_paper_revision.is_some() {
11821 return Err(::serde::de::Error::duplicate_field("paper_revision"));
11822 }
11823 field_paper_revision = Some(map.next_value()?);
11824 }
11825 _ => {
11826 map.next_value::<::serde_json::Value>()?;
11828 }
11829 }
11830 }
11831 if optional && nothing {
11832 return Ok(None);
11833 }
11834 let result = PaperUpdateResult {
11835 paper_revision: field_paper_revision.ok_or_else(|| ::serde::de::Error::missing_field("paper_revision"))?,
11836 };
11837 Ok(Some(result))
11838 }
11839
11840 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11841 &self,
11842 s: &mut S::SerializeStruct,
11843 ) -> Result<(), S::Error> {
11844 use serde::ser::SerializeStruct;
11845 s.serialize_field("paper_revision", &self.paper_revision)?;
11846 Ok(())
11847 }
11848}
11849
11850impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateResult {
11851 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11852 use serde::de::{MapAccess, Visitor};
11854 struct StructVisitor;
11855 impl<'de> Visitor<'de> for StructVisitor {
11856 type Value = PaperUpdateResult;
11857 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11858 f.write_str("a PaperUpdateResult struct")
11859 }
11860 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11861 PaperUpdateResult::internal_deserialize(map)
11862 }
11863 }
11864 deserializer.deserialize_struct("PaperUpdateResult", PAPER_UPDATE_RESULT_FIELDS, StructVisitor)
11865 }
11866}
11867
11868impl ::serde::ser::Serialize for PaperUpdateResult {
11869 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11870 use serde::ser::SerializeStruct;
11872 let mut s = serializer.serialize_struct("PaperUpdateResult", 1)?;
11873 self.internal_serialize::<S>(&mut s)?;
11874 s.end()
11875 }
11876}
11877
11878#[derive(Debug, Clone, PartialEq, Eq)]
11879#[non_exhaustive] pub enum PathOrLink {
11881 Path(ReadPath),
11882 Link(SharedLinkFileInfo),
11883 Other,
11886}
11887
11888impl<'de> ::serde::de::Deserialize<'de> for PathOrLink {
11889 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11890 use serde::de::{self, MapAccess, Visitor};
11892 struct EnumVisitor;
11893 impl<'de> Visitor<'de> for EnumVisitor {
11894 type Value = PathOrLink;
11895 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11896 f.write_str("a PathOrLink structure")
11897 }
11898 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11899 let tag: &str = match map.next_key()? {
11900 Some(".tag") => map.next_value()?,
11901 _ => return Err(de::Error::missing_field(".tag"))
11902 };
11903 let value = match tag {
11904 "path" => {
11905 match map.next_key()? {
11906 Some("path") => PathOrLink::Path(map.next_value()?),
11907 None => return Err(de::Error::missing_field("path")),
11908 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
11909 }
11910 }
11911 "link" => PathOrLink::Link(SharedLinkFileInfo::internal_deserialize(&mut map)?),
11912 _ => PathOrLink::Other,
11913 };
11914 crate::eat_json_fields(&mut map)?;
11915 Ok(value)
11916 }
11917 }
11918 const VARIANTS: &[&str] = &["path",
11919 "link",
11920 "other"];
11921 deserializer.deserialize_struct("PathOrLink", VARIANTS, EnumVisitor)
11922 }
11923}
11924
11925impl ::serde::ser::Serialize for PathOrLink {
11926 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11927 use serde::ser::SerializeStruct;
11929 match self {
11930 PathOrLink::Path(x) => {
11931 let mut s = serializer.serialize_struct("PathOrLink", 2)?;
11933 s.serialize_field(".tag", "path")?;
11934 s.serialize_field("path", x)?;
11935 s.end()
11936 }
11937 PathOrLink::Link(x) => {
11938 let mut s = serializer.serialize_struct("PathOrLink", 4)?;
11940 s.serialize_field(".tag", "link")?;
11941 x.internal_serialize::<S>(&mut s)?;
11942 s.end()
11943 }
11944 PathOrLink::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11945 }
11946 }
11947}
11948
11949#[derive(Debug, Clone, PartialEq, Eq)]
11950#[non_exhaustive] pub struct PathToTags {
11952 pub path: Path,
11954 pub tags: Vec<Tag>,
11956}
11957
11958impl PathToTags {
11959 pub fn new(path: Path, tags: Vec<Tag>) -> Self {
11960 PathToTags {
11961 path,
11962 tags,
11963 }
11964 }
11965}
11966
11967const PATH_TO_TAGS_FIELDS: &[&str] = &["path",
11968 "tags"];
11969impl PathToTags {
11970 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11971 map: V,
11972 ) -> Result<PathToTags, V::Error> {
11973 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11974 }
11975
11976 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11977 mut map: V,
11978 optional: bool,
11979 ) -> Result<Option<PathToTags>, V::Error> {
11980 let mut field_path = None;
11981 let mut field_tags = None;
11982 let mut nothing = true;
11983 while let Some(key) = map.next_key::<&str>()? {
11984 nothing = false;
11985 match key {
11986 "path" => {
11987 if field_path.is_some() {
11988 return Err(::serde::de::Error::duplicate_field("path"));
11989 }
11990 field_path = Some(map.next_value()?);
11991 }
11992 "tags" => {
11993 if field_tags.is_some() {
11994 return Err(::serde::de::Error::duplicate_field("tags"));
11995 }
11996 field_tags = Some(map.next_value()?);
11997 }
11998 _ => {
11999 map.next_value::<::serde_json::Value>()?;
12001 }
12002 }
12003 }
12004 if optional && nothing {
12005 return Ok(None);
12006 }
12007 let result = PathToTags {
12008 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
12009 tags: field_tags.ok_or_else(|| ::serde::de::Error::missing_field("tags"))?,
12010 };
12011 Ok(Some(result))
12012 }
12013
12014 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12015 &self,
12016 s: &mut S::SerializeStruct,
12017 ) -> Result<(), S::Error> {
12018 use serde::ser::SerializeStruct;
12019 s.serialize_field("path", &self.path)?;
12020 s.serialize_field("tags", &self.tags)?;
12021 Ok(())
12022 }
12023}
12024
12025impl<'de> ::serde::de::Deserialize<'de> for PathToTags {
12026 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12027 use serde::de::{MapAccess, Visitor};
12029 struct StructVisitor;
12030 impl<'de> Visitor<'de> for StructVisitor {
12031 type Value = PathToTags;
12032 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12033 f.write_str("a PathToTags struct")
12034 }
12035 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12036 PathToTags::internal_deserialize(map)
12037 }
12038 }
12039 deserializer.deserialize_struct("PathToTags", PATH_TO_TAGS_FIELDS, StructVisitor)
12040 }
12041}
12042
12043impl ::serde::ser::Serialize for PathToTags {
12044 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12045 use serde::ser::SerializeStruct;
12047 let mut s = serializer.serialize_struct("PathToTags", 2)?;
12048 self.internal_serialize::<S>(&mut s)?;
12049 s.end()
12050 }
12051}
12052
12053#[derive(Debug, Clone, PartialEq, Default)]
12055#[non_exhaustive] pub struct PhotoMetadata {
12057 pub dimensions: Option<Dimensions>,
12059 pub location: Option<GpsCoordinates>,
12061 pub time_taken: Option<crate::types::common::DropboxTimestamp>,
12063}
12064
12065impl PhotoMetadata {
12066 pub fn with_dimensions(mut self, value: Dimensions) -> Self {
12067 self.dimensions = Some(value);
12068 self
12069 }
12070
12071 pub fn with_location(mut self, value: GpsCoordinates) -> Self {
12072 self.location = Some(value);
12073 self
12074 }
12075
12076 pub fn with_time_taken(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
12077 self.time_taken = Some(value);
12078 self
12079 }
12080}
12081
12082const PHOTO_METADATA_FIELDS: &[&str] = &["dimensions",
12083 "location",
12084 "time_taken"];
12085impl PhotoMetadata {
12086 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12088 mut map: V,
12089 ) -> Result<PhotoMetadata, V::Error> {
12090 let mut field_dimensions = None;
12091 let mut field_location = None;
12092 let mut field_time_taken = None;
12093 while let Some(key) = map.next_key::<&str>()? {
12094 match key {
12095 "dimensions" => {
12096 if field_dimensions.is_some() {
12097 return Err(::serde::de::Error::duplicate_field("dimensions"));
12098 }
12099 field_dimensions = Some(map.next_value()?);
12100 }
12101 "location" => {
12102 if field_location.is_some() {
12103 return Err(::serde::de::Error::duplicate_field("location"));
12104 }
12105 field_location = Some(map.next_value()?);
12106 }
12107 "time_taken" => {
12108 if field_time_taken.is_some() {
12109 return Err(::serde::de::Error::duplicate_field("time_taken"));
12110 }
12111 field_time_taken = Some(map.next_value()?);
12112 }
12113 _ => {
12114 map.next_value::<::serde_json::Value>()?;
12116 }
12117 }
12118 }
12119 let result = PhotoMetadata {
12120 dimensions: field_dimensions.and_then(Option::flatten),
12121 location: field_location.and_then(Option::flatten),
12122 time_taken: field_time_taken.and_then(Option::flatten),
12123 };
12124 Ok(result)
12125 }
12126
12127 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12128 &self,
12129 s: &mut S::SerializeStruct,
12130 ) -> Result<(), S::Error> {
12131 use serde::ser::SerializeStruct;
12132 if let Some(val) = &self.dimensions {
12133 s.serialize_field("dimensions", val)?;
12134 }
12135 if let Some(val) = &self.location {
12136 s.serialize_field("location", val)?;
12137 }
12138 if let Some(val) = &self.time_taken {
12139 s.serialize_field("time_taken", val)?;
12140 }
12141 Ok(())
12142 }
12143}
12144
12145impl<'de> ::serde::de::Deserialize<'de> for PhotoMetadata {
12146 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12147 use serde::de::{MapAccess, Visitor};
12149 struct StructVisitor;
12150 impl<'de> Visitor<'de> for StructVisitor {
12151 type Value = PhotoMetadata;
12152 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12153 f.write_str("a PhotoMetadata struct")
12154 }
12155 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12156 PhotoMetadata::internal_deserialize(map)
12157 }
12158 }
12159 deserializer.deserialize_struct("PhotoMetadata", PHOTO_METADATA_FIELDS, StructVisitor)
12160 }
12161}
12162
12163impl ::serde::ser::Serialize for PhotoMetadata {
12164 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12165 use serde::ser::SerializeStruct;
12167 let mut s = serializer.serialize_struct("PhotoMetadata", 3)?;
12168 self.internal_serialize::<S>(&mut s)?;
12169 s.end()
12170 }
12171}
12172
12173impl From<PhotoMetadata> for MediaMetadata {
12175 fn from(subtype: PhotoMetadata) -> Self {
12176 MediaMetadata::Photo(subtype)
12177 }
12178}
12179#[derive(Debug, Clone, PartialEq, Eq)]
12180#[non_exhaustive] pub struct PreviewArg {
12182 pub path: ReadPath,
12184 pub rev: Option<Rev>,
12186}
12187
12188impl PreviewArg {
12189 pub fn new(path: ReadPath) -> Self {
12190 PreviewArg {
12191 path,
12192 rev: None,
12193 }
12194 }
12195
12196 pub fn with_rev(mut self, value: Rev) -> Self {
12197 self.rev = Some(value);
12198 self
12199 }
12200}
12201
12202const PREVIEW_ARG_FIELDS: &[&str] = &["path",
12203 "rev"];
12204impl PreviewArg {
12205 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12206 map: V,
12207 ) -> Result<PreviewArg, V::Error> {
12208 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12209 }
12210
12211 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12212 mut map: V,
12213 optional: bool,
12214 ) -> Result<Option<PreviewArg>, V::Error> {
12215 let mut field_path = None;
12216 let mut field_rev = None;
12217 let mut nothing = true;
12218 while let Some(key) = map.next_key::<&str>()? {
12219 nothing = false;
12220 match key {
12221 "path" => {
12222 if field_path.is_some() {
12223 return Err(::serde::de::Error::duplicate_field("path"));
12224 }
12225 field_path = Some(map.next_value()?);
12226 }
12227 "rev" => {
12228 if field_rev.is_some() {
12229 return Err(::serde::de::Error::duplicate_field("rev"));
12230 }
12231 field_rev = Some(map.next_value()?);
12232 }
12233 _ => {
12234 map.next_value::<::serde_json::Value>()?;
12236 }
12237 }
12238 }
12239 if optional && nothing {
12240 return Ok(None);
12241 }
12242 let result = PreviewArg {
12243 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
12244 rev: field_rev.and_then(Option::flatten),
12245 };
12246 Ok(Some(result))
12247 }
12248
12249 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12250 &self,
12251 s: &mut S::SerializeStruct,
12252 ) -> Result<(), S::Error> {
12253 use serde::ser::SerializeStruct;
12254 s.serialize_field("path", &self.path)?;
12255 if let Some(val) = &self.rev {
12256 s.serialize_field("rev", val)?;
12257 }
12258 Ok(())
12259 }
12260}
12261
12262impl<'de> ::serde::de::Deserialize<'de> for PreviewArg {
12263 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12264 use serde::de::{MapAccess, Visitor};
12266 struct StructVisitor;
12267 impl<'de> Visitor<'de> for StructVisitor {
12268 type Value = PreviewArg;
12269 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12270 f.write_str("a PreviewArg struct")
12271 }
12272 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12273 PreviewArg::internal_deserialize(map)
12274 }
12275 }
12276 deserializer.deserialize_struct("PreviewArg", PREVIEW_ARG_FIELDS, StructVisitor)
12277 }
12278}
12279
12280impl ::serde::ser::Serialize for PreviewArg {
12281 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12282 use serde::ser::SerializeStruct;
12284 let mut s = serializer.serialize_struct("PreviewArg", 2)?;
12285 self.internal_serialize::<S>(&mut s)?;
12286 s.end()
12287 }
12288}
12289
12290#[derive(Debug, Clone, PartialEq, Eq)]
12291pub enum PreviewError {
12292 Path(LookupError),
12294 InProgress,
12296 UnsupportedExtension,
12298 UnsupportedContent,
12300}
12301
12302impl<'de> ::serde::de::Deserialize<'de> for PreviewError {
12303 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12304 use serde::de::{self, MapAccess, Visitor};
12306 struct EnumVisitor;
12307 impl<'de> Visitor<'de> for EnumVisitor {
12308 type Value = PreviewError;
12309 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12310 f.write_str("a PreviewError structure")
12311 }
12312 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
12313 let tag: &str = match map.next_key()? {
12314 Some(".tag") => map.next_value()?,
12315 _ => return Err(de::Error::missing_field(".tag"))
12316 };
12317 let value = match tag {
12318 "path" => {
12319 match map.next_key()? {
12320 Some("path") => PreviewError::Path(map.next_value()?),
12321 None => return Err(de::Error::missing_field("path")),
12322 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
12323 }
12324 }
12325 "in_progress" => PreviewError::InProgress,
12326 "unsupported_extension" => PreviewError::UnsupportedExtension,
12327 "unsupported_content" => PreviewError::UnsupportedContent,
12328 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
12329 };
12330 crate::eat_json_fields(&mut map)?;
12331 Ok(value)
12332 }
12333 }
12334 const VARIANTS: &[&str] = &["path",
12335 "in_progress",
12336 "unsupported_extension",
12337 "unsupported_content"];
12338 deserializer.deserialize_struct("PreviewError", VARIANTS, EnumVisitor)
12339 }
12340}
12341
12342impl ::serde::ser::Serialize for PreviewError {
12343 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12344 use serde::ser::SerializeStruct;
12346 match self {
12347 PreviewError::Path(x) => {
12348 let mut s = serializer.serialize_struct("PreviewError", 2)?;
12350 s.serialize_field(".tag", "path")?;
12351 s.serialize_field("path", x)?;
12352 s.end()
12353 }
12354 PreviewError::InProgress => {
12355 let mut s = serializer.serialize_struct("PreviewError", 1)?;
12357 s.serialize_field(".tag", "in_progress")?;
12358 s.end()
12359 }
12360 PreviewError::UnsupportedExtension => {
12361 let mut s = serializer.serialize_struct("PreviewError", 1)?;
12363 s.serialize_field(".tag", "unsupported_extension")?;
12364 s.end()
12365 }
12366 PreviewError::UnsupportedContent => {
12367 let mut s = serializer.serialize_struct("PreviewError", 1)?;
12369 s.serialize_field(".tag", "unsupported_content")?;
12370 s.end()
12371 }
12372 }
12373 }
12374}
12375
12376impl ::std::error::Error for PreviewError {
12377 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
12378 match self {
12379 PreviewError::Path(inner) => Some(inner),
12380 _ => None,
12381 }
12382 }
12383}
12384
12385impl ::std::fmt::Display for PreviewError {
12386 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12387 match self {
12388 PreviewError::Path(inner) => write!(f, "An error occurs when downloading metadata for the file: {}", inner),
12389 PreviewError::InProgress => f.write_str("This preview generation is still in progress and the file is not ready for preview yet."),
12390 PreviewError::UnsupportedExtension => f.write_str("The file extension is not supported preview generation."),
12391 PreviewError::UnsupportedContent => f.write_str("The file content is not supported for preview generation."),
12392 }
12393 }
12394}
12395
12396#[derive(Debug, Clone, PartialEq, Default)]
12397#[non_exhaustive] pub struct PreviewResult {
12399 pub file_metadata: Option<FileMetadata>,
12402 pub link_metadata: Option<MinimalFileLinkMetadata>,
12405}
12406
12407impl PreviewResult {
12408 pub fn with_file_metadata(mut self, value: FileMetadata) -> Self {
12409 self.file_metadata = Some(value);
12410 self
12411 }
12412
12413 pub fn with_link_metadata(mut self, value: MinimalFileLinkMetadata) -> Self {
12414 self.link_metadata = Some(value);
12415 self
12416 }
12417}
12418
12419const PREVIEW_RESULT_FIELDS: &[&str] = &["file_metadata",
12420 "link_metadata"];
12421impl PreviewResult {
12422 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12424 mut map: V,
12425 ) -> Result<PreviewResult, V::Error> {
12426 let mut field_file_metadata = None;
12427 let mut field_link_metadata = None;
12428 while let Some(key) = map.next_key::<&str>()? {
12429 match key {
12430 "file_metadata" => {
12431 if field_file_metadata.is_some() {
12432 return Err(::serde::de::Error::duplicate_field("file_metadata"));
12433 }
12434 field_file_metadata = Some(map.next_value()?);
12435 }
12436 "link_metadata" => {
12437 if field_link_metadata.is_some() {
12438 return Err(::serde::de::Error::duplicate_field("link_metadata"));
12439 }
12440 field_link_metadata = Some(map.next_value()?);
12441 }
12442 _ => {
12443 map.next_value::<::serde_json::Value>()?;
12445 }
12446 }
12447 }
12448 let result = PreviewResult {
12449 file_metadata: field_file_metadata.and_then(Option::flatten),
12450 link_metadata: field_link_metadata.and_then(Option::flatten),
12451 };
12452 Ok(result)
12453 }
12454
12455 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12456 &self,
12457 s: &mut S::SerializeStruct,
12458 ) -> Result<(), S::Error> {
12459 use serde::ser::SerializeStruct;
12460 if let Some(val) = &self.file_metadata {
12461 s.serialize_field("file_metadata", val)?;
12462 }
12463 if let Some(val) = &self.link_metadata {
12464 s.serialize_field("link_metadata", val)?;
12465 }
12466 Ok(())
12467 }
12468}
12469
12470impl<'de> ::serde::de::Deserialize<'de> for PreviewResult {
12471 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12472 use serde::de::{MapAccess, Visitor};
12474 struct StructVisitor;
12475 impl<'de> Visitor<'de> for StructVisitor {
12476 type Value = PreviewResult;
12477 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12478 f.write_str("a PreviewResult struct")
12479 }
12480 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12481 PreviewResult::internal_deserialize(map)
12482 }
12483 }
12484 deserializer.deserialize_struct("PreviewResult", PREVIEW_RESULT_FIELDS, StructVisitor)
12485 }
12486}
12487
12488impl ::serde::ser::Serialize for PreviewResult {
12489 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12490 use serde::ser::SerializeStruct;
12492 let mut s = serializer.serialize_struct("PreviewResult", 2)?;
12493 self.internal_serialize::<S>(&mut s)?;
12494 s.end()
12495 }
12496}
12497
12498#[derive(Debug, Clone, PartialEq, Eq)]
12499#[non_exhaustive] pub struct RelocationArg {
12501 pub from_path: WritePathOrId,
12503 pub to_path: WritePathOrId,
12505 pub allow_shared_folder: bool,
12507 pub autorename: bool,
12510 pub allow_ownership_transfer: bool,
12513}
12514
12515impl RelocationArg {
12516 pub fn new(from_path: WritePathOrId, to_path: WritePathOrId) -> Self {
12517 RelocationArg {
12518 from_path,
12519 to_path,
12520 allow_shared_folder: false,
12521 autorename: false,
12522 allow_ownership_transfer: false,
12523 }
12524 }
12525
12526 pub fn with_allow_shared_folder(mut self, value: bool) -> Self {
12527 self.allow_shared_folder = value;
12528 self
12529 }
12530
12531 pub fn with_autorename(mut self, value: bool) -> Self {
12532 self.autorename = value;
12533 self
12534 }
12535
12536 pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
12537 self.allow_ownership_transfer = value;
12538 self
12539 }
12540}
12541
12542const RELOCATION_ARG_FIELDS: &[&str] = &["from_path",
12543 "to_path",
12544 "allow_shared_folder",
12545 "autorename",
12546 "allow_ownership_transfer"];
12547impl RelocationArg {
12548 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12549 map: V,
12550 ) -> Result<RelocationArg, V::Error> {
12551 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12552 }
12553
12554 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12555 mut map: V,
12556 optional: bool,
12557 ) -> Result<Option<RelocationArg>, V::Error> {
12558 let mut field_from_path = None;
12559 let mut field_to_path = None;
12560 let mut field_allow_shared_folder = None;
12561 let mut field_autorename = None;
12562 let mut field_allow_ownership_transfer = None;
12563 let mut nothing = true;
12564 while let Some(key) = map.next_key::<&str>()? {
12565 nothing = false;
12566 match key {
12567 "from_path" => {
12568 if field_from_path.is_some() {
12569 return Err(::serde::de::Error::duplicate_field("from_path"));
12570 }
12571 field_from_path = Some(map.next_value()?);
12572 }
12573 "to_path" => {
12574 if field_to_path.is_some() {
12575 return Err(::serde::de::Error::duplicate_field("to_path"));
12576 }
12577 field_to_path = Some(map.next_value()?);
12578 }
12579 "allow_shared_folder" => {
12580 if field_allow_shared_folder.is_some() {
12581 return Err(::serde::de::Error::duplicate_field("allow_shared_folder"));
12582 }
12583 field_allow_shared_folder = Some(map.next_value()?);
12584 }
12585 "autorename" => {
12586 if field_autorename.is_some() {
12587 return Err(::serde::de::Error::duplicate_field("autorename"));
12588 }
12589 field_autorename = Some(map.next_value()?);
12590 }
12591 "allow_ownership_transfer" => {
12592 if field_allow_ownership_transfer.is_some() {
12593 return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
12594 }
12595 field_allow_ownership_transfer = Some(map.next_value()?);
12596 }
12597 _ => {
12598 map.next_value::<::serde_json::Value>()?;
12600 }
12601 }
12602 }
12603 if optional && nothing {
12604 return Ok(None);
12605 }
12606 let result = RelocationArg {
12607 from_path: field_from_path.ok_or_else(|| ::serde::de::Error::missing_field("from_path"))?,
12608 to_path: field_to_path.ok_or_else(|| ::serde::de::Error::missing_field("to_path"))?,
12609 allow_shared_folder: field_allow_shared_folder.unwrap_or(false),
12610 autorename: field_autorename.unwrap_or(false),
12611 allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
12612 };
12613 Ok(Some(result))
12614 }
12615
12616 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12617 &self,
12618 s: &mut S::SerializeStruct,
12619 ) -> Result<(), S::Error> {
12620 use serde::ser::SerializeStruct;
12621 s.serialize_field("from_path", &self.from_path)?;
12622 s.serialize_field("to_path", &self.to_path)?;
12623 if self.allow_shared_folder {
12624 s.serialize_field("allow_shared_folder", &self.allow_shared_folder)?;
12625 }
12626 if self.autorename {
12627 s.serialize_field("autorename", &self.autorename)?;
12628 }
12629 if self.allow_ownership_transfer {
12630 s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
12631 }
12632 Ok(())
12633 }
12634}
12635
12636impl<'de> ::serde::de::Deserialize<'de> for RelocationArg {
12637 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12638 use serde::de::{MapAccess, Visitor};
12640 struct StructVisitor;
12641 impl<'de> Visitor<'de> for StructVisitor {
12642 type Value = RelocationArg;
12643 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12644 f.write_str("a RelocationArg struct")
12645 }
12646 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12647 RelocationArg::internal_deserialize(map)
12648 }
12649 }
12650 deserializer.deserialize_struct("RelocationArg", RELOCATION_ARG_FIELDS, StructVisitor)
12651 }
12652}
12653
12654impl ::serde::ser::Serialize for RelocationArg {
12655 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12656 use serde::ser::SerializeStruct;
12658 let mut s = serializer.serialize_struct("RelocationArg", 5)?;
12659 self.internal_serialize::<S>(&mut s)?;
12660 s.end()
12661 }
12662}
12663
12664impl From<RelocationArg> for RelocationPath {
12666 fn from(subtype: RelocationArg) -> Self {
12667 Self {
12668 from_path: subtype.from_path,
12669 to_path: subtype.to_path,
12670 }
12671 }
12672}
12673#[derive(Debug, Clone, PartialEq, Eq)]
12674#[non_exhaustive] pub struct RelocationBatchArg {
12676 pub entries: Vec<RelocationPath>,
12678 pub autorename: bool,
12681 pub allow_shared_folder: bool,
12683 pub allow_ownership_transfer: bool,
12686}
12687
12688impl RelocationBatchArg {
12689 pub fn new(entries: Vec<RelocationPath>) -> Self {
12690 RelocationBatchArg {
12691 entries,
12692 autorename: false,
12693 allow_shared_folder: false,
12694 allow_ownership_transfer: false,
12695 }
12696 }
12697
12698 pub fn with_autorename(mut self, value: bool) -> Self {
12699 self.autorename = value;
12700 self
12701 }
12702
12703 pub fn with_allow_shared_folder(mut self, value: bool) -> Self {
12704 self.allow_shared_folder = value;
12705 self
12706 }
12707
12708 pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
12709 self.allow_ownership_transfer = value;
12710 self
12711 }
12712}
12713
12714const RELOCATION_BATCH_ARG_FIELDS: &[&str] = &["entries",
12715 "autorename",
12716 "allow_shared_folder",
12717 "allow_ownership_transfer"];
12718impl RelocationBatchArg {
12719 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12720 map: V,
12721 ) -> Result<RelocationBatchArg, V::Error> {
12722 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12723 }
12724
12725 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12726 mut map: V,
12727 optional: bool,
12728 ) -> Result<Option<RelocationBatchArg>, V::Error> {
12729 let mut field_entries = None;
12730 let mut field_autorename = None;
12731 let mut field_allow_shared_folder = None;
12732 let mut field_allow_ownership_transfer = None;
12733 let mut nothing = true;
12734 while let Some(key) = map.next_key::<&str>()? {
12735 nothing = false;
12736 match key {
12737 "entries" => {
12738 if field_entries.is_some() {
12739 return Err(::serde::de::Error::duplicate_field("entries"));
12740 }
12741 field_entries = Some(map.next_value()?);
12742 }
12743 "autorename" => {
12744 if field_autorename.is_some() {
12745 return Err(::serde::de::Error::duplicate_field("autorename"));
12746 }
12747 field_autorename = Some(map.next_value()?);
12748 }
12749 "allow_shared_folder" => {
12750 if field_allow_shared_folder.is_some() {
12751 return Err(::serde::de::Error::duplicate_field("allow_shared_folder"));
12752 }
12753 field_allow_shared_folder = Some(map.next_value()?);
12754 }
12755 "allow_ownership_transfer" => {
12756 if field_allow_ownership_transfer.is_some() {
12757 return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
12758 }
12759 field_allow_ownership_transfer = Some(map.next_value()?);
12760 }
12761 _ => {
12762 map.next_value::<::serde_json::Value>()?;
12764 }
12765 }
12766 }
12767 if optional && nothing {
12768 return Ok(None);
12769 }
12770 let result = RelocationBatchArg {
12771 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
12772 autorename: field_autorename.unwrap_or(false),
12773 allow_shared_folder: field_allow_shared_folder.unwrap_or(false),
12774 allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
12775 };
12776 Ok(Some(result))
12777 }
12778
12779 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12780 &self,
12781 s: &mut S::SerializeStruct,
12782 ) -> Result<(), S::Error> {
12783 use serde::ser::SerializeStruct;
12784 s.serialize_field("entries", &self.entries)?;
12785 if self.autorename {
12786 s.serialize_field("autorename", &self.autorename)?;
12787 }
12788 if self.allow_shared_folder {
12789 s.serialize_field("allow_shared_folder", &self.allow_shared_folder)?;
12790 }
12791 if self.allow_ownership_transfer {
12792 s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
12793 }
12794 Ok(())
12795 }
12796}
12797
12798impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchArg {
12799 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12800 use serde::de::{MapAccess, Visitor};
12802 struct StructVisitor;
12803 impl<'de> Visitor<'de> for StructVisitor {
12804 type Value = RelocationBatchArg;
12805 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12806 f.write_str("a RelocationBatchArg struct")
12807 }
12808 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12809 RelocationBatchArg::internal_deserialize(map)
12810 }
12811 }
12812 deserializer.deserialize_struct("RelocationBatchArg", RELOCATION_BATCH_ARG_FIELDS, StructVisitor)
12813 }
12814}
12815
12816impl ::serde::ser::Serialize for RelocationBatchArg {
12817 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12818 use serde::ser::SerializeStruct;
12820 let mut s = serializer.serialize_struct("RelocationBatchArg", 4)?;
12821 self.internal_serialize::<S>(&mut s)?;
12822 s.end()
12823 }
12824}
12825
12826impl From<RelocationBatchArg> for RelocationBatchArgBase {
12828 fn from(subtype: RelocationBatchArg) -> Self {
12829 Self {
12830 entries: subtype.entries,
12831 autorename: subtype.autorename,
12832 }
12833 }
12834}
12835#[derive(Debug, Clone, PartialEq, Eq)]
12836#[non_exhaustive] pub struct RelocationBatchArgBase {
12838 pub entries: Vec<RelocationPath>,
12840 pub autorename: bool,
12843}
12844
12845impl RelocationBatchArgBase {
12846 pub fn new(entries: Vec<RelocationPath>) -> Self {
12847 RelocationBatchArgBase {
12848 entries,
12849 autorename: false,
12850 }
12851 }
12852
12853 pub fn with_autorename(mut self, value: bool) -> Self {
12854 self.autorename = value;
12855 self
12856 }
12857}
12858
12859const RELOCATION_BATCH_ARG_BASE_FIELDS: &[&str] = &["entries",
12860 "autorename"];
12861impl RelocationBatchArgBase {
12862 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12863 map: V,
12864 ) -> Result<RelocationBatchArgBase, V::Error> {
12865 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12866 }
12867
12868 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12869 mut map: V,
12870 optional: bool,
12871 ) -> Result<Option<RelocationBatchArgBase>, V::Error> {
12872 let mut field_entries = None;
12873 let mut field_autorename = None;
12874 let mut nothing = true;
12875 while let Some(key) = map.next_key::<&str>()? {
12876 nothing = false;
12877 match key {
12878 "entries" => {
12879 if field_entries.is_some() {
12880 return Err(::serde::de::Error::duplicate_field("entries"));
12881 }
12882 field_entries = Some(map.next_value()?);
12883 }
12884 "autorename" => {
12885 if field_autorename.is_some() {
12886 return Err(::serde::de::Error::duplicate_field("autorename"));
12887 }
12888 field_autorename = Some(map.next_value()?);
12889 }
12890 _ => {
12891 map.next_value::<::serde_json::Value>()?;
12893 }
12894 }
12895 }
12896 if optional && nothing {
12897 return Ok(None);
12898 }
12899 let result = RelocationBatchArgBase {
12900 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
12901 autorename: field_autorename.unwrap_or(false),
12902 };
12903 Ok(Some(result))
12904 }
12905
12906 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12907 &self,
12908 s: &mut S::SerializeStruct,
12909 ) -> Result<(), S::Error> {
12910 use serde::ser::SerializeStruct;
12911 s.serialize_field("entries", &self.entries)?;
12912 if self.autorename {
12913 s.serialize_field("autorename", &self.autorename)?;
12914 }
12915 Ok(())
12916 }
12917}
12918
12919impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchArgBase {
12920 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12921 use serde::de::{MapAccess, Visitor};
12923 struct StructVisitor;
12924 impl<'de> Visitor<'de> for StructVisitor {
12925 type Value = RelocationBatchArgBase;
12926 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12927 f.write_str("a RelocationBatchArgBase struct")
12928 }
12929 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12930 RelocationBatchArgBase::internal_deserialize(map)
12931 }
12932 }
12933 deserializer.deserialize_struct("RelocationBatchArgBase", RELOCATION_BATCH_ARG_BASE_FIELDS, StructVisitor)
12934 }
12935}
12936
12937impl ::serde::ser::Serialize for RelocationBatchArgBase {
12938 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12939 use serde::ser::SerializeStruct;
12941 let mut s = serializer.serialize_struct("RelocationBatchArgBase", 2)?;
12942 self.internal_serialize::<S>(&mut s)?;
12943 s.end()
12944 }
12945}
12946
12947#[derive(Debug, Clone, PartialEq, Eq)]
12948#[non_exhaustive] pub enum RelocationBatchError {
12950 FromLookup(LookupError),
12951 FromWrite(WriteError),
12952 To(WriteError),
12953 CantCopySharedFolder,
12955 CantNestSharedFolder,
12957 CantMoveFolderIntoItself,
12959 TooManyFiles,
12961 DuplicatedOrNestedPaths,
12964 CantTransferOwnership,
12967 InsufficientQuota,
12969 InternalError,
12972 CantMoveSharedFolder,
12974 CantMoveIntoVault(MoveIntoVaultError),
12976 CantMoveIntoFamily(MoveIntoFamilyError),
12979 TooManyWriteOperations,
12981 Other,
12984}
12985
12986impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchError {
12987 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12988 use serde::de::{self, MapAccess, Visitor};
12990 struct EnumVisitor;
12991 impl<'de> Visitor<'de> for EnumVisitor {
12992 type Value = RelocationBatchError;
12993 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12994 f.write_str("a RelocationBatchError structure")
12995 }
12996 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
12997 let tag: &str = match map.next_key()? {
12998 Some(".tag") => map.next_value()?,
12999 _ => return Err(de::Error::missing_field(".tag"))
13000 };
13001 let value = match tag {
13002 "from_lookup" => {
13003 match map.next_key()? {
13004 Some("from_lookup") => RelocationBatchError::FromLookup(map.next_value()?),
13005 None => return Err(de::Error::missing_field("from_lookup")),
13006 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13007 }
13008 }
13009 "from_write" => {
13010 match map.next_key()? {
13011 Some("from_write") => RelocationBatchError::FromWrite(map.next_value()?),
13012 None => return Err(de::Error::missing_field("from_write")),
13013 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13014 }
13015 }
13016 "to" => {
13017 match map.next_key()? {
13018 Some("to") => RelocationBatchError::To(map.next_value()?),
13019 None => return Err(de::Error::missing_field("to")),
13020 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13021 }
13022 }
13023 "cant_copy_shared_folder" => RelocationBatchError::CantCopySharedFolder,
13024 "cant_nest_shared_folder" => RelocationBatchError::CantNestSharedFolder,
13025 "cant_move_folder_into_itself" => RelocationBatchError::CantMoveFolderIntoItself,
13026 "too_many_files" => RelocationBatchError::TooManyFiles,
13027 "duplicated_or_nested_paths" => RelocationBatchError::DuplicatedOrNestedPaths,
13028 "cant_transfer_ownership" => RelocationBatchError::CantTransferOwnership,
13029 "insufficient_quota" => RelocationBatchError::InsufficientQuota,
13030 "internal_error" => RelocationBatchError::InternalError,
13031 "cant_move_shared_folder" => RelocationBatchError::CantMoveSharedFolder,
13032 "cant_move_into_vault" => {
13033 match map.next_key()? {
13034 Some("cant_move_into_vault") => RelocationBatchError::CantMoveIntoVault(map.next_value()?),
13035 None => return Err(de::Error::missing_field("cant_move_into_vault")),
13036 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13037 }
13038 }
13039 "cant_move_into_family" => {
13040 match map.next_key()? {
13041 Some("cant_move_into_family") => RelocationBatchError::CantMoveIntoFamily(map.next_value()?),
13042 None => return Err(de::Error::missing_field("cant_move_into_family")),
13043 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13044 }
13045 }
13046 "too_many_write_operations" => RelocationBatchError::TooManyWriteOperations,
13047 _ => RelocationBatchError::Other,
13048 };
13049 crate::eat_json_fields(&mut map)?;
13050 Ok(value)
13051 }
13052 }
13053 const VARIANTS: &[&str] = &["from_lookup",
13054 "from_write",
13055 "to",
13056 "cant_copy_shared_folder",
13057 "cant_nest_shared_folder",
13058 "cant_move_folder_into_itself",
13059 "too_many_files",
13060 "duplicated_or_nested_paths",
13061 "cant_transfer_ownership",
13062 "insufficient_quota",
13063 "internal_error",
13064 "cant_move_shared_folder",
13065 "cant_move_into_vault",
13066 "cant_move_into_family",
13067 "other",
13068 "too_many_write_operations"];
13069 deserializer.deserialize_struct("RelocationBatchError", VARIANTS, EnumVisitor)
13070 }
13071}
13072
13073impl ::serde::ser::Serialize for RelocationBatchError {
13074 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13075 use serde::ser::SerializeStruct;
13077 match self {
13078 RelocationBatchError::FromLookup(x) => {
13079 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13081 s.serialize_field(".tag", "from_lookup")?;
13082 s.serialize_field("from_lookup", x)?;
13083 s.end()
13084 }
13085 RelocationBatchError::FromWrite(x) => {
13086 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13088 s.serialize_field(".tag", "from_write")?;
13089 s.serialize_field("from_write", x)?;
13090 s.end()
13091 }
13092 RelocationBatchError::To(x) => {
13093 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13095 s.serialize_field(".tag", "to")?;
13096 s.serialize_field("to", x)?;
13097 s.end()
13098 }
13099 RelocationBatchError::CantCopySharedFolder => {
13100 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13102 s.serialize_field(".tag", "cant_copy_shared_folder")?;
13103 s.end()
13104 }
13105 RelocationBatchError::CantNestSharedFolder => {
13106 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13108 s.serialize_field(".tag", "cant_nest_shared_folder")?;
13109 s.end()
13110 }
13111 RelocationBatchError::CantMoveFolderIntoItself => {
13112 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13114 s.serialize_field(".tag", "cant_move_folder_into_itself")?;
13115 s.end()
13116 }
13117 RelocationBatchError::TooManyFiles => {
13118 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13120 s.serialize_field(".tag", "too_many_files")?;
13121 s.end()
13122 }
13123 RelocationBatchError::DuplicatedOrNestedPaths => {
13124 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13126 s.serialize_field(".tag", "duplicated_or_nested_paths")?;
13127 s.end()
13128 }
13129 RelocationBatchError::CantTransferOwnership => {
13130 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13132 s.serialize_field(".tag", "cant_transfer_ownership")?;
13133 s.end()
13134 }
13135 RelocationBatchError::InsufficientQuota => {
13136 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13138 s.serialize_field(".tag", "insufficient_quota")?;
13139 s.end()
13140 }
13141 RelocationBatchError::InternalError => {
13142 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13144 s.serialize_field(".tag", "internal_error")?;
13145 s.end()
13146 }
13147 RelocationBatchError::CantMoveSharedFolder => {
13148 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13150 s.serialize_field(".tag", "cant_move_shared_folder")?;
13151 s.end()
13152 }
13153 RelocationBatchError::CantMoveIntoVault(x) => {
13154 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13156 s.serialize_field(".tag", "cant_move_into_vault")?;
13157 s.serialize_field("cant_move_into_vault", x)?;
13158 s.end()
13159 }
13160 RelocationBatchError::CantMoveIntoFamily(x) => {
13161 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13163 s.serialize_field(".tag", "cant_move_into_family")?;
13164 s.serialize_field("cant_move_into_family", x)?;
13165 s.end()
13166 }
13167 RelocationBatchError::TooManyWriteOperations => {
13168 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13170 s.serialize_field(".tag", "too_many_write_operations")?;
13171 s.end()
13172 }
13173 RelocationBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13174 }
13175 }
13176}
13177
13178impl ::std::error::Error for RelocationBatchError {
13179 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
13180 match self {
13181 RelocationBatchError::FromLookup(inner) => Some(inner),
13182 RelocationBatchError::FromWrite(inner) => Some(inner),
13183 RelocationBatchError::To(inner) => Some(inner),
13184 RelocationBatchError::CantMoveIntoVault(inner) => Some(inner),
13185 RelocationBatchError::CantMoveIntoFamily(inner) => Some(inner),
13186 _ => None,
13187 }
13188 }
13189}
13190
13191impl ::std::fmt::Display for RelocationBatchError {
13192 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13193 match self {
13194 RelocationBatchError::FromLookup(inner) => write!(f, "RelocationBatchError: {}", inner),
13195 RelocationBatchError::FromWrite(inner) => write!(f, "RelocationBatchError: {}", inner),
13196 RelocationBatchError::To(inner) => write!(f, "RelocationBatchError: {}", inner),
13197 RelocationBatchError::CantCopySharedFolder => f.write_str("Shared folders can't be copied."),
13198 RelocationBatchError::CantNestSharedFolder => f.write_str("Your move operation would result in nested shared folders. This is not allowed."),
13199 RelocationBatchError::CantMoveFolderIntoItself => f.write_str("You cannot move a folder into itself."),
13200 RelocationBatchError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
13201 RelocationBatchError::InsufficientQuota => f.write_str("The current user does not have enough space to move or copy the files."),
13202 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."),
13203 RelocationBatchError::CantMoveSharedFolder => f.write_str("Can't move the shared folder to the given destination."),
13204 RelocationBatchError::CantMoveIntoVault(inner) => write!(f, "Some content cannot be moved into Vault under certain circumstances, see detailed error: {}", inner),
13205 RelocationBatchError::CantMoveIntoFamily(inner) => write!(f, "Some content cannot be moved into the Family Room folder under certain circumstances, see detailed error: {}", inner),
13206 RelocationBatchError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
13207 _ => write!(f, "{:?}", *self),
13208 }
13209 }
13210}
13211
13212impl From<RelocationError> for RelocationBatchError {
13214 fn from(parent: RelocationError) -> Self {
13215 match parent {
13216 RelocationError::FromLookup(x) => RelocationBatchError::FromLookup(x),
13217 RelocationError::FromWrite(x) => RelocationBatchError::FromWrite(x),
13218 RelocationError::To(x) => RelocationBatchError::To(x),
13219 RelocationError::CantCopySharedFolder => RelocationBatchError::CantCopySharedFolder,
13220 RelocationError::CantNestSharedFolder => RelocationBatchError::CantNestSharedFolder,
13221 RelocationError::CantMoveFolderIntoItself => RelocationBatchError::CantMoveFolderIntoItself,
13222 RelocationError::TooManyFiles => RelocationBatchError::TooManyFiles,
13223 RelocationError::DuplicatedOrNestedPaths => RelocationBatchError::DuplicatedOrNestedPaths,
13224 RelocationError::CantTransferOwnership => RelocationBatchError::CantTransferOwnership,
13225 RelocationError::InsufficientQuota => RelocationBatchError::InsufficientQuota,
13226 RelocationError::InternalError => RelocationBatchError::InternalError,
13227 RelocationError::CantMoveSharedFolder => RelocationBatchError::CantMoveSharedFolder,
13228 RelocationError::CantMoveIntoVault(x) => RelocationBatchError::CantMoveIntoVault(x),
13229 RelocationError::CantMoveIntoFamily(x) => RelocationBatchError::CantMoveIntoFamily(x),
13230 RelocationError::Other => RelocationBatchError::Other,
13231 }
13232 }
13233}
13234#[derive(Debug, Clone, PartialEq, Eq)]
13235#[non_exhaustive] pub enum RelocationBatchErrorEntry {
13237 RelocationError(RelocationError),
13239 InternalError,
13242 TooManyWriteOperations,
13244 Other,
13247}
13248
13249impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchErrorEntry {
13250 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13251 use serde::de::{self, MapAccess, Visitor};
13253 struct EnumVisitor;
13254 impl<'de> Visitor<'de> for EnumVisitor {
13255 type Value = RelocationBatchErrorEntry;
13256 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13257 f.write_str("a RelocationBatchErrorEntry structure")
13258 }
13259 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13260 let tag: &str = match map.next_key()? {
13261 Some(".tag") => map.next_value()?,
13262 _ => return Err(de::Error::missing_field(".tag"))
13263 };
13264 let value = match tag {
13265 "relocation_error" => {
13266 match map.next_key()? {
13267 Some("relocation_error") => RelocationBatchErrorEntry::RelocationError(map.next_value()?),
13268 None => return Err(de::Error::missing_field("relocation_error")),
13269 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13270 }
13271 }
13272 "internal_error" => RelocationBatchErrorEntry::InternalError,
13273 "too_many_write_operations" => RelocationBatchErrorEntry::TooManyWriteOperations,
13274 _ => RelocationBatchErrorEntry::Other,
13275 };
13276 crate::eat_json_fields(&mut map)?;
13277 Ok(value)
13278 }
13279 }
13280 const VARIANTS: &[&str] = &["relocation_error",
13281 "internal_error",
13282 "too_many_write_operations",
13283 "other"];
13284 deserializer.deserialize_struct("RelocationBatchErrorEntry", VARIANTS, EnumVisitor)
13285 }
13286}
13287
13288impl ::serde::ser::Serialize for RelocationBatchErrorEntry {
13289 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13290 use serde::ser::SerializeStruct;
13292 match self {
13293 RelocationBatchErrorEntry::RelocationError(x) => {
13294 let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 2)?;
13296 s.serialize_field(".tag", "relocation_error")?;
13297 s.serialize_field("relocation_error", x)?;
13298 s.end()
13299 }
13300 RelocationBatchErrorEntry::InternalError => {
13301 let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 1)?;
13303 s.serialize_field(".tag", "internal_error")?;
13304 s.end()
13305 }
13306 RelocationBatchErrorEntry::TooManyWriteOperations => {
13307 let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 1)?;
13309 s.serialize_field(".tag", "too_many_write_operations")?;
13310 s.end()
13311 }
13312 RelocationBatchErrorEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13313 }
13314 }
13315}
13316
13317#[derive(Debug, Clone, PartialEq)]
13318pub enum RelocationBatchJobStatus {
13319 InProgress,
13321 Complete(RelocationBatchResult),
13323 Failed(RelocationBatchError),
13325}
13326
13327impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchJobStatus {
13328 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13329 use serde::de::{self, MapAccess, Visitor};
13331 struct EnumVisitor;
13332 impl<'de> Visitor<'de> for EnumVisitor {
13333 type Value = RelocationBatchJobStatus;
13334 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13335 f.write_str("a RelocationBatchJobStatus structure")
13336 }
13337 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13338 let tag: &str = match map.next_key()? {
13339 Some(".tag") => map.next_value()?,
13340 _ => return Err(de::Error::missing_field(".tag"))
13341 };
13342 let value = match tag {
13343 "in_progress" => RelocationBatchJobStatus::InProgress,
13344 "complete" => RelocationBatchJobStatus::Complete(RelocationBatchResult::internal_deserialize(&mut map)?),
13345 "failed" => {
13346 match map.next_key()? {
13347 Some("failed") => RelocationBatchJobStatus::Failed(map.next_value()?),
13348 None => return Err(de::Error::missing_field("failed")),
13349 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13350 }
13351 }
13352 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
13353 };
13354 crate::eat_json_fields(&mut map)?;
13355 Ok(value)
13356 }
13357 }
13358 const VARIANTS: &[&str] = &["in_progress",
13359 "complete",
13360 "failed"];
13361 deserializer.deserialize_struct("RelocationBatchJobStatus", VARIANTS, EnumVisitor)
13362 }
13363}
13364
13365impl ::serde::ser::Serialize for RelocationBatchJobStatus {
13366 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13367 use serde::ser::SerializeStruct;
13369 match self {
13370 RelocationBatchJobStatus::InProgress => {
13371 let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 1)?;
13373 s.serialize_field(".tag", "in_progress")?;
13374 s.end()
13375 }
13376 RelocationBatchJobStatus::Complete(x) => {
13377 let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 2)?;
13379 s.serialize_field(".tag", "complete")?;
13380 x.internal_serialize::<S>(&mut s)?;
13381 s.end()
13382 }
13383 RelocationBatchJobStatus::Failed(x) => {
13384 let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 2)?;
13386 s.serialize_field(".tag", "failed")?;
13387 s.serialize_field("failed", x)?;
13388 s.end()
13389 }
13390 }
13391 }
13392}
13393
13394impl From<crate::types::dbx_async::PollResultBase> for RelocationBatchJobStatus {
13396 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
13397 match parent {
13398 crate::types::dbx_async::PollResultBase::InProgress => RelocationBatchJobStatus::InProgress,
13399 }
13400 }
13401}
13402#[derive(Debug, Clone, PartialEq)]
13406#[non_exhaustive] pub enum RelocationBatchLaunch {
13408 AsyncJobId(crate::types::dbx_async::AsyncJobId),
13411 Complete(RelocationBatchResult),
13412 Other,
13415}
13416
13417impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchLaunch {
13418 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13419 use serde::de::{self, MapAccess, Visitor};
13421 struct EnumVisitor;
13422 impl<'de> Visitor<'de> for EnumVisitor {
13423 type Value = RelocationBatchLaunch;
13424 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13425 f.write_str("a RelocationBatchLaunch structure")
13426 }
13427 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13428 let tag: &str = match map.next_key()? {
13429 Some(".tag") => map.next_value()?,
13430 _ => return Err(de::Error::missing_field(".tag"))
13431 };
13432 let value = match tag {
13433 "async_job_id" => {
13434 match map.next_key()? {
13435 Some("async_job_id") => RelocationBatchLaunch::AsyncJobId(map.next_value()?),
13436 None => return Err(de::Error::missing_field("async_job_id")),
13437 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13438 }
13439 }
13440 "complete" => RelocationBatchLaunch::Complete(RelocationBatchResult::internal_deserialize(&mut map)?),
13441 _ => RelocationBatchLaunch::Other,
13442 };
13443 crate::eat_json_fields(&mut map)?;
13444 Ok(value)
13445 }
13446 }
13447 const VARIANTS: &[&str] = &["async_job_id",
13448 "complete",
13449 "other"];
13450 deserializer.deserialize_struct("RelocationBatchLaunch", VARIANTS, EnumVisitor)
13451 }
13452}
13453
13454impl ::serde::ser::Serialize for RelocationBatchLaunch {
13455 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13456 use serde::ser::SerializeStruct;
13458 match self {
13459 RelocationBatchLaunch::AsyncJobId(x) => {
13460 let mut s = serializer.serialize_struct("RelocationBatchLaunch", 2)?;
13462 s.serialize_field(".tag", "async_job_id")?;
13463 s.serialize_field("async_job_id", x)?;
13464 s.end()
13465 }
13466 RelocationBatchLaunch::Complete(x) => {
13467 let mut s = serializer.serialize_struct("RelocationBatchLaunch", 2)?;
13469 s.serialize_field(".tag", "complete")?;
13470 x.internal_serialize::<S>(&mut s)?;
13471 s.end()
13472 }
13473 RelocationBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13474 }
13475 }
13476}
13477
13478impl From<crate::types::dbx_async::LaunchResultBase> for RelocationBatchLaunch {
13480 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
13481 match parent {
13482 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => RelocationBatchLaunch::AsyncJobId(x),
13483 }
13484 }
13485}
13486#[derive(Debug, Clone, PartialEq)]
13487#[non_exhaustive] pub struct RelocationBatchResult {
13489 pub entries: Vec<RelocationBatchResultData>,
13490}
13491
13492impl RelocationBatchResult {
13493 pub fn new(entries: Vec<RelocationBatchResultData>) -> Self {
13494 RelocationBatchResult {
13495 entries,
13496 }
13497 }
13498}
13499
13500const RELOCATION_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
13501impl RelocationBatchResult {
13502 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
13503 map: V,
13504 ) -> Result<RelocationBatchResult, V::Error> {
13505 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
13506 }
13507
13508 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
13509 mut map: V,
13510 optional: bool,
13511 ) -> Result<Option<RelocationBatchResult>, V::Error> {
13512 let mut field_entries = None;
13513 let mut nothing = true;
13514 while let Some(key) = map.next_key::<&str>()? {
13515 nothing = false;
13516 match key {
13517 "entries" => {
13518 if field_entries.is_some() {
13519 return Err(::serde::de::Error::duplicate_field("entries"));
13520 }
13521 field_entries = Some(map.next_value()?);
13522 }
13523 _ => {
13524 map.next_value::<::serde_json::Value>()?;
13526 }
13527 }
13528 }
13529 if optional && nothing {
13530 return Ok(None);
13531 }
13532 let result = RelocationBatchResult {
13533 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
13534 };
13535 Ok(Some(result))
13536 }
13537
13538 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
13539 &self,
13540 s: &mut S::SerializeStruct,
13541 ) -> Result<(), S::Error> {
13542 use serde::ser::SerializeStruct;
13543 s.serialize_field("entries", &self.entries)?;
13544 Ok(())
13545 }
13546}
13547
13548impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResult {
13549 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13550 use serde::de::{MapAccess, Visitor};
13552 struct StructVisitor;
13553 impl<'de> Visitor<'de> for StructVisitor {
13554 type Value = RelocationBatchResult;
13555 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13556 f.write_str("a RelocationBatchResult struct")
13557 }
13558 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
13559 RelocationBatchResult::internal_deserialize(map)
13560 }
13561 }
13562 deserializer.deserialize_struct("RelocationBatchResult", RELOCATION_BATCH_RESULT_FIELDS, StructVisitor)
13563 }
13564}
13565
13566impl ::serde::ser::Serialize for RelocationBatchResult {
13567 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13568 use serde::ser::SerializeStruct;
13570 let mut s = serializer.serialize_struct("RelocationBatchResult", 1)?;
13571 self.internal_serialize::<S>(&mut s)?;
13572 s.end()
13573 }
13574}
13575
13576impl From<RelocationBatchResult> for FileOpsResult {
13578 fn from(_: RelocationBatchResult) -> Self {
13579 Self {}
13580 }
13581}
13582#[derive(Debug, Clone, PartialEq)]
13583#[non_exhaustive] pub struct RelocationBatchResultData {
13585 pub metadata: Metadata,
13587}
13588
13589impl RelocationBatchResultData {
13590 pub fn new(metadata: Metadata) -> Self {
13591 RelocationBatchResultData {
13592 metadata,
13593 }
13594 }
13595}
13596
13597const RELOCATION_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata"];
13598impl RelocationBatchResultData {
13599 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
13600 map: V,
13601 ) -> Result<RelocationBatchResultData, V::Error> {
13602 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
13603 }
13604
13605 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
13606 mut map: V,
13607 optional: bool,
13608 ) -> Result<Option<RelocationBatchResultData>, V::Error> {
13609 let mut field_metadata = None;
13610 let mut nothing = true;
13611 while let Some(key) = map.next_key::<&str>()? {
13612 nothing = false;
13613 match key {
13614 "metadata" => {
13615 if field_metadata.is_some() {
13616 return Err(::serde::de::Error::duplicate_field("metadata"));
13617 }
13618 field_metadata = Some(map.next_value()?);
13619 }
13620 _ => {
13621 map.next_value::<::serde_json::Value>()?;
13623 }
13624 }
13625 }
13626 if optional && nothing {
13627 return Ok(None);
13628 }
13629 let result = RelocationBatchResultData {
13630 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
13631 };
13632 Ok(Some(result))
13633 }
13634
13635 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
13636 &self,
13637 s: &mut S::SerializeStruct,
13638 ) -> Result<(), S::Error> {
13639 use serde::ser::SerializeStruct;
13640 s.serialize_field("metadata", &self.metadata)?;
13641 Ok(())
13642 }
13643}
13644
13645impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResultData {
13646 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13647 use serde::de::{MapAccess, Visitor};
13649 struct StructVisitor;
13650 impl<'de> Visitor<'de> for StructVisitor {
13651 type Value = RelocationBatchResultData;
13652 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13653 f.write_str("a RelocationBatchResultData struct")
13654 }
13655 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
13656 RelocationBatchResultData::internal_deserialize(map)
13657 }
13658 }
13659 deserializer.deserialize_struct("RelocationBatchResultData", RELOCATION_BATCH_RESULT_DATA_FIELDS, StructVisitor)
13660 }
13661}
13662
13663impl ::serde::ser::Serialize for RelocationBatchResultData {
13664 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13665 use serde::ser::SerializeStruct;
13667 let mut s = serializer.serialize_struct("RelocationBatchResultData", 1)?;
13668 self.internal_serialize::<S>(&mut s)?;
13669 s.end()
13670 }
13671}
13672
13673#[derive(Debug, Clone, PartialEq)]
13674#[non_exhaustive] pub enum RelocationBatchResultEntry {
13676 Success(Metadata),
13677 Failure(RelocationBatchErrorEntry),
13678 Other,
13681}
13682
13683impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResultEntry {
13684 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13685 use serde::de::{self, MapAccess, Visitor};
13687 struct EnumVisitor;
13688 impl<'de> Visitor<'de> for EnumVisitor {
13689 type Value = RelocationBatchResultEntry;
13690 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13691 f.write_str("a RelocationBatchResultEntry structure")
13692 }
13693 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13694 let tag: &str = match map.next_key()? {
13695 Some(".tag") => map.next_value()?,
13696 _ => return Err(de::Error::missing_field(".tag"))
13697 };
13698 let value = match tag {
13699 "success" => {
13700 match map.next_key()? {
13701 Some("success") => RelocationBatchResultEntry::Success(map.next_value()?),
13702 None => return Err(de::Error::missing_field("success")),
13703 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13704 }
13705 }
13706 "failure" => {
13707 match map.next_key()? {
13708 Some("failure") => RelocationBatchResultEntry::Failure(map.next_value()?),
13709 None => return Err(de::Error::missing_field("failure")),
13710 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13711 }
13712 }
13713 _ => RelocationBatchResultEntry::Other,
13714 };
13715 crate::eat_json_fields(&mut map)?;
13716 Ok(value)
13717 }
13718 }
13719 const VARIANTS: &[&str] = &["success",
13720 "failure",
13721 "other"];
13722 deserializer.deserialize_struct("RelocationBatchResultEntry", VARIANTS, EnumVisitor)
13723 }
13724}
13725
13726impl ::serde::ser::Serialize for RelocationBatchResultEntry {
13727 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13728 use serde::ser::SerializeStruct;
13730 match self {
13731 RelocationBatchResultEntry::Success(x) => {
13732 let mut s = serializer.serialize_struct("RelocationBatchResultEntry", 2)?;
13734 s.serialize_field(".tag", "success")?;
13735 s.serialize_field("success", x)?;
13736 s.end()
13737 }
13738 RelocationBatchResultEntry::Failure(x) => {
13739 let mut s = serializer.serialize_struct("RelocationBatchResultEntry", 2)?;
13741 s.serialize_field(".tag", "failure")?;
13742 s.serialize_field("failure", x)?;
13743 s.end()
13744 }
13745 RelocationBatchResultEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13746 }
13747 }
13748}
13749
13750#[derive(Debug, Clone, PartialEq)]
13754pub enum RelocationBatchV2JobStatus {
13755 InProgress,
13757 Complete(RelocationBatchV2Result),
13759}
13760
13761impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2JobStatus {
13762 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13763 use serde::de::{self, MapAccess, Visitor};
13765 struct EnumVisitor;
13766 impl<'de> Visitor<'de> for EnumVisitor {
13767 type Value = RelocationBatchV2JobStatus;
13768 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13769 f.write_str("a RelocationBatchV2JobStatus structure")
13770 }
13771 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13772 let tag: &str = match map.next_key()? {
13773 Some(".tag") => map.next_value()?,
13774 _ => return Err(de::Error::missing_field(".tag"))
13775 };
13776 let value = match tag {
13777 "in_progress" => RelocationBatchV2JobStatus::InProgress,
13778 "complete" => RelocationBatchV2JobStatus::Complete(RelocationBatchV2Result::internal_deserialize(&mut map)?),
13779 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
13780 };
13781 crate::eat_json_fields(&mut map)?;
13782 Ok(value)
13783 }
13784 }
13785 const VARIANTS: &[&str] = &["in_progress",
13786 "complete"];
13787 deserializer.deserialize_struct("RelocationBatchV2JobStatus", VARIANTS, EnumVisitor)
13788 }
13789}
13790
13791impl ::serde::ser::Serialize for RelocationBatchV2JobStatus {
13792 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13793 use serde::ser::SerializeStruct;
13795 match self {
13796 RelocationBatchV2JobStatus::InProgress => {
13797 let mut s = serializer.serialize_struct("RelocationBatchV2JobStatus", 1)?;
13799 s.serialize_field(".tag", "in_progress")?;
13800 s.end()
13801 }
13802 RelocationBatchV2JobStatus::Complete(x) => {
13803 let mut s = serializer.serialize_struct("RelocationBatchV2JobStatus", 2)?;
13805 s.serialize_field(".tag", "complete")?;
13806 x.internal_serialize::<S>(&mut s)?;
13807 s.end()
13808 }
13809 }
13810 }
13811}
13812
13813impl From<crate::types::dbx_async::PollResultBase> for RelocationBatchV2JobStatus {
13815 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
13816 match parent {
13817 crate::types::dbx_async::PollResultBase::InProgress => RelocationBatchV2JobStatus::InProgress,
13818 }
13819 }
13820}
13821#[derive(Debug, Clone, PartialEq)]
13825pub enum RelocationBatchV2Launch {
13826 AsyncJobId(crate::types::dbx_async::AsyncJobId),
13829 Complete(RelocationBatchV2Result),
13830}
13831
13832impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2Launch {
13833 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13834 use serde::de::{self, MapAccess, Visitor};
13836 struct EnumVisitor;
13837 impl<'de> Visitor<'de> for EnumVisitor {
13838 type Value = RelocationBatchV2Launch;
13839 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13840 f.write_str("a RelocationBatchV2Launch structure")
13841 }
13842 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13843 let tag: &str = match map.next_key()? {
13844 Some(".tag") => map.next_value()?,
13845 _ => return Err(de::Error::missing_field(".tag"))
13846 };
13847 let value = match tag {
13848 "async_job_id" => {
13849 match map.next_key()? {
13850 Some("async_job_id") => RelocationBatchV2Launch::AsyncJobId(map.next_value()?),
13851 None => return Err(de::Error::missing_field("async_job_id")),
13852 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13853 }
13854 }
13855 "complete" => RelocationBatchV2Launch::Complete(RelocationBatchV2Result::internal_deserialize(&mut map)?),
13856 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
13857 };
13858 crate::eat_json_fields(&mut map)?;
13859 Ok(value)
13860 }
13861 }
13862 const VARIANTS: &[&str] = &["async_job_id",
13863 "complete"];
13864 deserializer.deserialize_struct("RelocationBatchV2Launch", VARIANTS, EnumVisitor)
13865 }
13866}
13867
13868impl ::serde::ser::Serialize for RelocationBatchV2Launch {
13869 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13870 use serde::ser::SerializeStruct;
13872 match self {
13873 RelocationBatchV2Launch::AsyncJobId(x) => {
13874 let mut s = serializer.serialize_struct("RelocationBatchV2Launch", 2)?;
13876 s.serialize_field(".tag", "async_job_id")?;
13877 s.serialize_field("async_job_id", x)?;
13878 s.end()
13879 }
13880 RelocationBatchV2Launch::Complete(x) => {
13881 let mut s = serializer.serialize_struct("RelocationBatchV2Launch", 2)?;
13883 s.serialize_field(".tag", "complete")?;
13884 x.internal_serialize::<S>(&mut s)?;
13885 s.end()
13886 }
13887 }
13888 }
13889}
13890
13891impl From<crate::types::dbx_async::LaunchResultBase> for RelocationBatchV2Launch {
13893 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
13894 match parent {
13895 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => RelocationBatchV2Launch::AsyncJobId(x),
13896 }
13897 }
13898}
13899#[derive(Debug, Clone, PartialEq)]
13900#[non_exhaustive] pub struct RelocationBatchV2Result {
13902 pub entries: Vec<RelocationBatchResultEntry>,
13905}
13906
13907impl RelocationBatchV2Result {
13908 pub fn new(entries: Vec<RelocationBatchResultEntry>) -> Self {
13909 RelocationBatchV2Result {
13910 entries,
13911 }
13912 }
13913}
13914
13915const RELOCATION_BATCH_V2_RESULT_FIELDS: &[&str] = &["entries"];
13916impl RelocationBatchV2Result {
13917 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
13918 map: V,
13919 ) -> Result<RelocationBatchV2Result, V::Error> {
13920 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
13921 }
13922
13923 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
13924 mut map: V,
13925 optional: bool,
13926 ) -> Result<Option<RelocationBatchV2Result>, V::Error> {
13927 let mut field_entries = None;
13928 let mut nothing = true;
13929 while let Some(key) = map.next_key::<&str>()? {
13930 nothing = false;
13931 match key {
13932 "entries" => {
13933 if field_entries.is_some() {
13934 return Err(::serde::de::Error::duplicate_field("entries"));
13935 }
13936 field_entries = Some(map.next_value()?);
13937 }
13938 _ => {
13939 map.next_value::<::serde_json::Value>()?;
13941 }
13942 }
13943 }
13944 if optional && nothing {
13945 return Ok(None);
13946 }
13947 let result = RelocationBatchV2Result {
13948 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
13949 };
13950 Ok(Some(result))
13951 }
13952
13953 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
13954 &self,
13955 s: &mut S::SerializeStruct,
13956 ) -> Result<(), S::Error> {
13957 use serde::ser::SerializeStruct;
13958 s.serialize_field("entries", &self.entries)?;
13959 Ok(())
13960 }
13961}
13962
13963impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2Result {
13964 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13965 use serde::de::{MapAccess, Visitor};
13967 struct StructVisitor;
13968 impl<'de> Visitor<'de> for StructVisitor {
13969 type Value = RelocationBatchV2Result;
13970 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13971 f.write_str("a RelocationBatchV2Result struct")
13972 }
13973 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
13974 RelocationBatchV2Result::internal_deserialize(map)
13975 }
13976 }
13977 deserializer.deserialize_struct("RelocationBatchV2Result", RELOCATION_BATCH_V2_RESULT_FIELDS, StructVisitor)
13978 }
13979}
13980
13981impl ::serde::ser::Serialize for RelocationBatchV2Result {
13982 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13983 use serde::ser::SerializeStruct;
13985 let mut s = serializer.serialize_struct("RelocationBatchV2Result", 1)?;
13986 self.internal_serialize::<S>(&mut s)?;
13987 s.end()
13988 }
13989}
13990
13991impl From<RelocationBatchV2Result> for FileOpsResult {
13993 fn from(_: RelocationBatchV2Result) -> Self {
13994 Self {}
13995 }
13996}
13997#[derive(Debug, Clone, PartialEq, Eq)]
13998#[non_exhaustive] pub enum RelocationError {
14000 FromLookup(LookupError),
14001 FromWrite(WriteError),
14002 To(WriteError),
14003 CantCopySharedFolder,
14005 CantNestSharedFolder,
14007 CantMoveFolderIntoItself,
14009 TooManyFiles,
14011 DuplicatedOrNestedPaths,
14014 CantTransferOwnership,
14017 InsufficientQuota,
14019 InternalError,
14022 CantMoveSharedFolder,
14024 CantMoveIntoVault(MoveIntoVaultError),
14026 CantMoveIntoFamily(MoveIntoFamilyError),
14029 Other,
14032}
14033
14034impl<'de> ::serde::de::Deserialize<'de> for RelocationError {
14035 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14036 use serde::de::{self, MapAccess, Visitor};
14038 struct EnumVisitor;
14039 impl<'de> Visitor<'de> for EnumVisitor {
14040 type Value = RelocationError;
14041 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14042 f.write_str("a RelocationError structure")
14043 }
14044 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
14045 let tag: &str = match map.next_key()? {
14046 Some(".tag") => map.next_value()?,
14047 _ => return Err(de::Error::missing_field(".tag"))
14048 };
14049 let value = match tag {
14050 "from_lookup" => {
14051 match map.next_key()? {
14052 Some("from_lookup") => RelocationError::FromLookup(map.next_value()?),
14053 None => return Err(de::Error::missing_field("from_lookup")),
14054 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14055 }
14056 }
14057 "from_write" => {
14058 match map.next_key()? {
14059 Some("from_write") => RelocationError::FromWrite(map.next_value()?),
14060 None => return Err(de::Error::missing_field("from_write")),
14061 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14062 }
14063 }
14064 "to" => {
14065 match map.next_key()? {
14066 Some("to") => RelocationError::To(map.next_value()?),
14067 None => return Err(de::Error::missing_field("to")),
14068 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14069 }
14070 }
14071 "cant_copy_shared_folder" => RelocationError::CantCopySharedFolder,
14072 "cant_nest_shared_folder" => RelocationError::CantNestSharedFolder,
14073 "cant_move_folder_into_itself" => RelocationError::CantMoveFolderIntoItself,
14074 "too_many_files" => RelocationError::TooManyFiles,
14075 "duplicated_or_nested_paths" => RelocationError::DuplicatedOrNestedPaths,
14076 "cant_transfer_ownership" => RelocationError::CantTransferOwnership,
14077 "insufficient_quota" => RelocationError::InsufficientQuota,
14078 "internal_error" => RelocationError::InternalError,
14079 "cant_move_shared_folder" => RelocationError::CantMoveSharedFolder,
14080 "cant_move_into_vault" => {
14081 match map.next_key()? {
14082 Some("cant_move_into_vault") => RelocationError::CantMoveIntoVault(map.next_value()?),
14083 None => return Err(de::Error::missing_field("cant_move_into_vault")),
14084 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14085 }
14086 }
14087 "cant_move_into_family" => {
14088 match map.next_key()? {
14089 Some("cant_move_into_family") => RelocationError::CantMoveIntoFamily(map.next_value()?),
14090 None => return Err(de::Error::missing_field("cant_move_into_family")),
14091 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14092 }
14093 }
14094 _ => RelocationError::Other,
14095 };
14096 crate::eat_json_fields(&mut map)?;
14097 Ok(value)
14098 }
14099 }
14100 const VARIANTS: &[&str] = &["from_lookup",
14101 "from_write",
14102 "to",
14103 "cant_copy_shared_folder",
14104 "cant_nest_shared_folder",
14105 "cant_move_folder_into_itself",
14106 "too_many_files",
14107 "duplicated_or_nested_paths",
14108 "cant_transfer_ownership",
14109 "insufficient_quota",
14110 "internal_error",
14111 "cant_move_shared_folder",
14112 "cant_move_into_vault",
14113 "cant_move_into_family",
14114 "other"];
14115 deserializer.deserialize_struct("RelocationError", VARIANTS, EnumVisitor)
14116 }
14117}
14118
14119impl ::serde::ser::Serialize for RelocationError {
14120 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14121 use serde::ser::SerializeStruct;
14123 match self {
14124 RelocationError::FromLookup(x) => {
14125 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14127 s.serialize_field(".tag", "from_lookup")?;
14128 s.serialize_field("from_lookup", x)?;
14129 s.end()
14130 }
14131 RelocationError::FromWrite(x) => {
14132 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14134 s.serialize_field(".tag", "from_write")?;
14135 s.serialize_field("from_write", x)?;
14136 s.end()
14137 }
14138 RelocationError::To(x) => {
14139 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14141 s.serialize_field(".tag", "to")?;
14142 s.serialize_field("to", x)?;
14143 s.end()
14144 }
14145 RelocationError::CantCopySharedFolder => {
14146 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14148 s.serialize_field(".tag", "cant_copy_shared_folder")?;
14149 s.end()
14150 }
14151 RelocationError::CantNestSharedFolder => {
14152 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14154 s.serialize_field(".tag", "cant_nest_shared_folder")?;
14155 s.end()
14156 }
14157 RelocationError::CantMoveFolderIntoItself => {
14158 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14160 s.serialize_field(".tag", "cant_move_folder_into_itself")?;
14161 s.end()
14162 }
14163 RelocationError::TooManyFiles => {
14164 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14166 s.serialize_field(".tag", "too_many_files")?;
14167 s.end()
14168 }
14169 RelocationError::DuplicatedOrNestedPaths => {
14170 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14172 s.serialize_field(".tag", "duplicated_or_nested_paths")?;
14173 s.end()
14174 }
14175 RelocationError::CantTransferOwnership => {
14176 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14178 s.serialize_field(".tag", "cant_transfer_ownership")?;
14179 s.end()
14180 }
14181 RelocationError::InsufficientQuota => {
14182 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14184 s.serialize_field(".tag", "insufficient_quota")?;
14185 s.end()
14186 }
14187 RelocationError::InternalError => {
14188 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14190 s.serialize_field(".tag", "internal_error")?;
14191 s.end()
14192 }
14193 RelocationError::CantMoveSharedFolder => {
14194 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14196 s.serialize_field(".tag", "cant_move_shared_folder")?;
14197 s.end()
14198 }
14199 RelocationError::CantMoveIntoVault(x) => {
14200 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14202 s.serialize_field(".tag", "cant_move_into_vault")?;
14203 s.serialize_field("cant_move_into_vault", x)?;
14204 s.end()
14205 }
14206 RelocationError::CantMoveIntoFamily(x) => {
14207 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14209 s.serialize_field(".tag", "cant_move_into_family")?;
14210 s.serialize_field("cant_move_into_family", x)?;
14211 s.end()
14212 }
14213 RelocationError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
14214 }
14215 }
14216}
14217
14218impl ::std::error::Error for RelocationError {
14219 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
14220 match self {
14221 RelocationError::FromLookup(inner) => Some(inner),
14222 RelocationError::FromWrite(inner) => Some(inner),
14223 RelocationError::To(inner) => Some(inner),
14224 RelocationError::CantMoveIntoVault(inner) => Some(inner),
14225 RelocationError::CantMoveIntoFamily(inner) => Some(inner),
14226 _ => None,
14227 }
14228 }
14229}
14230
14231impl ::std::fmt::Display for RelocationError {
14232 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14233 match self {
14234 RelocationError::FromLookup(inner) => write!(f, "RelocationError: {}", inner),
14235 RelocationError::FromWrite(inner) => write!(f, "RelocationError: {}", inner),
14236 RelocationError::To(inner) => write!(f, "RelocationError: {}", inner),
14237 RelocationError::CantCopySharedFolder => f.write_str("Shared folders can't be copied."),
14238 RelocationError::CantNestSharedFolder => f.write_str("Your move operation would result in nested shared folders. This is not allowed."),
14239 RelocationError::CantMoveFolderIntoItself => f.write_str("You cannot move a folder into itself."),
14240 RelocationError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
14241 RelocationError::InsufficientQuota => f.write_str("The current user does not have enough space to move or copy the files."),
14242 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."),
14243 RelocationError::CantMoveSharedFolder => f.write_str("Can't move the shared folder to the given destination."),
14244 RelocationError::CantMoveIntoVault(inner) => write!(f, "Some content cannot be moved into Vault under certain circumstances, see detailed error: {}", inner),
14245 RelocationError::CantMoveIntoFamily(inner) => write!(f, "Some content cannot be moved into the Family Room folder under certain circumstances, see detailed error: {}", inner),
14246 _ => write!(f, "{:?}", *self),
14247 }
14248 }
14249}
14250
14251#[derive(Debug, Clone, PartialEq, Eq)]
14252#[non_exhaustive] pub struct RelocationPath {
14254 pub from_path: WritePathOrId,
14256 pub to_path: WritePathOrId,
14258}
14259
14260impl RelocationPath {
14261 pub fn new(from_path: WritePathOrId, to_path: WritePathOrId) -> Self {
14262 RelocationPath {
14263 from_path,
14264 to_path,
14265 }
14266 }
14267}
14268
14269const RELOCATION_PATH_FIELDS: &[&str] = &["from_path",
14270 "to_path"];
14271impl RelocationPath {
14272 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14273 map: V,
14274 ) -> Result<RelocationPath, V::Error> {
14275 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14276 }
14277
14278 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14279 mut map: V,
14280 optional: bool,
14281 ) -> Result<Option<RelocationPath>, V::Error> {
14282 let mut field_from_path = None;
14283 let mut field_to_path = None;
14284 let mut nothing = true;
14285 while let Some(key) = map.next_key::<&str>()? {
14286 nothing = false;
14287 match key {
14288 "from_path" => {
14289 if field_from_path.is_some() {
14290 return Err(::serde::de::Error::duplicate_field("from_path"));
14291 }
14292 field_from_path = Some(map.next_value()?);
14293 }
14294 "to_path" => {
14295 if field_to_path.is_some() {
14296 return Err(::serde::de::Error::duplicate_field("to_path"));
14297 }
14298 field_to_path = Some(map.next_value()?);
14299 }
14300 _ => {
14301 map.next_value::<::serde_json::Value>()?;
14303 }
14304 }
14305 }
14306 if optional && nothing {
14307 return Ok(None);
14308 }
14309 let result = RelocationPath {
14310 from_path: field_from_path.ok_or_else(|| ::serde::de::Error::missing_field("from_path"))?,
14311 to_path: field_to_path.ok_or_else(|| ::serde::de::Error::missing_field("to_path"))?,
14312 };
14313 Ok(Some(result))
14314 }
14315
14316 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14317 &self,
14318 s: &mut S::SerializeStruct,
14319 ) -> Result<(), S::Error> {
14320 use serde::ser::SerializeStruct;
14321 s.serialize_field("from_path", &self.from_path)?;
14322 s.serialize_field("to_path", &self.to_path)?;
14323 Ok(())
14324 }
14325}
14326
14327impl<'de> ::serde::de::Deserialize<'de> for RelocationPath {
14328 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14329 use serde::de::{MapAccess, Visitor};
14331 struct StructVisitor;
14332 impl<'de> Visitor<'de> for StructVisitor {
14333 type Value = RelocationPath;
14334 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14335 f.write_str("a RelocationPath struct")
14336 }
14337 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14338 RelocationPath::internal_deserialize(map)
14339 }
14340 }
14341 deserializer.deserialize_struct("RelocationPath", RELOCATION_PATH_FIELDS, StructVisitor)
14342 }
14343}
14344
14345impl ::serde::ser::Serialize for RelocationPath {
14346 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14347 use serde::ser::SerializeStruct;
14349 let mut s = serializer.serialize_struct("RelocationPath", 2)?;
14350 self.internal_serialize::<S>(&mut s)?;
14351 s.end()
14352 }
14353}
14354
14355#[derive(Debug, Clone, PartialEq)]
14356#[non_exhaustive] pub struct RelocationResult {
14358 pub metadata: Metadata,
14360}
14361
14362impl RelocationResult {
14363 pub fn new(metadata: Metadata) -> Self {
14364 RelocationResult {
14365 metadata,
14366 }
14367 }
14368}
14369
14370const RELOCATION_RESULT_FIELDS: &[&str] = &["metadata"];
14371impl RelocationResult {
14372 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14373 map: V,
14374 ) -> Result<RelocationResult, V::Error> {
14375 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14376 }
14377
14378 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14379 mut map: V,
14380 optional: bool,
14381 ) -> Result<Option<RelocationResult>, V::Error> {
14382 let mut field_metadata = None;
14383 let mut nothing = true;
14384 while let Some(key) = map.next_key::<&str>()? {
14385 nothing = false;
14386 match key {
14387 "metadata" => {
14388 if field_metadata.is_some() {
14389 return Err(::serde::de::Error::duplicate_field("metadata"));
14390 }
14391 field_metadata = Some(map.next_value()?);
14392 }
14393 _ => {
14394 map.next_value::<::serde_json::Value>()?;
14396 }
14397 }
14398 }
14399 if optional && nothing {
14400 return Ok(None);
14401 }
14402 let result = RelocationResult {
14403 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
14404 };
14405 Ok(Some(result))
14406 }
14407
14408 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14409 &self,
14410 s: &mut S::SerializeStruct,
14411 ) -> Result<(), S::Error> {
14412 use serde::ser::SerializeStruct;
14413 s.serialize_field("metadata", &self.metadata)?;
14414 Ok(())
14415 }
14416}
14417
14418impl<'de> ::serde::de::Deserialize<'de> for RelocationResult {
14419 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14420 use serde::de::{MapAccess, Visitor};
14422 struct StructVisitor;
14423 impl<'de> Visitor<'de> for StructVisitor {
14424 type Value = RelocationResult;
14425 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14426 f.write_str("a RelocationResult struct")
14427 }
14428 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14429 RelocationResult::internal_deserialize(map)
14430 }
14431 }
14432 deserializer.deserialize_struct("RelocationResult", RELOCATION_RESULT_FIELDS, StructVisitor)
14433 }
14434}
14435
14436impl ::serde::ser::Serialize for RelocationResult {
14437 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14438 use serde::ser::SerializeStruct;
14440 let mut s = serializer.serialize_struct("RelocationResult", 1)?;
14441 self.internal_serialize::<S>(&mut s)?;
14442 s.end()
14443 }
14444}
14445
14446impl From<RelocationResult> for FileOpsResult {
14448 fn from(_: RelocationResult) -> Self {
14449 Self {}
14450 }
14451}
14452#[derive(Debug, Clone, PartialEq, Eq)]
14453#[non_exhaustive] pub struct RemoveTagArg {
14455 pub path: Path,
14457 pub tag_text: TagText,
14459}
14460
14461impl RemoveTagArg {
14462 pub fn new(path: Path, tag_text: TagText) -> Self {
14463 RemoveTagArg {
14464 path,
14465 tag_text,
14466 }
14467 }
14468}
14469
14470const REMOVE_TAG_ARG_FIELDS: &[&str] = &["path",
14471 "tag_text"];
14472impl RemoveTagArg {
14473 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14474 map: V,
14475 ) -> Result<RemoveTagArg, V::Error> {
14476 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14477 }
14478
14479 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14480 mut map: V,
14481 optional: bool,
14482 ) -> Result<Option<RemoveTagArg>, V::Error> {
14483 let mut field_path = None;
14484 let mut field_tag_text = None;
14485 let mut nothing = true;
14486 while let Some(key) = map.next_key::<&str>()? {
14487 nothing = false;
14488 match key {
14489 "path" => {
14490 if field_path.is_some() {
14491 return Err(::serde::de::Error::duplicate_field("path"));
14492 }
14493 field_path = Some(map.next_value()?);
14494 }
14495 "tag_text" => {
14496 if field_tag_text.is_some() {
14497 return Err(::serde::de::Error::duplicate_field("tag_text"));
14498 }
14499 field_tag_text = Some(map.next_value()?);
14500 }
14501 _ => {
14502 map.next_value::<::serde_json::Value>()?;
14504 }
14505 }
14506 }
14507 if optional && nothing {
14508 return Ok(None);
14509 }
14510 let result = RemoveTagArg {
14511 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
14512 tag_text: field_tag_text.ok_or_else(|| ::serde::de::Error::missing_field("tag_text"))?,
14513 };
14514 Ok(Some(result))
14515 }
14516
14517 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14518 &self,
14519 s: &mut S::SerializeStruct,
14520 ) -> Result<(), S::Error> {
14521 use serde::ser::SerializeStruct;
14522 s.serialize_field("path", &self.path)?;
14523 s.serialize_field("tag_text", &self.tag_text)?;
14524 Ok(())
14525 }
14526}
14527
14528impl<'de> ::serde::de::Deserialize<'de> for RemoveTagArg {
14529 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14530 use serde::de::{MapAccess, Visitor};
14532 struct StructVisitor;
14533 impl<'de> Visitor<'de> for StructVisitor {
14534 type Value = RemoveTagArg;
14535 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14536 f.write_str("a RemoveTagArg struct")
14537 }
14538 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14539 RemoveTagArg::internal_deserialize(map)
14540 }
14541 }
14542 deserializer.deserialize_struct("RemoveTagArg", REMOVE_TAG_ARG_FIELDS, StructVisitor)
14543 }
14544}
14545
14546impl ::serde::ser::Serialize for RemoveTagArg {
14547 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14548 use serde::ser::SerializeStruct;
14550 let mut s = serializer.serialize_struct("RemoveTagArg", 2)?;
14551 self.internal_serialize::<S>(&mut s)?;
14552 s.end()
14553 }
14554}
14555
14556#[derive(Debug, Clone, PartialEq, Eq)]
14557#[non_exhaustive] pub enum RemoveTagError {
14559 Path(LookupError),
14560 TagNotPresent,
14562 Other,
14565}
14566
14567impl<'de> ::serde::de::Deserialize<'de> for RemoveTagError {
14568 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14569 use serde::de::{self, MapAccess, Visitor};
14571 struct EnumVisitor;
14572 impl<'de> Visitor<'de> for EnumVisitor {
14573 type Value = RemoveTagError;
14574 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14575 f.write_str("a RemoveTagError structure")
14576 }
14577 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
14578 let tag: &str = match map.next_key()? {
14579 Some(".tag") => map.next_value()?,
14580 _ => return Err(de::Error::missing_field(".tag"))
14581 };
14582 let value = match tag {
14583 "path" => {
14584 match map.next_key()? {
14585 Some("path") => RemoveTagError::Path(map.next_value()?),
14586 None => return Err(de::Error::missing_field("path")),
14587 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14588 }
14589 }
14590 "tag_not_present" => RemoveTagError::TagNotPresent,
14591 _ => RemoveTagError::Other,
14592 };
14593 crate::eat_json_fields(&mut map)?;
14594 Ok(value)
14595 }
14596 }
14597 const VARIANTS: &[&str] = &["path",
14598 "other",
14599 "tag_not_present"];
14600 deserializer.deserialize_struct("RemoveTagError", VARIANTS, EnumVisitor)
14601 }
14602}
14603
14604impl ::serde::ser::Serialize for RemoveTagError {
14605 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14606 use serde::ser::SerializeStruct;
14608 match self {
14609 RemoveTagError::Path(x) => {
14610 let mut s = serializer.serialize_struct("RemoveTagError", 2)?;
14612 s.serialize_field(".tag", "path")?;
14613 s.serialize_field("path", x)?;
14614 s.end()
14615 }
14616 RemoveTagError::TagNotPresent => {
14617 let mut s = serializer.serialize_struct("RemoveTagError", 1)?;
14619 s.serialize_field(".tag", "tag_not_present")?;
14620 s.end()
14621 }
14622 RemoveTagError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
14623 }
14624 }
14625}
14626
14627impl ::std::error::Error for RemoveTagError {
14628 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
14629 match self {
14630 RemoveTagError::Path(inner) => Some(inner),
14631 _ => None,
14632 }
14633 }
14634}
14635
14636impl ::std::fmt::Display for RemoveTagError {
14637 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14638 match self {
14639 RemoveTagError::Path(inner) => write!(f, "RemoveTagError: {}", inner),
14640 RemoveTagError::TagNotPresent => f.write_str("That tag doesn't exist at this path."),
14641 _ => write!(f, "{:?}", *self),
14642 }
14643 }
14644}
14645
14646impl From<BaseTagError> for RemoveTagError {
14648 fn from(parent: BaseTagError) -> Self {
14649 match parent {
14650 BaseTagError::Path(x) => RemoveTagError::Path(x),
14651 BaseTagError::Other => RemoveTagError::Other,
14652 }
14653 }
14654}
14655#[derive(Debug, Clone, PartialEq, Eq)]
14656#[non_exhaustive] pub struct RestoreArg {
14658 pub path: WritePath,
14660 pub rev: Rev,
14662}
14663
14664impl RestoreArg {
14665 pub fn new(path: WritePath, rev: Rev) -> Self {
14666 RestoreArg {
14667 path,
14668 rev,
14669 }
14670 }
14671}
14672
14673const RESTORE_ARG_FIELDS: &[&str] = &["path",
14674 "rev"];
14675impl RestoreArg {
14676 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14677 map: V,
14678 ) -> Result<RestoreArg, V::Error> {
14679 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14680 }
14681
14682 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14683 mut map: V,
14684 optional: bool,
14685 ) -> Result<Option<RestoreArg>, V::Error> {
14686 let mut field_path = None;
14687 let mut field_rev = None;
14688 let mut nothing = true;
14689 while let Some(key) = map.next_key::<&str>()? {
14690 nothing = false;
14691 match key {
14692 "path" => {
14693 if field_path.is_some() {
14694 return Err(::serde::de::Error::duplicate_field("path"));
14695 }
14696 field_path = Some(map.next_value()?);
14697 }
14698 "rev" => {
14699 if field_rev.is_some() {
14700 return Err(::serde::de::Error::duplicate_field("rev"));
14701 }
14702 field_rev = Some(map.next_value()?);
14703 }
14704 _ => {
14705 map.next_value::<::serde_json::Value>()?;
14707 }
14708 }
14709 }
14710 if optional && nothing {
14711 return Ok(None);
14712 }
14713 let result = RestoreArg {
14714 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
14715 rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
14716 };
14717 Ok(Some(result))
14718 }
14719
14720 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14721 &self,
14722 s: &mut S::SerializeStruct,
14723 ) -> Result<(), S::Error> {
14724 use serde::ser::SerializeStruct;
14725 s.serialize_field("path", &self.path)?;
14726 s.serialize_field("rev", &self.rev)?;
14727 Ok(())
14728 }
14729}
14730
14731impl<'de> ::serde::de::Deserialize<'de> for RestoreArg {
14732 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14733 use serde::de::{MapAccess, Visitor};
14735 struct StructVisitor;
14736 impl<'de> Visitor<'de> for StructVisitor {
14737 type Value = RestoreArg;
14738 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14739 f.write_str("a RestoreArg struct")
14740 }
14741 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14742 RestoreArg::internal_deserialize(map)
14743 }
14744 }
14745 deserializer.deserialize_struct("RestoreArg", RESTORE_ARG_FIELDS, StructVisitor)
14746 }
14747}
14748
14749impl ::serde::ser::Serialize for RestoreArg {
14750 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14751 use serde::ser::SerializeStruct;
14753 let mut s = serializer.serialize_struct("RestoreArg", 2)?;
14754 self.internal_serialize::<S>(&mut s)?;
14755 s.end()
14756 }
14757}
14758
14759#[derive(Debug, Clone, PartialEq, Eq)]
14760#[non_exhaustive] pub enum RestoreError {
14762 PathLookup(LookupError),
14764 PathWrite(WriteError),
14766 InvalidRevision,
14768 InProgress,
14770 Other,
14773}
14774
14775impl<'de> ::serde::de::Deserialize<'de> for RestoreError {
14776 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14777 use serde::de::{self, MapAccess, Visitor};
14779 struct EnumVisitor;
14780 impl<'de> Visitor<'de> for EnumVisitor {
14781 type Value = RestoreError;
14782 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14783 f.write_str("a RestoreError structure")
14784 }
14785 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
14786 let tag: &str = match map.next_key()? {
14787 Some(".tag") => map.next_value()?,
14788 _ => return Err(de::Error::missing_field(".tag"))
14789 };
14790 let value = match tag {
14791 "path_lookup" => {
14792 match map.next_key()? {
14793 Some("path_lookup") => RestoreError::PathLookup(map.next_value()?),
14794 None => return Err(de::Error::missing_field("path_lookup")),
14795 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14796 }
14797 }
14798 "path_write" => {
14799 match map.next_key()? {
14800 Some("path_write") => RestoreError::PathWrite(map.next_value()?),
14801 None => return Err(de::Error::missing_field("path_write")),
14802 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14803 }
14804 }
14805 "invalid_revision" => RestoreError::InvalidRevision,
14806 "in_progress" => RestoreError::InProgress,
14807 _ => RestoreError::Other,
14808 };
14809 crate::eat_json_fields(&mut map)?;
14810 Ok(value)
14811 }
14812 }
14813 const VARIANTS: &[&str] = &["path_lookup",
14814 "path_write",
14815 "invalid_revision",
14816 "in_progress",
14817 "other"];
14818 deserializer.deserialize_struct("RestoreError", VARIANTS, EnumVisitor)
14819 }
14820}
14821
14822impl ::serde::ser::Serialize for RestoreError {
14823 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14824 use serde::ser::SerializeStruct;
14826 match self {
14827 RestoreError::PathLookup(x) => {
14828 let mut s = serializer.serialize_struct("RestoreError", 2)?;
14830 s.serialize_field(".tag", "path_lookup")?;
14831 s.serialize_field("path_lookup", x)?;
14832 s.end()
14833 }
14834 RestoreError::PathWrite(x) => {
14835 let mut s = serializer.serialize_struct("RestoreError", 2)?;
14837 s.serialize_field(".tag", "path_write")?;
14838 s.serialize_field("path_write", x)?;
14839 s.end()
14840 }
14841 RestoreError::InvalidRevision => {
14842 let mut s = serializer.serialize_struct("RestoreError", 1)?;
14844 s.serialize_field(".tag", "invalid_revision")?;
14845 s.end()
14846 }
14847 RestoreError::InProgress => {
14848 let mut s = serializer.serialize_struct("RestoreError", 1)?;
14850 s.serialize_field(".tag", "in_progress")?;
14851 s.end()
14852 }
14853 RestoreError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
14854 }
14855 }
14856}
14857
14858impl ::std::error::Error for RestoreError {
14859 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
14860 match self {
14861 RestoreError::PathLookup(inner) => Some(inner),
14862 RestoreError::PathWrite(inner) => Some(inner),
14863 _ => None,
14864 }
14865 }
14866}
14867
14868impl ::std::fmt::Display for RestoreError {
14869 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14870 match self {
14871 RestoreError::PathLookup(inner) => write!(f, "An error occurs when downloading metadata for the file: {}", inner),
14872 RestoreError::PathWrite(inner) => write!(f, "An error occurs when trying to restore the file to that path: {}", inner),
14873 RestoreError::InvalidRevision => f.write_str("The revision is invalid. It may not exist or may point to a deleted file."),
14874 RestoreError::InProgress => f.write_str("The restore is currently executing, but has not yet completed."),
14875 _ => write!(f, "{:?}", *self),
14876 }
14877 }
14878}
14879
14880#[derive(Debug, Clone, PartialEq, Eq)]
14881#[non_exhaustive] pub struct SaveCopyReferenceArg {
14883 pub copy_reference: String,
14885 pub path: Path,
14887}
14888
14889impl SaveCopyReferenceArg {
14890 pub fn new(copy_reference: String, path: Path) -> Self {
14891 SaveCopyReferenceArg {
14892 copy_reference,
14893 path,
14894 }
14895 }
14896}
14897
14898const SAVE_COPY_REFERENCE_ARG_FIELDS: &[&str] = &["copy_reference",
14899 "path"];
14900impl SaveCopyReferenceArg {
14901 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14902 map: V,
14903 ) -> Result<SaveCopyReferenceArg, V::Error> {
14904 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14905 }
14906
14907 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14908 mut map: V,
14909 optional: bool,
14910 ) -> Result<Option<SaveCopyReferenceArg>, V::Error> {
14911 let mut field_copy_reference = None;
14912 let mut field_path = None;
14913 let mut nothing = true;
14914 while let Some(key) = map.next_key::<&str>()? {
14915 nothing = false;
14916 match key {
14917 "copy_reference" => {
14918 if field_copy_reference.is_some() {
14919 return Err(::serde::de::Error::duplicate_field("copy_reference"));
14920 }
14921 field_copy_reference = Some(map.next_value()?);
14922 }
14923 "path" => {
14924 if field_path.is_some() {
14925 return Err(::serde::de::Error::duplicate_field("path"));
14926 }
14927 field_path = Some(map.next_value()?);
14928 }
14929 _ => {
14930 map.next_value::<::serde_json::Value>()?;
14932 }
14933 }
14934 }
14935 if optional && nothing {
14936 return Ok(None);
14937 }
14938 let result = SaveCopyReferenceArg {
14939 copy_reference: field_copy_reference.ok_or_else(|| ::serde::de::Error::missing_field("copy_reference"))?,
14940 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
14941 };
14942 Ok(Some(result))
14943 }
14944
14945 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14946 &self,
14947 s: &mut S::SerializeStruct,
14948 ) -> Result<(), S::Error> {
14949 use serde::ser::SerializeStruct;
14950 s.serialize_field("copy_reference", &self.copy_reference)?;
14951 s.serialize_field("path", &self.path)?;
14952 Ok(())
14953 }
14954}
14955
14956impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceArg {
14957 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14958 use serde::de::{MapAccess, Visitor};
14960 struct StructVisitor;
14961 impl<'de> Visitor<'de> for StructVisitor {
14962 type Value = SaveCopyReferenceArg;
14963 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14964 f.write_str("a SaveCopyReferenceArg struct")
14965 }
14966 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14967 SaveCopyReferenceArg::internal_deserialize(map)
14968 }
14969 }
14970 deserializer.deserialize_struct("SaveCopyReferenceArg", SAVE_COPY_REFERENCE_ARG_FIELDS, StructVisitor)
14971 }
14972}
14973
14974impl ::serde::ser::Serialize for SaveCopyReferenceArg {
14975 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14976 use serde::ser::SerializeStruct;
14978 let mut s = serializer.serialize_struct("SaveCopyReferenceArg", 2)?;
14979 self.internal_serialize::<S>(&mut s)?;
14980 s.end()
14981 }
14982}
14983
14984#[derive(Debug, Clone, PartialEq, Eq)]
14985#[non_exhaustive] pub enum SaveCopyReferenceError {
14987 Path(WriteError),
14988 InvalidCopyReference,
14990 NoPermission,
14993 NotFound,
14995 TooManyFiles,
14997 Other,
15000}
15001
15002impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceError {
15003 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15004 use serde::de::{self, MapAccess, Visitor};
15006 struct EnumVisitor;
15007 impl<'de> Visitor<'de> for EnumVisitor {
15008 type Value = SaveCopyReferenceError;
15009 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15010 f.write_str("a SaveCopyReferenceError structure")
15011 }
15012 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15013 let tag: &str = match map.next_key()? {
15014 Some(".tag") => map.next_value()?,
15015 _ => return Err(de::Error::missing_field(".tag"))
15016 };
15017 let value = match tag {
15018 "path" => {
15019 match map.next_key()? {
15020 Some("path") => SaveCopyReferenceError::Path(map.next_value()?),
15021 None => return Err(de::Error::missing_field("path")),
15022 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15023 }
15024 }
15025 "invalid_copy_reference" => SaveCopyReferenceError::InvalidCopyReference,
15026 "no_permission" => SaveCopyReferenceError::NoPermission,
15027 "not_found" => SaveCopyReferenceError::NotFound,
15028 "too_many_files" => SaveCopyReferenceError::TooManyFiles,
15029 _ => SaveCopyReferenceError::Other,
15030 };
15031 crate::eat_json_fields(&mut map)?;
15032 Ok(value)
15033 }
15034 }
15035 const VARIANTS: &[&str] = &["path",
15036 "invalid_copy_reference",
15037 "no_permission",
15038 "not_found",
15039 "too_many_files",
15040 "other"];
15041 deserializer.deserialize_struct("SaveCopyReferenceError", VARIANTS, EnumVisitor)
15042 }
15043}
15044
15045impl ::serde::ser::Serialize for SaveCopyReferenceError {
15046 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15047 use serde::ser::SerializeStruct;
15049 match self {
15050 SaveCopyReferenceError::Path(x) => {
15051 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 2)?;
15053 s.serialize_field(".tag", "path")?;
15054 s.serialize_field("path", x)?;
15055 s.end()
15056 }
15057 SaveCopyReferenceError::InvalidCopyReference => {
15058 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15060 s.serialize_field(".tag", "invalid_copy_reference")?;
15061 s.end()
15062 }
15063 SaveCopyReferenceError::NoPermission => {
15064 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15066 s.serialize_field(".tag", "no_permission")?;
15067 s.end()
15068 }
15069 SaveCopyReferenceError::NotFound => {
15070 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15072 s.serialize_field(".tag", "not_found")?;
15073 s.end()
15074 }
15075 SaveCopyReferenceError::TooManyFiles => {
15076 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15078 s.serialize_field(".tag", "too_many_files")?;
15079 s.end()
15080 }
15081 SaveCopyReferenceError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
15082 }
15083 }
15084}
15085
15086impl ::std::error::Error for SaveCopyReferenceError {
15087 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
15088 match self {
15089 SaveCopyReferenceError::Path(inner) => Some(inner),
15090 _ => None,
15091 }
15092 }
15093}
15094
15095impl ::std::fmt::Display for SaveCopyReferenceError {
15096 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15097 match self {
15098 SaveCopyReferenceError::Path(inner) => write!(f, "SaveCopyReferenceError: {}", inner),
15099 SaveCopyReferenceError::InvalidCopyReference => f.write_str("The copy reference is invalid."),
15100 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."),
15101 SaveCopyReferenceError::NotFound => f.write_str("The file referenced by the copy reference cannot be found."),
15102 SaveCopyReferenceError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
15103 _ => write!(f, "{:?}", *self),
15104 }
15105 }
15106}
15107
15108#[derive(Debug, Clone, PartialEq)]
15109#[non_exhaustive] pub struct SaveCopyReferenceResult {
15111 pub metadata: Metadata,
15113}
15114
15115impl SaveCopyReferenceResult {
15116 pub fn new(metadata: Metadata) -> Self {
15117 SaveCopyReferenceResult {
15118 metadata,
15119 }
15120 }
15121}
15122
15123const SAVE_COPY_REFERENCE_RESULT_FIELDS: &[&str] = &["metadata"];
15124impl SaveCopyReferenceResult {
15125 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15126 map: V,
15127 ) -> Result<SaveCopyReferenceResult, V::Error> {
15128 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15129 }
15130
15131 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15132 mut map: V,
15133 optional: bool,
15134 ) -> Result<Option<SaveCopyReferenceResult>, V::Error> {
15135 let mut field_metadata = None;
15136 let mut nothing = true;
15137 while let Some(key) = map.next_key::<&str>()? {
15138 nothing = false;
15139 match key {
15140 "metadata" => {
15141 if field_metadata.is_some() {
15142 return Err(::serde::de::Error::duplicate_field("metadata"));
15143 }
15144 field_metadata = Some(map.next_value()?);
15145 }
15146 _ => {
15147 map.next_value::<::serde_json::Value>()?;
15149 }
15150 }
15151 }
15152 if optional && nothing {
15153 return Ok(None);
15154 }
15155 let result = SaveCopyReferenceResult {
15156 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
15157 };
15158 Ok(Some(result))
15159 }
15160
15161 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15162 &self,
15163 s: &mut S::SerializeStruct,
15164 ) -> Result<(), S::Error> {
15165 use serde::ser::SerializeStruct;
15166 s.serialize_field("metadata", &self.metadata)?;
15167 Ok(())
15168 }
15169}
15170
15171impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceResult {
15172 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15173 use serde::de::{MapAccess, Visitor};
15175 struct StructVisitor;
15176 impl<'de> Visitor<'de> for StructVisitor {
15177 type Value = SaveCopyReferenceResult;
15178 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15179 f.write_str("a SaveCopyReferenceResult struct")
15180 }
15181 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15182 SaveCopyReferenceResult::internal_deserialize(map)
15183 }
15184 }
15185 deserializer.deserialize_struct("SaveCopyReferenceResult", SAVE_COPY_REFERENCE_RESULT_FIELDS, StructVisitor)
15186 }
15187}
15188
15189impl ::serde::ser::Serialize for SaveCopyReferenceResult {
15190 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15191 use serde::ser::SerializeStruct;
15193 let mut s = serializer.serialize_struct("SaveCopyReferenceResult", 1)?;
15194 self.internal_serialize::<S>(&mut s)?;
15195 s.end()
15196 }
15197}
15198
15199#[derive(Debug, Clone, PartialEq, Eq)]
15200#[non_exhaustive] pub struct SaveUrlArg {
15202 pub path: Path,
15204 pub url: String,
15206}
15207
15208impl SaveUrlArg {
15209 pub fn new(path: Path, url: String) -> Self {
15210 SaveUrlArg {
15211 path,
15212 url,
15213 }
15214 }
15215}
15216
15217const SAVE_URL_ARG_FIELDS: &[&str] = &["path",
15218 "url"];
15219impl SaveUrlArg {
15220 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15221 map: V,
15222 ) -> Result<SaveUrlArg, V::Error> {
15223 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15224 }
15225
15226 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15227 mut map: V,
15228 optional: bool,
15229 ) -> Result<Option<SaveUrlArg>, V::Error> {
15230 let mut field_path = None;
15231 let mut field_url = None;
15232 let mut nothing = true;
15233 while let Some(key) = map.next_key::<&str>()? {
15234 nothing = false;
15235 match key {
15236 "path" => {
15237 if field_path.is_some() {
15238 return Err(::serde::de::Error::duplicate_field("path"));
15239 }
15240 field_path = Some(map.next_value()?);
15241 }
15242 "url" => {
15243 if field_url.is_some() {
15244 return Err(::serde::de::Error::duplicate_field("url"));
15245 }
15246 field_url = Some(map.next_value()?);
15247 }
15248 _ => {
15249 map.next_value::<::serde_json::Value>()?;
15251 }
15252 }
15253 }
15254 if optional && nothing {
15255 return Ok(None);
15256 }
15257 let result = SaveUrlArg {
15258 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
15259 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
15260 };
15261 Ok(Some(result))
15262 }
15263
15264 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15265 &self,
15266 s: &mut S::SerializeStruct,
15267 ) -> Result<(), S::Error> {
15268 use serde::ser::SerializeStruct;
15269 s.serialize_field("path", &self.path)?;
15270 s.serialize_field("url", &self.url)?;
15271 Ok(())
15272 }
15273}
15274
15275impl<'de> ::serde::de::Deserialize<'de> for SaveUrlArg {
15276 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15277 use serde::de::{MapAccess, Visitor};
15279 struct StructVisitor;
15280 impl<'de> Visitor<'de> for StructVisitor {
15281 type Value = SaveUrlArg;
15282 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15283 f.write_str("a SaveUrlArg struct")
15284 }
15285 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15286 SaveUrlArg::internal_deserialize(map)
15287 }
15288 }
15289 deserializer.deserialize_struct("SaveUrlArg", SAVE_URL_ARG_FIELDS, StructVisitor)
15290 }
15291}
15292
15293impl ::serde::ser::Serialize for SaveUrlArg {
15294 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15295 use serde::ser::SerializeStruct;
15297 let mut s = serializer.serialize_struct("SaveUrlArg", 2)?;
15298 self.internal_serialize::<S>(&mut s)?;
15299 s.end()
15300 }
15301}
15302
15303#[derive(Debug, Clone, PartialEq, Eq)]
15304#[non_exhaustive] pub enum SaveUrlError {
15306 Path(WriteError),
15307 DownloadFailed,
15310 InvalidUrl,
15312 NotFound,
15314 Other,
15317}
15318
15319impl<'de> ::serde::de::Deserialize<'de> for SaveUrlError {
15320 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15321 use serde::de::{self, MapAccess, Visitor};
15323 struct EnumVisitor;
15324 impl<'de> Visitor<'de> for EnumVisitor {
15325 type Value = SaveUrlError;
15326 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15327 f.write_str("a SaveUrlError structure")
15328 }
15329 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15330 let tag: &str = match map.next_key()? {
15331 Some(".tag") => map.next_value()?,
15332 _ => return Err(de::Error::missing_field(".tag"))
15333 };
15334 let value = match tag {
15335 "path" => {
15336 match map.next_key()? {
15337 Some("path") => SaveUrlError::Path(map.next_value()?),
15338 None => return Err(de::Error::missing_field("path")),
15339 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15340 }
15341 }
15342 "download_failed" => SaveUrlError::DownloadFailed,
15343 "invalid_url" => SaveUrlError::InvalidUrl,
15344 "not_found" => SaveUrlError::NotFound,
15345 _ => SaveUrlError::Other,
15346 };
15347 crate::eat_json_fields(&mut map)?;
15348 Ok(value)
15349 }
15350 }
15351 const VARIANTS: &[&str] = &["path",
15352 "download_failed",
15353 "invalid_url",
15354 "not_found",
15355 "other"];
15356 deserializer.deserialize_struct("SaveUrlError", VARIANTS, EnumVisitor)
15357 }
15358}
15359
15360impl ::serde::ser::Serialize for SaveUrlError {
15361 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15362 use serde::ser::SerializeStruct;
15364 match self {
15365 SaveUrlError::Path(x) => {
15366 let mut s = serializer.serialize_struct("SaveUrlError", 2)?;
15368 s.serialize_field(".tag", "path")?;
15369 s.serialize_field("path", x)?;
15370 s.end()
15371 }
15372 SaveUrlError::DownloadFailed => {
15373 let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
15375 s.serialize_field(".tag", "download_failed")?;
15376 s.end()
15377 }
15378 SaveUrlError::InvalidUrl => {
15379 let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
15381 s.serialize_field(".tag", "invalid_url")?;
15382 s.end()
15383 }
15384 SaveUrlError::NotFound => {
15385 let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
15387 s.serialize_field(".tag", "not_found")?;
15388 s.end()
15389 }
15390 SaveUrlError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
15391 }
15392 }
15393}
15394
15395impl ::std::error::Error for SaveUrlError {
15396 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
15397 match self {
15398 SaveUrlError::Path(inner) => Some(inner),
15399 _ => None,
15400 }
15401 }
15402}
15403
15404impl ::std::fmt::Display for SaveUrlError {
15405 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15406 match self {
15407 SaveUrlError::Path(inner) => write!(f, "SaveUrlError: {}", inner),
15408 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."),
15409 SaveUrlError::InvalidUrl => f.write_str("The given URL is invalid."),
15410 SaveUrlError::NotFound => f.write_str("The file where the URL is saved to no longer exists."),
15411 _ => write!(f, "{:?}", *self),
15412 }
15413 }
15414}
15415
15416#[derive(Debug, Clone, PartialEq)]
15417pub enum SaveUrlJobStatus {
15418 InProgress,
15420 Complete(FileMetadata),
15422 Failed(SaveUrlError),
15423}
15424
15425impl<'de> ::serde::de::Deserialize<'de> for SaveUrlJobStatus {
15426 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15427 use serde::de::{self, MapAccess, Visitor};
15429 struct EnumVisitor;
15430 impl<'de> Visitor<'de> for EnumVisitor {
15431 type Value = SaveUrlJobStatus;
15432 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15433 f.write_str("a SaveUrlJobStatus structure")
15434 }
15435 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15436 let tag: &str = match map.next_key()? {
15437 Some(".tag") => map.next_value()?,
15438 _ => return Err(de::Error::missing_field(".tag"))
15439 };
15440 let value = match tag {
15441 "in_progress" => SaveUrlJobStatus::InProgress,
15442 "complete" => SaveUrlJobStatus::Complete(FileMetadata::internal_deserialize(&mut map)?),
15443 "failed" => {
15444 match map.next_key()? {
15445 Some("failed") => SaveUrlJobStatus::Failed(map.next_value()?),
15446 None => return Err(de::Error::missing_field("failed")),
15447 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15448 }
15449 }
15450 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
15451 };
15452 crate::eat_json_fields(&mut map)?;
15453 Ok(value)
15454 }
15455 }
15456 const VARIANTS: &[&str] = &["in_progress",
15457 "complete",
15458 "failed"];
15459 deserializer.deserialize_struct("SaveUrlJobStatus", VARIANTS, EnumVisitor)
15460 }
15461}
15462
15463impl ::serde::ser::Serialize for SaveUrlJobStatus {
15464 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15465 use serde::ser::SerializeStruct;
15467 match self {
15468 SaveUrlJobStatus::InProgress => {
15469 let mut s = serializer.serialize_struct("SaveUrlJobStatus", 1)?;
15471 s.serialize_field(".tag", "in_progress")?;
15472 s.end()
15473 }
15474 SaveUrlJobStatus::Complete(x) => {
15475 let mut s = serializer.serialize_struct("SaveUrlJobStatus", 20)?;
15477 s.serialize_field(".tag", "complete")?;
15478 x.internal_serialize::<S>(&mut s)?;
15479 s.end()
15480 }
15481 SaveUrlJobStatus::Failed(x) => {
15482 let mut s = serializer.serialize_struct("SaveUrlJobStatus", 2)?;
15484 s.serialize_field(".tag", "failed")?;
15485 s.serialize_field("failed", x)?;
15486 s.end()
15487 }
15488 }
15489 }
15490}
15491
15492impl From<crate::types::dbx_async::PollResultBase> for SaveUrlJobStatus {
15494 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
15495 match parent {
15496 crate::types::dbx_async::PollResultBase::InProgress => SaveUrlJobStatus::InProgress,
15497 }
15498 }
15499}
15500#[derive(Debug, Clone, PartialEq)]
15501pub enum SaveUrlResult {
15502 AsyncJobId(crate::types::dbx_async::AsyncJobId),
15505 Complete(FileMetadata),
15507}
15508
15509impl<'de> ::serde::de::Deserialize<'de> for SaveUrlResult {
15510 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15511 use serde::de::{self, MapAccess, Visitor};
15513 struct EnumVisitor;
15514 impl<'de> Visitor<'de> for EnumVisitor {
15515 type Value = SaveUrlResult;
15516 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15517 f.write_str("a SaveUrlResult structure")
15518 }
15519 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15520 let tag: &str = match map.next_key()? {
15521 Some(".tag") => map.next_value()?,
15522 _ => return Err(de::Error::missing_field(".tag"))
15523 };
15524 let value = match tag {
15525 "async_job_id" => {
15526 match map.next_key()? {
15527 Some("async_job_id") => SaveUrlResult::AsyncJobId(map.next_value()?),
15528 None => return Err(de::Error::missing_field("async_job_id")),
15529 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15530 }
15531 }
15532 "complete" => SaveUrlResult::Complete(FileMetadata::internal_deserialize(&mut map)?),
15533 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
15534 };
15535 crate::eat_json_fields(&mut map)?;
15536 Ok(value)
15537 }
15538 }
15539 const VARIANTS: &[&str] = &["async_job_id",
15540 "complete"];
15541 deserializer.deserialize_struct("SaveUrlResult", VARIANTS, EnumVisitor)
15542 }
15543}
15544
15545impl ::serde::ser::Serialize for SaveUrlResult {
15546 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15547 use serde::ser::SerializeStruct;
15549 match self {
15550 SaveUrlResult::AsyncJobId(x) => {
15551 let mut s = serializer.serialize_struct("SaveUrlResult", 2)?;
15553 s.serialize_field(".tag", "async_job_id")?;
15554 s.serialize_field("async_job_id", x)?;
15555 s.end()
15556 }
15557 SaveUrlResult::Complete(x) => {
15558 let mut s = serializer.serialize_struct("SaveUrlResult", 20)?;
15560 s.serialize_field(".tag", "complete")?;
15561 x.internal_serialize::<S>(&mut s)?;
15562 s.end()
15563 }
15564 }
15565 }
15566}
15567
15568impl From<crate::types::dbx_async::LaunchResultBase> for SaveUrlResult {
15570 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
15571 match parent {
15572 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => SaveUrlResult::AsyncJobId(x),
15573 }
15574 }
15575}
15576#[derive(Debug, Clone, PartialEq, Eq)]
15577#[non_exhaustive] pub struct SearchArg {
15579 pub path: PathROrId,
15581 pub query: String,
15585 pub start: u64,
15587 pub max_results: u64,
15589 pub mode: SearchMode,
15592}
15593
15594impl SearchArg {
15595 pub fn new(path: PathROrId, query: String) -> Self {
15596 SearchArg {
15597 path,
15598 query,
15599 start: 0,
15600 max_results: 100,
15601 mode: SearchMode::Filename,
15602 }
15603 }
15604
15605 pub fn with_start(mut self, value: u64) -> Self {
15606 self.start = value;
15607 self
15608 }
15609
15610 pub fn with_max_results(mut self, value: u64) -> Self {
15611 self.max_results = value;
15612 self
15613 }
15614
15615 pub fn with_mode(mut self, value: SearchMode) -> Self {
15616 self.mode = value;
15617 self
15618 }
15619}
15620
15621const SEARCH_ARG_FIELDS: &[&str] = &["path",
15622 "query",
15623 "start",
15624 "max_results",
15625 "mode"];
15626impl SearchArg {
15627 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15628 map: V,
15629 ) -> Result<SearchArg, V::Error> {
15630 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15631 }
15632
15633 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15634 mut map: V,
15635 optional: bool,
15636 ) -> Result<Option<SearchArg>, V::Error> {
15637 let mut field_path = None;
15638 let mut field_query = None;
15639 let mut field_start = None;
15640 let mut field_max_results = None;
15641 let mut field_mode = None;
15642 let mut nothing = true;
15643 while let Some(key) = map.next_key::<&str>()? {
15644 nothing = false;
15645 match key {
15646 "path" => {
15647 if field_path.is_some() {
15648 return Err(::serde::de::Error::duplicate_field("path"));
15649 }
15650 field_path = Some(map.next_value()?);
15651 }
15652 "query" => {
15653 if field_query.is_some() {
15654 return Err(::serde::de::Error::duplicate_field("query"));
15655 }
15656 field_query = Some(map.next_value()?);
15657 }
15658 "start" => {
15659 if field_start.is_some() {
15660 return Err(::serde::de::Error::duplicate_field("start"));
15661 }
15662 field_start = Some(map.next_value()?);
15663 }
15664 "max_results" => {
15665 if field_max_results.is_some() {
15666 return Err(::serde::de::Error::duplicate_field("max_results"));
15667 }
15668 field_max_results = Some(map.next_value()?);
15669 }
15670 "mode" => {
15671 if field_mode.is_some() {
15672 return Err(::serde::de::Error::duplicate_field("mode"));
15673 }
15674 field_mode = Some(map.next_value()?);
15675 }
15676 _ => {
15677 map.next_value::<::serde_json::Value>()?;
15679 }
15680 }
15681 }
15682 if optional && nothing {
15683 return Ok(None);
15684 }
15685 let result = SearchArg {
15686 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
15687 query: field_query.ok_or_else(|| ::serde::de::Error::missing_field("query"))?,
15688 start: field_start.unwrap_or(0),
15689 max_results: field_max_results.unwrap_or(100),
15690 mode: field_mode.unwrap_or(SearchMode::Filename),
15691 };
15692 Ok(Some(result))
15693 }
15694
15695 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15696 &self,
15697 s: &mut S::SerializeStruct,
15698 ) -> Result<(), S::Error> {
15699 use serde::ser::SerializeStruct;
15700 s.serialize_field("path", &self.path)?;
15701 s.serialize_field("query", &self.query)?;
15702 if self.start != 0 {
15703 s.serialize_field("start", &self.start)?;
15704 }
15705 if self.max_results != 100 {
15706 s.serialize_field("max_results", &self.max_results)?;
15707 }
15708 if self.mode != SearchMode::Filename {
15709 s.serialize_field("mode", &self.mode)?;
15710 }
15711 Ok(())
15712 }
15713}
15714
15715impl<'de> ::serde::de::Deserialize<'de> for SearchArg {
15716 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15717 use serde::de::{MapAccess, Visitor};
15719 struct StructVisitor;
15720 impl<'de> Visitor<'de> for StructVisitor {
15721 type Value = SearchArg;
15722 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15723 f.write_str("a SearchArg struct")
15724 }
15725 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15726 SearchArg::internal_deserialize(map)
15727 }
15728 }
15729 deserializer.deserialize_struct("SearchArg", SEARCH_ARG_FIELDS, StructVisitor)
15730 }
15731}
15732
15733impl ::serde::ser::Serialize for SearchArg {
15734 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15735 use serde::ser::SerializeStruct;
15737 let mut s = serializer.serialize_struct("SearchArg", 5)?;
15738 self.internal_serialize::<S>(&mut s)?;
15739 s.end()
15740 }
15741}
15742
15743#[derive(Debug, Clone, PartialEq, Eq)]
15744#[non_exhaustive] pub enum SearchError {
15746 Path(LookupError),
15747 InvalidArgument(Option<String>),
15748 InternalError,
15750 Other,
15753}
15754
15755impl<'de> ::serde::de::Deserialize<'de> for SearchError {
15756 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15757 use serde::de::{self, MapAccess, Visitor};
15759 struct EnumVisitor;
15760 impl<'de> Visitor<'de> for EnumVisitor {
15761 type Value = SearchError;
15762 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15763 f.write_str("a SearchError structure")
15764 }
15765 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15766 let tag: &str = match map.next_key()? {
15767 Some(".tag") => map.next_value()?,
15768 _ => return Err(de::Error::missing_field(".tag"))
15769 };
15770 let value = match tag {
15771 "path" => {
15772 match map.next_key()? {
15773 Some("path") => SearchError::Path(map.next_value()?),
15774 None => return Err(de::Error::missing_field("path")),
15775 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15776 }
15777 }
15778 "invalid_argument" => {
15779 match map.next_key()? {
15780 Some("invalid_argument") => SearchError::InvalidArgument(map.next_value()?),
15781 None => SearchError::InvalidArgument(None),
15782 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15783 }
15784 }
15785 "internal_error" => SearchError::InternalError,
15786 _ => SearchError::Other,
15787 };
15788 crate::eat_json_fields(&mut map)?;
15789 Ok(value)
15790 }
15791 }
15792 const VARIANTS: &[&str] = &["path",
15793 "invalid_argument",
15794 "internal_error",
15795 "other"];
15796 deserializer.deserialize_struct("SearchError", VARIANTS, EnumVisitor)
15797 }
15798}
15799
15800impl ::serde::ser::Serialize for SearchError {
15801 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15802 use serde::ser::SerializeStruct;
15804 match self {
15805 SearchError::Path(x) => {
15806 let mut s = serializer.serialize_struct("SearchError", 2)?;
15808 s.serialize_field(".tag", "path")?;
15809 s.serialize_field("path", x)?;
15810 s.end()
15811 }
15812 SearchError::InvalidArgument(x) => {
15813 let n = if x.is_some() { 2 } else { 1 };
15815 let mut s = serializer.serialize_struct("SearchError", n)?;
15816 s.serialize_field(".tag", "invalid_argument")?;
15817 if let Some(x) = x {
15818 s.serialize_field("invalid_argument", &x)?;
15819 }
15820 s.end()
15821 }
15822 SearchError::InternalError => {
15823 let mut s = serializer.serialize_struct("SearchError", 1)?;
15825 s.serialize_field(".tag", "internal_error")?;
15826 s.end()
15827 }
15828 SearchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
15829 }
15830 }
15831}
15832
15833impl ::std::error::Error for SearchError {
15834 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
15835 match self {
15836 SearchError::Path(inner) => Some(inner),
15837 _ => None,
15838 }
15839 }
15840}
15841
15842impl ::std::fmt::Display for SearchError {
15843 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15844 match self {
15845 SearchError::Path(inner) => write!(f, "SearchError: {}", inner),
15846 SearchError::InvalidArgument(None) => f.write_str("invalid_argument"),
15847 SearchError::InvalidArgument(Some(inner)) => write!(f, "invalid_argument: {:?}", inner),
15848 SearchError::InternalError => f.write_str("Something went wrong, please try again."),
15849 _ => write!(f, "{:?}", *self),
15850 }
15851 }
15852}
15853
15854#[derive(Debug, Clone, PartialEq)]
15855#[non_exhaustive] pub struct SearchMatch {
15857 pub match_type: SearchMatchType,
15859 pub metadata: Metadata,
15861}
15862
15863impl SearchMatch {
15864 pub fn new(match_type: SearchMatchType, metadata: Metadata) -> Self {
15865 SearchMatch {
15866 match_type,
15867 metadata,
15868 }
15869 }
15870}
15871
15872const SEARCH_MATCH_FIELDS: &[&str] = &["match_type",
15873 "metadata"];
15874impl SearchMatch {
15875 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15876 map: V,
15877 ) -> Result<SearchMatch, V::Error> {
15878 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15879 }
15880
15881 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15882 mut map: V,
15883 optional: bool,
15884 ) -> Result<Option<SearchMatch>, V::Error> {
15885 let mut field_match_type = None;
15886 let mut field_metadata = None;
15887 let mut nothing = true;
15888 while let Some(key) = map.next_key::<&str>()? {
15889 nothing = false;
15890 match key {
15891 "match_type" => {
15892 if field_match_type.is_some() {
15893 return Err(::serde::de::Error::duplicate_field("match_type"));
15894 }
15895 field_match_type = Some(map.next_value()?);
15896 }
15897 "metadata" => {
15898 if field_metadata.is_some() {
15899 return Err(::serde::de::Error::duplicate_field("metadata"));
15900 }
15901 field_metadata = Some(map.next_value()?);
15902 }
15903 _ => {
15904 map.next_value::<::serde_json::Value>()?;
15906 }
15907 }
15908 }
15909 if optional && nothing {
15910 return Ok(None);
15911 }
15912 let result = SearchMatch {
15913 match_type: field_match_type.ok_or_else(|| ::serde::de::Error::missing_field("match_type"))?,
15914 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
15915 };
15916 Ok(Some(result))
15917 }
15918
15919 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15920 &self,
15921 s: &mut S::SerializeStruct,
15922 ) -> Result<(), S::Error> {
15923 use serde::ser::SerializeStruct;
15924 s.serialize_field("match_type", &self.match_type)?;
15925 s.serialize_field("metadata", &self.metadata)?;
15926 Ok(())
15927 }
15928}
15929
15930impl<'de> ::serde::de::Deserialize<'de> for SearchMatch {
15931 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15932 use serde::de::{MapAccess, Visitor};
15934 struct StructVisitor;
15935 impl<'de> Visitor<'de> for StructVisitor {
15936 type Value = SearchMatch;
15937 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15938 f.write_str("a SearchMatch struct")
15939 }
15940 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15941 SearchMatch::internal_deserialize(map)
15942 }
15943 }
15944 deserializer.deserialize_struct("SearchMatch", SEARCH_MATCH_FIELDS, StructVisitor)
15945 }
15946}
15947
15948impl ::serde::ser::Serialize for SearchMatch {
15949 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15950 use serde::ser::SerializeStruct;
15952 let mut s = serializer.serialize_struct("SearchMatch", 2)?;
15953 self.internal_serialize::<S>(&mut s)?;
15954 s.end()
15955 }
15956}
15957
15958#[derive(Debug, Clone, PartialEq, Eq, Default)]
15959#[non_exhaustive] pub struct SearchMatchFieldOptions {
15961 pub include_highlights: bool,
15963}
15964
15965impl SearchMatchFieldOptions {
15966 pub fn with_include_highlights(mut self, value: bool) -> Self {
15967 self.include_highlights = value;
15968 self
15969 }
15970}
15971
15972const SEARCH_MATCH_FIELD_OPTIONS_FIELDS: &[&str] = &["include_highlights"];
15973impl SearchMatchFieldOptions {
15974 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15976 mut map: V,
15977 ) -> Result<SearchMatchFieldOptions, V::Error> {
15978 let mut field_include_highlights = None;
15979 while let Some(key) = map.next_key::<&str>()? {
15980 match key {
15981 "include_highlights" => {
15982 if field_include_highlights.is_some() {
15983 return Err(::serde::de::Error::duplicate_field("include_highlights"));
15984 }
15985 field_include_highlights = Some(map.next_value()?);
15986 }
15987 _ => {
15988 map.next_value::<::serde_json::Value>()?;
15990 }
15991 }
15992 }
15993 let result = SearchMatchFieldOptions {
15994 include_highlights: field_include_highlights.unwrap_or(false),
15995 };
15996 Ok(result)
15997 }
15998
15999 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16000 &self,
16001 s: &mut S::SerializeStruct,
16002 ) -> Result<(), S::Error> {
16003 use serde::ser::SerializeStruct;
16004 if self.include_highlights {
16005 s.serialize_field("include_highlights", &self.include_highlights)?;
16006 }
16007 Ok(())
16008 }
16009}
16010
16011impl<'de> ::serde::de::Deserialize<'de> for SearchMatchFieldOptions {
16012 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16013 use serde::de::{MapAccess, Visitor};
16015 struct StructVisitor;
16016 impl<'de> Visitor<'de> for StructVisitor {
16017 type Value = SearchMatchFieldOptions;
16018 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16019 f.write_str("a SearchMatchFieldOptions struct")
16020 }
16021 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16022 SearchMatchFieldOptions::internal_deserialize(map)
16023 }
16024 }
16025 deserializer.deserialize_struct("SearchMatchFieldOptions", SEARCH_MATCH_FIELD_OPTIONS_FIELDS, StructVisitor)
16026 }
16027}
16028
16029impl ::serde::ser::Serialize for SearchMatchFieldOptions {
16030 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16031 use serde::ser::SerializeStruct;
16033 let mut s = serializer.serialize_struct("SearchMatchFieldOptions", 1)?;
16034 self.internal_serialize::<S>(&mut s)?;
16035 s.end()
16036 }
16037}
16038
16039#[derive(Debug, Clone, PartialEq, Eq)]
16041pub enum SearchMatchType {
16042 Filename,
16044 Content,
16046 Both,
16048}
16049
16050impl<'de> ::serde::de::Deserialize<'de> for SearchMatchType {
16051 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16052 use serde::de::{self, MapAccess, Visitor};
16054 struct EnumVisitor;
16055 impl<'de> Visitor<'de> for EnumVisitor {
16056 type Value = SearchMatchType;
16057 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16058 f.write_str("a SearchMatchType structure")
16059 }
16060 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16061 let tag: &str = match map.next_key()? {
16062 Some(".tag") => map.next_value()?,
16063 _ => return Err(de::Error::missing_field(".tag"))
16064 };
16065 let value = match tag {
16066 "filename" => SearchMatchType::Filename,
16067 "content" => SearchMatchType::Content,
16068 "both" => SearchMatchType::Both,
16069 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
16070 };
16071 crate::eat_json_fields(&mut map)?;
16072 Ok(value)
16073 }
16074 }
16075 const VARIANTS: &[&str] = &["filename",
16076 "content",
16077 "both"];
16078 deserializer.deserialize_struct("SearchMatchType", VARIANTS, EnumVisitor)
16079 }
16080}
16081
16082impl ::serde::ser::Serialize for SearchMatchType {
16083 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16084 use serde::ser::SerializeStruct;
16086 match self {
16087 SearchMatchType::Filename => {
16088 let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
16090 s.serialize_field(".tag", "filename")?;
16091 s.end()
16092 }
16093 SearchMatchType::Content => {
16094 let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
16096 s.serialize_field(".tag", "content")?;
16097 s.end()
16098 }
16099 SearchMatchType::Both => {
16100 let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
16102 s.serialize_field(".tag", "both")?;
16103 s.end()
16104 }
16105 }
16106 }
16107}
16108
16109#[derive(Debug, Clone, PartialEq, Eq)]
16111#[non_exhaustive] pub enum SearchMatchTypeV2 {
16113 Filename,
16115 FileContent,
16117 FilenameAndContent,
16119 ImageContent,
16121 Metadata,
16123 Other,
16126}
16127
16128impl<'de> ::serde::de::Deserialize<'de> for SearchMatchTypeV2 {
16129 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16130 use serde::de::{self, MapAccess, Visitor};
16132 struct EnumVisitor;
16133 impl<'de> Visitor<'de> for EnumVisitor {
16134 type Value = SearchMatchTypeV2;
16135 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16136 f.write_str("a SearchMatchTypeV2 structure")
16137 }
16138 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16139 let tag: &str = match map.next_key()? {
16140 Some(".tag") => map.next_value()?,
16141 _ => return Err(de::Error::missing_field(".tag"))
16142 };
16143 let value = match tag {
16144 "filename" => SearchMatchTypeV2::Filename,
16145 "file_content" => SearchMatchTypeV2::FileContent,
16146 "filename_and_content" => SearchMatchTypeV2::FilenameAndContent,
16147 "image_content" => SearchMatchTypeV2::ImageContent,
16148 "metadata" => SearchMatchTypeV2::Metadata,
16149 _ => SearchMatchTypeV2::Other,
16150 };
16151 crate::eat_json_fields(&mut map)?;
16152 Ok(value)
16153 }
16154 }
16155 const VARIANTS: &[&str] = &["filename",
16156 "file_content",
16157 "filename_and_content",
16158 "image_content",
16159 "metadata",
16160 "other"];
16161 deserializer.deserialize_struct("SearchMatchTypeV2", VARIANTS, EnumVisitor)
16162 }
16163}
16164
16165impl ::serde::ser::Serialize for SearchMatchTypeV2 {
16166 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16167 use serde::ser::SerializeStruct;
16169 match self {
16170 SearchMatchTypeV2::Filename => {
16171 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16173 s.serialize_field(".tag", "filename")?;
16174 s.end()
16175 }
16176 SearchMatchTypeV2::FileContent => {
16177 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16179 s.serialize_field(".tag", "file_content")?;
16180 s.end()
16181 }
16182 SearchMatchTypeV2::FilenameAndContent => {
16183 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16185 s.serialize_field(".tag", "filename_and_content")?;
16186 s.end()
16187 }
16188 SearchMatchTypeV2::ImageContent => {
16189 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16191 s.serialize_field(".tag", "image_content")?;
16192 s.end()
16193 }
16194 SearchMatchTypeV2::Metadata => {
16195 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16197 s.serialize_field(".tag", "metadata")?;
16198 s.end()
16199 }
16200 SearchMatchTypeV2::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
16201 }
16202 }
16203}
16204
16205#[derive(Debug, Clone, PartialEq)]
16206#[non_exhaustive] pub struct SearchMatchV2 {
16208 pub metadata: MetadataV2,
16210 pub match_type: Option<SearchMatchTypeV2>,
16212 pub highlight_spans: Option<Vec<HighlightSpan>>,
16214}
16215
16216impl SearchMatchV2 {
16217 pub fn new(metadata: MetadataV2) -> Self {
16218 SearchMatchV2 {
16219 metadata,
16220 match_type: None,
16221 highlight_spans: None,
16222 }
16223 }
16224
16225 pub fn with_match_type(mut self, value: SearchMatchTypeV2) -> Self {
16226 self.match_type = Some(value);
16227 self
16228 }
16229
16230 pub fn with_highlight_spans(mut self, value: Vec<HighlightSpan>) -> Self {
16231 self.highlight_spans = Some(value);
16232 self
16233 }
16234}
16235
16236const SEARCH_MATCH_V2_FIELDS: &[&str] = &["metadata",
16237 "match_type",
16238 "highlight_spans"];
16239impl SearchMatchV2 {
16240 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16241 map: V,
16242 ) -> Result<SearchMatchV2, V::Error> {
16243 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16244 }
16245
16246 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16247 mut map: V,
16248 optional: bool,
16249 ) -> Result<Option<SearchMatchV2>, V::Error> {
16250 let mut field_metadata = None;
16251 let mut field_match_type = None;
16252 let mut field_highlight_spans = None;
16253 let mut nothing = true;
16254 while let Some(key) = map.next_key::<&str>()? {
16255 nothing = false;
16256 match key {
16257 "metadata" => {
16258 if field_metadata.is_some() {
16259 return Err(::serde::de::Error::duplicate_field("metadata"));
16260 }
16261 field_metadata = Some(map.next_value()?);
16262 }
16263 "match_type" => {
16264 if field_match_type.is_some() {
16265 return Err(::serde::de::Error::duplicate_field("match_type"));
16266 }
16267 field_match_type = Some(map.next_value()?);
16268 }
16269 "highlight_spans" => {
16270 if field_highlight_spans.is_some() {
16271 return Err(::serde::de::Error::duplicate_field("highlight_spans"));
16272 }
16273 field_highlight_spans = Some(map.next_value()?);
16274 }
16275 _ => {
16276 map.next_value::<::serde_json::Value>()?;
16278 }
16279 }
16280 }
16281 if optional && nothing {
16282 return Ok(None);
16283 }
16284 let result = SearchMatchV2 {
16285 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
16286 match_type: field_match_type.and_then(Option::flatten),
16287 highlight_spans: field_highlight_spans.and_then(Option::flatten),
16288 };
16289 Ok(Some(result))
16290 }
16291
16292 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16293 &self,
16294 s: &mut S::SerializeStruct,
16295 ) -> Result<(), S::Error> {
16296 use serde::ser::SerializeStruct;
16297 s.serialize_field("metadata", &self.metadata)?;
16298 if let Some(val) = &self.match_type {
16299 s.serialize_field("match_type", val)?;
16300 }
16301 if let Some(val) = &self.highlight_spans {
16302 s.serialize_field("highlight_spans", val)?;
16303 }
16304 Ok(())
16305 }
16306}
16307
16308impl<'de> ::serde::de::Deserialize<'de> for SearchMatchV2 {
16309 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16310 use serde::de::{MapAccess, Visitor};
16312 struct StructVisitor;
16313 impl<'de> Visitor<'de> for StructVisitor {
16314 type Value = SearchMatchV2;
16315 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16316 f.write_str("a SearchMatchV2 struct")
16317 }
16318 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16319 SearchMatchV2::internal_deserialize(map)
16320 }
16321 }
16322 deserializer.deserialize_struct("SearchMatchV2", SEARCH_MATCH_V2_FIELDS, StructVisitor)
16323 }
16324}
16325
16326impl ::serde::ser::Serialize for SearchMatchV2 {
16327 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16328 use serde::ser::SerializeStruct;
16330 let mut s = serializer.serialize_struct("SearchMatchV2", 3)?;
16331 self.internal_serialize::<S>(&mut s)?;
16332 s.end()
16333 }
16334}
16335
16336#[derive(Debug, Clone, PartialEq, Eq)]
16337pub enum SearchMode {
16338 Filename,
16340 FilenameAndContent,
16342 DeletedFilename,
16344}
16345
16346impl<'de> ::serde::de::Deserialize<'de> for SearchMode {
16347 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16348 use serde::de::{self, MapAccess, Visitor};
16350 struct EnumVisitor;
16351 impl<'de> Visitor<'de> for EnumVisitor {
16352 type Value = SearchMode;
16353 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16354 f.write_str("a SearchMode structure")
16355 }
16356 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16357 let tag: &str = match map.next_key()? {
16358 Some(".tag") => map.next_value()?,
16359 _ => return Err(de::Error::missing_field(".tag"))
16360 };
16361 let value = match tag {
16362 "filename" => SearchMode::Filename,
16363 "filename_and_content" => SearchMode::FilenameAndContent,
16364 "deleted_filename" => SearchMode::DeletedFilename,
16365 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
16366 };
16367 crate::eat_json_fields(&mut map)?;
16368 Ok(value)
16369 }
16370 }
16371 const VARIANTS: &[&str] = &["filename",
16372 "filename_and_content",
16373 "deleted_filename"];
16374 deserializer.deserialize_struct("SearchMode", VARIANTS, EnumVisitor)
16375 }
16376}
16377
16378impl ::serde::ser::Serialize for SearchMode {
16379 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16380 use serde::ser::SerializeStruct;
16382 match self {
16383 SearchMode::Filename => {
16384 let mut s = serializer.serialize_struct("SearchMode", 1)?;
16386 s.serialize_field(".tag", "filename")?;
16387 s.end()
16388 }
16389 SearchMode::FilenameAndContent => {
16390 let mut s = serializer.serialize_struct("SearchMode", 1)?;
16392 s.serialize_field(".tag", "filename_and_content")?;
16393 s.end()
16394 }
16395 SearchMode::DeletedFilename => {
16396 let mut s = serializer.serialize_struct("SearchMode", 1)?;
16398 s.serialize_field(".tag", "deleted_filename")?;
16399 s.end()
16400 }
16401 }
16402 }
16403}
16404
16405#[derive(Debug, Clone, PartialEq, Eq)]
16406#[non_exhaustive] pub struct SearchOptions {
16408 pub path: Option<PathROrId>,
16411 pub max_results: u64,
16413 pub order_by: Option<SearchOrderBy>,
16416 pub file_status: FileStatus,
16418 pub filename_only: bool,
16420 pub file_extensions: Option<Vec<String>>,
16422 pub file_categories: Option<Vec<FileCategory>>,
16425 pub account_id: Option<crate::types::users_common::AccountId>,
16427}
16428
16429impl Default for SearchOptions {
16430 fn default() -> Self {
16431 SearchOptions {
16432 path: None,
16433 max_results: 100,
16434 order_by: None,
16435 file_status: FileStatus::Active,
16436 filename_only: false,
16437 file_extensions: None,
16438 file_categories: None,
16439 account_id: None,
16440 }
16441 }
16442}
16443
16444impl SearchOptions {
16445 pub fn with_path(mut self, value: PathROrId) -> Self {
16446 self.path = Some(value);
16447 self
16448 }
16449
16450 pub fn with_max_results(mut self, value: u64) -> Self {
16451 self.max_results = value;
16452 self
16453 }
16454
16455 pub fn with_order_by(mut self, value: SearchOrderBy) -> Self {
16456 self.order_by = Some(value);
16457 self
16458 }
16459
16460 pub fn with_file_status(mut self, value: FileStatus) -> Self {
16461 self.file_status = value;
16462 self
16463 }
16464
16465 pub fn with_filename_only(mut self, value: bool) -> Self {
16466 self.filename_only = value;
16467 self
16468 }
16469
16470 pub fn with_file_extensions(mut self, value: Vec<String>) -> Self {
16471 self.file_extensions = Some(value);
16472 self
16473 }
16474
16475 pub fn with_file_categories(mut self, value: Vec<FileCategory>) -> Self {
16476 self.file_categories = Some(value);
16477 self
16478 }
16479
16480 pub fn with_account_id(mut self, value: crate::types::users_common::AccountId) -> Self {
16481 self.account_id = Some(value);
16482 self
16483 }
16484}
16485
16486const SEARCH_OPTIONS_FIELDS: &[&str] = &["path",
16487 "max_results",
16488 "order_by",
16489 "file_status",
16490 "filename_only",
16491 "file_extensions",
16492 "file_categories",
16493 "account_id"];
16494impl SearchOptions {
16495 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16497 mut map: V,
16498 ) -> Result<SearchOptions, V::Error> {
16499 let mut field_path = None;
16500 let mut field_max_results = None;
16501 let mut field_order_by = None;
16502 let mut field_file_status = None;
16503 let mut field_filename_only = None;
16504 let mut field_file_extensions = None;
16505 let mut field_file_categories = None;
16506 let mut field_account_id = None;
16507 while let Some(key) = map.next_key::<&str>()? {
16508 match key {
16509 "path" => {
16510 if field_path.is_some() {
16511 return Err(::serde::de::Error::duplicate_field("path"));
16512 }
16513 field_path = Some(map.next_value()?);
16514 }
16515 "max_results" => {
16516 if field_max_results.is_some() {
16517 return Err(::serde::de::Error::duplicate_field("max_results"));
16518 }
16519 field_max_results = Some(map.next_value()?);
16520 }
16521 "order_by" => {
16522 if field_order_by.is_some() {
16523 return Err(::serde::de::Error::duplicate_field("order_by"));
16524 }
16525 field_order_by = Some(map.next_value()?);
16526 }
16527 "file_status" => {
16528 if field_file_status.is_some() {
16529 return Err(::serde::de::Error::duplicate_field("file_status"));
16530 }
16531 field_file_status = Some(map.next_value()?);
16532 }
16533 "filename_only" => {
16534 if field_filename_only.is_some() {
16535 return Err(::serde::de::Error::duplicate_field("filename_only"));
16536 }
16537 field_filename_only = Some(map.next_value()?);
16538 }
16539 "file_extensions" => {
16540 if field_file_extensions.is_some() {
16541 return Err(::serde::de::Error::duplicate_field("file_extensions"));
16542 }
16543 field_file_extensions = Some(map.next_value()?);
16544 }
16545 "file_categories" => {
16546 if field_file_categories.is_some() {
16547 return Err(::serde::de::Error::duplicate_field("file_categories"));
16548 }
16549 field_file_categories = Some(map.next_value()?);
16550 }
16551 "account_id" => {
16552 if field_account_id.is_some() {
16553 return Err(::serde::de::Error::duplicate_field("account_id"));
16554 }
16555 field_account_id = Some(map.next_value()?);
16556 }
16557 _ => {
16558 map.next_value::<::serde_json::Value>()?;
16560 }
16561 }
16562 }
16563 let result = SearchOptions {
16564 path: field_path.and_then(Option::flatten),
16565 max_results: field_max_results.unwrap_or(100),
16566 order_by: field_order_by.and_then(Option::flatten),
16567 file_status: field_file_status.unwrap_or(FileStatus::Active),
16568 filename_only: field_filename_only.unwrap_or(false),
16569 file_extensions: field_file_extensions.and_then(Option::flatten),
16570 file_categories: field_file_categories.and_then(Option::flatten),
16571 account_id: field_account_id.and_then(Option::flatten),
16572 };
16573 Ok(result)
16574 }
16575
16576 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16577 &self,
16578 s: &mut S::SerializeStruct,
16579 ) -> Result<(), S::Error> {
16580 use serde::ser::SerializeStruct;
16581 if let Some(val) = &self.path {
16582 s.serialize_field("path", val)?;
16583 }
16584 if self.max_results != 100 {
16585 s.serialize_field("max_results", &self.max_results)?;
16586 }
16587 if let Some(val) = &self.order_by {
16588 s.serialize_field("order_by", val)?;
16589 }
16590 if self.file_status != FileStatus::Active {
16591 s.serialize_field("file_status", &self.file_status)?;
16592 }
16593 if self.filename_only {
16594 s.serialize_field("filename_only", &self.filename_only)?;
16595 }
16596 if let Some(val) = &self.file_extensions {
16597 s.serialize_field("file_extensions", val)?;
16598 }
16599 if let Some(val) = &self.file_categories {
16600 s.serialize_field("file_categories", val)?;
16601 }
16602 if let Some(val) = &self.account_id {
16603 s.serialize_field("account_id", val)?;
16604 }
16605 Ok(())
16606 }
16607}
16608
16609impl<'de> ::serde::de::Deserialize<'de> for SearchOptions {
16610 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16611 use serde::de::{MapAccess, Visitor};
16613 struct StructVisitor;
16614 impl<'de> Visitor<'de> for StructVisitor {
16615 type Value = SearchOptions;
16616 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16617 f.write_str("a SearchOptions struct")
16618 }
16619 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16620 SearchOptions::internal_deserialize(map)
16621 }
16622 }
16623 deserializer.deserialize_struct("SearchOptions", SEARCH_OPTIONS_FIELDS, StructVisitor)
16624 }
16625}
16626
16627impl ::serde::ser::Serialize for SearchOptions {
16628 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16629 use serde::ser::SerializeStruct;
16631 let mut s = serializer.serialize_struct("SearchOptions", 8)?;
16632 self.internal_serialize::<S>(&mut s)?;
16633 s.end()
16634 }
16635}
16636
16637#[derive(Debug, Clone, PartialEq, Eq)]
16638#[non_exhaustive] pub enum SearchOrderBy {
16640 Relevance,
16641 LastModifiedTime,
16642 Other,
16645}
16646
16647impl<'de> ::serde::de::Deserialize<'de> for SearchOrderBy {
16648 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16649 use serde::de::{self, MapAccess, Visitor};
16651 struct EnumVisitor;
16652 impl<'de> Visitor<'de> for EnumVisitor {
16653 type Value = SearchOrderBy;
16654 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16655 f.write_str("a SearchOrderBy structure")
16656 }
16657 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16658 let tag: &str = match map.next_key()? {
16659 Some(".tag") => map.next_value()?,
16660 _ => return Err(de::Error::missing_field(".tag"))
16661 };
16662 let value = match tag {
16663 "relevance" => SearchOrderBy::Relevance,
16664 "last_modified_time" => SearchOrderBy::LastModifiedTime,
16665 _ => SearchOrderBy::Other,
16666 };
16667 crate::eat_json_fields(&mut map)?;
16668 Ok(value)
16669 }
16670 }
16671 const VARIANTS: &[&str] = &["relevance",
16672 "last_modified_time",
16673 "other"];
16674 deserializer.deserialize_struct("SearchOrderBy", VARIANTS, EnumVisitor)
16675 }
16676}
16677
16678impl ::serde::ser::Serialize for SearchOrderBy {
16679 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16680 use serde::ser::SerializeStruct;
16682 match self {
16683 SearchOrderBy::Relevance => {
16684 let mut s = serializer.serialize_struct("SearchOrderBy", 1)?;
16686 s.serialize_field(".tag", "relevance")?;
16687 s.end()
16688 }
16689 SearchOrderBy::LastModifiedTime => {
16690 let mut s = serializer.serialize_struct("SearchOrderBy", 1)?;
16692 s.serialize_field(".tag", "last_modified_time")?;
16693 s.end()
16694 }
16695 SearchOrderBy::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
16696 }
16697 }
16698}
16699
16700#[derive(Debug, Clone, PartialEq)]
16701#[non_exhaustive] pub struct SearchResult {
16703 pub matches: Vec<SearchMatch>,
16705 pub more: bool,
16708 pub start: u64,
16711}
16712
16713impl SearchResult {
16714 pub fn new(matches: Vec<SearchMatch>, more: bool, start: u64) -> Self {
16715 SearchResult {
16716 matches,
16717 more,
16718 start,
16719 }
16720 }
16721}
16722
16723const SEARCH_RESULT_FIELDS: &[&str] = &["matches",
16724 "more",
16725 "start"];
16726impl SearchResult {
16727 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16728 map: V,
16729 ) -> Result<SearchResult, V::Error> {
16730 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16731 }
16732
16733 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16734 mut map: V,
16735 optional: bool,
16736 ) -> Result<Option<SearchResult>, V::Error> {
16737 let mut field_matches = None;
16738 let mut field_more = None;
16739 let mut field_start = None;
16740 let mut nothing = true;
16741 while let Some(key) = map.next_key::<&str>()? {
16742 nothing = false;
16743 match key {
16744 "matches" => {
16745 if field_matches.is_some() {
16746 return Err(::serde::de::Error::duplicate_field("matches"));
16747 }
16748 field_matches = Some(map.next_value()?);
16749 }
16750 "more" => {
16751 if field_more.is_some() {
16752 return Err(::serde::de::Error::duplicate_field("more"));
16753 }
16754 field_more = Some(map.next_value()?);
16755 }
16756 "start" => {
16757 if field_start.is_some() {
16758 return Err(::serde::de::Error::duplicate_field("start"));
16759 }
16760 field_start = Some(map.next_value()?);
16761 }
16762 _ => {
16763 map.next_value::<::serde_json::Value>()?;
16765 }
16766 }
16767 }
16768 if optional && nothing {
16769 return Ok(None);
16770 }
16771 let result = SearchResult {
16772 matches: field_matches.ok_or_else(|| ::serde::de::Error::missing_field("matches"))?,
16773 more: field_more.ok_or_else(|| ::serde::de::Error::missing_field("more"))?,
16774 start: field_start.ok_or_else(|| ::serde::de::Error::missing_field("start"))?,
16775 };
16776 Ok(Some(result))
16777 }
16778
16779 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16780 &self,
16781 s: &mut S::SerializeStruct,
16782 ) -> Result<(), S::Error> {
16783 use serde::ser::SerializeStruct;
16784 s.serialize_field("matches", &self.matches)?;
16785 s.serialize_field("more", &self.more)?;
16786 s.serialize_field("start", &self.start)?;
16787 Ok(())
16788 }
16789}
16790
16791impl<'de> ::serde::de::Deserialize<'de> for SearchResult {
16792 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16793 use serde::de::{MapAccess, Visitor};
16795 struct StructVisitor;
16796 impl<'de> Visitor<'de> for StructVisitor {
16797 type Value = SearchResult;
16798 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16799 f.write_str("a SearchResult struct")
16800 }
16801 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16802 SearchResult::internal_deserialize(map)
16803 }
16804 }
16805 deserializer.deserialize_struct("SearchResult", SEARCH_RESULT_FIELDS, StructVisitor)
16806 }
16807}
16808
16809impl ::serde::ser::Serialize for SearchResult {
16810 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16811 use serde::ser::SerializeStruct;
16813 let mut s = serializer.serialize_struct("SearchResult", 3)?;
16814 self.internal_serialize::<S>(&mut s)?;
16815 s.end()
16816 }
16817}
16818
16819#[derive(Debug, Clone, PartialEq, Eq)]
16820#[non_exhaustive] pub struct SearchV2Arg {
16822 pub query: String,
16824 pub options: Option<SearchOptions>,
16826 pub match_field_options: Option<SearchMatchFieldOptions>,
16828 pub include_highlights: Option<bool>,
16830}
16831
16832impl SearchV2Arg {
16833 pub fn new(query: String) -> Self {
16834 SearchV2Arg {
16835 query,
16836 options: None,
16837 match_field_options: None,
16838 include_highlights: None,
16839 }
16840 }
16841
16842 pub fn with_options(mut self, value: SearchOptions) -> Self {
16843 self.options = Some(value);
16844 self
16845 }
16846
16847 pub fn with_match_field_options(mut self, value: SearchMatchFieldOptions) -> Self {
16848 self.match_field_options = Some(value);
16849 self
16850 }
16851
16852 pub fn with_include_highlights(mut self, value: bool) -> Self {
16853 self.include_highlights = Some(value);
16854 self
16855 }
16856}
16857
16858const SEARCH_V2_ARG_FIELDS: &[&str] = &["query",
16859 "options",
16860 "match_field_options",
16861 "include_highlights"];
16862impl SearchV2Arg {
16863 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16864 map: V,
16865 ) -> Result<SearchV2Arg, V::Error> {
16866 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16867 }
16868
16869 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16870 mut map: V,
16871 optional: bool,
16872 ) -> Result<Option<SearchV2Arg>, V::Error> {
16873 let mut field_query = None;
16874 let mut field_options = None;
16875 let mut field_match_field_options = None;
16876 let mut field_include_highlights = None;
16877 let mut nothing = true;
16878 while let Some(key) = map.next_key::<&str>()? {
16879 nothing = false;
16880 match key {
16881 "query" => {
16882 if field_query.is_some() {
16883 return Err(::serde::de::Error::duplicate_field("query"));
16884 }
16885 field_query = Some(map.next_value()?);
16886 }
16887 "options" => {
16888 if field_options.is_some() {
16889 return Err(::serde::de::Error::duplicate_field("options"));
16890 }
16891 field_options = Some(map.next_value()?);
16892 }
16893 "match_field_options" => {
16894 if field_match_field_options.is_some() {
16895 return Err(::serde::de::Error::duplicate_field("match_field_options"));
16896 }
16897 field_match_field_options = Some(map.next_value()?);
16898 }
16899 "include_highlights" => {
16900 if field_include_highlights.is_some() {
16901 return Err(::serde::de::Error::duplicate_field("include_highlights"));
16902 }
16903 field_include_highlights = Some(map.next_value()?);
16904 }
16905 _ => {
16906 map.next_value::<::serde_json::Value>()?;
16908 }
16909 }
16910 }
16911 if optional && nothing {
16912 return Ok(None);
16913 }
16914 let result = SearchV2Arg {
16915 query: field_query.ok_or_else(|| ::serde::de::Error::missing_field("query"))?,
16916 options: field_options.and_then(Option::flatten),
16917 match_field_options: field_match_field_options.and_then(Option::flatten),
16918 include_highlights: field_include_highlights.and_then(Option::flatten),
16919 };
16920 Ok(Some(result))
16921 }
16922
16923 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16924 &self,
16925 s: &mut S::SerializeStruct,
16926 ) -> Result<(), S::Error> {
16927 use serde::ser::SerializeStruct;
16928 s.serialize_field("query", &self.query)?;
16929 if let Some(val) = &self.options {
16930 s.serialize_field("options", val)?;
16931 }
16932 if let Some(val) = &self.match_field_options {
16933 s.serialize_field("match_field_options", val)?;
16934 }
16935 if let Some(val) = &self.include_highlights {
16936 s.serialize_field("include_highlights", val)?;
16937 }
16938 Ok(())
16939 }
16940}
16941
16942impl<'de> ::serde::de::Deserialize<'de> for SearchV2Arg {
16943 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16944 use serde::de::{MapAccess, Visitor};
16946 struct StructVisitor;
16947 impl<'de> Visitor<'de> for StructVisitor {
16948 type Value = SearchV2Arg;
16949 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16950 f.write_str("a SearchV2Arg struct")
16951 }
16952 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16953 SearchV2Arg::internal_deserialize(map)
16954 }
16955 }
16956 deserializer.deserialize_struct("SearchV2Arg", SEARCH_V2_ARG_FIELDS, StructVisitor)
16957 }
16958}
16959
16960impl ::serde::ser::Serialize for SearchV2Arg {
16961 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16962 use serde::ser::SerializeStruct;
16964 let mut s = serializer.serialize_struct("SearchV2Arg", 4)?;
16965 self.internal_serialize::<S>(&mut s)?;
16966 s.end()
16967 }
16968}
16969
16970#[derive(Debug, Clone, PartialEq, Eq)]
16971#[non_exhaustive] pub struct SearchV2ContinueArg {
16973 pub cursor: SearchV2Cursor,
16976}
16977
16978impl SearchV2ContinueArg {
16979 pub fn new(cursor: SearchV2Cursor) -> Self {
16980 SearchV2ContinueArg {
16981 cursor,
16982 }
16983 }
16984}
16985
16986const SEARCH_V2_CONTINUE_ARG_FIELDS: &[&str] = &["cursor"];
16987impl SearchV2ContinueArg {
16988 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16989 map: V,
16990 ) -> Result<SearchV2ContinueArg, V::Error> {
16991 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16992 }
16993
16994 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16995 mut map: V,
16996 optional: bool,
16997 ) -> Result<Option<SearchV2ContinueArg>, V::Error> {
16998 let mut field_cursor = None;
16999 let mut nothing = true;
17000 while let Some(key) = map.next_key::<&str>()? {
17001 nothing = false;
17002 match key {
17003 "cursor" => {
17004 if field_cursor.is_some() {
17005 return Err(::serde::de::Error::duplicate_field("cursor"));
17006 }
17007 field_cursor = Some(map.next_value()?);
17008 }
17009 _ => {
17010 map.next_value::<::serde_json::Value>()?;
17012 }
17013 }
17014 }
17015 if optional && nothing {
17016 return Ok(None);
17017 }
17018 let result = SearchV2ContinueArg {
17019 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
17020 };
17021 Ok(Some(result))
17022 }
17023
17024 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17025 &self,
17026 s: &mut S::SerializeStruct,
17027 ) -> Result<(), S::Error> {
17028 use serde::ser::SerializeStruct;
17029 s.serialize_field("cursor", &self.cursor)?;
17030 Ok(())
17031 }
17032}
17033
17034impl<'de> ::serde::de::Deserialize<'de> for SearchV2ContinueArg {
17035 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17036 use serde::de::{MapAccess, Visitor};
17038 struct StructVisitor;
17039 impl<'de> Visitor<'de> for StructVisitor {
17040 type Value = SearchV2ContinueArg;
17041 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17042 f.write_str("a SearchV2ContinueArg struct")
17043 }
17044 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17045 SearchV2ContinueArg::internal_deserialize(map)
17046 }
17047 }
17048 deserializer.deserialize_struct("SearchV2ContinueArg", SEARCH_V2_CONTINUE_ARG_FIELDS, StructVisitor)
17049 }
17050}
17051
17052impl ::serde::ser::Serialize for SearchV2ContinueArg {
17053 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17054 use serde::ser::SerializeStruct;
17056 let mut s = serializer.serialize_struct("SearchV2ContinueArg", 1)?;
17057 self.internal_serialize::<S>(&mut s)?;
17058 s.end()
17059 }
17060}
17061
17062#[derive(Debug, Clone, PartialEq)]
17063#[non_exhaustive] pub struct SearchV2Result {
17065 pub matches: Vec<SearchMatchV2>,
17067 pub has_more: bool,
17071 pub cursor: Option<SearchV2Cursor>,
17074}
17075
17076impl SearchV2Result {
17077 pub fn new(matches: Vec<SearchMatchV2>, has_more: bool) -> Self {
17078 SearchV2Result {
17079 matches,
17080 has_more,
17081 cursor: None,
17082 }
17083 }
17084
17085 pub fn with_cursor(mut self, value: SearchV2Cursor) -> Self {
17086 self.cursor = Some(value);
17087 self
17088 }
17089}
17090
17091const SEARCH_V2_RESULT_FIELDS: &[&str] = &["matches",
17092 "has_more",
17093 "cursor"];
17094impl SearchV2Result {
17095 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17096 map: V,
17097 ) -> Result<SearchV2Result, V::Error> {
17098 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17099 }
17100
17101 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17102 mut map: V,
17103 optional: bool,
17104 ) -> Result<Option<SearchV2Result>, V::Error> {
17105 let mut field_matches = None;
17106 let mut field_has_more = None;
17107 let mut field_cursor = None;
17108 let mut nothing = true;
17109 while let Some(key) = map.next_key::<&str>()? {
17110 nothing = false;
17111 match key {
17112 "matches" => {
17113 if field_matches.is_some() {
17114 return Err(::serde::de::Error::duplicate_field("matches"));
17115 }
17116 field_matches = Some(map.next_value()?);
17117 }
17118 "has_more" => {
17119 if field_has_more.is_some() {
17120 return Err(::serde::de::Error::duplicate_field("has_more"));
17121 }
17122 field_has_more = Some(map.next_value()?);
17123 }
17124 "cursor" => {
17125 if field_cursor.is_some() {
17126 return Err(::serde::de::Error::duplicate_field("cursor"));
17127 }
17128 field_cursor = Some(map.next_value()?);
17129 }
17130 _ => {
17131 map.next_value::<::serde_json::Value>()?;
17133 }
17134 }
17135 }
17136 if optional && nothing {
17137 return Ok(None);
17138 }
17139 let result = SearchV2Result {
17140 matches: field_matches.ok_or_else(|| ::serde::de::Error::missing_field("matches"))?,
17141 has_more: field_has_more.ok_or_else(|| ::serde::de::Error::missing_field("has_more"))?,
17142 cursor: field_cursor.and_then(Option::flatten),
17143 };
17144 Ok(Some(result))
17145 }
17146
17147 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17148 &self,
17149 s: &mut S::SerializeStruct,
17150 ) -> Result<(), S::Error> {
17151 use serde::ser::SerializeStruct;
17152 s.serialize_field("matches", &self.matches)?;
17153 s.serialize_field("has_more", &self.has_more)?;
17154 if let Some(val) = &self.cursor {
17155 s.serialize_field("cursor", val)?;
17156 }
17157 Ok(())
17158 }
17159}
17160
17161impl<'de> ::serde::de::Deserialize<'de> for SearchV2Result {
17162 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17163 use serde::de::{MapAccess, Visitor};
17165 struct StructVisitor;
17166 impl<'de> Visitor<'de> for StructVisitor {
17167 type Value = SearchV2Result;
17168 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17169 f.write_str("a SearchV2Result struct")
17170 }
17171 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17172 SearchV2Result::internal_deserialize(map)
17173 }
17174 }
17175 deserializer.deserialize_struct("SearchV2Result", SEARCH_V2_RESULT_FIELDS, StructVisitor)
17176 }
17177}
17178
17179impl ::serde::ser::Serialize for SearchV2Result {
17180 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17181 use serde::ser::SerializeStruct;
17183 let mut s = serializer.serialize_struct("SearchV2Result", 3)?;
17184 self.internal_serialize::<S>(&mut s)?;
17185 s.end()
17186 }
17187}
17188
17189#[derive(Debug, Clone, PartialEq, Eq)]
17190#[non_exhaustive] pub struct SharedLink {
17192 pub url: SharedLinkUrl,
17194 pub password: Option<String>,
17196}
17197
17198impl SharedLink {
17199 pub fn new(url: SharedLinkUrl) -> Self {
17200 SharedLink {
17201 url,
17202 password: None,
17203 }
17204 }
17205
17206 pub fn with_password(mut self, value: String) -> Self {
17207 self.password = Some(value);
17208 self
17209 }
17210}
17211
17212const SHARED_LINK_FIELDS: &[&str] = &["url",
17213 "password"];
17214impl SharedLink {
17215 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17216 map: V,
17217 ) -> Result<SharedLink, V::Error> {
17218 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17219 }
17220
17221 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17222 mut map: V,
17223 optional: bool,
17224 ) -> Result<Option<SharedLink>, V::Error> {
17225 let mut field_url = None;
17226 let mut field_password = None;
17227 let mut nothing = true;
17228 while let Some(key) = map.next_key::<&str>()? {
17229 nothing = false;
17230 match key {
17231 "url" => {
17232 if field_url.is_some() {
17233 return Err(::serde::de::Error::duplicate_field("url"));
17234 }
17235 field_url = Some(map.next_value()?);
17236 }
17237 "password" => {
17238 if field_password.is_some() {
17239 return Err(::serde::de::Error::duplicate_field("password"));
17240 }
17241 field_password = Some(map.next_value()?);
17242 }
17243 _ => {
17244 map.next_value::<::serde_json::Value>()?;
17246 }
17247 }
17248 }
17249 if optional && nothing {
17250 return Ok(None);
17251 }
17252 let result = SharedLink {
17253 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
17254 password: field_password.and_then(Option::flatten),
17255 };
17256 Ok(Some(result))
17257 }
17258
17259 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17260 &self,
17261 s: &mut S::SerializeStruct,
17262 ) -> Result<(), S::Error> {
17263 use serde::ser::SerializeStruct;
17264 s.serialize_field("url", &self.url)?;
17265 if let Some(val) = &self.password {
17266 s.serialize_field("password", val)?;
17267 }
17268 Ok(())
17269 }
17270}
17271
17272impl<'de> ::serde::de::Deserialize<'de> for SharedLink {
17273 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17274 use serde::de::{MapAccess, Visitor};
17276 struct StructVisitor;
17277 impl<'de> Visitor<'de> for StructVisitor {
17278 type Value = SharedLink;
17279 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17280 f.write_str("a SharedLink struct")
17281 }
17282 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17283 SharedLink::internal_deserialize(map)
17284 }
17285 }
17286 deserializer.deserialize_struct("SharedLink", SHARED_LINK_FIELDS, StructVisitor)
17287 }
17288}
17289
17290impl ::serde::ser::Serialize for SharedLink {
17291 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17292 use serde::ser::SerializeStruct;
17294 let mut s = serializer.serialize_struct("SharedLink", 2)?;
17295 self.internal_serialize::<S>(&mut s)?;
17296 s.end()
17297 }
17298}
17299
17300#[derive(Debug, Clone, PartialEq, Eq)]
17301#[non_exhaustive] pub struct SharedLinkFileInfo {
17303 pub url: String,
17307 pub path: Option<String>,
17310 pub password: Option<String>,
17313}
17314
17315impl SharedLinkFileInfo {
17316 pub fn new(url: String) -> Self {
17317 SharedLinkFileInfo {
17318 url,
17319 path: None,
17320 password: None,
17321 }
17322 }
17323
17324 pub fn with_path(mut self, value: String) -> Self {
17325 self.path = Some(value);
17326 self
17327 }
17328
17329 pub fn with_password(mut self, value: String) -> Self {
17330 self.password = Some(value);
17331 self
17332 }
17333}
17334
17335const SHARED_LINK_FILE_INFO_FIELDS: &[&str] = &["url",
17336 "path",
17337 "password"];
17338impl SharedLinkFileInfo {
17339 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17340 map: V,
17341 ) -> Result<SharedLinkFileInfo, V::Error> {
17342 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17343 }
17344
17345 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17346 mut map: V,
17347 optional: bool,
17348 ) -> Result<Option<SharedLinkFileInfo>, V::Error> {
17349 let mut field_url = None;
17350 let mut field_path = None;
17351 let mut field_password = None;
17352 let mut nothing = true;
17353 while let Some(key) = map.next_key::<&str>()? {
17354 nothing = false;
17355 match key {
17356 "url" => {
17357 if field_url.is_some() {
17358 return Err(::serde::de::Error::duplicate_field("url"));
17359 }
17360 field_url = Some(map.next_value()?);
17361 }
17362 "path" => {
17363 if field_path.is_some() {
17364 return Err(::serde::de::Error::duplicate_field("path"));
17365 }
17366 field_path = Some(map.next_value()?);
17367 }
17368 "password" => {
17369 if field_password.is_some() {
17370 return Err(::serde::de::Error::duplicate_field("password"));
17371 }
17372 field_password = Some(map.next_value()?);
17373 }
17374 _ => {
17375 map.next_value::<::serde_json::Value>()?;
17377 }
17378 }
17379 }
17380 if optional && nothing {
17381 return Ok(None);
17382 }
17383 let result = SharedLinkFileInfo {
17384 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
17385 path: field_path.and_then(Option::flatten),
17386 password: field_password.and_then(Option::flatten),
17387 };
17388 Ok(Some(result))
17389 }
17390
17391 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17392 &self,
17393 s: &mut S::SerializeStruct,
17394 ) -> Result<(), S::Error> {
17395 use serde::ser::SerializeStruct;
17396 s.serialize_field("url", &self.url)?;
17397 if let Some(val) = &self.path {
17398 s.serialize_field("path", val)?;
17399 }
17400 if let Some(val) = &self.password {
17401 s.serialize_field("password", val)?;
17402 }
17403 Ok(())
17404 }
17405}
17406
17407impl<'de> ::serde::de::Deserialize<'de> for SharedLinkFileInfo {
17408 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17409 use serde::de::{MapAccess, Visitor};
17411 struct StructVisitor;
17412 impl<'de> Visitor<'de> for StructVisitor {
17413 type Value = SharedLinkFileInfo;
17414 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17415 f.write_str("a SharedLinkFileInfo struct")
17416 }
17417 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17418 SharedLinkFileInfo::internal_deserialize(map)
17419 }
17420 }
17421 deserializer.deserialize_struct("SharedLinkFileInfo", SHARED_LINK_FILE_INFO_FIELDS, StructVisitor)
17422 }
17423}
17424
17425impl ::serde::ser::Serialize for SharedLinkFileInfo {
17426 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17427 use serde::ser::SerializeStruct;
17429 let mut s = serializer.serialize_struct("SharedLinkFileInfo", 3)?;
17430 self.internal_serialize::<S>(&mut s)?;
17431 s.end()
17432 }
17433}
17434
17435#[derive(Debug, Clone, PartialEq, Eq)]
17437#[non_exhaustive] pub struct SharingInfo {
17439 pub read_only: bool,
17441}
17442
17443impl SharingInfo {
17444 pub fn new(read_only: bool) -> Self {
17445 SharingInfo {
17446 read_only,
17447 }
17448 }
17449}
17450
17451const SHARING_INFO_FIELDS: &[&str] = &["read_only"];
17452impl SharingInfo {
17453 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17454 map: V,
17455 ) -> Result<SharingInfo, V::Error> {
17456 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17457 }
17458
17459 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17460 mut map: V,
17461 optional: bool,
17462 ) -> Result<Option<SharingInfo>, V::Error> {
17463 let mut field_read_only = None;
17464 let mut nothing = true;
17465 while let Some(key) = map.next_key::<&str>()? {
17466 nothing = false;
17467 match key {
17468 "read_only" => {
17469 if field_read_only.is_some() {
17470 return Err(::serde::de::Error::duplicate_field("read_only"));
17471 }
17472 field_read_only = Some(map.next_value()?);
17473 }
17474 _ => {
17475 map.next_value::<::serde_json::Value>()?;
17477 }
17478 }
17479 }
17480 if optional && nothing {
17481 return Ok(None);
17482 }
17483 let result = SharingInfo {
17484 read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
17485 };
17486 Ok(Some(result))
17487 }
17488
17489 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17490 &self,
17491 s: &mut S::SerializeStruct,
17492 ) -> Result<(), S::Error> {
17493 use serde::ser::SerializeStruct;
17494 s.serialize_field("read_only", &self.read_only)?;
17495 Ok(())
17496 }
17497}
17498
17499impl<'de> ::serde::de::Deserialize<'de> for SharingInfo {
17500 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17501 use serde::de::{MapAccess, Visitor};
17503 struct StructVisitor;
17504 impl<'de> Visitor<'de> for StructVisitor {
17505 type Value = SharingInfo;
17506 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17507 f.write_str("a SharingInfo struct")
17508 }
17509 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17510 SharingInfo::internal_deserialize(map)
17511 }
17512 }
17513 deserializer.deserialize_struct("SharingInfo", SHARING_INFO_FIELDS, StructVisitor)
17514 }
17515}
17516
17517impl ::serde::ser::Serialize for SharingInfo {
17518 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17519 use serde::ser::SerializeStruct;
17521 let mut s = serializer.serialize_struct("SharingInfo", 1)?;
17522 self.internal_serialize::<S>(&mut s)?;
17523 s.end()
17524 }
17525}
17526
17527#[derive(Debug, Clone, PartialEq, Eq)]
17528#[non_exhaustive] pub struct SingleUserLock {
17530 pub created: crate::types::common::DropboxTimestamp,
17532 pub lock_holder_account_id: crate::types::users_common::AccountId,
17534 pub lock_holder_team_id: Option<String>,
17536}
17537
17538impl SingleUserLock {
17539 pub fn new(
17540 created: crate::types::common::DropboxTimestamp,
17541 lock_holder_account_id: crate::types::users_common::AccountId,
17542 ) -> Self {
17543 SingleUserLock {
17544 created,
17545 lock_holder_account_id,
17546 lock_holder_team_id: None,
17547 }
17548 }
17549
17550 pub fn with_lock_holder_team_id(mut self, value: String) -> Self {
17551 self.lock_holder_team_id = Some(value);
17552 self
17553 }
17554}
17555
17556const SINGLE_USER_LOCK_FIELDS: &[&str] = &["created",
17557 "lock_holder_account_id",
17558 "lock_holder_team_id"];
17559impl SingleUserLock {
17560 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17561 map: V,
17562 ) -> Result<SingleUserLock, V::Error> {
17563 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17564 }
17565
17566 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17567 mut map: V,
17568 optional: bool,
17569 ) -> Result<Option<SingleUserLock>, V::Error> {
17570 let mut field_created = None;
17571 let mut field_lock_holder_account_id = None;
17572 let mut field_lock_holder_team_id = None;
17573 let mut nothing = true;
17574 while let Some(key) = map.next_key::<&str>()? {
17575 nothing = false;
17576 match key {
17577 "created" => {
17578 if field_created.is_some() {
17579 return Err(::serde::de::Error::duplicate_field("created"));
17580 }
17581 field_created = Some(map.next_value()?);
17582 }
17583 "lock_holder_account_id" => {
17584 if field_lock_holder_account_id.is_some() {
17585 return Err(::serde::de::Error::duplicate_field("lock_holder_account_id"));
17586 }
17587 field_lock_holder_account_id = Some(map.next_value()?);
17588 }
17589 "lock_holder_team_id" => {
17590 if field_lock_holder_team_id.is_some() {
17591 return Err(::serde::de::Error::duplicate_field("lock_holder_team_id"));
17592 }
17593 field_lock_holder_team_id = Some(map.next_value()?);
17594 }
17595 _ => {
17596 map.next_value::<::serde_json::Value>()?;
17598 }
17599 }
17600 }
17601 if optional && nothing {
17602 return Ok(None);
17603 }
17604 let result = SingleUserLock {
17605 created: field_created.ok_or_else(|| ::serde::de::Error::missing_field("created"))?,
17606 lock_holder_account_id: field_lock_holder_account_id.ok_or_else(|| ::serde::de::Error::missing_field("lock_holder_account_id"))?,
17607 lock_holder_team_id: field_lock_holder_team_id.and_then(Option::flatten),
17608 };
17609 Ok(Some(result))
17610 }
17611
17612 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17613 &self,
17614 s: &mut S::SerializeStruct,
17615 ) -> Result<(), S::Error> {
17616 use serde::ser::SerializeStruct;
17617 s.serialize_field("created", &self.created)?;
17618 s.serialize_field("lock_holder_account_id", &self.lock_holder_account_id)?;
17619 if let Some(val) = &self.lock_holder_team_id {
17620 s.serialize_field("lock_holder_team_id", val)?;
17621 }
17622 Ok(())
17623 }
17624}
17625
17626impl<'de> ::serde::de::Deserialize<'de> for SingleUserLock {
17627 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17628 use serde::de::{MapAccess, Visitor};
17630 struct StructVisitor;
17631 impl<'de> Visitor<'de> for StructVisitor {
17632 type Value = SingleUserLock;
17633 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17634 f.write_str("a SingleUserLock struct")
17635 }
17636 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17637 SingleUserLock::internal_deserialize(map)
17638 }
17639 }
17640 deserializer.deserialize_struct("SingleUserLock", SINGLE_USER_LOCK_FIELDS, StructVisitor)
17641 }
17642}
17643
17644impl ::serde::ser::Serialize for SingleUserLock {
17645 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17646 use serde::ser::SerializeStruct;
17648 let mut s = serializer.serialize_struct("SingleUserLock", 3)?;
17649 self.internal_serialize::<S>(&mut s)?;
17650 s.end()
17651 }
17652}
17653
17654#[derive(Debug, Clone, PartialEq, Eq)]
17655#[non_exhaustive] pub struct SymlinkInfo {
17657 pub target: String,
17659}
17660
17661impl SymlinkInfo {
17662 pub fn new(target: String) -> Self {
17663 SymlinkInfo {
17664 target,
17665 }
17666 }
17667}
17668
17669const SYMLINK_INFO_FIELDS: &[&str] = &["target"];
17670impl SymlinkInfo {
17671 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17672 map: V,
17673 ) -> Result<SymlinkInfo, V::Error> {
17674 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17675 }
17676
17677 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17678 mut map: V,
17679 optional: bool,
17680 ) -> Result<Option<SymlinkInfo>, V::Error> {
17681 let mut field_target = None;
17682 let mut nothing = true;
17683 while let Some(key) = map.next_key::<&str>()? {
17684 nothing = false;
17685 match key {
17686 "target" => {
17687 if field_target.is_some() {
17688 return Err(::serde::de::Error::duplicate_field("target"));
17689 }
17690 field_target = Some(map.next_value()?);
17691 }
17692 _ => {
17693 map.next_value::<::serde_json::Value>()?;
17695 }
17696 }
17697 }
17698 if optional && nothing {
17699 return Ok(None);
17700 }
17701 let result = SymlinkInfo {
17702 target: field_target.ok_or_else(|| ::serde::de::Error::missing_field("target"))?,
17703 };
17704 Ok(Some(result))
17705 }
17706
17707 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17708 &self,
17709 s: &mut S::SerializeStruct,
17710 ) -> Result<(), S::Error> {
17711 use serde::ser::SerializeStruct;
17712 s.serialize_field("target", &self.target)?;
17713 Ok(())
17714 }
17715}
17716
17717impl<'de> ::serde::de::Deserialize<'de> for SymlinkInfo {
17718 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17719 use serde::de::{MapAccess, Visitor};
17721 struct StructVisitor;
17722 impl<'de> Visitor<'de> for StructVisitor {
17723 type Value = SymlinkInfo;
17724 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17725 f.write_str("a SymlinkInfo struct")
17726 }
17727 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17728 SymlinkInfo::internal_deserialize(map)
17729 }
17730 }
17731 deserializer.deserialize_struct("SymlinkInfo", SYMLINK_INFO_FIELDS, StructVisitor)
17732 }
17733}
17734
17735impl ::serde::ser::Serialize for SymlinkInfo {
17736 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17737 use serde::ser::SerializeStruct;
17739 let mut s = serializer.serialize_struct("SymlinkInfo", 1)?;
17740 self.internal_serialize::<S>(&mut s)?;
17741 s.end()
17742 }
17743}
17744
17745#[derive(Debug, Clone, PartialEq, Eq)]
17746#[non_exhaustive] pub enum SyncSetting {
17748 Default,
17751 NotSynced,
17754 NotSyncedInactive,
17757 Other,
17760}
17761
17762impl<'de> ::serde::de::Deserialize<'de> for SyncSetting {
17763 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17764 use serde::de::{self, MapAccess, Visitor};
17766 struct EnumVisitor;
17767 impl<'de> Visitor<'de> for EnumVisitor {
17768 type Value = SyncSetting;
17769 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17770 f.write_str("a SyncSetting structure")
17771 }
17772 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
17773 let tag: &str = match map.next_key()? {
17774 Some(".tag") => map.next_value()?,
17775 _ => return Err(de::Error::missing_field(".tag"))
17776 };
17777 let value = match tag {
17778 "default" => SyncSetting::Default,
17779 "not_synced" => SyncSetting::NotSynced,
17780 "not_synced_inactive" => SyncSetting::NotSyncedInactive,
17781 _ => SyncSetting::Other,
17782 };
17783 crate::eat_json_fields(&mut map)?;
17784 Ok(value)
17785 }
17786 }
17787 const VARIANTS: &[&str] = &["default",
17788 "not_synced",
17789 "not_synced_inactive",
17790 "other"];
17791 deserializer.deserialize_struct("SyncSetting", VARIANTS, EnumVisitor)
17792 }
17793}
17794
17795impl ::serde::ser::Serialize for SyncSetting {
17796 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17797 use serde::ser::SerializeStruct;
17799 match self {
17800 SyncSetting::Default => {
17801 let mut s = serializer.serialize_struct("SyncSetting", 1)?;
17803 s.serialize_field(".tag", "default")?;
17804 s.end()
17805 }
17806 SyncSetting::NotSynced => {
17807 let mut s = serializer.serialize_struct("SyncSetting", 1)?;
17809 s.serialize_field(".tag", "not_synced")?;
17810 s.end()
17811 }
17812 SyncSetting::NotSyncedInactive => {
17813 let mut s = serializer.serialize_struct("SyncSetting", 1)?;
17815 s.serialize_field(".tag", "not_synced_inactive")?;
17816 s.end()
17817 }
17818 SyncSetting::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
17819 }
17820 }
17821}
17822
17823#[derive(Debug, Clone, PartialEq, Eq)]
17824#[non_exhaustive] pub enum SyncSettingArg {
17826 Default,
17829 NotSynced,
17832 Other,
17835}
17836
17837impl<'de> ::serde::de::Deserialize<'de> for SyncSettingArg {
17838 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17839 use serde::de::{self, MapAccess, Visitor};
17841 struct EnumVisitor;
17842 impl<'de> Visitor<'de> for EnumVisitor {
17843 type Value = SyncSettingArg;
17844 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17845 f.write_str("a SyncSettingArg structure")
17846 }
17847 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
17848 let tag: &str = match map.next_key()? {
17849 Some(".tag") => map.next_value()?,
17850 _ => return Err(de::Error::missing_field(".tag"))
17851 };
17852 let value = match tag {
17853 "default" => SyncSettingArg::Default,
17854 "not_synced" => SyncSettingArg::NotSynced,
17855 _ => SyncSettingArg::Other,
17856 };
17857 crate::eat_json_fields(&mut map)?;
17858 Ok(value)
17859 }
17860 }
17861 const VARIANTS: &[&str] = &["default",
17862 "not_synced",
17863 "other"];
17864 deserializer.deserialize_struct("SyncSettingArg", VARIANTS, EnumVisitor)
17865 }
17866}
17867
17868impl ::serde::ser::Serialize for SyncSettingArg {
17869 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17870 use serde::ser::SerializeStruct;
17872 match self {
17873 SyncSettingArg::Default => {
17874 let mut s = serializer.serialize_struct("SyncSettingArg", 1)?;
17876 s.serialize_field(".tag", "default")?;
17877 s.end()
17878 }
17879 SyncSettingArg::NotSynced => {
17880 let mut s = serializer.serialize_struct("SyncSettingArg", 1)?;
17882 s.serialize_field(".tag", "not_synced")?;
17883 s.end()
17884 }
17885 SyncSettingArg::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
17886 }
17887 }
17888}
17889
17890#[derive(Debug, Clone, PartialEq, Eq)]
17891#[non_exhaustive] pub enum SyncSettingsError {
17893 Path(LookupError),
17894 UnsupportedCombination,
17896 UnsupportedConfiguration,
17898 Other,
17901}
17902
17903impl<'de> ::serde::de::Deserialize<'de> for SyncSettingsError {
17904 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17905 use serde::de::{self, MapAccess, Visitor};
17907 struct EnumVisitor;
17908 impl<'de> Visitor<'de> for EnumVisitor {
17909 type Value = SyncSettingsError;
17910 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17911 f.write_str("a SyncSettingsError structure")
17912 }
17913 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
17914 let tag: &str = match map.next_key()? {
17915 Some(".tag") => map.next_value()?,
17916 _ => return Err(de::Error::missing_field(".tag"))
17917 };
17918 let value = match tag {
17919 "path" => {
17920 match map.next_key()? {
17921 Some("path") => SyncSettingsError::Path(map.next_value()?),
17922 None => return Err(de::Error::missing_field("path")),
17923 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
17924 }
17925 }
17926 "unsupported_combination" => SyncSettingsError::UnsupportedCombination,
17927 "unsupported_configuration" => SyncSettingsError::UnsupportedConfiguration,
17928 _ => SyncSettingsError::Other,
17929 };
17930 crate::eat_json_fields(&mut map)?;
17931 Ok(value)
17932 }
17933 }
17934 const VARIANTS: &[&str] = &["path",
17935 "unsupported_combination",
17936 "unsupported_configuration",
17937 "other"];
17938 deserializer.deserialize_struct("SyncSettingsError", VARIANTS, EnumVisitor)
17939 }
17940}
17941
17942impl ::serde::ser::Serialize for SyncSettingsError {
17943 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17944 use serde::ser::SerializeStruct;
17946 match self {
17947 SyncSettingsError::Path(x) => {
17948 let mut s = serializer.serialize_struct("SyncSettingsError", 2)?;
17950 s.serialize_field(".tag", "path")?;
17951 s.serialize_field("path", x)?;
17952 s.end()
17953 }
17954 SyncSettingsError::UnsupportedCombination => {
17955 let mut s = serializer.serialize_struct("SyncSettingsError", 1)?;
17957 s.serialize_field(".tag", "unsupported_combination")?;
17958 s.end()
17959 }
17960 SyncSettingsError::UnsupportedConfiguration => {
17961 let mut s = serializer.serialize_struct("SyncSettingsError", 1)?;
17963 s.serialize_field(".tag", "unsupported_configuration")?;
17964 s.end()
17965 }
17966 SyncSettingsError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
17967 }
17968 }
17969}
17970
17971impl ::std::error::Error for SyncSettingsError {
17972 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
17973 match self {
17974 SyncSettingsError::Path(inner) => Some(inner),
17975 _ => None,
17976 }
17977 }
17978}
17979
17980impl ::std::fmt::Display for SyncSettingsError {
17981 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17982 match self {
17983 SyncSettingsError::Path(inner) => write!(f, "SyncSettingsError: {}", inner),
17984 SyncSettingsError::UnsupportedCombination => f.write_str("Setting this combination of sync settings simultaneously is not supported."),
17985 SyncSettingsError::UnsupportedConfiguration => f.write_str("The specified configuration is not supported."),
17986 _ => write!(f, "{:?}", *self),
17987 }
17988 }
17989}
17990
17991#[derive(Debug, Clone, PartialEq, Eq)]
17993#[non_exhaustive] pub enum Tag {
17995 UserGeneratedTag(UserGeneratedTag),
17997 Other,
18000}
18001
18002impl<'de> ::serde::de::Deserialize<'de> for Tag {
18003 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18004 use serde::de::{self, MapAccess, Visitor};
18006 struct EnumVisitor;
18007 impl<'de> Visitor<'de> for EnumVisitor {
18008 type Value = Tag;
18009 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18010 f.write_str("a Tag structure")
18011 }
18012 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18013 let tag: &str = match map.next_key()? {
18014 Some(".tag") => map.next_value()?,
18015 _ => return Err(de::Error::missing_field(".tag"))
18016 };
18017 let value = match tag {
18018 "user_generated_tag" => Tag::UserGeneratedTag(UserGeneratedTag::internal_deserialize(&mut map)?),
18019 _ => Tag::Other,
18020 };
18021 crate::eat_json_fields(&mut map)?;
18022 Ok(value)
18023 }
18024 }
18025 const VARIANTS: &[&str] = &["user_generated_tag",
18026 "other"];
18027 deserializer.deserialize_struct("Tag", VARIANTS, EnumVisitor)
18028 }
18029}
18030
18031impl ::serde::ser::Serialize for Tag {
18032 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18033 use serde::ser::SerializeStruct;
18035 match self {
18036 Tag::UserGeneratedTag(x) => {
18037 let mut s = serializer.serialize_struct("Tag", 2)?;
18039 s.serialize_field(".tag", "user_generated_tag")?;
18040 x.internal_serialize::<S>(&mut s)?;
18041 s.end()
18042 }
18043 Tag::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
18044 }
18045 }
18046}
18047
18048#[derive(Debug, Clone, PartialEq, Eq)]
18049#[non_exhaustive] pub struct ThumbnailArg {
18051 pub path: ReadPath,
18053 pub format: ThumbnailFormat,
18057 pub size: ThumbnailSize,
18059 pub mode: ThumbnailMode,
18061 pub quality: ThumbnailQuality,
18063 pub exclude_media_info: Option<bool>,
18067}
18068
18069impl ThumbnailArg {
18070 pub fn new(path: ReadPath) -> Self {
18071 ThumbnailArg {
18072 path,
18073 format: ThumbnailFormat::Jpeg,
18074 size: ThumbnailSize::W64h64,
18075 mode: ThumbnailMode::Strict,
18076 quality: ThumbnailQuality::Quality80,
18077 exclude_media_info: None,
18078 }
18079 }
18080
18081 pub fn with_format(mut self, value: ThumbnailFormat) -> Self {
18082 self.format = value;
18083 self
18084 }
18085
18086 pub fn with_size(mut self, value: ThumbnailSize) -> Self {
18087 self.size = value;
18088 self
18089 }
18090
18091 pub fn with_mode(mut self, value: ThumbnailMode) -> Self {
18092 self.mode = value;
18093 self
18094 }
18095
18096 pub fn with_quality(mut self, value: ThumbnailQuality) -> Self {
18097 self.quality = value;
18098 self
18099 }
18100
18101 pub fn with_exclude_media_info(mut self, value: bool) -> Self {
18102 self.exclude_media_info = Some(value);
18103 self
18104 }
18105}
18106
18107const THUMBNAIL_ARG_FIELDS: &[&str] = &["path",
18108 "format",
18109 "size",
18110 "mode",
18111 "quality",
18112 "exclude_media_info"];
18113impl ThumbnailArg {
18114 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
18115 map: V,
18116 ) -> Result<ThumbnailArg, V::Error> {
18117 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
18118 }
18119
18120 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
18121 mut map: V,
18122 optional: bool,
18123 ) -> Result<Option<ThumbnailArg>, V::Error> {
18124 let mut field_path = None;
18125 let mut field_format = None;
18126 let mut field_size = None;
18127 let mut field_mode = None;
18128 let mut field_quality = None;
18129 let mut field_exclude_media_info = None;
18130 let mut nothing = true;
18131 while let Some(key) = map.next_key::<&str>()? {
18132 nothing = false;
18133 match key {
18134 "path" => {
18135 if field_path.is_some() {
18136 return Err(::serde::de::Error::duplicate_field("path"));
18137 }
18138 field_path = Some(map.next_value()?);
18139 }
18140 "format" => {
18141 if field_format.is_some() {
18142 return Err(::serde::de::Error::duplicate_field("format"));
18143 }
18144 field_format = Some(map.next_value()?);
18145 }
18146 "size" => {
18147 if field_size.is_some() {
18148 return Err(::serde::de::Error::duplicate_field("size"));
18149 }
18150 field_size = Some(map.next_value()?);
18151 }
18152 "mode" => {
18153 if field_mode.is_some() {
18154 return Err(::serde::de::Error::duplicate_field("mode"));
18155 }
18156 field_mode = Some(map.next_value()?);
18157 }
18158 "quality" => {
18159 if field_quality.is_some() {
18160 return Err(::serde::de::Error::duplicate_field("quality"));
18161 }
18162 field_quality = Some(map.next_value()?);
18163 }
18164 "exclude_media_info" => {
18165 if field_exclude_media_info.is_some() {
18166 return Err(::serde::de::Error::duplicate_field("exclude_media_info"));
18167 }
18168 field_exclude_media_info = Some(map.next_value()?);
18169 }
18170 _ => {
18171 map.next_value::<::serde_json::Value>()?;
18173 }
18174 }
18175 }
18176 if optional && nothing {
18177 return Ok(None);
18178 }
18179 let result = ThumbnailArg {
18180 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
18181 format: field_format.unwrap_or(ThumbnailFormat::Jpeg),
18182 size: field_size.unwrap_or(ThumbnailSize::W64h64),
18183 mode: field_mode.unwrap_or(ThumbnailMode::Strict),
18184 quality: field_quality.unwrap_or(ThumbnailQuality::Quality80),
18185 exclude_media_info: field_exclude_media_info.and_then(Option::flatten),
18186 };
18187 Ok(Some(result))
18188 }
18189
18190 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
18191 &self,
18192 s: &mut S::SerializeStruct,
18193 ) -> Result<(), S::Error> {
18194 use serde::ser::SerializeStruct;
18195 s.serialize_field("path", &self.path)?;
18196 if self.format != ThumbnailFormat::Jpeg {
18197 s.serialize_field("format", &self.format)?;
18198 }
18199 if self.size != ThumbnailSize::W64h64 {
18200 s.serialize_field("size", &self.size)?;
18201 }
18202 if self.mode != ThumbnailMode::Strict {
18203 s.serialize_field("mode", &self.mode)?;
18204 }
18205 if self.quality != ThumbnailQuality::Quality80 {
18206 s.serialize_field("quality", &self.quality)?;
18207 }
18208 if let Some(val) = &self.exclude_media_info {
18209 s.serialize_field("exclude_media_info", val)?;
18210 }
18211 Ok(())
18212 }
18213}
18214
18215impl<'de> ::serde::de::Deserialize<'de> for ThumbnailArg {
18216 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18217 use serde::de::{MapAccess, Visitor};
18219 struct StructVisitor;
18220 impl<'de> Visitor<'de> for StructVisitor {
18221 type Value = ThumbnailArg;
18222 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18223 f.write_str("a ThumbnailArg struct")
18224 }
18225 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
18226 ThumbnailArg::internal_deserialize(map)
18227 }
18228 }
18229 deserializer.deserialize_struct("ThumbnailArg", THUMBNAIL_ARG_FIELDS, StructVisitor)
18230 }
18231}
18232
18233impl ::serde::ser::Serialize for ThumbnailArg {
18234 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18235 use serde::ser::SerializeStruct;
18237 let mut s = serializer.serialize_struct("ThumbnailArg", 6)?;
18238 self.internal_serialize::<S>(&mut s)?;
18239 s.end()
18240 }
18241}
18242
18243#[derive(Debug, Clone, PartialEq, Eq)]
18244pub enum ThumbnailError {
18245 Path(LookupError),
18247 UnsupportedExtension,
18249 UnsupportedImage,
18251 EncryptedContent,
18253 ConversionError,
18255}
18256
18257impl<'de> ::serde::de::Deserialize<'de> for ThumbnailError {
18258 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18259 use serde::de::{self, MapAccess, Visitor};
18261 struct EnumVisitor;
18262 impl<'de> Visitor<'de> for EnumVisitor {
18263 type Value = ThumbnailError;
18264 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18265 f.write_str("a ThumbnailError structure")
18266 }
18267 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18268 let tag: &str = match map.next_key()? {
18269 Some(".tag") => map.next_value()?,
18270 _ => return Err(de::Error::missing_field(".tag"))
18271 };
18272 let value = match tag {
18273 "path" => {
18274 match map.next_key()? {
18275 Some("path") => ThumbnailError::Path(map.next_value()?),
18276 None => return Err(de::Error::missing_field("path")),
18277 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
18278 }
18279 }
18280 "unsupported_extension" => ThumbnailError::UnsupportedExtension,
18281 "unsupported_image" => ThumbnailError::UnsupportedImage,
18282 "encrypted_content" => ThumbnailError::EncryptedContent,
18283 "conversion_error" => ThumbnailError::ConversionError,
18284 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18285 };
18286 crate::eat_json_fields(&mut map)?;
18287 Ok(value)
18288 }
18289 }
18290 const VARIANTS: &[&str] = &["path",
18291 "unsupported_extension",
18292 "unsupported_image",
18293 "encrypted_content",
18294 "conversion_error"];
18295 deserializer.deserialize_struct("ThumbnailError", VARIANTS, EnumVisitor)
18296 }
18297}
18298
18299impl ::serde::ser::Serialize for ThumbnailError {
18300 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18301 use serde::ser::SerializeStruct;
18303 match self {
18304 ThumbnailError::Path(x) => {
18305 let mut s = serializer.serialize_struct("ThumbnailError", 2)?;
18307 s.serialize_field(".tag", "path")?;
18308 s.serialize_field("path", x)?;
18309 s.end()
18310 }
18311 ThumbnailError::UnsupportedExtension => {
18312 let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18314 s.serialize_field(".tag", "unsupported_extension")?;
18315 s.end()
18316 }
18317 ThumbnailError::UnsupportedImage => {
18318 let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18320 s.serialize_field(".tag", "unsupported_image")?;
18321 s.end()
18322 }
18323 ThumbnailError::EncryptedContent => {
18324 let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18326 s.serialize_field(".tag", "encrypted_content")?;
18327 s.end()
18328 }
18329 ThumbnailError::ConversionError => {
18330 let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18332 s.serialize_field(".tag", "conversion_error")?;
18333 s.end()
18334 }
18335 }
18336 }
18337}
18338
18339impl ::std::error::Error for ThumbnailError {
18340 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
18341 match self {
18342 ThumbnailError::Path(inner) => Some(inner),
18343 _ => None,
18344 }
18345 }
18346}
18347
18348impl ::std::fmt::Display for ThumbnailError {
18349 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18350 match self {
18351 ThumbnailError::Path(inner) => write!(f, "An error occurs when downloading metadata for the image: {}", inner),
18352 ThumbnailError::UnsupportedExtension => f.write_str("The file extension doesn't allow conversion to a thumbnail."),
18353 ThumbnailError::UnsupportedImage => f.write_str("The image cannot be converted to a thumbnail."),
18354 ThumbnailError::EncryptedContent => f.write_str("Encrypted content cannot be converted to a thumbnail."),
18355 ThumbnailError::ConversionError => f.write_str("An error occurs during thumbnail conversion."),
18356 }
18357 }
18358}
18359
18360#[derive(Debug, Clone, PartialEq, Eq)]
18361pub enum ThumbnailFormat {
18362 Jpeg,
18363 Png,
18364 Webp,
18365}
18366
18367impl<'de> ::serde::de::Deserialize<'de> for ThumbnailFormat {
18368 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18369 use serde::de::{self, MapAccess, Visitor};
18371 struct EnumVisitor;
18372 impl<'de> Visitor<'de> for EnumVisitor {
18373 type Value = ThumbnailFormat;
18374 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18375 f.write_str("a ThumbnailFormat structure")
18376 }
18377 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18378 let tag: &str = match map.next_key()? {
18379 Some(".tag") => map.next_value()?,
18380 _ => return Err(de::Error::missing_field(".tag"))
18381 };
18382 let value = match tag {
18383 "jpeg" => ThumbnailFormat::Jpeg,
18384 "png" => ThumbnailFormat::Png,
18385 "webp" => ThumbnailFormat::Webp,
18386 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18387 };
18388 crate::eat_json_fields(&mut map)?;
18389 Ok(value)
18390 }
18391 }
18392 const VARIANTS: &[&str] = &["jpeg",
18393 "png",
18394 "webp"];
18395 deserializer.deserialize_struct("ThumbnailFormat", VARIANTS, EnumVisitor)
18396 }
18397}
18398
18399impl ::serde::ser::Serialize for ThumbnailFormat {
18400 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18401 use serde::ser::SerializeStruct;
18403 match self {
18404 ThumbnailFormat::Jpeg => {
18405 let mut s = serializer.serialize_struct("ThumbnailFormat", 1)?;
18407 s.serialize_field(".tag", "jpeg")?;
18408 s.end()
18409 }
18410 ThumbnailFormat::Png => {
18411 let mut s = serializer.serialize_struct("ThumbnailFormat", 1)?;
18413 s.serialize_field(".tag", "png")?;
18414 s.end()
18415 }
18416 ThumbnailFormat::Webp => {
18417 let mut s = serializer.serialize_struct("ThumbnailFormat", 1)?;
18419 s.serialize_field(".tag", "webp")?;
18420 s.end()
18421 }
18422 }
18423 }
18424}
18425
18426#[derive(Debug, Clone, PartialEq, Eq)]
18427pub enum ThumbnailMode {
18428 Strict,
18430 Bestfit,
18432 FitoneBestfit,
18434 Original,
18436}
18437
18438impl<'de> ::serde::de::Deserialize<'de> for ThumbnailMode {
18439 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18440 use serde::de::{self, MapAccess, Visitor};
18442 struct EnumVisitor;
18443 impl<'de> Visitor<'de> for EnumVisitor {
18444 type Value = ThumbnailMode;
18445 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18446 f.write_str("a ThumbnailMode structure")
18447 }
18448 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18449 let tag: &str = match map.next_key()? {
18450 Some(".tag") => map.next_value()?,
18451 _ => return Err(de::Error::missing_field(".tag"))
18452 };
18453 let value = match tag {
18454 "strict" => ThumbnailMode::Strict,
18455 "bestfit" => ThumbnailMode::Bestfit,
18456 "fitone_bestfit" => ThumbnailMode::FitoneBestfit,
18457 "original" => ThumbnailMode::Original,
18458 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18459 };
18460 crate::eat_json_fields(&mut map)?;
18461 Ok(value)
18462 }
18463 }
18464 const VARIANTS: &[&str] = &["strict",
18465 "bestfit",
18466 "fitone_bestfit",
18467 "original"];
18468 deserializer.deserialize_struct("ThumbnailMode", VARIANTS, EnumVisitor)
18469 }
18470}
18471
18472impl ::serde::ser::Serialize for ThumbnailMode {
18473 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18474 use serde::ser::SerializeStruct;
18476 match self {
18477 ThumbnailMode::Strict => {
18478 let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18480 s.serialize_field(".tag", "strict")?;
18481 s.end()
18482 }
18483 ThumbnailMode::Bestfit => {
18484 let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18486 s.serialize_field(".tag", "bestfit")?;
18487 s.end()
18488 }
18489 ThumbnailMode::FitoneBestfit => {
18490 let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18492 s.serialize_field(".tag", "fitone_bestfit")?;
18493 s.end()
18494 }
18495 ThumbnailMode::Original => {
18496 let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18498 s.serialize_field(".tag", "original")?;
18499 s.end()
18500 }
18501 }
18502 }
18503}
18504
18505#[derive(Debug, Clone, PartialEq, Eq)]
18506pub enum ThumbnailQuality {
18507 Quality80,
18509 Quality90,
18511}
18512
18513impl<'de> ::serde::de::Deserialize<'de> for ThumbnailQuality {
18514 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18515 use serde::de::{self, MapAccess, Visitor};
18517 struct EnumVisitor;
18518 impl<'de> Visitor<'de> for EnumVisitor {
18519 type Value = ThumbnailQuality;
18520 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18521 f.write_str("a ThumbnailQuality structure")
18522 }
18523 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18524 let tag: &str = match map.next_key()? {
18525 Some(".tag") => map.next_value()?,
18526 _ => return Err(de::Error::missing_field(".tag"))
18527 };
18528 let value = match tag {
18529 "quality_80" => ThumbnailQuality::Quality80,
18530 "quality_90" => ThumbnailQuality::Quality90,
18531 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18532 };
18533 crate::eat_json_fields(&mut map)?;
18534 Ok(value)
18535 }
18536 }
18537 const VARIANTS: &[&str] = &["quality_80",
18538 "quality_90"];
18539 deserializer.deserialize_struct("ThumbnailQuality", VARIANTS, EnumVisitor)
18540 }
18541}
18542
18543impl ::serde::ser::Serialize for ThumbnailQuality {
18544 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18545 use serde::ser::SerializeStruct;
18547 match self {
18548 ThumbnailQuality::Quality80 => {
18549 let mut s = serializer.serialize_struct("ThumbnailQuality", 1)?;
18551 s.serialize_field(".tag", "quality_80")?;
18552 s.end()
18553 }
18554 ThumbnailQuality::Quality90 => {
18555 let mut s = serializer.serialize_struct("ThumbnailQuality", 1)?;
18557 s.serialize_field(".tag", "quality_90")?;
18558 s.end()
18559 }
18560 }
18561 }
18562}
18563
18564#[derive(Debug, Clone, PartialEq, Eq)]
18565pub enum ThumbnailSize {
18566 W32h32,
18568 W64h64,
18570 W128h128,
18572 W256h256,
18574 W480h320,
18576 W640h480,
18578 W960h640,
18580 W1024h768,
18582 W2048h1536,
18584 W3200h2400,
18586}
18587
18588impl<'de> ::serde::de::Deserialize<'de> for ThumbnailSize {
18589 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18590 use serde::de::{self, MapAccess, Visitor};
18592 struct EnumVisitor;
18593 impl<'de> Visitor<'de> for EnumVisitor {
18594 type Value = ThumbnailSize;
18595 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18596 f.write_str("a ThumbnailSize structure")
18597 }
18598 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18599 let tag: &str = match map.next_key()? {
18600 Some(".tag") => map.next_value()?,
18601 _ => return Err(de::Error::missing_field(".tag"))
18602 };
18603 let value = match tag {
18604 "w32h32" => ThumbnailSize::W32h32,
18605 "w64h64" => ThumbnailSize::W64h64,
18606 "w128h128" => ThumbnailSize::W128h128,
18607 "w256h256" => ThumbnailSize::W256h256,
18608 "w480h320" => ThumbnailSize::W480h320,
18609 "w640h480" => ThumbnailSize::W640h480,
18610 "w960h640" => ThumbnailSize::W960h640,
18611 "w1024h768" => ThumbnailSize::W1024h768,
18612 "w2048h1536" => ThumbnailSize::W2048h1536,
18613 "w3200h2400" => ThumbnailSize::W3200h2400,
18614 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18615 };
18616 crate::eat_json_fields(&mut map)?;
18617 Ok(value)
18618 }
18619 }
18620 const VARIANTS: &[&str] = &["w32h32",
18621 "w64h64",
18622 "w128h128",
18623 "w256h256",
18624 "w480h320",
18625 "w640h480",
18626 "w960h640",
18627 "w1024h768",
18628 "w2048h1536",
18629 "w3200h2400"];
18630 deserializer.deserialize_struct("ThumbnailSize", VARIANTS, EnumVisitor)
18631 }
18632}
18633
18634impl ::serde::ser::Serialize for ThumbnailSize {
18635 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18636 use serde::ser::SerializeStruct;
18638 match self {
18639 ThumbnailSize::W32h32 => {
18640 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18642 s.serialize_field(".tag", "w32h32")?;
18643 s.end()
18644 }
18645 ThumbnailSize::W64h64 => {
18646 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18648 s.serialize_field(".tag", "w64h64")?;
18649 s.end()
18650 }
18651 ThumbnailSize::W128h128 => {
18652 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18654 s.serialize_field(".tag", "w128h128")?;
18655 s.end()
18656 }
18657 ThumbnailSize::W256h256 => {
18658 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18660 s.serialize_field(".tag", "w256h256")?;
18661 s.end()
18662 }
18663 ThumbnailSize::W480h320 => {
18664 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18666 s.serialize_field(".tag", "w480h320")?;
18667 s.end()
18668 }
18669 ThumbnailSize::W640h480 => {
18670 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18672 s.serialize_field(".tag", "w640h480")?;
18673 s.end()
18674 }
18675 ThumbnailSize::W960h640 => {
18676 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18678 s.serialize_field(".tag", "w960h640")?;
18679 s.end()
18680 }
18681 ThumbnailSize::W1024h768 => {
18682 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18684 s.serialize_field(".tag", "w1024h768")?;
18685 s.end()
18686 }
18687 ThumbnailSize::W2048h1536 => {
18688 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18690 s.serialize_field(".tag", "w2048h1536")?;
18691 s.end()
18692 }
18693 ThumbnailSize::W3200h2400 => {
18694 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18696 s.serialize_field(".tag", "w3200h2400")?;
18697 s.end()
18698 }
18699 }
18700 }
18701}
18702
18703#[derive(Debug, Clone, PartialEq, Eq)]
18704#[non_exhaustive] pub struct ThumbnailV2Arg {
18706 pub resource: PathOrLink,
18709 pub format: ThumbnailFormat,
18713 pub size: ThumbnailSize,
18715 pub mode: ThumbnailMode,
18717 pub quality: ThumbnailQuality,
18719 pub exclude_media_info: Option<bool>,
18723}
18724
18725impl ThumbnailV2Arg {
18726 pub fn new(resource: PathOrLink) -> Self {
18727 ThumbnailV2Arg {
18728 resource,
18729 format: ThumbnailFormat::Jpeg,
18730 size: ThumbnailSize::W64h64,
18731 mode: ThumbnailMode::Strict,
18732 quality: ThumbnailQuality::Quality80,
18733 exclude_media_info: None,
18734 }
18735 }
18736
18737 pub fn with_format(mut self, value: ThumbnailFormat) -> Self {
18738 self.format = value;
18739 self
18740 }
18741
18742 pub fn with_size(mut self, value: ThumbnailSize) -> Self {
18743 self.size = value;
18744 self
18745 }
18746
18747 pub fn with_mode(mut self, value: ThumbnailMode) -> Self {
18748 self.mode = value;
18749 self
18750 }
18751
18752 pub fn with_quality(mut self, value: ThumbnailQuality) -> Self {
18753 self.quality = value;
18754 self
18755 }
18756
18757 pub fn with_exclude_media_info(mut self, value: bool) -> Self {
18758 self.exclude_media_info = Some(value);
18759 self
18760 }
18761}
18762
18763const THUMBNAIL_V2_ARG_FIELDS: &[&str] = &["resource",
18764 "format",
18765 "size",
18766 "mode",
18767 "quality",
18768 "exclude_media_info"];
18769impl ThumbnailV2Arg {
18770 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
18771 map: V,
18772 ) -> Result<ThumbnailV2Arg, V::Error> {
18773 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
18774 }
18775
18776 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
18777 mut map: V,
18778 optional: bool,
18779 ) -> Result<Option<ThumbnailV2Arg>, V::Error> {
18780 let mut field_resource = None;
18781 let mut field_format = None;
18782 let mut field_size = None;
18783 let mut field_mode = None;
18784 let mut field_quality = None;
18785 let mut field_exclude_media_info = None;
18786 let mut nothing = true;
18787 while let Some(key) = map.next_key::<&str>()? {
18788 nothing = false;
18789 match key {
18790 "resource" => {
18791 if field_resource.is_some() {
18792 return Err(::serde::de::Error::duplicate_field("resource"));
18793 }
18794 field_resource = Some(map.next_value()?);
18795 }
18796 "format" => {
18797 if field_format.is_some() {
18798 return Err(::serde::de::Error::duplicate_field("format"));
18799 }
18800 field_format = Some(map.next_value()?);
18801 }
18802 "size" => {
18803 if field_size.is_some() {
18804 return Err(::serde::de::Error::duplicate_field("size"));
18805 }
18806 field_size = Some(map.next_value()?);
18807 }
18808 "mode" => {
18809 if field_mode.is_some() {
18810 return Err(::serde::de::Error::duplicate_field("mode"));
18811 }
18812 field_mode = Some(map.next_value()?);
18813 }
18814 "quality" => {
18815 if field_quality.is_some() {
18816 return Err(::serde::de::Error::duplicate_field("quality"));
18817 }
18818 field_quality = Some(map.next_value()?);
18819 }
18820 "exclude_media_info" => {
18821 if field_exclude_media_info.is_some() {
18822 return Err(::serde::de::Error::duplicate_field("exclude_media_info"));
18823 }
18824 field_exclude_media_info = Some(map.next_value()?);
18825 }
18826 _ => {
18827 map.next_value::<::serde_json::Value>()?;
18829 }
18830 }
18831 }
18832 if optional && nothing {
18833 return Ok(None);
18834 }
18835 let result = ThumbnailV2Arg {
18836 resource: field_resource.ok_or_else(|| ::serde::de::Error::missing_field("resource"))?,
18837 format: field_format.unwrap_or(ThumbnailFormat::Jpeg),
18838 size: field_size.unwrap_or(ThumbnailSize::W64h64),
18839 mode: field_mode.unwrap_or(ThumbnailMode::Strict),
18840 quality: field_quality.unwrap_or(ThumbnailQuality::Quality80),
18841 exclude_media_info: field_exclude_media_info.and_then(Option::flatten),
18842 };
18843 Ok(Some(result))
18844 }
18845
18846 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
18847 &self,
18848 s: &mut S::SerializeStruct,
18849 ) -> Result<(), S::Error> {
18850 use serde::ser::SerializeStruct;
18851 s.serialize_field("resource", &self.resource)?;
18852 if self.format != ThumbnailFormat::Jpeg {
18853 s.serialize_field("format", &self.format)?;
18854 }
18855 if self.size != ThumbnailSize::W64h64 {
18856 s.serialize_field("size", &self.size)?;
18857 }
18858 if self.mode != ThumbnailMode::Strict {
18859 s.serialize_field("mode", &self.mode)?;
18860 }
18861 if self.quality != ThumbnailQuality::Quality80 {
18862 s.serialize_field("quality", &self.quality)?;
18863 }
18864 if let Some(val) = &self.exclude_media_info {
18865 s.serialize_field("exclude_media_info", val)?;
18866 }
18867 Ok(())
18868 }
18869}
18870
18871impl<'de> ::serde::de::Deserialize<'de> for ThumbnailV2Arg {
18872 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18873 use serde::de::{MapAccess, Visitor};
18875 struct StructVisitor;
18876 impl<'de> Visitor<'de> for StructVisitor {
18877 type Value = ThumbnailV2Arg;
18878 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18879 f.write_str("a ThumbnailV2Arg struct")
18880 }
18881 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
18882 ThumbnailV2Arg::internal_deserialize(map)
18883 }
18884 }
18885 deserializer.deserialize_struct("ThumbnailV2Arg", THUMBNAIL_V2_ARG_FIELDS, StructVisitor)
18886 }
18887}
18888
18889impl ::serde::ser::Serialize for ThumbnailV2Arg {
18890 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18891 use serde::ser::SerializeStruct;
18893 let mut s = serializer.serialize_struct("ThumbnailV2Arg", 6)?;
18894 self.internal_serialize::<S>(&mut s)?;
18895 s.end()
18896 }
18897}
18898
18899#[derive(Debug, Clone, PartialEq, Eq)]
18900#[non_exhaustive] pub enum ThumbnailV2Error {
18902 Path(LookupError),
18904 UnsupportedExtension,
18906 UnsupportedImage,
18908 EncryptedContent,
18910 ConversionError,
18912 AccessDenied,
18914 NotFound,
18916 Other,
18919}
18920
18921impl<'de> ::serde::de::Deserialize<'de> for ThumbnailV2Error {
18922 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18923 use serde::de::{self, MapAccess, Visitor};
18925 struct EnumVisitor;
18926 impl<'de> Visitor<'de> for EnumVisitor {
18927 type Value = ThumbnailV2Error;
18928 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18929 f.write_str("a ThumbnailV2Error structure")
18930 }
18931 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18932 let tag: &str = match map.next_key()? {
18933 Some(".tag") => map.next_value()?,
18934 _ => return Err(de::Error::missing_field(".tag"))
18935 };
18936 let value = match tag {
18937 "path" => {
18938 match map.next_key()? {
18939 Some("path") => ThumbnailV2Error::Path(map.next_value()?),
18940 None => return Err(de::Error::missing_field("path")),
18941 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
18942 }
18943 }
18944 "unsupported_extension" => ThumbnailV2Error::UnsupportedExtension,
18945 "unsupported_image" => ThumbnailV2Error::UnsupportedImage,
18946 "encrypted_content" => ThumbnailV2Error::EncryptedContent,
18947 "conversion_error" => ThumbnailV2Error::ConversionError,
18948 "access_denied" => ThumbnailV2Error::AccessDenied,
18949 "not_found" => ThumbnailV2Error::NotFound,
18950 _ => ThumbnailV2Error::Other,
18951 };
18952 crate::eat_json_fields(&mut map)?;
18953 Ok(value)
18954 }
18955 }
18956 const VARIANTS: &[&str] = &["path",
18957 "unsupported_extension",
18958 "unsupported_image",
18959 "encrypted_content",
18960 "conversion_error",
18961 "access_denied",
18962 "not_found",
18963 "other"];
18964 deserializer.deserialize_struct("ThumbnailV2Error", VARIANTS, EnumVisitor)
18965 }
18966}
18967
18968impl ::serde::ser::Serialize for ThumbnailV2Error {
18969 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18970 use serde::ser::SerializeStruct;
18972 match self {
18973 ThumbnailV2Error::Path(x) => {
18974 let mut s = serializer.serialize_struct("ThumbnailV2Error", 2)?;
18976 s.serialize_field(".tag", "path")?;
18977 s.serialize_field("path", x)?;
18978 s.end()
18979 }
18980 ThumbnailV2Error::UnsupportedExtension => {
18981 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
18983 s.serialize_field(".tag", "unsupported_extension")?;
18984 s.end()
18985 }
18986 ThumbnailV2Error::UnsupportedImage => {
18987 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
18989 s.serialize_field(".tag", "unsupported_image")?;
18990 s.end()
18991 }
18992 ThumbnailV2Error::EncryptedContent => {
18993 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
18995 s.serialize_field(".tag", "encrypted_content")?;
18996 s.end()
18997 }
18998 ThumbnailV2Error::ConversionError => {
18999 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19001 s.serialize_field(".tag", "conversion_error")?;
19002 s.end()
19003 }
19004 ThumbnailV2Error::AccessDenied => {
19005 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19007 s.serialize_field(".tag", "access_denied")?;
19008 s.end()
19009 }
19010 ThumbnailV2Error::NotFound => {
19011 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19013 s.serialize_field(".tag", "not_found")?;
19014 s.end()
19015 }
19016 ThumbnailV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
19017 }
19018 }
19019}
19020
19021impl ::std::error::Error for ThumbnailV2Error {
19022 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
19023 match self {
19024 ThumbnailV2Error::Path(inner) => Some(inner),
19025 _ => None,
19026 }
19027 }
19028}
19029
19030impl ::std::fmt::Display for ThumbnailV2Error {
19031 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19032 match self {
19033 ThumbnailV2Error::Path(inner) => write!(f, "An error occurred when downloading metadata for the image: {}", inner),
19034 ThumbnailV2Error::UnsupportedExtension => f.write_str("The file extension doesn't allow conversion to a thumbnail."),
19035 ThumbnailV2Error::UnsupportedImage => f.write_str("The image cannot be converted to a thumbnail."),
19036 ThumbnailV2Error::EncryptedContent => f.write_str("Encrypted content cannot be converted to a thumbnail."),
19037 ThumbnailV2Error::ConversionError => f.write_str("An error occurred during thumbnail conversion."),
19038 ThumbnailV2Error::AccessDenied => f.write_str("Access to this shared link is forbidden."),
19039 ThumbnailV2Error::NotFound => f.write_str("The shared link does not exist."),
19040 _ => write!(f, "{:?}", *self),
19041 }
19042 }
19043}
19044
19045#[derive(Debug, Clone, PartialEq, Eq)]
19046#[non_exhaustive] pub struct UnlockFileArg {
19048 pub path: WritePathOrId,
19050}
19051
19052impl UnlockFileArg {
19053 pub fn new(path: WritePathOrId) -> Self {
19054 UnlockFileArg {
19055 path,
19056 }
19057 }
19058}
19059
19060const UNLOCK_FILE_ARG_FIELDS: &[&str] = &["path"];
19061impl UnlockFileArg {
19062 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19063 map: V,
19064 ) -> Result<UnlockFileArg, V::Error> {
19065 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19066 }
19067
19068 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19069 mut map: V,
19070 optional: bool,
19071 ) -> Result<Option<UnlockFileArg>, V::Error> {
19072 let mut field_path = None;
19073 let mut nothing = true;
19074 while let Some(key) = map.next_key::<&str>()? {
19075 nothing = false;
19076 match key {
19077 "path" => {
19078 if field_path.is_some() {
19079 return Err(::serde::de::Error::duplicate_field("path"));
19080 }
19081 field_path = Some(map.next_value()?);
19082 }
19083 _ => {
19084 map.next_value::<::serde_json::Value>()?;
19086 }
19087 }
19088 }
19089 if optional && nothing {
19090 return Ok(None);
19091 }
19092 let result = UnlockFileArg {
19093 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
19094 };
19095 Ok(Some(result))
19096 }
19097
19098 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19099 &self,
19100 s: &mut S::SerializeStruct,
19101 ) -> Result<(), S::Error> {
19102 use serde::ser::SerializeStruct;
19103 s.serialize_field("path", &self.path)?;
19104 Ok(())
19105 }
19106}
19107
19108impl<'de> ::serde::de::Deserialize<'de> for UnlockFileArg {
19109 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19110 use serde::de::{MapAccess, Visitor};
19112 struct StructVisitor;
19113 impl<'de> Visitor<'de> for StructVisitor {
19114 type Value = UnlockFileArg;
19115 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19116 f.write_str("a UnlockFileArg struct")
19117 }
19118 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19119 UnlockFileArg::internal_deserialize(map)
19120 }
19121 }
19122 deserializer.deserialize_struct("UnlockFileArg", UNLOCK_FILE_ARG_FIELDS, StructVisitor)
19123 }
19124}
19125
19126impl ::serde::ser::Serialize for UnlockFileArg {
19127 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19128 use serde::ser::SerializeStruct;
19130 let mut s = serializer.serialize_struct("UnlockFileArg", 1)?;
19131 self.internal_serialize::<S>(&mut s)?;
19132 s.end()
19133 }
19134}
19135
19136#[derive(Debug, Clone, PartialEq, Eq)]
19137#[non_exhaustive] pub struct UnlockFileBatchArg {
19139 pub entries: Vec<UnlockFileArg>,
19142}
19143
19144impl UnlockFileBatchArg {
19145 pub fn new(entries: Vec<UnlockFileArg>) -> Self {
19146 UnlockFileBatchArg {
19147 entries,
19148 }
19149 }
19150}
19151
19152const UNLOCK_FILE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
19153impl UnlockFileBatchArg {
19154 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19155 map: V,
19156 ) -> Result<UnlockFileBatchArg, V::Error> {
19157 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19158 }
19159
19160 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19161 mut map: V,
19162 optional: bool,
19163 ) -> Result<Option<UnlockFileBatchArg>, V::Error> {
19164 let mut field_entries = None;
19165 let mut nothing = true;
19166 while let Some(key) = map.next_key::<&str>()? {
19167 nothing = false;
19168 match key {
19169 "entries" => {
19170 if field_entries.is_some() {
19171 return Err(::serde::de::Error::duplicate_field("entries"));
19172 }
19173 field_entries = Some(map.next_value()?);
19174 }
19175 _ => {
19176 map.next_value::<::serde_json::Value>()?;
19178 }
19179 }
19180 }
19181 if optional && nothing {
19182 return Ok(None);
19183 }
19184 let result = UnlockFileBatchArg {
19185 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
19186 };
19187 Ok(Some(result))
19188 }
19189
19190 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19191 &self,
19192 s: &mut S::SerializeStruct,
19193 ) -> Result<(), S::Error> {
19194 use serde::ser::SerializeStruct;
19195 s.serialize_field("entries", &self.entries)?;
19196 Ok(())
19197 }
19198}
19199
19200impl<'de> ::serde::de::Deserialize<'de> for UnlockFileBatchArg {
19201 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19202 use serde::de::{MapAccess, Visitor};
19204 struct StructVisitor;
19205 impl<'de> Visitor<'de> for StructVisitor {
19206 type Value = UnlockFileBatchArg;
19207 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19208 f.write_str("a UnlockFileBatchArg struct")
19209 }
19210 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19211 UnlockFileBatchArg::internal_deserialize(map)
19212 }
19213 }
19214 deserializer.deserialize_struct("UnlockFileBatchArg", UNLOCK_FILE_BATCH_ARG_FIELDS, StructVisitor)
19215 }
19216}
19217
19218impl ::serde::ser::Serialize for UnlockFileBatchArg {
19219 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19220 use serde::ser::SerializeStruct;
19222 let mut s = serializer.serialize_struct("UnlockFileBatchArg", 1)?;
19223 self.internal_serialize::<S>(&mut s)?;
19224 s.end()
19225 }
19226}
19227
19228#[derive(Debug, Clone, PartialEq, Eq)]
19229#[non_exhaustive] pub struct UploadArg {
19231 pub path: WritePathOrId,
19233 pub mode: WriteMode,
19235 pub autorename: bool,
19238 pub client_modified: Option<crate::types::common::DropboxTimestamp>,
19243 pub mute: bool,
19247 pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
19249 pub strict_conflict: bool,
19254 pub content_hash: Option<Sha256HexHash>,
19258}
19259
19260impl UploadArg {
19261 pub fn new(path: WritePathOrId) -> Self {
19262 UploadArg {
19263 path,
19264 mode: WriteMode::Add,
19265 autorename: false,
19266 client_modified: None,
19267 mute: false,
19268 property_groups: None,
19269 strict_conflict: false,
19270 content_hash: None,
19271 }
19272 }
19273
19274 pub fn with_mode(mut self, value: WriteMode) -> Self {
19275 self.mode = value;
19276 self
19277 }
19278
19279 pub fn with_autorename(mut self, value: bool) -> Self {
19280 self.autorename = value;
19281 self
19282 }
19283
19284 pub fn with_client_modified(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
19285 self.client_modified = Some(value);
19286 self
19287 }
19288
19289 pub fn with_mute(mut self, value: bool) -> Self {
19290 self.mute = value;
19291 self
19292 }
19293
19294 pub fn with_property_groups(
19295 mut self,
19296 value: Vec<crate::types::file_properties::PropertyGroup>,
19297 ) -> Self {
19298 self.property_groups = Some(value);
19299 self
19300 }
19301
19302 pub fn with_strict_conflict(mut self, value: bool) -> Self {
19303 self.strict_conflict = value;
19304 self
19305 }
19306
19307 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
19308 self.content_hash = Some(value);
19309 self
19310 }
19311}
19312
19313const UPLOAD_ARG_FIELDS: &[&str] = &["path",
19314 "mode",
19315 "autorename",
19316 "client_modified",
19317 "mute",
19318 "property_groups",
19319 "strict_conflict",
19320 "content_hash"];
19321impl UploadArg {
19322 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19323 map: V,
19324 ) -> Result<UploadArg, V::Error> {
19325 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19326 }
19327
19328 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19329 mut map: V,
19330 optional: bool,
19331 ) -> Result<Option<UploadArg>, V::Error> {
19332 let mut field_path = None;
19333 let mut field_mode = None;
19334 let mut field_autorename = None;
19335 let mut field_client_modified = None;
19336 let mut field_mute = None;
19337 let mut field_property_groups = None;
19338 let mut field_strict_conflict = None;
19339 let mut field_content_hash = None;
19340 let mut nothing = true;
19341 while let Some(key) = map.next_key::<&str>()? {
19342 nothing = false;
19343 match key {
19344 "path" => {
19345 if field_path.is_some() {
19346 return Err(::serde::de::Error::duplicate_field("path"));
19347 }
19348 field_path = Some(map.next_value()?);
19349 }
19350 "mode" => {
19351 if field_mode.is_some() {
19352 return Err(::serde::de::Error::duplicate_field("mode"));
19353 }
19354 field_mode = Some(map.next_value()?);
19355 }
19356 "autorename" => {
19357 if field_autorename.is_some() {
19358 return Err(::serde::de::Error::duplicate_field("autorename"));
19359 }
19360 field_autorename = Some(map.next_value()?);
19361 }
19362 "client_modified" => {
19363 if field_client_modified.is_some() {
19364 return Err(::serde::de::Error::duplicate_field("client_modified"));
19365 }
19366 field_client_modified = Some(map.next_value()?);
19367 }
19368 "mute" => {
19369 if field_mute.is_some() {
19370 return Err(::serde::de::Error::duplicate_field("mute"));
19371 }
19372 field_mute = Some(map.next_value()?);
19373 }
19374 "property_groups" => {
19375 if field_property_groups.is_some() {
19376 return Err(::serde::de::Error::duplicate_field("property_groups"));
19377 }
19378 field_property_groups = Some(map.next_value()?);
19379 }
19380 "strict_conflict" => {
19381 if field_strict_conflict.is_some() {
19382 return Err(::serde::de::Error::duplicate_field("strict_conflict"));
19383 }
19384 field_strict_conflict = Some(map.next_value()?);
19385 }
19386 "content_hash" => {
19387 if field_content_hash.is_some() {
19388 return Err(::serde::de::Error::duplicate_field("content_hash"));
19389 }
19390 field_content_hash = Some(map.next_value()?);
19391 }
19392 _ => {
19393 map.next_value::<::serde_json::Value>()?;
19395 }
19396 }
19397 }
19398 if optional && nothing {
19399 return Ok(None);
19400 }
19401 let result = UploadArg {
19402 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
19403 mode: field_mode.unwrap_or(WriteMode::Add),
19404 autorename: field_autorename.unwrap_or(false),
19405 client_modified: field_client_modified.and_then(Option::flatten),
19406 mute: field_mute.unwrap_or(false),
19407 property_groups: field_property_groups.and_then(Option::flatten),
19408 strict_conflict: field_strict_conflict.unwrap_or(false),
19409 content_hash: field_content_hash.and_then(Option::flatten),
19410 };
19411 Ok(Some(result))
19412 }
19413
19414 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19415 &self,
19416 s: &mut S::SerializeStruct,
19417 ) -> Result<(), S::Error> {
19418 use serde::ser::SerializeStruct;
19419 s.serialize_field("path", &self.path)?;
19420 if self.mode != WriteMode::Add {
19421 s.serialize_field("mode", &self.mode)?;
19422 }
19423 if self.autorename {
19424 s.serialize_field("autorename", &self.autorename)?;
19425 }
19426 if let Some(val) = &self.client_modified {
19427 s.serialize_field("client_modified", val)?;
19428 }
19429 if self.mute {
19430 s.serialize_field("mute", &self.mute)?;
19431 }
19432 if let Some(val) = &self.property_groups {
19433 s.serialize_field("property_groups", val)?;
19434 }
19435 if self.strict_conflict {
19436 s.serialize_field("strict_conflict", &self.strict_conflict)?;
19437 }
19438 if let Some(val) = &self.content_hash {
19439 s.serialize_field("content_hash", val)?;
19440 }
19441 Ok(())
19442 }
19443}
19444
19445impl<'de> ::serde::de::Deserialize<'de> for UploadArg {
19446 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19447 use serde::de::{MapAccess, Visitor};
19449 struct StructVisitor;
19450 impl<'de> Visitor<'de> for StructVisitor {
19451 type Value = UploadArg;
19452 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19453 f.write_str("a UploadArg struct")
19454 }
19455 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19456 UploadArg::internal_deserialize(map)
19457 }
19458 }
19459 deserializer.deserialize_struct("UploadArg", UPLOAD_ARG_FIELDS, StructVisitor)
19460 }
19461}
19462
19463impl ::serde::ser::Serialize for UploadArg {
19464 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19465 use serde::ser::SerializeStruct;
19467 let mut s = serializer.serialize_struct("UploadArg", 8)?;
19468 self.internal_serialize::<S>(&mut s)?;
19469 s.end()
19470 }
19471}
19472
19473impl From<UploadArg> for CommitInfo {
19475 fn from(subtype: UploadArg) -> Self {
19476 Self {
19477 path: subtype.path,
19478 mode: subtype.mode,
19479 autorename: subtype.autorename,
19480 client_modified: subtype.client_modified,
19481 mute: subtype.mute,
19482 property_groups: subtype.property_groups,
19483 strict_conflict: subtype.strict_conflict,
19484 }
19485 }
19486}
19487#[derive(Debug, Clone, PartialEq, Eq)]
19488#[non_exhaustive] pub enum UploadError {
19490 Path(UploadWriteFailed),
19492 PropertiesError(crate::types::file_properties::InvalidPropertyGroupError),
19494 PayloadTooLarge,
19496 ContentHashMismatch,
19499 EncryptionNotSupported,
19501 Other,
19504}
19505
19506impl<'de> ::serde::de::Deserialize<'de> for UploadError {
19507 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19508 use serde::de::{self, MapAccess, Visitor};
19510 struct EnumVisitor;
19511 impl<'de> Visitor<'de> for EnumVisitor {
19512 type Value = UploadError;
19513 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19514 f.write_str("a UploadError structure")
19515 }
19516 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
19517 let tag: &str = match map.next_key()? {
19518 Some(".tag") => map.next_value()?,
19519 _ => return Err(de::Error::missing_field(".tag"))
19520 };
19521 let value = match tag {
19522 "path" => UploadError::Path(UploadWriteFailed::internal_deserialize(&mut map)?),
19523 "properties_error" => {
19524 match map.next_key()? {
19525 Some("properties_error") => UploadError::PropertiesError(map.next_value()?),
19526 None => return Err(de::Error::missing_field("properties_error")),
19527 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
19528 }
19529 }
19530 "payload_too_large" => UploadError::PayloadTooLarge,
19531 "content_hash_mismatch" => UploadError::ContentHashMismatch,
19532 "encryption_not_supported" => UploadError::EncryptionNotSupported,
19533 _ => UploadError::Other,
19534 };
19535 crate::eat_json_fields(&mut map)?;
19536 Ok(value)
19537 }
19538 }
19539 const VARIANTS: &[&str] = &["path",
19540 "properties_error",
19541 "payload_too_large",
19542 "content_hash_mismatch",
19543 "encryption_not_supported",
19544 "other"];
19545 deserializer.deserialize_struct("UploadError", VARIANTS, EnumVisitor)
19546 }
19547}
19548
19549impl ::serde::ser::Serialize for UploadError {
19550 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19551 use serde::ser::SerializeStruct;
19553 match self {
19554 UploadError::Path(x) => {
19555 let mut s = serializer.serialize_struct("UploadError", 3)?;
19557 s.serialize_field(".tag", "path")?;
19558 x.internal_serialize::<S>(&mut s)?;
19559 s.end()
19560 }
19561 UploadError::PropertiesError(x) => {
19562 let mut s = serializer.serialize_struct("UploadError", 2)?;
19564 s.serialize_field(".tag", "properties_error")?;
19565 s.serialize_field("properties_error", x)?;
19566 s.end()
19567 }
19568 UploadError::PayloadTooLarge => {
19569 let mut s = serializer.serialize_struct("UploadError", 1)?;
19571 s.serialize_field(".tag", "payload_too_large")?;
19572 s.end()
19573 }
19574 UploadError::ContentHashMismatch => {
19575 let mut s = serializer.serialize_struct("UploadError", 1)?;
19577 s.serialize_field(".tag", "content_hash_mismatch")?;
19578 s.end()
19579 }
19580 UploadError::EncryptionNotSupported => {
19581 let mut s = serializer.serialize_struct("UploadError", 1)?;
19583 s.serialize_field(".tag", "encryption_not_supported")?;
19584 s.end()
19585 }
19586 UploadError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
19587 }
19588 }
19589}
19590
19591impl ::std::error::Error for UploadError {
19592 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
19593 match self {
19594 UploadError::PropertiesError(inner) => Some(inner),
19595 _ => None,
19596 }
19597 }
19598}
19599
19600impl ::std::fmt::Display for UploadError {
19601 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19602 match self {
19603 UploadError::Path(inner) => write!(f, "Unable to save the uploaded contents to a file: {:?}", inner),
19604 UploadError::PropertiesError(inner) => write!(f, "The supplied property group is invalid. The file has uploaded without property groups: {}", inner),
19605 UploadError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
19606 UploadError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
19607 UploadError::EncryptionNotSupported => f.write_str("The file is required to be encrypted, which is not supported in our public API."),
19608 _ => write!(f, "{:?}", *self),
19609 }
19610 }
19611}
19612
19613#[derive(Debug, Clone, PartialEq, Eq)]
19614#[non_exhaustive] pub struct UploadSessionAppendArg {
19616 pub cursor: UploadSessionCursor,
19618 pub close: bool,
19622 pub content_hash: Option<Sha256HexHash>,
19626}
19627
19628impl UploadSessionAppendArg {
19629 pub fn new(cursor: UploadSessionCursor) -> Self {
19630 UploadSessionAppendArg {
19631 cursor,
19632 close: false,
19633 content_hash: None,
19634 }
19635 }
19636
19637 pub fn with_close(mut self, value: bool) -> Self {
19638 self.close = value;
19639 self
19640 }
19641
19642 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
19643 self.content_hash = Some(value);
19644 self
19645 }
19646}
19647
19648const UPLOAD_SESSION_APPEND_ARG_FIELDS: &[&str] = &["cursor",
19649 "close",
19650 "content_hash"];
19651impl UploadSessionAppendArg {
19652 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19653 map: V,
19654 ) -> Result<UploadSessionAppendArg, V::Error> {
19655 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19656 }
19657
19658 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19659 mut map: V,
19660 optional: bool,
19661 ) -> Result<Option<UploadSessionAppendArg>, V::Error> {
19662 let mut field_cursor = None;
19663 let mut field_close = None;
19664 let mut field_content_hash = None;
19665 let mut nothing = true;
19666 while let Some(key) = map.next_key::<&str>()? {
19667 nothing = false;
19668 match key {
19669 "cursor" => {
19670 if field_cursor.is_some() {
19671 return Err(::serde::de::Error::duplicate_field("cursor"));
19672 }
19673 field_cursor = Some(map.next_value()?);
19674 }
19675 "close" => {
19676 if field_close.is_some() {
19677 return Err(::serde::de::Error::duplicate_field("close"));
19678 }
19679 field_close = Some(map.next_value()?);
19680 }
19681 "content_hash" => {
19682 if field_content_hash.is_some() {
19683 return Err(::serde::de::Error::duplicate_field("content_hash"));
19684 }
19685 field_content_hash = Some(map.next_value()?);
19686 }
19687 _ => {
19688 map.next_value::<::serde_json::Value>()?;
19690 }
19691 }
19692 }
19693 if optional && nothing {
19694 return Ok(None);
19695 }
19696 let result = UploadSessionAppendArg {
19697 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
19698 close: field_close.unwrap_or(false),
19699 content_hash: field_content_hash.and_then(Option::flatten),
19700 };
19701 Ok(Some(result))
19702 }
19703
19704 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19705 &self,
19706 s: &mut S::SerializeStruct,
19707 ) -> Result<(), S::Error> {
19708 use serde::ser::SerializeStruct;
19709 s.serialize_field("cursor", &self.cursor)?;
19710 if self.close {
19711 s.serialize_field("close", &self.close)?;
19712 }
19713 if let Some(val) = &self.content_hash {
19714 s.serialize_field("content_hash", val)?;
19715 }
19716 Ok(())
19717 }
19718}
19719
19720impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendArg {
19721 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19722 use serde::de::{MapAccess, Visitor};
19724 struct StructVisitor;
19725 impl<'de> Visitor<'de> for StructVisitor {
19726 type Value = UploadSessionAppendArg;
19727 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19728 f.write_str("a UploadSessionAppendArg struct")
19729 }
19730 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19731 UploadSessionAppendArg::internal_deserialize(map)
19732 }
19733 }
19734 deserializer.deserialize_struct("UploadSessionAppendArg", UPLOAD_SESSION_APPEND_ARG_FIELDS, StructVisitor)
19735 }
19736}
19737
19738impl ::serde::ser::Serialize for UploadSessionAppendArg {
19739 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19740 use serde::ser::SerializeStruct;
19742 let mut s = serializer.serialize_struct("UploadSessionAppendArg", 3)?;
19743 self.internal_serialize::<S>(&mut s)?;
19744 s.end()
19745 }
19746}
19747
19748#[derive(Debug, Clone, PartialEq, Eq)]
19749#[non_exhaustive] pub struct UploadSessionAppendBatchArg {
19751 pub entries: Vec<UploadSessionAppendBatchArgEntry>,
19753 pub content_hash: Option<Sha256HexHash>,
19758}
19759
19760impl UploadSessionAppendBatchArg {
19761 pub fn new(entries: Vec<UploadSessionAppendBatchArgEntry>) -> Self {
19762 UploadSessionAppendBatchArg {
19763 entries,
19764 content_hash: None,
19765 }
19766 }
19767
19768 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
19769 self.content_hash = Some(value);
19770 self
19771 }
19772}
19773
19774const UPLOAD_SESSION_APPEND_BATCH_ARG_FIELDS: &[&str] = &["entries",
19775 "content_hash"];
19776impl UploadSessionAppendBatchArg {
19777 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19778 map: V,
19779 ) -> Result<UploadSessionAppendBatchArg, V::Error> {
19780 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19781 }
19782
19783 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19784 mut map: V,
19785 optional: bool,
19786 ) -> Result<Option<UploadSessionAppendBatchArg>, V::Error> {
19787 let mut field_entries = None;
19788 let mut field_content_hash = None;
19789 let mut nothing = true;
19790 while let Some(key) = map.next_key::<&str>()? {
19791 nothing = false;
19792 match key {
19793 "entries" => {
19794 if field_entries.is_some() {
19795 return Err(::serde::de::Error::duplicate_field("entries"));
19796 }
19797 field_entries = Some(map.next_value()?);
19798 }
19799 "content_hash" => {
19800 if field_content_hash.is_some() {
19801 return Err(::serde::de::Error::duplicate_field("content_hash"));
19802 }
19803 field_content_hash = Some(map.next_value()?);
19804 }
19805 _ => {
19806 map.next_value::<::serde_json::Value>()?;
19808 }
19809 }
19810 }
19811 if optional && nothing {
19812 return Ok(None);
19813 }
19814 let result = UploadSessionAppendBatchArg {
19815 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
19816 content_hash: field_content_hash.and_then(Option::flatten),
19817 };
19818 Ok(Some(result))
19819 }
19820
19821 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19822 &self,
19823 s: &mut S::SerializeStruct,
19824 ) -> Result<(), S::Error> {
19825 use serde::ser::SerializeStruct;
19826 s.serialize_field("entries", &self.entries)?;
19827 if let Some(val) = &self.content_hash {
19828 s.serialize_field("content_hash", val)?;
19829 }
19830 Ok(())
19831 }
19832}
19833
19834impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchArg {
19835 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19836 use serde::de::{MapAccess, Visitor};
19838 struct StructVisitor;
19839 impl<'de> Visitor<'de> for StructVisitor {
19840 type Value = UploadSessionAppendBatchArg;
19841 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19842 f.write_str("a UploadSessionAppendBatchArg struct")
19843 }
19844 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19845 UploadSessionAppendBatchArg::internal_deserialize(map)
19846 }
19847 }
19848 deserializer.deserialize_struct("UploadSessionAppendBatchArg", UPLOAD_SESSION_APPEND_BATCH_ARG_FIELDS, StructVisitor)
19849 }
19850}
19851
19852impl ::serde::ser::Serialize for UploadSessionAppendBatchArg {
19853 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19854 use serde::ser::SerializeStruct;
19856 let mut s = serializer.serialize_struct("UploadSessionAppendBatchArg", 2)?;
19857 self.internal_serialize::<S>(&mut s)?;
19858 s.end()
19859 }
19860}
19861
19862#[derive(Debug, Clone, PartialEq, Eq)]
19863#[non_exhaustive] pub struct UploadSessionAppendBatchArgEntry {
19865 pub cursor: UploadSessionCursor,
19867 pub length: u64,
19870 pub close: bool,
19874}
19875
19876impl UploadSessionAppendBatchArgEntry {
19877 pub fn new(cursor: UploadSessionCursor, length: u64) -> Self {
19878 UploadSessionAppendBatchArgEntry {
19879 cursor,
19880 length,
19881 close: false,
19882 }
19883 }
19884
19885 pub fn with_close(mut self, value: bool) -> Self {
19886 self.close = value;
19887 self
19888 }
19889}
19890
19891const UPLOAD_SESSION_APPEND_BATCH_ARG_ENTRY_FIELDS: &[&str] = &["cursor",
19892 "length",
19893 "close"];
19894impl UploadSessionAppendBatchArgEntry {
19895 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19896 map: V,
19897 ) -> Result<UploadSessionAppendBatchArgEntry, V::Error> {
19898 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19899 }
19900
19901 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19902 mut map: V,
19903 optional: bool,
19904 ) -> Result<Option<UploadSessionAppendBatchArgEntry>, V::Error> {
19905 let mut field_cursor = None;
19906 let mut field_length = None;
19907 let mut field_close = None;
19908 let mut nothing = true;
19909 while let Some(key) = map.next_key::<&str>()? {
19910 nothing = false;
19911 match key {
19912 "cursor" => {
19913 if field_cursor.is_some() {
19914 return Err(::serde::de::Error::duplicate_field("cursor"));
19915 }
19916 field_cursor = Some(map.next_value()?);
19917 }
19918 "length" => {
19919 if field_length.is_some() {
19920 return Err(::serde::de::Error::duplicate_field("length"));
19921 }
19922 field_length = Some(map.next_value()?);
19923 }
19924 "close" => {
19925 if field_close.is_some() {
19926 return Err(::serde::de::Error::duplicate_field("close"));
19927 }
19928 field_close = Some(map.next_value()?);
19929 }
19930 _ => {
19931 map.next_value::<::serde_json::Value>()?;
19933 }
19934 }
19935 }
19936 if optional && nothing {
19937 return Ok(None);
19938 }
19939 let result = UploadSessionAppendBatchArgEntry {
19940 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
19941 length: field_length.ok_or_else(|| ::serde::de::Error::missing_field("length"))?,
19942 close: field_close.unwrap_or(false),
19943 };
19944 Ok(Some(result))
19945 }
19946
19947 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19948 &self,
19949 s: &mut S::SerializeStruct,
19950 ) -> Result<(), S::Error> {
19951 use serde::ser::SerializeStruct;
19952 s.serialize_field("cursor", &self.cursor)?;
19953 s.serialize_field("length", &self.length)?;
19954 if self.close {
19955 s.serialize_field("close", &self.close)?;
19956 }
19957 Ok(())
19958 }
19959}
19960
19961impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchArgEntry {
19962 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19963 use serde::de::{MapAccess, Visitor};
19965 struct StructVisitor;
19966 impl<'de> Visitor<'de> for StructVisitor {
19967 type Value = UploadSessionAppendBatchArgEntry;
19968 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19969 f.write_str("a UploadSessionAppendBatchArgEntry struct")
19970 }
19971 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19972 UploadSessionAppendBatchArgEntry::internal_deserialize(map)
19973 }
19974 }
19975 deserializer.deserialize_struct("UploadSessionAppendBatchArgEntry", UPLOAD_SESSION_APPEND_BATCH_ARG_ENTRY_FIELDS, StructVisitor)
19976 }
19977}
19978
19979impl ::serde::ser::Serialize for UploadSessionAppendBatchArgEntry {
19980 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19981 use serde::ser::SerializeStruct;
19983 let mut s = serializer.serialize_struct("UploadSessionAppendBatchArgEntry", 3)?;
19984 self.internal_serialize::<S>(&mut s)?;
19985 s.end()
19986 }
19987}
19988
19989#[derive(Debug, Clone, PartialEq, Eq)]
19990#[non_exhaustive] pub enum UploadSessionAppendBatchEntryError {
19992 NotFound,
19994 IncorrectOffset(UploadSessionOffsetError),
19998 Closed,
20001 TooLarge,
20004 ConcurrentSessionInvalidOffset,
20006 ConcurrentSessionInvalidDataSize,
20009 Other,
20012}
20013
20014impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchEntryError {
20015 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20016 use serde::de::{self, MapAccess, Visitor};
20018 struct EnumVisitor;
20019 impl<'de> Visitor<'de> for EnumVisitor {
20020 type Value = UploadSessionAppendBatchEntryError;
20021 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20022 f.write_str("a UploadSessionAppendBatchEntryError structure")
20023 }
20024 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20025 let tag: &str = match map.next_key()? {
20026 Some(".tag") => map.next_value()?,
20027 _ => return Err(de::Error::missing_field(".tag"))
20028 };
20029 let value = match tag {
20030 "not_found" => UploadSessionAppendBatchEntryError::NotFound,
20031 "incorrect_offset" => UploadSessionAppendBatchEntryError::IncorrectOffset(UploadSessionOffsetError::internal_deserialize(&mut map)?),
20032 "closed" => UploadSessionAppendBatchEntryError::Closed,
20033 "too_large" => UploadSessionAppendBatchEntryError::TooLarge,
20034 "concurrent_session_invalid_offset" => UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidOffset,
20035 "concurrent_session_invalid_data_size" => UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidDataSize,
20036 _ => UploadSessionAppendBatchEntryError::Other,
20037 };
20038 crate::eat_json_fields(&mut map)?;
20039 Ok(value)
20040 }
20041 }
20042 const VARIANTS: &[&str] = &["not_found",
20043 "incorrect_offset",
20044 "closed",
20045 "too_large",
20046 "concurrent_session_invalid_offset",
20047 "concurrent_session_invalid_data_size",
20048 "other"];
20049 deserializer.deserialize_struct("UploadSessionAppendBatchEntryError", VARIANTS, EnumVisitor)
20050 }
20051}
20052
20053impl ::serde::ser::Serialize for UploadSessionAppendBatchEntryError {
20054 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20055 use serde::ser::SerializeStruct;
20057 match self {
20058 UploadSessionAppendBatchEntryError::NotFound => {
20059 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20061 s.serialize_field(".tag", "not_found")?;
20062 s.end()
20063 }
20064 UploadSessionAppendBatchEntryError::IncorrectOffset(x) => {
20065 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 2)?;
20067 s.serialize_field(".tag", "incorrect_offset")?;
20068 x.internal_serialize::<S>(&mut s)?;
20069 s.end()
20070 }
20071 UploadSessionAppendBatchEntryError::Closed => {
20072 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20074 s.serialize_field(".tag", "closed")?;
20075 s.end()
20076 }
20077 UploadSessionAppendBatchEntryError::TooLarge => {
20078 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20080 s.serialize_field(".tag", "too_large")?;
20081 s.end()
20082 }
20083 UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidOffset => {
20084 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20086 s.serialize_field(".tag", "concurrent_session_invalid_offset")?;
20087 s.end()
20088 }
20089 UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidDataSize => {
20090 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20092 s.serialize_field(".tag", "concurrent_session_invalid_data_size")?;
20093 s.end()
20094 }
20095 UploadSessionAppendBatchEntryError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
20096 }
20097 }
20098}
20099
20100impl ::std::error::Error for UploadSessionAppendBatchEntryError {
20101}
20102
20103impl ::std::fmt::Display for UploadSessionAppendBatchEntryError {
20104 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20105 match self {
20106 UploadSessionAppendBatchEntryError::NotFound => f.write_str("The upload session ID was not found or has expired. Upload sessions are valid for 7 days."),
20107 UploadSessionAppendBatchEntryError::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),
20108 UploadSessionAppendBatchEntryError::Closed => f.write_str("You are attempting to append data to an upload session that has already been closed (i.e. committed)."),
20109 UploadSessionAppendBatchEntryError::TooLarge => f.write_str("You can not append to the upload session because the size of a file should not exceed the max file size limit (i.e. 2^41 - 2^22 or 2,199,019,061,248 bytes)."),
20110 UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidOffset => f.write_str("For concurrent upload sessions, offset needs to be multiple of 2^22 (4,194,304) bytes."),
20111 UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidDataSize => f.write_str("For concurrent upload sessions, only chunks with size multiple of 2^22 (4,194,304) bytes can be uploaded."),
20112 _ => write!(f, "{:?}", *self),
20113 }
20114 }
20115}
20116
20117#[derive(Debug, Clone, PartialEq, Eq)]
20118#[non_exhaustive] pub enum UploadSessionAppendBatchError {
20120 PayloadTooLarge,
20122 ContentHashMismatch,
20125 LengthMismatch,
20128 Other,
20131}
20132
20133impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchError {
20134 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20135 use serde::de::{self, MapAccess, Visitor};
20137 struct EnumVisitor;
20138 impl<'de> Visitor<'de> for EnumVisitor {
20139 type Value = UploadSessionAppendBatchError;
20140 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20141 f.write_str("a UploadSessionAppendBatchError structure")
20142 }
20143 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20144 let tag: &str = match map.next_key()? {
20145 Some(".tag") => map.next_value()?,
20146 _ => return Err(de::Error::missing_field(".tag"))
20147 };
20148 let value = match tag {
20149 "payload_too_large" => UploadSessionAppendBatchError::PayloadTooLarge,
20150 "content_hash_mismatch" => UploadSessionAppendBatchError::ContentHashMismatch,
20151 "length_mismatch" => UploadSessionAppendBatchError::LengthMismatch,
20152 _ => UploadSessionAppendBatchError::Other,
20153 };
20154 crate::eat_json_fields(&mut map)?;
20155 Ok(value)
20156 }
20157 }
20158 const VARIANTS: &[&str] = &["payload_too_large",
20159 "content_hash_mismatch",
20160 "length_mismatch",
20161 "other"];
20162 deserializer.deserialize_struct("UploadSessionAppendBatchError", VARIANTS, EnumVisitor)
20163 }
20164}
20165
20166impl ::serde::ser::Serialize for UploadSessionAppendBatchError {
20167 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20168 use serde::ser::SerializeStruct;
20170 match self {
20171 UploadSessionAppendBatchError::PayloadTooLarge => {
20172 let mut s = serializer.serialize_struct("UploadSessionAppendBatchError", 1)?;
20174 s.serialize_field(".tag", "payload_too_large")?;
20175 s.end()
20176 }
20177 UploadSessionAppendBatchError::ContentHashMismatch => {
20178 let mut s = serializer.serialize_struct("UploadSessionAppendBatchError", 1)?;
20180 s.serialize_field(".tag", "content_hash_mismatch")?;
20181 s.end()
20182 }
20183 UploadSessionAppendBatchError::LengthMismatch => {
20184 let mut s = serializer.serialize_struct("UploadSessionAppendBatchError", 1)?;
20186 s.serialize_field(".tag", "length_mismatch")?;
20187 s.end()
20188 }
20189 UploadSessionAppendBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
20190 }
20191 }
20192}
20193
20194impl ::std::error::Error for UploadSessionAppendBatchError {
20195}
20196
20197impl ::std::fmt::Display for UploadSessionAppendBatchError {
20198 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20199 match self {
20200 UploadSessionAppendBatchError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
20201 UploadSessionAppendBatchError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
20202 UploadSessionAppendBatchError::LengthMismatch => f.write_str("The total length of the content received by the Dropbox server in this call does not match the total of the provided lengths in the batch arguments."),
20203 _ => write!(f, "{:?}", *self),
20204 }
20205 }
20206}
20207
20208#[derive(Debug, Clone, PartialEq, Eq)]
20209#[non_exhaustive] pub struct UploadSessionAppendBatchResult {
20211 pub entries: Vec<UploadSessionAppendBatchResultEntry>,
20215}
20216
20217impl UploadSessionAppendBatchResult {
20218 pub fn new(entries: Vec<UploadSessionAppendBatchResultEntry>) -> Self {
20219 UploadSessionAppendBatchResult {
20220 entries,
20221 }
20222 }
20223}
20224
20225const UPLOAD_SESSION_APPEND_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
20226impl UploadSessionAppendBatchResult {
20227 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20228 map: V,
20229 ) -> Result<UploadSessionAppendBatchResult, V::Error> {
20230 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20231 }
20232
20233 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20234 mut map: V,
20235 optional: bool,
20236 ) -> Result<Option<UploadSessionAppendBatchResult>, V::Error> {
20237 let mut field_entries = None;
20238 let mut nothing = true;
20239 while let Some(key) = map.next_key::<&str>()? {
20240 nothing = false;
20241 match key {
20242 "entries" => {
20243 if field_entries.is_some() {
20244 return Err(::serde::de::Error::duplicate_field("entries"));
20245 }
20246 field_entries = Some(map.next_value()?);
20247 }
20248 _ => {
20249 map.next_value::<::serde_json::Value>()?;
20251 }
20252 }
20253 }
20254 if optional && nothing {
20255 return Ok(None);
20256 }
20257 let result = UploadSessionAppendBatchResult {
20258 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
20259 };
20260 Ok(Some(result))
20261 }
20262
20263 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20264 &self,
20265 s: &mut S::SerializeStruct,
20266 ) -> Result<(), S::Error> {
20267 use serde::ser::SerializeStruct;
20268 s.serialize_field("entries", &self.entries)?;
20269 Ok(())
20270 }
20271}
20272
20273impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchResult {
20274 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20275 use serde::de::{MapAccess, Visitor};
20277 struct StructVisitor;
20278 impl<'de> Visitor<'de> for StructVisitor {
20279 type Value = UploadSessionAppendBatchResult;
20280 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20281 f.write_str("a UploadSessionAppendBatchResult struct")
20282 }
20283 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20284 UploadSessionAppendBatchResult::internal_deserialize(map)
20285 }
20286 }
20287 deserializer.deserialize_struct("UploadSessionAppendBatchResult", UPLOAD_SESSION_APPEND_BATCH_RESULT_FIELDS, StructVisitor)
20288 }
20289}
20290
20291impl ::serde::ser::Serialize for UploadSessionAppendBatchResult {
20292 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20293 use serde::ser::SerializeStruct;
20295 let mut s = serializer.serialize_struct("UploadSessionAppendBatchResult", 1)?;
20296 self.internal_serialize::<S>(&mut s)?;
20297 s.end()
20298 }
20299}
20300
20301#[derive(Debug, Clone, PartialEq, Eq)]
20302pub enum UploadSessionAppendBatchResultEntry {
20303 Success,
20304 Failure(UploadSessionAppendBatchEntryError),
20305}
20306
20307impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchResultEntry {
20308 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20309 use serde::de::{self, MapAccess, Visitor};
20311 struct EnumVisitor;
20312 impl<'de> Visitor<'de> for EnumVisitor {
20313 type Value = UploadSessionAppendBatchResultEntry;
20314 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20315 f.write_str("a UploadSessionAppendBatchResultEntry structure")
20316 }
20317 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20318 let tag: &str = match map.next_key()? {
20319 Some(".tag") => map.next_value()?,
20320 _ => return Err(de::Error::missing_field(".tag"))
20321 };
20322 let value = match tag {
20323 "success" => UploadSessionAppendBatchResultEntry::Success,
20324 "failure" => {
20325 match map.next_key()? {
20326 Some("failure") => UploadSessionAppendBatchResultEntry::Failure(map.next_value()?),
20327 None => return Err(de::Error::missing_field("failure")),
20328 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
20329 }
20330 }
20331 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
20332 };
20333 crate::eat_json_fields(&mut map)?;
20334 Ok(value)
20335 }
20336 }
20337 const VARIANTS: &[&str] = &["success",
20338 "failure"];
20339 deserializer.deserialize_struct("UploadSessionAppendBatchResultEntry", VARIANTS, EnumVisitor)
20340 }
20341}
20342
20343impl ::serde::ser::Serialize for UploadSessionAppendBatchResultEntry {
20344 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20345 use serde::ser::SerializeStruct;
20347 match self {
20348 UploadSessionAppendBatchResultEntry::Success => {
20349 let mut s = serializer.serialize_struct("UploadSessionAppendBatchResultEntry", 1)?;
20351 s.serialize_field(".tag", "success")?;
20352 s.end()
20353 }
20354 UploadSessionAppendBatchResultEntry::Failure(x) => {
20355 let mut s = serializer.serialize_struct("UploadSessionAppendBatchResultEntry", 2)?;
20357 s.serialize_field(".tag", "failure")?;
20358 s.serialize_field("failure", x)?;
20359 s.end()
20360 }
20361 }
20362 }
20363}
20364
20365#[derive(Debug, Clone, PartialEq, Eq)]
20366#[non_exhaustive] pub enum UploadSessionAppendError {
20368 NotFound,
20370 IncorrectOffset(UploadSessionOffsetError),
20374 Closed,
20377 TooLarge,
20380 ConcurrentSessionInvalidOffset,
20382 ConcurrentSessionInvalidDataSize,
20385 PayloadTooLarge,
20387 ContentHashMismatch,
20390 Other,
20393}
20394
20395impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendError {
20396 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20397 use serde::de::{self, MapAccess, Visitor};
20399 struct EnumVisitor;
20400 impl<'de> Visitor<'de> for EnumVisitor {
20401 type Value = UploadSessionAppendError;
20402 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20403 f.write_str("a UploadSessionAppendError structure")
20404 }
20405 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20406 let tag: &str = match map.next_key()? {
20407 Some(".tag") => map.next_value()?,
20408 _ => return Err(de::Error::missing_field(".tag"))
20409 };
20410 let value = match tag {
20411 "not_found" => UploadSessionAppendError::NotFound,
20412 "incorrect_offset" => UploadSessionAppendError::IncorrectOffset(UploadSessionOffsetError::internal_deserialize(&mut map)?),
20413 "closed" => UploadSessionAppendError::Closed,
20414 "too_large" => UploadSessionAppendError::TooLarge,
20415 "concurrent_session_invalid_offset" => UploadSessionAppendError::ConcurrentSessionInvalidOffset,
20416 "concurrent_session_invalid_data_size" => UploadSessionAppendError::ConcurrentSessionInvalidDataSize,
20417 "payload_too_large" => UploadSessionAppendError::PayloadTooLarge,
20418 "content_hash_mismatch" => UploadSessionAppendError::ContentHashMismatch,
20419 _ => UploadSessionAppendError::Other,
20420 };
20421 crate::eat_json_fields(&mut map)?;
20422 Ok(value)
20423 }
20424 }
20425 const VARIANTS: &[&str] = &["not_found",
20426 "incorrect_offset",
20427 "closed",
20428 "too_large",
20429 "concurrent_session_invalid_offset",
20430 "concurrent_session_invalid_data_size",
20431 "payload_too_large",
20432 "content_hash_mismatch",
20433 "other"];
20434 deserializer.deserialize_struct("UploadSessionAppendError", VARIANTS, EnumVisitor)
20435 }
20436}
20437
20438impl ::serde::ser::Serialize for UploadSessionAppendError {
20439 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20440 use serde::ser::SerializeStruct;
20442 match self {
20443 UploadSessionAppendError::NotFound => {
20444 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20446 s.serialize_field(".tag", "not_found")?;
20447 s.end()
20448 }
20449 UploadSessionAppendError::IncorrectOffset(x) => {
20450 let mut s = serializer.serialize_struct("UploadSessionAppendError", 2)?;
20452 s.serialize_field(".tag", "incorrect_offset")?;
20453 x.internal_serialize::<S>(&mut s)?;
20454 s.end()
20455 }
20456 UploadSessionAppendError::Closed => {
20457 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20459 s.serialize_field(".tag", "closed")?;
20460 s.end()
20461 }
20462 UploadSessionAppendError::TooLarge => {
20463 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20465 s.serialize_field(".tag", "too_large")?;
20466 s.end()
20467 }
20468 UploadSessionAppendError::ConcurrentSessionInvalidOffset => {
20469 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20471 s.serialize_field(".tag", "concurrent_session_invalid_offset")?;
20472 s.end()
20473 }
20474 UploadSessionAppendError::ConcurrentSessionInvalidDataSize => {
20475 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20477 s.serialize_field(".tag", "concurrent_session_invalid_data_size")?;
20478 s.end()
20479 }
20480 UploadSessionAppendError::PayloadTooLarge => {
20481 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20483 s.serialize_field(".tag", "payload_too_large")?;
20484 s.end()
20485 }
20486 UploadSessionAppendError::ContentHashMismatch => {
20487 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20489 s.serialize_field(".tag", "content_hash_mismatch")?;
20490 s.end()
20491 }
20492 UploadSessionAppendError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
20493 }
20494 }
20495}
20496
20497impl ::std::error::Error for UploadSessionAppendError {
20498}
20499
20500impl ::std::fmt::Display for UploadSessionAppendError {
20501 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20502 match self {
20503 UploadSessionAppendError::NotFound => f.write_str("The upload session ID was not found or has expired. Upload sessions are valid for 7 days."),
20504 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),
20505 UploadSessionAppendError::Closed => f.write_str("You are attempting to append data to an upload session that has already been closed (i.e. committed)."),
20506 UploadSessionAppendError::TooLarge => f.write_str("You can not append to the upload session because the size of a file should not exceed the max file size limit (i.e. 2^41 - 2^22 or 2,199,019,061,248 bytes)."),
20507 UploadSessionAppendError::ConcurrentSessionInvalidOffset => f.write_str("For concurrent upload sessions, offset needs to be multiple of 2^22 (4,194,304) bytes."),
20508 UploadSessionAppendError::ConcurrentSessionInvalidDataSize => f.write_str("For concurrent upload sessions, only chunks with size multiple of 2^22 (4,194,304) bytes can be uploaded."),
20509 UploadSessionAppendError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
20510 UploadSessionAppendError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
20511 _ => write!(f, "{:?}", *self),
20512 }
20513 }
20514}
20515
20516#[derive(Debug, Clone, PartialEq, Eq)]
20517#[non_exhaustive] pub struct UploadSessionCursor {
20519 pub session_id: String,
20522 pub offset: u64,
20525}
20526
20527impl UploadSessionCursor {
20528 pub fn new(session_id: String, offset: u64) -> Self {
20529 UploadSessionCursor {
20530 session_id,
20531 offset,
20532 }
20533 }
20534}
20535
20536const UPLOAD_SESSION_CURSOR_FIELDS: &[&str] = &["session_id",
20537 "offset"];
20538impl UploadSessionCursor {
20539 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20540 map: V,
20541 ) -> Result<UploadSessionCursor, V::Error> {
20542 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20543 }
20544
20545 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20546 mut map: V,
20547 optional: bool,
20548 ) -> Result<Option<UploadSessionCursor>, V::Error> {
20549 let mut field_session_id = None;
20550 let mut field_offset = None;
20551 let mut nothing = true;
20552 while let Some(key) = map.next_key::<&str>()? {
20553 nothing = false;
20554 match key {
20555 "session_id" => {
20556 if field_session_id.is_some() {
20557 return Err(::serde::de::Error::duplicate_field("session_id"));
20558 }
20559 field_session_id = Some(map.next_value()?);
20560 }
20561 "offset" => {
20562 if field_offset.is_some() {
20563 return Err(::serde::de::Error::duplicate_field("offset"));
20564 }
20565 field_offset = Some(map.next_value()?);
20566 }
20567 _ => {
20568 map.next_value::<::serde_json::Value>()?;
20570 }
20571 }
20572 }
20573 if optional && nothing {
20574 return Ok(None);
20575 }
20576 let result = UploadSessionCursor {
20577 session_id: field_session_id.ok_or_else(|| ::serde::de::Error::missing_field("session_id"))?,
20578 offset: field_offset.ok_or_else(|| ::serde::de::Error::missing_field("offset"))?,
20579 };
20580 Ok(Some(result))
20581 }
20582
20583 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20584 &self,
20585 s: &mut S::SerializeStruct,
20586 ) -> Result<(), S::Error> {
20587 use serde::ser::SerializeStruct;
20588 s.serialize_field("session_id", &self.session_id)?;
20589 s.serialize_field("offset", &self.offset)?;
20590 Ok(())
20591 }
20592}
20593
20594impl<'de> ::serde::de::Deserialize<'de> for UploadSessionCursor {
20595 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20596 use serde::de::{MapAccess, Visitor};
20598 struct StructVisitor;
20599 impl<'de> Visitor<'de> for StructVisitor {
20600 type Value = UploadSessionCursor;
20601 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20602 f.write_str("a UploadSessionCursor struct")
20603 }
20604 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20605 UploadSessionCursor::internal_deserialize(map)
20606 }
20607 }
20608 deserializer.deserialize_struct("UploadSessionCursor", UPLOAD_SESSION_CURSOR_FIELDS, StructVisitor)
20609 }
20610}
20611
20612impl ::serde::ser::Serialize for UploadSessionCursor {
20613 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20614 use serde::ser::SerializeStruct;
20616 let mut s = serializer.serialize_struct("UploadSessionCursor", 2)?;
20617 self.internal_serialize::<S>(&mut s)?;
20618 s.end()
20619 }
20620}
20621
20622#[derive(Debug, Clone, PartialEq, Eq)]
20623#[non_exhaustive] pub struct UploadSessionFinishArg {
20625 pub cursor: UploadSessionCursor,
20627 pub commit: CommitInfo,
20629 pub content_hash: Option<Sha256HexHash>,
20633}
20634
20635impl UploadSessionFinishArg {
20636 pub fn new(cursor: UploadSessionCursor, commit: CommitInfo) -> Self {
20637 UploadSessionFinishArg {
20638 cursor,
20639 commit,
20640 content_hash: None,
20641 }
20642 }
20643
20644 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
20645 self.content_hash = Some(value);
20646 self
20647 }
20648}
20649
20650const UPLOAD_SESSION_FINISH_ARG_FIELDS: &[&str] = &["cursor",
20651 "commit",
20652 "content_hash"];
20653impl UploadSessionFinishArg {
20654 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20655 map: V,
20656 ) -> Result<UploadSessionFinishArg, V::Error> {
20657 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20658 }
20659
20660 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20661 mut map: V,
20662 optional: bool,
20663 ) -> Result<Option<UploadSessionFinishArg>, V::Error> {
20664 let mut field_cursor = None;
20665 let mut field_commit = None;
20666 let mut field_content_hash = None;
20667 let mut nothing = true;
20668 while let Some(key) = map.next_key::<&str>()? {
20669 nothing = false;
20670 match key {
20671 "cursor" => {
20672 if field_cursor.is_some() {
20673 return Err(::serde::de::Error::duplicate_field("cursor"));
20674 }
20675 field_cursor = Some(map.next_value()?);
20676 }
20677 "commit" => {
20678 if field_commit.is_some() {
20679 return Err(::serde::de::Error::duplicate_field("commit"));
20680 }
20681 field_commit = Some(map.next_value()?);
20682 }
20683 "content_hash" => {
20684 if field_content_hash.is_some() {
20685 return Err(::serde::de::Error::duplicate_field("content_hash"));
20686 }
20687 field_content_hash = Some(map.next_value()?);
20688 }
20689 _ => {
20690 map.next_value::<::serde_json::Value>()?;
20692 }
20693 }
20694 }
20695 if optional && nothing {
20696 return Ok(None);
20697 }
20698 let result = UploadSessionFinishArg {
20699 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
20700 commit: field_commit.ok_or_else(|| ::serde::de::Error::missing_field("commit"))?,
20701 content_hash: field_content_hash.and_then(Option::flatten),
20702 };
20703 Ok(Some(result))
20704 }
20705
20706 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20707 &self,
20708 s: &mut S::SerializeStruct,
20709 ) -> Result<(), S::Error> {
20710 use serde::ser::SerializeStruct;
20711 s.serialize_field("cursor", &self.cursor)?;
20712 s.serialize_field("commit", &self.commit)?;
20713 if let Some(val) = &self.content_hash {
20714 s.serialize_field("content_hash", val)?;
20715 }
20716 Ok(())
20717 }
20718}
20719
20720impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishArg {
20721 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20722 use serde::de::{MapAccess, Visitor};
20724 struct StructVisitor;
20725 impl<'de> Visitor<'de> for StructVisitor {
20726 type Value = UploadSessionFinishArg;
20727 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20728 f.write_str("a UploadSessionFinishArg struct")
20729 }
20730 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20731 UploadSessionFinishArg::internal_deserialize(map)
20732 }
20733 }
20734 deserializer.deserialize_struct("UploadSessionFinishArg", UPLOAD_SESSION_FINISH_ARG_FIELDS, StructVisitor)
20735 }
20736}
20737
20738impl ::serde::ser::Serialize for UploadSessionFinishArg {
20739 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20740 use serde::ser::SerializeStruct;
20742 let mut s = serializer.serialize_struct("UploadSessionFinishArg", 3)?;
20743 self.internal_serialize::<S>(&mut s)?;
20744 s.end()
20745 }
20746}
20747
20748#[derive(Debug, Clone, PartialEq, Eq)]
20749#[non_exhaustive] pub struct UploadSessionFinishBatchArg {
20751 pub entries: Vec<UploadSessionFinishArg>,
20753}
20754
20755impl UploadSessionFinishBatchArg {
20756 pub fn new(entries: Vec<UploadSessionFinishArg>) -> Self {
20757 UploadSessionFinishBatchArg {
20758 entries,
20759 }
20760 }
20761}
20762
20763const UPLOAD_SESSION_FINISH_BATCH_ARG_FIELDS: &[&str] = &["entries"];
20764impl UploadSessionFinishBatchArg {
20765 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20766 map: V,
20767 ) -> Result<UploadSessionFinishBatchArg, V::Error> {
20768 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20769 }
20770
20771 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20772 mut map: V,
20773 optional: bool,
20774 ) -> Result<Option<UploadSessionFinishBatchArg>, V::Error> {
20775 let mut field_entries = None;
20776 let mut nothing = true;
20777 while let Some(key) = map.next_key::<&str>()? {
20778 nothing = false;
20779 match key {
20780 "entries" => {
20781 if field_entries.is_some() {
20782 return Err(::serde::de::Error::duplicate_field("entries"));
20783 }
20784 field_entries = Some(map.next_value()?);
20785 }
20786 _ => {
20787 map.next_value::<::serde_json::Value>()?;
20789 }
20790 }
20791 }
20792 if optional && nothing {
20793 return Ok(None);
20794 }
20795 let result = UploadSessionFinishBatchArg {
20796 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
20797 };
20798 Ok(Some(result))
20799 }
20800
20801 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20802 &self,
20803 s: &mut S::SerializeStruct,
20804 ) -> Result<(), S::Error> {
20805 use serde::ser::SerializeStruct;
20806 s.serialize_field("entries", &self.entries)?;
20807 Ok(())
20808 }
20809}
20810
20811impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchArg {
20812 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20813 use serde::de::{MapAccess, Visitor};
20815 struct StructVisitor;
20816 impl<'de> Visitor<'de> for StructVisitor {
20817 type Value = UploadSessionFinishBatchArg;
20818 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20819 f.write_str("a UploadSessionFinishBatchArg struct")
20820 }
20821 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20822 UploadSessionFinishBatchArg::internal_deserialize(map)
20823 }
20824 }
20825 deserializer.deserialize_struct("UploadSessionFinishBatchArg", UPLOAD_SESSION_FINISH_BATCH_ARG_FIELDS, StructVisitor)
20826 }
20827}
20828
20829impl ::serde::ser::Serialize for UploadSessionFinishBatchArg {
20830 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20831 use serde::ser::SerializeStruct;
20833 let mut s = serializer.serialize_struct("UploadSessionFinishBatchArg", 1)?;
20834 self.internal_serialize::<S>(&mut s)?;
20835 s.end()
20836 }
20837}
20838
20839#[derive(Debug, Clone, PartialEq)]
20840pub enum UploadSessionFinishBatchJobStatus {
20841 InProgress,
20843 Complete(UploadSessionFinishBatchResult),
20846}
20847
20848impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchJobStatus {
20849 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20850 use serde::de::{self, MapAccess, Visitor};
20852 struct EnumVisitor;
20853 impl<'de> Visitor<'de> for EnumVisitor {
20854 type Value = UploadSessionFinishBatchJobStatus;
20855 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20856 f.write_str("a UploadSessionFinishBatchJobStatus structure")
20857 }
20858 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20859 let tag: &str = match map.next_key()? {
20860 Some(".tag") => map.next_value()?,
20861 _ => return Err(de::Error::missing_field(".tag"))
20862 };
20863 let value = match tag {
20864 "in_progress" => UploadSessionFinishBatchJobStatus::InProgress,
20865 "complete" => UploadSessionFinishBatchJobStatus::Complete(UploadSessionFinishBatchResult::internal_deserialize(&mut map)?),
20866 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
20867 };
20868 crate::eat_json_fields(&mut map)?;
20869 Ok(value)
20870 }
20871 }
20872 const VARIANTS: &[&str] = &["in_progress",
20873 "complete"];
20874 deserializer.deserialize_struct("UploadSessionFinishBatchJobStatus", VARIANTS, EnumVisitor)
20875 }
20876}
20877
20878impl ::serde::ser::Serialize for UploadSessionFinishBatchJobStatus {
20879 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20880 use serde::ser::SerializeStruct;
20882 match self {
20883 UploadSessionFinishBatchJobStatus::InProgress => {
20884 let mut s = serializer.serialize_struct("UploadSessionFinishBatchJobStatus", 1)?;
20886 s.serialize_field(".tag", "in_progress")?;
20887 s.end()
20888 }
20889 UploadSessionFinishBatchJobStatus::Complete(x) => {
20890 let mut s = serializer.serialize_struct("UploadSessionFinishBatchJobStatus", 2)?;
20892 s.serialize_field(".tag", "complete")?;
20893 x.internal_serialize::<S>(&mut s)?;
20894 s.end()
20895 }
20896 }
20897 }
20898}
20899
20900impl From<crate::types::dbx_async::PollResultBase> for UploadSessionFinishBatchJobStatus {
20902 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
20903 match parent {
20904 crate::types::dbx_async::PollResultBase::InProgress => UploadSessionFinishBatchJobStatus::InProgress,
20905 }
20906 }
20907}
20908#[derive(Debug, Clone, PartialEq)]
20911#[non_exhaustive] pub enum UploadSessionFinishBatchLaunch {
20913 AsyncJobId(crate::types::dbx_async::AsyncJobId),
20916 Complete(UploadSessionFinishBatchResult),
20917 Other,
20920}
20921
20922impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchLaunch {
20923 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20924 use serde::de::{self, MapAccess, Visitor};
20926 struct EnumVisitor;
20927 impl<'de> Visitor<'de> for EnumVisitor {
20928 type Value = UploadSessionFinishBatchLaunch;
20929 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20930 f.write_str("a UploadSessionFinishBatchLaunch structure")
20931 }
20932 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20933 let tag: &str = match map.next_key()? {
20934 Some(".tag") => map.next_value()?,
20935 _ => return Err(de::Error::missing_field(".tag"))
20936 };
20937 let value = match tag {
20938 "async_job_id" => {
20939 match map.next_key()? {
20940 Some("async_job_id") => UploadSessionFinishBatchLaunch::AsyncJobId(map.next_value()?),
20941 None => return Err(de::Error::missing_field("async_job_id")),
20942 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
20943 }
20944 }
20945 "complete" => UploadSessionFinishBatchLaunch::Complete(UploadSessionFinishBatchResult::internal_deserialize(&mut map)?),
20946 _ => UploadSessionFinishBatchLaunch::Other,
20947 };
20948 crate::eat_json_fields(&mut map)?;
20949 Ok(value)
20950 }
20951 }
20952 const VARIANTS: &[&str] = &["async_job_id",
20953 "complete",
20954 "other"];
20955 deserializer.deserialize_struct("UploadSessionFinishBatchLaunch", VARIANTS, EnumVisitor)
20956 }
20957}
20958
20959impl ::serde::ser::Serialize for UploadSessionFinishBatchLaunch {
20960 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20961 use serde::ser::SerializeStruct;
20963 match self {
20964 UploadSessionFinishBatchLaunch::AsyncJobId(x) => {
20965 let mut s = serializer.serialize_struct("UploadSessionFinishBatchLaunch", 2)?;
20967 s.serialize_field(".tag", "async_job_id")?;
20968 s.serialize_field("async_job_id", x)?;
20969 s.end()
20970 }
20971 UploadSessionFinishBatchLaunch::Complete(x) => {
20972 let mut s = serializer.serialize_struct("UploadSessionFinishBatchLaunch", 2)?;
20974 s.serialize_field(".tag", "complete")?;
20975 x.internal_serialize::<S>(&mut s)?;
20976 s.end()
20977 }
20978 UploadSessionFinishBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
20979 }
20980 }
20981}
20982
20983impl From<crate::types::dbx_async::LaunchResultBase> for UploadSessionFinishBatchLaunch {
20985 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
20986 match parent {
20987 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => UploadSessionFinishBatchLaunch::AsyncJobId(x),
20988 }
20989 }
20990}
20991#[derive(Debug, Clone, PartialEq)]
20992#[non_exhaustive] pub struct UploadSessionFinishBatchResult {
20994 pub entries: Vec<UploadSessionFinishBatchResultEntry>,
20998}
20999
21000impl UploadSessionFinishBatchResult {
21001 pub fn new(entries: Vec<UploadSessionFinishBatchResultEntry>) -> Self {
21002 UploadSessionFinishBatchResult {
21003 entries,
21004 }
21005 }
21006}
21007
21008const UPLOAD_SESSION_FINISH_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
21009impl UploadSessionFinishBatchResult {
21010 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21011 map: V,
21012 ) -> Result<UploadSessionFinishBatchResult, V::Error> {
21013 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21014 }
21015
21016 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21017 mut map: V,
21018 optional: bool,
21019 ) -> Result<Option<UploadSessionFinishBatchResult>, V::Error> {
21020 let mut field_entries = None;
21021 let mut nothing = true;
21022 while let Some(key) = map.next_key::<&str>()? {
21023 nothing = false;
21024 match key {
21025 "entries" => {
21026 if field_entries.is_some() {
21027 return Err(::serde::de::Error::duplicate_field("entries"));
21028 }
21029 field_entries = Some(map.next_value()?);
21030 }
21031 _ => {
21032 map.next_value::<::serde_json::Value>()?;
21034 }
21035 }
21036 }
21037 if optional && nothing {
21038 return Ok(None);
21039 }
21040 let result = UploadSessionFinishBatchResult {
21041 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
21042 };
21043 Ok(Some(result))
21044 }
21045
21046 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21047 &self,
21048 s: &mut S::SerializeStruct,
21049 ) -> Result<(), S::Error> {
21050 use serde::ser::SerializeStruct;
21051 s.serialize_field("entries", &self.entries)?;
21052 Ok(())
21053 }
21054}
21055
21056impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchResult {
21057 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21058 use serde::de::{MapAccess, Visitor};
21060 struct StructVisitor;
21061 impl<'de> Visitor<'de> for StructVisitor {
21062 type Value = UploadSessionFinishBatchResult;
21063 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21064 f.write_str("a UploadSessionFinishBatchResult struct")
21065 }
21066 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21067 UploadSessionFinishBatchResult::internal_deserialize(map)
21068 }
21069 }
21070 deserializer.deserialize_struct("UploadSessionFinishBatchResult", UPLOAD_SESSION_FINISH_BATCH_RESULT_FIELDS, StructVisitor)
21071 }
21072}
21073
21074impl ::serde::ser::Serialize for UploadSessionFinishBatchResult {
21075 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21076 use serde::ser::SerializeStruct;
21078 let mut s = serializer.serialize_struct("UploadSessionFinishBatchResult", 1)?;
21079 self.internal_serialize::<S>(&mut s)?;
21080 s.end()
21081 }
21082}
21083
21084#[derive(Debug, Clone, PartialEq)]
21085pub enum UploadSessionFinishBatchResultEntry {
21086 Success(FileMetadata),
21087 Failure(UploadSessionFinishError),
21088}
21089
21090impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchResultEntry {
21091 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21092 use serde::de::{self, MapAccess, Visitor};
21094 struct EnumVisitor;
21095 impl<'de> Visitor<'de> for EnumVisitor {
21096 type Value = UploadSessionFinishBatchResultEntry;
21097 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21098 f.write_str("a UploadSessionFinishBatchResultEntry structure")
21099 }
21100 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21101 let tag: &str = match map.next_key()? {
21102 Some(".tag") => map.next_value()?,
21103 _ => return Err(de::Error::missing_field(".tag"))
21104 };
21105 let value = match tag {
21106 "success" => UploadSessionFinishBatchResultEntry::Success(FileMetadata::internal_deserialize(&mut map)?),
21107 "failure" => {
21108 match map.next_key()? {
21109 Some("failure") => UploadSessionFinishBatchResultEntry::Failure(map.next_value()?),
21110 None => return Err(de::Error::missing_field("failure")),
21111 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21112 }
21113 }
21114 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
21115 };
21116 crate::eat_json_fields(&mut map)?;
21117 Ok(value)
21118 }
21119 }
21120 const VARIANTS: &[&str] = &["success",
21121 "failure"];
21122 deserializer.deserialize_struct("UploadSessionFinishBatchResultEntry", VARIANTS, EnumVisitor)
21123 }
21124}
21125
21126impl ::serde::ser::Serialize for UploadSessionFinishBatchResultEntry {
21127 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21128 use serde::ser::SerializeStruct;
21130 match self {
21131 UploadSessionFinishBatchResultEntry::Success(x) => {
21132 let mut s = serializer.serialize_struct("UploadSessionFinishBatchResultEntry", 20)?;
21134 s.serialize_field(".tag", "success")?;
21135 x.internal_serialize::<S>(&mut s)?;
21136 s.end()
21137 }
21138 UploadSessionFinishBatchResultEntry::Failure(x) => {
21139 let mut s = serializer.serialize_struct("UploadSessionFinishBatchResultEntry", 2)?;
21141 s.serialize_field(".tag", "failure")?;
21142 s.serialize_field("failure", x)?;
21143 s.end()
21144 }
21145 }
21146 }
21147}
21148
21149#[derive(Debug, Clone, PartialEq, Eq)]
21150#[non_exhaustive] pub enum UploadSessionFinishError {
21152 LookupFailed(UploadSessionLookupError),
21154 Path(WriteError),
21157 PropertiesError(crate::types::file_properties::InvalidPropertyGroupError),
21159 TooManySharedFolderTargets,
21162 TooManyWriteOperations,
21165 ConcurrentSessionDataNotAllowed,
21167 ConcurrentSessionNotClosed,
21169 ConcurrentSessionMissingData,
21171 PayloadTooLarge,
21173 ContentHashMismatch,
21176 EncryptionNotSupported,
21178 Other,
21181}
21182
21183impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishError {
21184 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21185 use serde::de::{self, MapAccess, Visitor};
21187 struct EnumVisitor;
21188 impl<'de> Visitor<'de> for EnumVisitor {
21189 type Value = UploadSessionFinishError;
21190 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21191 f.write_str("a UploadSessionFinishError structure")
21192 }
21193 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21194 let tag: &str = match map.next_key()? {
21195 Some(".tag") => map.next_value()?,
21196 _ => return Err(de::Error::missing_field(".tag"))
21197 };
21198 let value = match tag {
21199 "lookup_failed" => {
21200 match map.next_key()? {
21201 Some("lookup_failed") => UploadSessionFinishError::LookupFailed(map.next_value()?),
21202 None => return Err(de::Error::missing_field("lookup_failed")),
21203 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21204 }
21205 }
21206 "path" => {
21207 match map.next_key()? {
21208 Some("path") => UploadSessionFinishError::Path(map.next_value()?),
21209 None => return Err(de::Error::missing_field("path")),
21210 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21211 }
21212 }
21213 "properties_error" => {
21214 match map.next_key()? {
21215 Some("properties_error") => UploadSessionFinishError::PropertiesError(map.next_value()?),
21216 None => return Err(de::Error::missing_field("properties_error")),
21217 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21218 }
21219 }
21220 "too_many_shared_folder_targets" => UploadSessionFinishError::TooManySharedFolderTargets,
21221 "too_many_write_operations" => UploadSessionFinishError::TooManyWriteOperations,
21222 "concurrent_session_data_not_allowed" => UploadSessionFinishError::ConcurrentSessionDataNotAllowed,
21223 "concurrent_session_not_closed" => UploadSessionFinishError::ConcurrentSessionNotClosed,
21224 "concurrent_session_missing_data" => UploadSessionFinishError::ConcurrentSessionMissingData,
21225 "payload_too_large" => UploadSessionFinishError::PayloadTooLarge,
21226 "content_hash_mismatch" => UploadSessionFinishError::ContentHashMismatch,
21227 "encryption_not_supported" => UploadSessionFinishError::EncryptionNotSupported,
21228 _ => UploadSessionFinishError::Other,
21229 };
21230 crate::eat_json_fields(&mut map)?;
21231 Ok(value)
21232 }
21233 }
21234 const VARIANTS: &[&str] = &["lookup_failed",
21235 "path",
21236 "properties_error",
21237 "too_many_shared_folder_targets",
21238 "too_many_write_operations",
21239 "concurrent_session_data_not_allowed",
21240 "concurrent_session_not_closed",
21241 "concurrent_session_missing_data",
21242 "payload_too_large",
21243 "content_hash_mismatch",
21244 "encryption_not_supported",
21245 "other"];
21246 deserializer.deserialize_struct("UploadSessionFinishError", VARIANTS, EnumVisitor)
21247 }
21248}
21249
21250impl ::serde::ser::Serialize for UploadSessionFinishError {
21251 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21252 use serde::ser::SerializeStruct;
21254 match self {
21255 UploadSessionFinishError::LookupFailed(x) => {
21256 let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
21258 s.serialize_field(".tag", "lookup_failed")?;
21259 s.serialize_field("lookup_failed", x)?;
21260 s.end()
21261 }
21262 UploadSessionFinishError::Path(x) => {
21263 let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
21265 s.serialize_field(".tag", "path")?;
21266 s.serialize_field("path", x)?;
21267 s.end()
21268 }
21269 UploadSessionFinishError::PropertiesError(x) => {
21270 let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
21272 s.serialize_field(".tag", "properties_error")?;
21273 s.serialize_field("properties_error", x)?;
21274 s.end()
21275 }
21276 UploadSessionFinishError::TooManySharedFolderTargets => {
21277 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21279 s.serialize_field(".tag", "too_many_shared_folder_targets")?;
21280 s.end()
21281 }
21282 UploadSessionFinishError::TooManyWriteOperations => {
21283 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21285 s.serialize_field(".tag", "too_many_write_operations")?;
21286 s.end()
21287 }
21288 UploadSessionFinishError::ConcurrentSessionDataNotAllowed => {
21289 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21291 s.serialize_field(".tag", "concurrent_session_data_not_allowed")?;
21292 s.end()
21293 }
21294 UploadSessionFinishError::ConcurrentSessionNotClosed => {
21295 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21297 s.serialize_field(".tag", "concurrent_session_not_closed")?;
21298 s.end()
21299 }
21300 UploadSessionFinishError::ConcurrentSessionMissingData => {
21301 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21303 s.serialize_field(".tag", "concurrent_session_missing_data")?;
21304 s.end()
21305 }
21306 UploadSessionFinishError::PayloadTooLarge => {
21307 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21309 s.serialize_field(".tag", "payload_too_large")?;
21310 s.end()
21311 }
21312 UploadSessionFinishError::ContentHashMismatch => {
21313 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21315 s.serialize_field(".tag", "content_hash_mismatch")?;
21316 s.end()
21317 }
21318 UploadSessionFinishError::EncryptionNotSupported => {
21319 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21321 s.serialize_field(".tag", "encryption_not_supported")?;
21322 s.end()
21323 }
21324 UploadSessionFinishError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
21325 }
21326 }
21327}
21328
21329impl ::std::error::Error for UploadSessionFinishError {
21330 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
21331 match self {
21332 UploadSessionFinishError::LookupFailed(inner) => Some(inner),
21333 UploadSessionFinishError::Path(inner) => Some(inner),
21334 UploadSessionFinishError::PropertiesError(inner) => Some(inner),
21335 _ => None,
21336 }
21337 }
21338}
21339
21340impl ::std::fmt::Display for UploadSessionFinishError {
21341 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21342 match self {
21343 UploadSessionFinishError::LookupFailed(inner) => write!(f, "The session arguments are incorrect; the value explains the reason: {}", inner),
21344 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),
21345 UploadSessionFinishError::PropertiesError(inner) => write!(f, "The supplied property group is invalid. The file has uploaded without property groups: {}", inner),
21346 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."),
21347 UploadSessionFinishError::TooManyWriteOperations => f.write_str("There are too many write operations happening in the user's Dropbox. You should retry uploading this file."),
21348 UploadSessionFinishError::ConcurrentSessionDataNotAllowed => f.write_str("Uploading data not allowed when finishing concurrent upload session."),
21349 UploadSessionFinishError::ConcurrentSessionNotClosed => f.write_str("Concurrent upload sessions need to be closed before finishing."),
21350 UploadSessionFinishError::ConcurrentSessionMissingData => f.write_str("Not all pieces of data were uploaded before trying to finish the session."),
21351 UploadSessionFinishError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
21352 UploadSessionFinishError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
21353 UploadSessionFinishError::EncryptionNotSupported => f.write_str("The file is required to be encrypted, which is not supported in our public API."),
21354 _ => write!(f, "{:?}", *self),
21355 }
21356 }
21357}
21358
21359#[derive(Debug, Clone, PartialEq, Eq)]
21360#[non_exhaustive] pub enum UploadSessionLookupError {
21362 NotFound,
21364 IncorrectOffset(UploadSessionOffsetError),
21368 Closed,
21371 NotClosed,
21373 TooLarge,
21376 ConcurrentSessionInvalidOffset,
21378 ConcurrentSessionInvalidDataSize,
21381 PayloadTooLarge,
21383 Other,
21386}
21387
21388impl<'de> ::serde::de::Deserialize<'de> for UploadSessionLookupError {
21389 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21390 use serde::de::{self, MapAccess, Visitor};
21392 struct EnumVisitor;
21393 impl<'de> Visitor<'de> for EnumVisitor {
21394 type Value = UploadSessionLookupError;
21395 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21396 f.write_str("a UploadSessionLookupError structure")
21397 }
21398 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21399 let tag: &str = match map.next_key()? {
21400 Some(".tag") => map.next_value()?,
21401 _ => return Err(de::Error::missing_field(".tag"))
21402 };
21403 let value = match tag {
21404 "not_found" => UploadSessionLookupError::NotFound,
21405 "incorrect_offset" => UploadSessionLookupError::IncorrectOffset(UploadSessionOffsetError::internal_deserialize(&mut map)?),
21406 "closed" => UploadSessionLookupError::Closed,
21407 "not_closed" => UploadSessionLookupError::NotClosed,
21408 "too_large" => UploadSessionLookupError::TooLarge,
21409 "concurrent_session_invalid_offset" => UploadSessionLookupError::ConcurrentSessionInvalidOffset,
21410 "concurrent_session_invalid_data_size" => UploadSessionLookupError::ConcurrentSessionInvalidDataSize,
21411 "payload_too_large" => UploadSessionLookupError::PayloadTooLarge,
21412 _ => UploadSessionLookupError::Other,
21413 };
21414 crate::eat_json_fields(&mut map)?;
21415 Ok(value)
21416 }
21417 }
21418 const VARIANTS: &[&str] = &["not_found",
21419 "incorrect_offset",
21420 "closed",
21421 "not_closed",
21422 "too_large",
21423 "concurrent_session_invalid_offset",
21424 "concurrent_session_invalid_data_size",
21425 "payload_too_large",
21426 "other"];
21427 deserializer.deserialize_struct("UploadSessionLookupError", VARIANTS, EnumVisitor)
21428 }
21429}
21430
21431impl ::serde::ser::Serialize for UploadSessionLookupError {
21432 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21433 use serde::ser::SerializeStruct;
21435 match self {
21436 UploadSessionLookupError::NotFound => {
21437 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21439 s.serialize_field(".tag", "not_found")?;
21440 s.end()
21441 }
21442 UploadSessionLookupError::IncorrectOffset(x) => {
21443 let mut s = serializer.serialize_struct("UploadSessionLookupError", 2)?;
21445 s.serialize_field(".tag", "incorrect_offset")?;
21446 x.internal_serialize::<S>(&mut s)?;
21447 s.end()
21448 }
21449 UploadSessionLookupError::Closed => {
21450 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21452 s.serialize_field(".tag", "closed")?;
21453 s.end()
21454 }
21455 UploadSessionLookupError::NotClosed => {
21456 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21458 s.serialize_field(".tag", "not_closed")?;
21459 s.end()
21460 }
21461 UploadSessionLookupError::TooLarge => {
21462 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21464 s.serialize_field(".tag", "too_large")?;
21465 s.end()
21466 }
21467 UploadSessionLookupError::ConcurrentSessionInvalidOffset => {
21468 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21470 s.serialize_field(".tag", "concurrent_session_invalid_offset")?;
21471 s.end()
21472 }
21473 UploadSessionLookupError::ConcurrentSessionInvalidDataSize => {
21474 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21476 s.serialize_field(".tag", "concurrent_session_invalid_data_size")?;
21477 s.end()
21478 }
21479 UploadSessionLookupError::PayloadTooLarge => {
21480 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21482 s.serialize_field(".tag", "payload_too_large")?;
21483 s.end()
21484 }
21485 UploadSessionLookupError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
21486 }
21487 }
21488}
21489
21490impl ::std::error::Error for UploadSessionLookupError {
21491}
21492
21493impl ::std::fmt::Display for UploadSessionLookupError {
21494 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21495 match self {
21496 UploadSessionLookupError::NotFound => f.write_str("The upload session ID was not found or has expired. Upload sessions are valid for 7 days."),
21497 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),
21498 UploadSessionLookupError::Closed => f.write_str("You are attempting to append data to an upload session that has already been closed (i.e. committed)."),
21499 UploadSessionLookupError::NotClosed => f.write_str("The session must be closed before calling upload_session/finish_batch."),
21500 UploadSessionLookupError::TooLarge => f.write_str("You can not append to the upload session because the size of a file should not exceed the max file size limit (i.e. 2^41 - 2^22 or 2,199,019,061,248 bytes)."),
21501 UploadSessionLookupError::ConcurrentSessionInvalidOffset => f.write_str("For concurrent upload sessions, offset needs to be multiple of 2^22 (4,194,304) bytes."),
21502 UploadSessionLookupError::ConcurrentSessionInvalidDataSize => f.write_str("For concurrent upload sessions, only chunks with size multiple of 2^22 (4,194,304) bytes can be uploaded."),
21503 UploadSessionLookupError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
21504 _ => write!(f, "{:?}", *self),
21505 }
21506 }
21507}
21508
21509#[derive(Debug, Clone, PartialEq, Eq)]
21510#[non_exhaustive] pub struct UploadSessionOffsetError {
21512 pub correct_offset: u64,
21514}
21515
21516impl UploadSessionOffsetError {
21517 pub fn new(correct_offset: u64) -> Self {
21518 UploadSessionOffsetError {
21519 correct_offset,
21520 }
21521 }
21522}
21523
21524const UPLOAD_SESSION_OFFSET_ERROR_FIELDS: &[&str] = &["correct_offset"];
21525impl UploadSessionOffsetError {
21526 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21527 map: V,
21528 ) -> Result<UploadSessionOffsetError, V::Error> {
21529 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21530 }
21531
21532 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21533 mut map: V,
21534 optional: bool,
21535 ) -> Result<Option<UploadSessionOffsetError>, V::Error> {
21536 let mut field_correct_offset = None;
21537 let mut nothing = true;
21538 while let Some(key) = map.next_key::<&str>()? {
21539 nothing = false;
21540 match key {
21541 "correct_offset" => {
21542 if field_correct_offset.is_some() {
21543 return Err(::serde::de::Error::duplicate_field("correct_offset"));
21544 }
21545 field_correct_offset = Some(map.next_value()?);
21546 }
21547 _ => {
21548 map.next_value::<::serde_json::Value>()?;
21550 }
21551 }
21552 }
21553 if optional && nothing {
21554 return Ok(None);
21555 }
21556 let result = UploadSessionOffsetError {
21557 correct_offset: field_correct_offset.ok_or_else(|| ::serde::de::Error::missing_field("correct_offset"))?,
21558 };
21559 Ok(Some(result))
21560 }
21561
21562 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21563 &self,
21564 s: &mut S::SerializeStruct,
21565 ) -> Result<(), S::Error> {
21566 use serde::ser::SerializeStruct;
21567 s.serialize_field("correct_offset", &self.correct_offset)?;
21568 Ok(())
21569 }
21570}
21571
21572impl<'de> ::serde::de::Deserialize<'de> for UploadSessionOffsetError {
21573 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21574 use serde::de::{MapAccess, Visitor};
21576 struct StructVisitor;
21577 impl<'de> Visitor<'de> for StructVisitor {
21578 type Value = UploadSessionOffsetError;
21579 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21580 f.write_str("a UploadSessionOffsetError struct")
21581 }
21582 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21583 UploadSessionOffsetError::internal_deserialize(map)
21584 }
21585 }
21586 deserializer.deserialize_struct("UploadSessionOffsetError", UPLOAD_SESSION_OFFSET_ERROR_FIELDS, StructVisitor)
21587 }
21588}
21589
21590impl ::serde::ser::Serialize for UploadSessionOffsetError {
21591 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21592 use serde::ser::SerializeStruct;
21594 let mut s = serializer.serialize_struct("UploadSessionOffsetError", 1)?;
21595 self.internal_serialize::<S>(&mut s)?;
21596 s.end()
21597 }
21598}
21599
21600#[derive(Debug, Clone, PartialEq, Eq, Default)]
21601#[non_exhaustive] pub struct UploadSessionStartArg {
21603 pub close: bool,
21607 pub session_type: Option<UploadSessionType>,
21610 pub content_hash: Option<Sha256HexHash>,
21614}
21615
21616impl UploadSessionStartArg {
21617 pub fn with_close(mut self, value: bool) -> Self {
21618 self.close = value;
21619 self
21620 }
21621
21622 pub fn with_session_type(mut self, value: UploadSessionType) -> Self {
21623 self.session_type = Some(value);
21624 self
21625 }
21626
21627 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
21628 self.content_hash = Some(value);
21629 self
21630 }
21631}
21632
21633const UPLOAD_SESSION_START_ARG_FIELDS: &[&str] = &["close",
21634 "session_type",
21635 "content_hash"];
21636impl UploadSessionStartArg {
21637 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21639 mut map: V,
21640 ) -> Result<UploadSessionStartArg, V::Error> {
21641 let mut field_close = None;
21642 let mut field_session_type = None;
21643 let mut field_content_hash = None;
21644 while let Some(key) = map.next_key::<&str>()? {
21645 match key {
21646 "close" => {
21647 if field_close.is_some() {
21648 return Err(::serde::de::Error::duplicate_field("close"));
21649 }
21650 field_close = Some(map.next_value()?);
21651 }
21652 "session_type" => {
21653 if field_session_type.is_some() {
21654 return Err(::serde::de::Error::duplicate_field("session_type"));
21655 }
21656 field_session_type = Some(map.next_value()?);
21657 }
21658 "content_hash" => {
21659 if field_content_hash.is_some() {
21660 return Err(::serde::de::Error::duplicate_field("content_hash"));
21661 }
21662 field_content_hash = Some(map.next_value()?);
21663 }
21664 _ => {
21665 map.next_value::<::serde_json::Value>()?;
21667 }
21668 }
21669 }
21670 let result = UploadSessionStartArg {
21671 close: field_close.unwrap_or(false),
21672 session_type: field_session_type.and_then(Option::flatten),
21673 content_hash: field_content_hash.and_then(Option::flatten),
21674 };
21675 Ok(result)
21676 }
21677
21678 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21679 &self,
21680 s: &mut S::SerializeStruct,
21681 ) -> Result<(), S::Error> {
21682 use serde::ser::SerializeStruct;
21683 if self.close {
21684 s.serialize_field("close", &self.close)?;
21685 }
21686 if let Some(val) = &self.session_type {
21687 s.serialize_field("session_type", val)?;
21688 }
21689 if let Some(val) = &self.content_hash {
21690 s.serialize_field("content_hash", val)?;
21691 }
21692 Ok(())
21693 }
21694}
21695
21696impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartArg {
21697 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21698 use serde::de::{MapAccess, Visitor};
21700 struct StructVisitor;
21701 impl<'de> Visitor<'de> for StructVisitor {
21702 type Value = UploadSessionStartArg;
21703 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21704 f.write_str("a UploadSessionStartArg struct")
21705 }
21706 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21707 UploadSessionStartArg::internal_deserialize(map)
21708 }
21709 }
21710 deserializer.deserialize_struct("UploadSessionStartArg", UPLOAD_SESSION_START_ARG_FIELDS, StructVisitor)
21711 }
21712}
21713
21714impl ::serde::ser::Serialize for UploadSessionStartArg {
21715 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21716 use serde::ser::SerializeStruct;
21718 let mut s = serializer.serialize_struct("UploadSessionStartArg", 3)?;
21719 self.internal_serialize::<S>(&mut s)?;
21720 s.end()
21721 }
21722}
21723
21724#[derive(Debug, Clone, PartialEq, Eq)]
21725#[non_exhaustive] pub struct UploadSessionStartBatchArg {
21727 pub num_sessions: u64,
21729 pub session_type: Option<UploadSessionType>,
21732}
21733
21734impl UploadSessionStartBatchArg {
21735 pub fn new(num_sessions: u64) -> Self {
21736 UploadSessionStartBatchArg {
21737 num_sessions,
21738 session_type: None,
21739 }
21740 }
21741
21742 pub fn with_session_type(mut self, value: UploadSessionType) -> Self {
21743 self.session_type = Some(value);
21744 self
21745 }
21746}
21747
21748const UPLOAD_SESSION_START_BATCH_ARG_FIELDS: &[&str] = &["num_sessions",
21749 "session_type"];
21750impl UploadSessionStartBatchArg {
21751 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21752 map: V,
21753 ) -> Result<UploadSessionStartBatchArg, V::Error> {
21754 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21755 }
21756
21757 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21758 mut map: V,
21759 optional: bool,
21760 ) -> Result<Option<UploadSessionStartBatchArg>, V::Error> {
21761 let mut field_num_sessions = None;
21762 let mut field_session_type = None;
21763 let mut nothing = true;
21764 while let Some(key) = map.next_key::<&str>()? {
21765 nothing = false;
21766 match key {
21767 "num_sessions" => {
21768 if field_num_sessions.is_some() {
21769 return Err(::serde::de::Error::duplicate_field("num_sessions"));
21770 }
21771 field_num_sessions = Some(map.next_value()?);
21772 }
21773 "session_type" => {
21774 if field_session_type.is_some() {
21775 return Err(::serde::de::Error::duplicate_field("session_type"));
21776 }
21777 field_session_type = Some(map.next_value()?);
21778 }
21779 _ => {
21780 map.next_value::<::serde_json::Value>()?;
21782 }
21783 }
21784 }
21785 if optional && nothing {
21786 return Ok(None);
21787 }
21788 let result = UploadSessionStartBatchArg {
21789 num_sessions: field_num_sessions.ok_or_else(|| ::serde::de::Error::missing_field("num_sessions"))?,
21790 session_type: field_session_type.and_then(Option::flatten),
21791 };
21792 Ok(Some(result))
21793 }
21794
21795 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21796 &self,
21797 s: &mut S::SerializeStruct,
21798 ) -> Result<(), S::Error> {
21799 use serde::ser::SerializeStruct;
21800 s.serialize_field("num_sessions", &self.num_sessions)?;
21801 if let Some(val) = &self.session_type {
21802 s.serialize_field("session_type", val)?;
21803 }
21804 Ok(())
21805 }
21806}
21807
21808impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartBatchArg {
21809 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21810 use serde::de::{MapAccess, Visitor};
21812 struct StructVisitor;
21813 impl<'de> Visitor<'de> for StructVisitor {
21814 type Value = UploadSessionStartBatchArg;
21815 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21816 f.write_str("a UploadSessionStartBatchArg struct")
21817 }
21818 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21819 UploadSessionStartBatchArg::internal_deserialize(map)
21820 }
21821 }
21822 deserializer.deserialize_struct("UploadSessionStartBatchArg", UPLOAD_SESSION_START_BATCH_ARG_FIELDS, StructVisitor)
21823 }
21824}
21825
21826impl ::serde::ser::Serialize for UploadSessionStartBatchArg {
21827 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21828 use serde::ser::SerializeStruct;
21830 let mut s = serializer.serialize_struct("UploadSessionStartBatchArg", 2)?;
21831 self.internal_serialize::<S>(&mut s)?;
21832 s.end()
21833 }
21834}
21835
21836#[derive(Debug, Clone, PartialEq, Eq)]
21837#[non_exhaustive] pub struct UploadSessionStartBatchResult {
21839 pub session_ids: Vec<String>,
21843}
21844
21845impl UploadSessionStartBatchResult {
21846 pub fn new(session_ids: Vec<String>) -> Self {
21847 UploadSessionStartBatchResult {
21848 session_ids,
21849 }
21850 }
21851}
21852
21853const UPLOAD_SESSION_START_BATCH_RESULT_FIELDS: &[&str] = &["session_ids"];
21854impl UploadSessionStartBatchResult {
21855 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21856 map: V,
21857 ) -> Result<UploadSessionStartBatchResult, V::Error> {
21858 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21859 }
21860
21861 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21862 mut map: V,
21863 optional: bool,
21864 ) -> Result<Option<UploadSessionStartBatchResult>, V::Error> {
21865 let mut field_session_ids = None;
21866 let mut nothing = true;
21867 while let Some(key) = map.next_key::<&str>()? {
21868 nothing = false;
21869 match key {
21870 "session_ids" => {
21871 if field_session_ids.is_some() {
21872 return Err(::serde::de::Error::duplicate_field("session_ids"));
21873 }
21874 field_session_ids = Some(map.next_value()?);
21875 }
21876 _ => {
21877 map.next_value::<::serde_json::Value>()?;
21879 }
21880 }
21881 }
21882 if optional && nothing {
21883 return Ok(None);
21884 }
21885 let result = UploadSessionStartBatchResult {
21886 session_ids: field_session_ids.ok_or_else(|| ::serde::de::Error::missing_field("session_ids"))?,
21887 };
21888 Ok(Some(result))
21889 }
21890
21891 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21892 &self,
21893 s: &mut S::SerializeStruct,
21894 ) -> Result<(), S::Error> {
21895 use serde::ser::SerializeStruct;
21896 s.serialize_field("session_ids", &self.session_ids)?;
21897 Ok(())
21898 }
21899}
21900
21901impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartBatchResult {
21902 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21903 use serde::de::{MapAccess, Visitor};
21905 struct StructVisitor;
21906 impl<'de> Visitor<'de> for StructVisitor {
21907 type Value = UploadSessionStartBatchResult;
21908 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21909 f.write_str("a UploadSessionStartBatchResult struct")
21910 }
21911 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21912 UploadSessionStartBatchResult::internal_deserialize(map)
21913 }
21914 }
21915 deserializer.deserialize_struct("UploadSessionStartBatchResult", UPLOAD_SESSION_START_BATCH_RESULT_FIELDS, StructVisitor)
21916 }
21917}
21918
21919impl ::serde::ser::Serialize for UploadSessionStartBatchResult {
21920 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21921 use serde::ser::SerializeStruct;
21923 let mut s = serializer.serialize_struct("UploadSessionStartBatchResult", 1)?;
21924 self.internal_serialize::<S>(&mut s)?;
21925 s.end()
21926 }
21927}
21928
21929#[derive(Debug, Clone, PartialEq, Eq)]
21930#[non_exhaustive] pub enum UploadSessionStartError {
21932 ConcurrentSessionDataNotAllowed,
21934 ConcurrentSessionCloseNotAllowed,
21936 PayloadTooLarge,
21938 ContentHashMismatch,
21941 Other,
21944}
21945
21946impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartError {
21947 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21948 use serde::de::{self, MapAccess, Visitor};
21950 struct EnumVisitor;
21951 impl<'de> Visitor<'de> for EnumVisitor {
21952 type Value = UploadSessionStartError;
21953 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21954 f.write_str("a UploadSessionStartError structure")
21955 }
21956 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21957 let tag: &str = match map.next_key()? {
21958 Some(".tag") => map.next_value()?,
21959 _ => return Err(de::Error::missing_field(".tag"))
21960 };
21961 let value = match tag {
21962 "concurrent_session_data_not_allowed" => UploadSessionStartError::ConcurrentSessionDataNotAllowed,
21963 "concurrent_session_close_not_allowed" => UploadSessionStartError::ConcurrentSessionCloseNotAllowed,
21964 "payload_too_large" => UploadSessionStartError::PayloadTooLarge,
21965 "content_hash_mismatch" => UploadSessionStartError::ContentHashMismatch,
21966 _ => UploadSessionStartError::Other,
21967 };
21968 crate::eat_json_fields(&mut map)?;
21969 Ok(value)
21970 }
21971 }
21972 const VARIANTS: &[&str] = &["concurrent_session_data_not_allowed",
21973 "concurrent_session_close_not_allowed",
21974 "payload_too_large",
21975 "content_hash_mismatch",
21976 "other"];
21977 deserializer.deserialize_struct("UploadSessionStartError", VARIANTS, EnumVisitor)
21978 }
21979}
21980
21981impl ::serde::ser::Serialize for UploadSessionStartError {
21982 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21983 use serde::ser::SerializeStruct;
21985 match self {
21986 UploadSessionStartError::ConcurrentSessionDataNotAllowed => {
21987 let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
21989 s.serialize_field(".tag", "concurrent_session_data_not_allowed")?;
21990 s.end()
21991 }
21992 UploadSessionStartError::ConcurrentSessionCloseNotAllowed => {
21993 let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
21995 s.serialize_field(".tag", "concurrent_session_close_not_allowed")?;
21996 s.end()
21997 }
21998 UploadSessionStartError::PayloadTooLarge => {
21999 let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
22001 s.serialize_field(".tag", "payload_too_large")?;
22002 s.end()
22003 }
22004 UploadSessionStartError::ContentHashMismatch => {
22005 let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
22007 s.serialize_field(".tag", "content_hash_mismatch")?;
22008 s.end()
22009 }
22010 UploadSessionStartError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
22011 }
22012 }
22013}
22014
22015impl ::std::error::Error for UploadSessionStartError {
22016}
22017
22018impl ::std::fmt::Display for UploadSessionStartError {
22019 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22020 match self {
22021 UploadSessionStartError::ConcurrentSessionDataNotAllowed => f.write_str("Uploading data not allowed when starting concurrent upload session."),
22022 UploadSessionStartError::ConcurrentSessionCloseNotAllowed => f.write_str("Can not start a closed concurrent upload session."),
22023 UploadSessionStartError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
22024 UploadSessionStartError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
22025 _ => write!(f, "{:?}", *self),
22026 }
22027 }
22028}
22029
22030#[derive(Debug, Clone, PartialEq, Eq)]
22031#[non_exhaustive] pub struct UploadSessionStartResult {
22033 pub session_id: String,
22037}
22038
22039impl UploadSessionStartResult {
22040 pub fn new(session_id: String) -> Self {
22041 UploadSessionStartResult {
22042 session_id,
22043 }
22044 }
22045}
22046
22047const UPLOAD_SESSION_START_RESULT_FIELDS: &[&str] = &["session_id"];
22048impl UploadSessionStartResult {
22049 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
22050 map: V,
22051 ) -> Result<UploadSessionStartResult, V::Error> {
22052 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
22053 }
22054
22055 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
22056 mut map: V,
22057 optional: bool,
22058 ) -> Result<Option<UploadSessionStartResult>, V::Error> {
22059 let mut field_session_id = None;
22060 let mut nothing = true;
22061 while let Some(key) = map.next_key::<&str>()? {
22062 nothing = false;
22063 match key {
22064 "session_id" => {
22065 if field_session_id.is_some() {
22066 return Err(::serde::de::Error::duplicate_field("session_id"));
22067 }
22068 field_session_id = Some(map.next_value()?);
22069 }
22070 _ => {
22071 map.next_value::<::serde_json::Value>()?;
22073 }
22074 }
22075 }
22076 if optional && nothing {
22077 return Ok(None);
22078 }
22079 let result = UploadSessionStartResult {
22080 session_id: field_session_id.ok_or_else(|| ::serde::de::Error::missing_field("session_id"))?,
22081 };
22082 Ok(Some(result))
22083 }
22084
22085 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
22086 &self,
22087 s: &mut S::SerializeStruct,
22088 ) -> Result<(), S::Error> {
22089 use serde::ser::SerializeStruct;
22090 s.serialize_field("session_id", &self.session_id)?;
22091 Ok(())
22092 }
22093}
22094
22095impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartResult {
22096 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22097 use serde::de::{MapAccess, Visitor};
22099 struct StructVisitor;
22100 impl<'de> Visitor<'de> for StructVisitor {
22101 type Value = UploadSessionStartResult;
22102 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22103 f.write_str("a UploadSessionStartResult struct")
22104 }
22105 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
22106 UploadSessionStartResult::internal_deserialize(map)
22107 }
22108 }
22109 deserializer.deserialize_struct("UploadSessionStartResult", UPLOAD_SESSION_START_RESULT_FIELDS, StructVisitor)
22110 }
22111}
22112
22113impl ::serde::ser::Serialize for UploadSessionStartResult {
22114 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22115 use serde::ser::SerializeStruct;
22117 let mut s = serializer.serialize_struct("UploadSessionStartResult", 1)?;
22118 self.internal_serialize::<S>(&mut s)?;
22119 s.end()
22120 }
22121}
22122
22123#[derive(Debug, Clone, PartialEq, Eq)]
22124#[non_exhaustive] pub enum UploadSessionType {
22126 Sequential,
22128 Concurrent,
22130 Other,
22133}
22134
22135impl<'de> ::serde::de::Deserialize<'de> for UploadSessionType {
22136 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22137 use serde::de::{self, MapAccess, Visitor};
22139 struct EnumVisitor;
22140 impl<'de> Visitor<'de> for EnumVisitor {
22141 type Value = UploadSessionType;
22142 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22143 f.write_str("a UploadSessionType structure")
22144 }
22145 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22146 let tag: &str = match map.next_key()? {
22147 Some(".tag") => map.next_value()?,
22148 _ => return Err(de::Error::missing_field(".tag"))
22149 };
22150 let value = match tag {
22151 "sequential" => UploadSessionType::Sequential,
22152 "concurrent" => UploadSessionType::Concurrent,
22153 _ => UploadSessionType::Other,
22154 };
22155 crate::eat_json_fields(&mut map)?;
22156 Ok(value)
22157 }
22158 }
22159 const VARIANTS: &[&str] = &["sequential",
22160 "concurrent",
22161 "other"];
22162 deserializer.deserialize_struct("UploadSessionType", VARIANTS, EnumVisitor)
22163 }
22164}
22165
22166impl ::serde::ser::Serialize for UploadSessionType {
22167 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22168 use serde::ser::SerializeStruct;
22170 match self {
22171 UploadSessionType::Sequential => {
22172 let mut s = serializer.serialize_struct("UploadSessionType", 1)?;
22174 s.serialize_field(".tag", "sequential")?;
22175 s.end()
22176 }
22177 UploadSessionType::Concurrent => {
22178 let mut s = serializer.serialize_struct("UploadSessionType", 1)?;
22180 s.serialize_field(".tag", "concurrent")?;
22181 s.end()
22182 }
22183 UploadSessionType::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
22184 }
22185 }
22186}
22187
22188#[derive(Debug, Clone, PartialEq, Eq)]
22189#[non_exhaustive] pub struct UploadWriteFailed {
22191 pub reason: WriteError,
22193 pub upload_session_id: String,
22197}
22198
22199impl UploadWriteFailed {
22200 pub fn new(reason: WriteError, upload_session_id: String) -> Self {
22201 UploadWriteFailed {
22202 reason,
22203 upload_session_id,
22204 }
22205 }
22206}
22207
22208const UPLOAD_WRITE_FAILED_FIELDS: &[&str] = &["reason",
22209 "upload_session_id"];
22210impl UploadWriteFailed {
22211 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
22212 map: V,
22213 ) -> Result<UploadWriteFailed, V::Error> {
22214 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
22215 }
22216
22217 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
22218 mut map: V,
22219 optional: bool,
22220 ) -> Result<Option<UploadWriteFailed>, V::Error> {
22221 let mut field_reason = None;
22222 let mut field_upload_session_id = None;
22223 let mut nothing = true;
22224 while let Some(key) = map.next_key::<&str>()? {
22225 nothing = false;
22226 match key {
22227 "reason" => {
22228 if field_reason.is_some() {
22229 return Err(::serde::de::Error::duplicate_field("reason"));
22230 }
22231 field_reason = Some(map.next_value()?);
22232 }
22233 "upload_session_id" => {
22234 if field_upload_session_id.is_some() {
22235 return Err(::serde::de::Error::duplicate_field("upload_session_id"));
22236 }
22237 field_upload_session_id = Some(map.next_value()?);
22238 }
22239 _ => {
22240 map.next_value::<::serde_json::Value>()?;
22242 }
22243 }
22244 }
22245 if optional && nothing {
22246 return Ok(None);
22247 }
22248 let result = UploadWriteFailed {
22249 reason: field_reason.ok_or_else(|| ::serde::de::Error::missing_field("reason"))?,
22250 upload_session_id: field_upload_session_id.ok_or_else(|| ::serde::de::Error::missing_field("upload_session_id"))?,
22251 };
22252 Ok(Some(result))
22253 }
22254
22255 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
22256 &self,
22257 s: &mut S::SerializeStruct,
22258 ) -> Result<(), S::Error> {
22259 use serde::ser::SerializeStruct;
22260 s.serialize_field("reason", &self.reason)?;
22261 s.serialize_field("upload_session_id", &self.upload_session_id)?;
22262 Ok(())
22263 }
22264}
22265
22266impl<'de> ::serde::de::Deserialize<'de> for UploadWriteFailed {
22267 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22268 use serde::de::{MapAccess, Visitor};
22270 struct StructVisitor;
22271 impl<'de> Visitor<'de> for StructVisitor {
22272 type Value = UploadWriteFailed;
22273 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22274 f.write_str("a UploadWriteFailed struct")
22275 }
22276 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
22277 UploadWriteFailed::internal_deserialize(map)
22278 }
22279 }
22280 deserializer.deserialize_struct("UploadWriteFailed", UPLOAD_WRITE_FAILED_FIELDS, StructVisitor)
22281 }
22282}
22283
22284impl ::serde::ser::Serialize for UploadWriteFailed {
22285 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22286 use serde::ser::SerializeStruct;
22288 let mut s = serializer.serialize_struct("UploadWriteFailed", 2)?;
22289 self.internal_serialize::<S>(&mut s)?;
22290 s.end()
22291 }
22292}
22293
22294#[derive(Debug, Clone, PartialEq, Eq)]
22295#[non_exhaustive] pub struct UserGeneratedTag {
22297 pub tag_text: TagText,
22298}
22299
22300impl UserGeneratedTag {
22301 pub fn new(tag_text: TagText) -> Self {
22302 UserGeneratedTag {
22303 tag_text,
22304 }
22305 }
22306}
22307
22308const USER_GENERATED_TAG_FIELDS: &[&str] = &["tag_text"];
22309impl UserGeneratedTag {
22310 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
22311 map: V,
22312 ) -> Result<UserGeneratedTag, V::Error> {
22313 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
22314 }
22315
22316 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
22317 mut map: V,
22318 optional: bool,
22319 ) -> Result<Option<UserGeneratedTag>, V::Error> {
22320 let mut field_tag_text = None;
22321 let mut nothing = true;
22322 while let Some(key) = map.next_key::<&str>()? {
22323 nothing = false;
22324 match key {
22325 "tag_text" => {
22326 if field_tag_text.is_some() {
22327 return Err(::serde::de::Error::duplicate_field("tag_text"));
22328 }
22329 field_tag_text = Some(map.next_value()?);
22330 }
22331 _ => {
22332 map.next_value::<::serde_json::Value>()?;
22334 }
22335 }
22336 }
22337 if optional && nothing {
22338 return Ok(None);
22339 }
22340 let result = UserGeneratedTag {
22341 tag_text: field_tag_text.ok_or_else(|| ::serde::de::Error::missing_field("tag_text"))?,
22342 };
22343 Ok(Some(result))
22344 }
22345
22346 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
22347 &self,
22348 s: &mut S::SerializeStruct,
22349 ) -> Result<(), S::Error> {
22350 use serde::ser::SerializeStruct;
22351 s.serialize_field("tag_text", &self.tag_text)?;
22352 Ok(())
22353 }
22354}
22355
22356impl<'de> ::serde::de::Deserialize<'de> for UserGeneratedTag {
22357 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22358 use serde::de::{MapAccess, Visitor};
22360 struct StructVisitor;
22361 impl<'de> Visitor<'de> for StructVisitor {
22362 type Value = UserGeneratedTag;
22363 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22364 f.write_str("a UserGeneratedTag struct")
22365 }
22366 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
22367 UserGeneratedTag::internal_deserialize(map)
22368 }
22369 }
22370 deserializer.deserialize_struct("UserGeneratedTag", USER_GENERATED_TAG_FIELDS, StructVisitor)
22371 }
22372}
22373
22374impl ::serde::ser::Serialize for UserGeneratedTag {
22375 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22376 use serde::ser::SerializeStruct;
22378 let mut s = serializer.serialize_struct("UserGeneratedTag", 1)?;
22379 self.internal_serialize::<S>(&mut s)?;
22380 s.end()
22381 }
22382}
22383
22384#[derive(Debug, Clone, PartialEq, Default)]
22386#[non_exhaustive] pub struct VideoMetadata {
22388 pub dimensions: Option<Dimensions>,
22390 pub location: Option<GpsCoordinates>,
22392 pub time_taken: Option<crate::types::common::DropboxTimestamp>,
22394 pub duration: Option<u64>,
22396}
22397
22398impl VideoMetadata {
22399 pub fn with_dimensions(mut self, value: Dimensions) -> Self {
22400 self.dimensions = Some(value);
22401 self
22402 }
22403
22404 pub fn with_location(mut self, value: GpsCoordinates) -> Self {
22405 self.location = Some(value);
22406 self
22407 }
22408
22409 pub fn with_time_taken(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
22410 self.time_taken = Some(value);
22411 self
22412 }
22413
22414 pub fn with_duration(mut self, value: u64) -> Self {
22415 self.duration = Some(value);
22416 self
22417 }
22418}
22419
22420const VIDEO_METADATA_FIELDS: &[&str] = &["dimensions",
22421 "location",
22422 "time_taken",
22423 "duration"];
22424impl VideoMetadata {
22425 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
22427 mut map: V,
22428 ) -> Result<VideoMetadata, V::Error> {
22429 let mut field_dimensions = None;
22430 let mut field_location = None;
22431 let mut field_time_taken = None;
22432 let mut field_duration = None;
22433 while let Some(key) = map.next_key::<&str>()? {
22434 match key {
22435 "dimensions" => {
22436 if field_dimensions.is_some() {
22437 return Err(::serde::de::Error::duplicate_field("dimensions"));
22438 }
22439 field_dimensions = Some(map.next_value()?);
22440 }
22441 "location" => {
22442 if field_location.is_some() {
22443 return Err(::serde::de::Error::duplicate_field("location"));
22444 }
22445 field_location = Some(map.next_value()?);
22446 }
22447 "time_taken" => {
22448 if field_time_taken.is_some() {
22449 return Err(::serde::de::Error::duplicate_field("time_taken"));
22450 }
22451 field_time_taken = Some(map.next_value()?);
22452 }
22453 "duration" => {
22454 if field_duration.is_some() {
22455 return Err(::serde::de::Error::duplicate_field("duration"));
22456 }
22457 field_duration = Some(map.next_value()?);
22458 }
22459 _ => {
22460 map.next_value::<::serde_json::Value>()?;
22462 }
22463 }
22464 }
22465 let result = VideoMetadata {
22466 dimensions: field_dimensions.and_then(Option::flatten),
22467 location: field_location.and_then(Option::flatten),
22468 time_taken: field_time_taken.and_then(Option::flatten),
22469 duration: field_duration.and_then(Option::flatten),
22470 };
22471 Ok(result)
22472 }
22473
22474 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
22475 &self,
22476 s: &mut S::SerializeStruct,
22477 ) -> Result<(), S::Error> {
22478 use serde::ser::SerializeStruct;
22479 if let Some(val) = &self.dimensions {
22480 s.serialize_field("dimensions", val)?;
22481 }
22482 if let Some(val) = &self.location {
22483 s.serialize_field("location", val)?;
22484 }
22485 if let Some(val) = &self.time_taken {
22486 s.serialize_field("time_taken", val)?;
22487 }
22488 if let Some(val) = &self.duration {
22489 s.serialize_field("duration", val)?;
22490 }
22491 Ok(())
22492 }
22493}
22494
22495impl<'de> ::serde::de::Deserialize<'de> for VideoMetadata {
22496 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22497 use serde::de::{MapAccess, Visitor};
22499 struct StructVisitor;
22500 impl<'de> Visitor<'de> for StructVisitor {
22501 type Value = VideoMetadata;
22502 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22503 f.write_str("a VideoMetadata struct")
22504 }
22505 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
22506 VideoMetadata::internal_deserialize(map)
22507 }
22508 }
22509 deserializer.deserialize_struct("VideoMetadata", VIDEO_METADATA_FIELDS, StructVisitor)
22510 }
22511}
22512
22513impl ::serde::ser::Serialize for VideoMetadata {
22514 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22515 use serde::ser::SerializeStruct;
22517 let mut s = serializer.serialize_struct("VideoMetadata", 4)?;
22518 self.internal_serialize::<S>(&mut s)?;
22519 s.end()
22520 }
22521}
22522
22523impl From<VideoMetadata> for MediaMetadata {
22525 fn from(subtype: VideoMetadata) -> Self {
22526 MediaMetadata::Video(subtype)
22527 }
22528}
22529#[derive(Debug, Clone, PartialEq, Eq)]
22530#[non_exhaustive] pub enum WriteConflictError {
22532 File,
22534 Folder,
22536 FileAncestor,
22538 Other,
22541}
22542
22543impl<'de> ::serde::de::Deserialize<'de> for WriteConflictError {
22544 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22545 use serde::de::{self, MapAccess, Visitor};
22547 struct EnumVisitor;
22548 impl<'de> Visitor<'de> for EnumVisitor {
22549 type Value = WriteConflictError;
22550 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22551 f.write_str("a WriteConflictError structure")
22552 }
22553 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22554 let tag: &str = match map.next_key()? {
22555 Some(".tag") => map.next_value()?,
22556 _ => return Err(de::Error::missing_field(".tag"))
22557 };
22558 let value = match tag {
22559 "file" => WriteConflictError::File,
22560 "folder" => WriteConflictError::Folder,
22561 "file_ancestor" => WriteConflictError::FileAncestor,
22562 _ => WriteConflictError::Other,
22563 };
22564 crate::eat_json_fields(&mut map)?;
22565 Ok(value)
22566 }
22567 }
22568 const VARIANTS: &[&str] = &["file",
22569 "folder",
22570 "file_ancestor",
22571 "other"];
22572 deserializer.deserialize_struct("WriteConflictError", VARIANTS, EnumVisitor)
22573 }
22574}
22575
22576impl ::serde::ser::Serialize for WriteConflictError {
22577 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22578 use serde::ser::SerializeStruct;
22580 match self {
22581 WriteConflictError::File => {
22582 let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
22584 s.serialize_field(".tag", "file")?;
22585 s.end()
22586 }
22587 WriteConflictError::Folder => {
22588 let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
22590 s.serialize_field(".tag", "folder")?;
22591 s.end()
22592 }
22593 WriteConflictError::FileAncestor => {
22594 let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
22596 s.serialize_field(".tag", "file_ancestor")?;
22597 s.end()
22598 }
22599 WriteConflictError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
22600 }
22601 }
22602}
22603
22604impl ::std::error::Error for WriteConflictError {
22605}
22606
22607impl ::std::fmt::Display for WriteConflictError {
22608 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22609 match self {
22610 WriteConflictError::File => f.write_str("There's a file in the way."),
22611 WriteConflictError::Folder => f.write_str("There's a folder in the way."),
22612 WriteConflictError::FileAncestor => f.write_str("There's a file at an ancestor path, so we couldn't create the required parent folders."),
22613 _ => write!(f, "{:?}", *self),
22614 }
22615 }
22616}
22617
22618#[derive(Debug, Clone, PartialEq, Eq)]
22619#[non_exhaustive] pub enum WriteError {
22621 MalformedPath(MalformedPathError),
22625 Conflict(WriteConflictError),
22627 NoWritePermission,
22629 InsufficientSpace,
22631 DisallowedName,
22633 TeamFolder,
22635 OperationSuppressed,
22637 TooManyWriteOperations,
22639 AccessRestricted,
22642 Other,
22645}
22646
22647impl<'de> ::serde::de::Deserialize<'de> for WriteError {
22648 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22649 use serde::de::{self, MapAccess, Visitor};
22651 struct EnumVisitor;
22652 impl<'de> Visitor<'de> for EnumVisitor {
22653 type Value = WriteError;
22654 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22655 f.write_str("a WriteError structure")
22656 }
22657 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22658 let tag: &str = match map.next_key()? {
22659 Some(".tag") => map.next_value()?,
22660 _ => return Err(de::Error::missing_field(".tag"))
22661 };
22662 let value = match tag {
22663 "malformed_path" => {
22664 match map.next_key()? {
22665 Some("malformed_path") => WriteError::MalformedPath(map.next_value()?),
22666 None => WriteError::MalformedPath(None),
22667 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
22668 }
22669 }
22670 "conflict" => {
22671 match map.next_key()? {
22672 Some("conflict") => WriteError::Conflict(map.next_value()?),
22673 None => return Err(de::Error::missing_field("conflict")),
22674 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
22675 }
22676 }
22677 "no_write_permission" => WriteError::NoWritePermission,
22678 "insufficient_space" => WriteError::InsufficientSpace,
22679 "disallowed_name" => WriteError::DisallowedName,
22680 "team_folder" => WriteError::TeamFolder,
22681 "operation_suppressed" => WriteError::OperationSuppressed,
22682 "too_many_write_operations" => WriteError::TooManyWriteOperations,
22683 "access_restricted" => WriteError::AccessRestricted,
22684 _ => WriteError::Other,
22685 };
22686 crate::eat_json_fields(&mut map)?;
22687 Ok(value)
22688 }
22689 }
22690 const VARIANTS: &[&str] = &["malformed_path",
22691 "conflict",
22692 "no_write_permission",
22693 "insufficient_space",
22694 "disallowed_name",
22695 "team_folder",
22696 "operation_suppressed",
22697 "too_many_write_operations",
22698 "access_restricted",
22699 "other"];
22700 deserializer.deserialize_struct("WriteError", VARIANTS, EnumVisitor)
22701 }
22702}
22703
22704impl ::serde::ser::Serialize for WriteError {
22705 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22706 use serde::ser::SerializeStruct;
22708 match self {
22709 WriteError::MalformedPath(x) => {
22710 let n = if x.is_some() { 2 } else { 1 };
22712 let mut s = serializer.serialize_struct("WriteError", n)?;
22713 s.serialize_field(".tag", "malformed_path")?;
22714 if let Some(x) = x {
22715 s.serialize_field("malformed_path", &x)?;
22716 }
22717 s.end()
22718 }
22719 WriteError::Conflict(x) => {
22720 let mut s = serializer.serialize_struct("WriteError", 2)?;
22722 s.serialize_field(".tag", "conflict")?;
22723 s.serialize_field("conflict", x)?;
22724 s.end()
22725 }
22726 WriteError::NoWritePermission => {
22727 let mut s = serializer.serialize_struct("WriteError", 1)?;
22729 s.serialize_field(".tag", "no_write_permission")?;
22730 s.end()
22731 }
22732 WriteError::InsufficientSpace => {
22733 let mut s = serializer.serialize_struct("WriteError", 1)?;
22735 s.serialize_field(".tag", "insufficient_space")?;
22736 s.end()
22737 }
22738 WriteError::DisallowedName => {
22739 let mut s = serializer.serialize_struct("WriteError", 1)?;
22741 s.serialize_field(".tag", "disallowed_name")?;
22742 s.end()
22743 }
22744 WriteError::TeamFolder => {
22745 let mut s = serializer.serialize_struct("WriteError", 1)?;
22747 s.serialize_field(".tag", "team_folder")?;
22748 s.end()
22749 }
22750 WriteError::OperationSuppressed => {
22751 let mut s = serializer.serialize_struct("WriteError", 1)?;
22753 s.serialize_field(".tag", "operation_suppressed")?;
22754 s.end()
22755 }
22756 WriteError::TooManyWriteOperations => {
22757 let mut s = serializer.serialize_struct("WriteError", 1)?;
22759 s.serialize_field(".tag", "too_many_write_operations")?;
22760 s.end()
22761 }
22762 WriteError::AccessRestricted => {
22763 let mut s = serializer.serialize_struct("WriteError", 1)?;
22765 s.serialize_field(".tag", "access_restricted")?;
22766 s.end()
22767 }
22768 WriteError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
22769 }
22770 }
22771}
22772
22773impl ::std::error::Error for WriteError {
22774 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
22775 match self {
22776 WriteError::Conflict(inner) => Some(inner),
22777 _ => None,
22778 }
22779 }
22780}
22781
22782impl ::std::fmt::Display for WriteError {
22783 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22784 match self {
22785 WriteError::MalformedPath(inner) => write!(f, "malformed_path: {:?}", inner),
22786 WriteError::Conflict(inner) => write!(f, "Couldn't write to the target path because there was something in the way: {}", inner),
22787 WriteError::NoWritePermission => f.write_str("The user doesn't have permissions to write to the target location."),
22788 WriteError::InsufficientSpace => f.write_str("The user doesn't have enough available space (bytes) to write more data."),
22789 WriteError::DisallowedName => f.write_str("Dropbox will not save the file or folder because of its name."),
22790 WriteError::TeamFolder => f.write_str("This endpoint cannot move or delete team folders."),
22791 WriteError::OperationSuppressed => f.write_str("This file operation is not allowed at this path."),
22792 WriteError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
22793 WriteError::AccessRestricted => f.write_str("The user doesn't have permission to perform the action due to restrictions set by a team administrator"),
22794 _ => write!(f, "{:?}", *self),
22795 }
22796 }
22797}
22798
22799#[derive(Debug, Clone, PartialEq, Eq)]
22807pub enum WriteMode {
22808 Add,
22812 Overwrite,
22815 Update(Rev),
22823}
22824
22825impl<'de> ::serde::de::Deserialize<'de> for WriteMode {
22826 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22827 use serde::de::{self, MapAccess, Visitor};
22829 struct EnumVisitor;
22830 impl<'de> Visitor<'de> for EnumVisitor {
22831 type Value = WriteMode;
22832 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22833 f.write_str("a WriteMode structure")
22834 }
22835 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22836 let tag: &str = match map.next_key()? {
22837 Some(".tag") => map.next_value()?,
22838 _ => return Err(de::Error::missing_field(".tag"))
22839 };
22840 let value = match tag {
22841 "add" => WriteMode::Add,
22842 "overwrite" => WriteMode::Overwrite,
22843 "update" => {
22844 match map.next_key()? {
22845 Some("update") => WriteMode::Update(map.next_value()?),
22846 None => return Err(de::Error::missing_field("update")),
22847 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
22848 }
22849 }
22850 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
22851 };
22852 crate::eat_json_fields(&mut map)?;
22853 Ok(value)
22854 }
22855 }
22856 const VARIANTS: &[&str] = &["add",
22857 "overwrite",
22858 "update"];
22859 deserializer.deserialize_struct("WriteMode", VARIANTS, EnumVisitor)
22860 }
22861}
22862
22863impl ::serde::ser::Serialize for WriteMode {
22864 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22865 use serde::ser::SerializeStruct;
22867 match self {
22868 WriteMode::Add => {
22869 let mut s = serializer.serialize_struct("WriteMode", 1)?;
22871 s.serialize_field(".tag", "add")?;
22872 s.end()
22873 }
22874 WriteMode::Overwrite => {
22875 let mut s = serializer.serialize_struct("WriteMode", 1)?;
22877 s.serialize_field(".tag", "overwrite")?;
22878 s.end()
22879 }
22880 WriteMode::Update(x) => {
22881 let mut s = serializer.serialize_struct("WriteMode", 2)?;
22883 s.serialize_field(".tag", "update")?;
22884 s.serialize_field("update", x)?;
22885 s.end()
22886 }
22887 }
22888 }
22889}
22890