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 #[deprecated]
254 pub include_property_templates: Option<Vec<crate::types::file_properties::TemplateId>>,
255}
256
257impl AlphaGetMetadataArg {
258 pub fn new(path: ReadPath) -> Self {
259 AlphaGetMetadataArg {
260 path,
261 include_media_info: false,
262 include_deleted: false,
263 include_has_explicit_shared_members: false,
264 include_property_groups: None,
265 #[allow(deprecated)] include_property_templates: None,
266 }
267 }
268
269 pub fn with_include_media_info(mut self, value: bool) -> Self {
270 self.include_media_info = value;
271 self
272 }
273
274 pub fn with_include_deleted(mut self, value: bool) -> Self {
275 self.include_deleted = value;
276 self
277 }
278
279 pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
280 self.include_has_explicit_shared_members = value;
281 self
282 }
283
284 pub fn with_include_property_groups(
285 mut self,
286 value: crate::types::file_properties::TemplateFilterBase,
287 ) -> Self {
288 self.include_property_groups = Some(value);
289 self
290 }
291
292 #[deprecated]
293 #[allow(deprecated)]
294 pub fn with_include_property_templates(
295 mut self,
296 value: Vec<crate::types::file_properties::TemplateId>,
297 ) -> Self {
298 self.include_property_templates = Some(value);
299 self
300 }
301}
302
303const ALPHA_GET_METADATA_ARG_FIELDS: &[&str] = &["path",
304 "include_media_info",
305 "include_deleted",
306 "include_has_explicit_shared_members",
307 "include_property_groups",
308 "include_property_templates"];
309impl AlphaGetMetadataArg {
310 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
311 map: V,
312 ) -> Result<AlphaGetMetadataArg, V::Error> {
313 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
314 }
315
316 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
317 mut map: V,
318 optional: bool,
319 ) -> Result<Option<AlphaGetMetadataArg>, V::Error> {
320 let mut field_path = None;
321 let mut field_include_media_info = None;
322 let mut field_include_deleted = None;
323 let mut field_include_has_explicit_shared_members = None;
324 let mut field_include_property_groups = None;
325 let mut field_include_property_templates = None;
326 let mut nothing = true;
327 while let Some(key) = map.next_key::<&str>()? {
328 nothing = false;
329 match key {
330 "path" => {
331 if field_path.is_some() {
332 return Err(::serde::de::Error::duplicate_field("path"));
333 }
334 field_path = Some(map.next_value()?);
335 }
336 "include_media_info" => {
337 if field_include_media_info.is_some() {
338 return Err(::serde::de::Error::duplicate_field("include_media_info"));
339 }
340 field_include_media_info = Some(map.next_value()?);
341 }
342 "include_deleted" => {
343 if field_include_deleted.is_some() {
344 return Err(::serde::de::Error::duplicate_field("include_deleted"));
345 }
346 field_include_deleted = Some(map.next_value()?);
347 }
348 "include_has_explicit_shared_members" => {
349 if field_include_has_explicit_shared_members.is_some() {
350 return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
351 }
352 field_include_has_explicit_shared_members = Some(map.next_value()?);
353 }
354 "include_property_groups" => {
355 if field_include_property_groups.is_some() {
356 return Err(::serde::de::Error::duplicate_field("include_property_groups"));
357 }
358 field_include_property_groups = Some(map.next_value()?);
359 }
360 "include_property_templates" => {
361 if field_include_property_templates.is_some() {
362 return Err(::serde::de::Error::duplicate_field("include_property_templates"));
363 }
364 field_include_property_templates = Some(map.next_value()?);
365 }
366 _ => {
367 map.next_value::<::serde_json::Value>()?;
369 }
370 }
371 }
372 if optional && nothing {
373 return Ok(None);
374 }
375 let result = AlphaGetMetadataArg {
376 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
377 include_media_info: field_include_media_info.unwrap_or(false),
378 include_deleted: field_include_deleted.unwrap_or(false),
379 include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
380 include_property_groups: field_include_property_groups.and_then(Option::flatten),
381 #[allow(deprecated)] include_property_templates: field_include_property_templates.and_then(Option::flatten),
382 };
383 Ok(Some(result))
384 }
385
386 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
387 &self,
388 s: &mut S::SerializeStruct,
389 ) -> Result<(), S::Error> {
390 use serde::ser::SerializeStruct;
391 s.serialize_field("path", &self.path)?;
392 if self.include_media_info {
393 s.serialize_field("include_media_info", &self.include_media_info)?;
394 }
395 if self.include_deleted {
396 s.serialize_field("include_deleted", &self.include_deleted)?;
397 }
398 if self.include_has_explicit_shared_members {
399 s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
400 }
401 if let Some(val) = &self.include_property_groups {
402 s.serialize_field("include_property_groups", val)?;
403 }
404 #[allow(deprecated)]
405 if let Some(val) = &self.include_property_templates {
406 s.serialize_field("include_property_templates", val)?;
407 }
408 Ok(())
409 }
410}
411
412impl<'de> ::serde::de::Deserialize<'de> for AlphaGetMetadataArg {
413 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
414 use serde::de::{MapAccess, Visitor};
416 struct StructVisitor;
417 impl<'de> Visitor<'de> for StructVisitor {
418 type Value = AlphaGetMetadataArg;
419 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
420 f.write_str("a AlphaGetMetadataArg struct")
421 }
422 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
423 AlphaGetMetadataArg::internal_deserialize(map)
424 }
425 }
426 deserializer.deserialize_struct("AlphaGetMetadataArg", ALPHA_GET_METADATA_ARG_FIELDS, StructVisitor)
427 }
428}
429
430impl ::serde::ser::Serialize for AlphaGetMetadataArg {
431 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
432 use serde::ser::SerializeStruct;
434 let mut s = serializer.serialize_struct("AlphaGetMetadataArg", 6)?;
435 self.internal_serialize::<S>(&mut s)?;
436 s.end()
437 }
438}
439
440impl From<AlphaGetMetadataArg> for GetMetadataArg {
442 fn from(subtype: AlphaGetMetadataArg) -> Self {
443 Self {
444 path: subtype.path,
445 include_media_info: subtype.include_media_info,
446 include_deleted: subtype.include_deleted,
447 include_has_explicit_shared_members: subtype.include_has_explicit_shared_members,
448 include_property_groups: subtype.include_property_groups,
449 }
450 }
451}
452#[derive(Debug, Clone, PartialEq, Eq)]
453pub enum AlphaGetMetadataError {
454 Path(LookupError),
455 PropertiesError(crate::types::file_properties::LookUpPropertiesError),
456}
457
458impl<'de> ::serde::de::Deserialize<'de> for AlphaGetMetadataError {
459 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
460 use serde::de::{self, MapAccess, Visitor};
462 struct EnumVisitor;
463 impl<'de> Visitor<'de> for EnumVisitor {
464 type Value = AlphaGetMetadataError;
465 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
466 f.write_str("a AlphaGetMetadataError structure")
467 }
468 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
469 let tag: &str = match map.next_key()? {
470 Some(".tag") => map.next_value()?,
471 _ => return Err(de::Error::missing_field(".tag"))
472 };
473 let value = match tag {
474 "path" => {
475 match map.next_key()? {
476 Some("path") => AlphaGetMetadataError::Path(map.next_value()?),
477 None => return Err(de::Error::missing_field("path")),
478 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
479 }
480 }
481 "properties_error" => {
482 match map.next_key()? {
483 Some("properties_error") => AlphaGetMetadataError::PropertiesError(map.next_value()?),
484 None => return Err(de::Error::missing_field("properties_error")),
485 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
486 }
487 }
488 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
489 };
490 crate::eat_json_fields(&mut map)?;
491 Ok(value)
492 }
493 }
494 const VARIANTS: &[&str] = &["path",
495 "properties_error"];
496 deserializer.deserialize_struct("AlphaGetMetadataError", VARIANTS, EnumVisitor)
497 }
498}
499
500impl ::serde::ser::Serialize for AlphaGetMetadataError {
501 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
502 use serde::ser::SerializeStruct;
504 match self {
505 AlphaGetMetadataError::Path(x) => {
506 let mut s = serializer.serialize_struct("AlphaGetMetadataError", 2)?;
508 s.serialize_field(".tag", "path")?;
509 s.serialize_field("path", x)?;
510 s.end()
511 }
512 AlphaGetMetadataError::PropertiesError(x) => {
513 let mut s = serializer.serialize_struct("AlphaGetMetadataError", 2)?;
515 s.serialize_field(".tag", "properties_error")?;
516 s.serialize_field("properties_error", x)?;
517 s.end()
518 }
519 }
520 }
521}
522
523impl ::std::error::Error for AlphaGetMetadataError {
524 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
525 match self {
526 AlphaGetMetadataError::Path(inner) => Some(inner),
527 AlphaGetMetadataError::PropertiesError(inner) => Some(inner),
528 }
529 }
530}
531
532impl ::std::fmt::Display for AlphaGetMetadataError {
533 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
534 match self {
535 AlphaGetMetadataError::Path(inner) => write!(f, "AlphaGetMetadataError: {}", inner),
536 AlphaGetMetadataError::PropertiesError(inner) => write!(f, "AlphaGetMetadataError: {}", inner),
537 }
538 }
539}
540
541impl From<GetMetadataError> for AlphaGetMetadataError {
543 fn from(parent: GetMetadataError) -> Self {
544 match parent {
545 GetMetadataError::Path(x) => AlphaGetMetadataError::Path(x),
546 }
547 }
548}
549#[derive(Debug, Clone, PartialEq, Eq)]
550#[non_exhaustive] pub enum BaseTagError {
552 Path(LookupError),
553 Other,
556}
557
558impl<'de> ::serde::de::Deserialize<'de> for BaseTagError {
559 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
560 use serde::de::{self, MapAccess, Visitor};
562 struct EnumVisitor;
563 impl<'de> Visitor<'de> for EnumVisitor {
564 type Value = BaseTagError;
565 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
566 f.write_str("a BaseTagError structure")
567 }
568 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
569 let tag: &str = match map.next_key()? {
570 Some(".tag") => map.next_value()?,
571 _ => return Err(de::Error::missing_field(".tag"))
572 };
573 let value = match tag {
574 "path" => {
575 match map.next_key()? {
576 Some("path") => BaseTagError::Path(map.next_value()?),
577 None => return Err(de::Error::missing_field("path")),
578 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
579 }
580 }
581 _ => BaseTagError::Other,
582 };
583 crate::eat_json_fields(&mut map)?;
584 Ok(value)
585 }
586 }
587 const VARIANTS: &[&str] = &["path",
588 "other"];
589 deserializer.deserialize_struct("BaseTagError", VARIANTS, EnumVisitor)
590 }
591}
592
593impl ::serde::ser::Serialize for BaseTagError {
594 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
595 use serde::ser::SerializeStruct;
597 match self {
598 BaseTagError::Path(x) => {
599 let mut s = serializer.serialize_struct("BaseTagError", 2)?;
601 s.serialize_field(".tag", "path")?;
602 s.serialize_field("path", x)?;
603 s.end()
604 }
605 BaseTagError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
606 }
607 }
608}
609
610impl ::std::error::Error for BaseTagError {
611 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
612 match self {
613 BaseTagError::Path(inner) => Some(inner),
614 _ => None,
615 }
616 }
617}
618
619impl ::std::fmt::Display for BaseTagError {
620 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
621 match self {
622 BaseTagError::Path(inner) => write!(f, "BaseTagError: {}", inner),
623 _ => write!(f, "{:?}", *self),
624 }
625 }
626}
627
628#[derive(Debug, Clone, PartialEq, Eq)]
629#[non_exhaustive] pub struct CommitInfo {
631 pub path: WritePathOrId,
633 pub mode: WriteMode,
635 pub autorename: bool,
638 pub client_modified: Option<crate::types::common::DropboxTimestamp>,
643 pub mute: bool,
647 pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
649 pub strict_conflict: bool,
654}
655
656impl CommitInfo {
657 pub fn new(path: WritePathOrId) -> Self {
658 CommitInfo {
659 path,
660 mode: WriteMode::Add,
661 autorename: false,
662 client_modified: None,
663 mute: false,
664 property_groups: None,
665 strict_conflict: false,
666 }
667 }
668
669 pub fn with_mode(mut self, value: WriteMode) -> Self {
670 self.mode = value;
671 self
672 }
673
674 pub fn with_autorename(mut self, value: bool) -> Self {
675 self.autorename = value;
676 self
677 }
678
679 pub fn with_client_modified(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
680 self.client_modified = Some(value);
681 self
682 }
683
684 pub fn with_mute(mut self, value: bool) -> Self {
685 self.mute = value;
686 self
687 }
688
689 pub fn with_property_groups(
690 mut self,
691 value: Vec<crate::types::file_properties::PropertyGroup>,
692 ) -> Self {
693 self.property_groups = Some(value);
694 self
695 }
696
697 pub fn with_strict_conflict(mut self, value: bool) -> Self {
698 self.strict_conflict = value;
699 self
700 }
701}
702
703const COMMIT_INFO_FIELDS: &[&str] = &["path",
704 "mode",
705 "autorename",
706 "client_modified",
707 "mute",
708 "property_groups",
709 "strict_conflict"];
710impl CommitInfo {
711 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
712 map: V,
713 ) -> Result<CommitInfo, V::Error> {
714 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
715 }
716
717 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
718 mut map: V,
719 optional: bool,
720 ) -> Result<Option<CommitInfo>, V::Error> {
721 let mut field_path = None;
722 let mut field_mode = None;
723 let mut field_autorename = None;
724 let mut field_client_modified = None;
725 let mut field_mute = None;
726 let mut field_property_groups = None;
727 let mut field_strict_conflict = None;
728 let mut nothing = true;
729 while let Some(key) = map.next_key::<&str>()? {
730 nothing = false;
731 match key {
732 "path" => {
733 if field_path.is_some() {
734 return Err(::serde::de::Error::duplicate_field("path"));
735 }
736 field_path = Some(map.next_value()?);
737 }
738 "mode" => {
739 if field_mode.is_some() {
740 return Err(::serde::de::Error::duplicate_field("mode"));
741 }
742 field_mode = Some(map.next_value()?);
743 }
744 "autorename" => {
745 if field_autorename.is_some() {
746 return Err(::serde::de::Error::duplicate_field("autorename"));
747 }
748 field_autorename = Some(map.next_value()?);
749 }
750 "client_modified" => {
751 if field_client_modified.is_some() {
752 return Err(::serde::de::Error::duplicate_field("client_modified"));
753 }
754 field_client_modified = Some(map.next_value()?);
755 }
756 "mute" => {
757 if field_mute.is_some() {
758 return Err(::serde::de::Error::duplicate_field("mute"));
759 }
760 field_mute = Some(map.next_value()?);
761 }
762 "property_groups" => {
763 if field_property_groups.is_some() {
764 return Err(::serde::de::Error::duplicate_field("property_groups"));
765 }
766 field_property_groups = Some(map.next_value()?);
767 }
768 "strict_conflict" => {
769 if field_strict_conflict.is_some() {
770 return Err(::serde::de::Error::duplicate_field("strict_conflict"));
771 }
772 field_strict_conflict = Some(map.next_value()?);
773 }
774 _ => {
775 map.next_value::<::serde_json::Value>()?;
777 }
778 }
779 }
780 if optional && nothing {
781 return Ok(None);
782 }
783 let result = CommitInfo {
784 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
785 mode: field_mode.unwrap_or(WriteMode::Add),
786 autorename: field_autorename.unwrap_or(false),
787 client_modified: field_client_modified.and_then(Option::flatten),
788 mute: field_mute.unwrap_or(false),
789 property_groups: field_property_groups.and_then(Option::flatten),
790 strict_conflict: field_strict_conflict.unwrap_or(false),
791 };
792 Ok(Some(result))
793 }
794
795 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
796 &self,
797 s: &mut S::SerializeStruct,
798 ) -> Result<(), S::Error> {
799 use serde::ser::SerializeStruct;
800 s.serialize_field("path", &self.path)?;
801 if self.mode != WriteMode::Add {
802 s.serialize_field("mode", &self.mode)?;
803 }
804 if self.autorename {
805 s.serialize_field("autorename", &self.autorename)?;
806 }
807 if let Some(val) = &self.client_modified {
808 s.serialize_field("client_modified", val)?;
809 }
810 if self.mute {
811 s.serialize_field("mute", &self.mute)?;
812 }
813 if let Some(val) = &self.property_groups {
814 s.serialize_field("property_groups", val)?;
815 }
816 if self.strict_conflict {
817 s.serialize_field("strict_conflict", &self.strict_conflict)?;
818 }
819 Ok(())
820 }
821}
822
823impl<'de> ::serde::de::Deserialize<'de> for CommitInfo {
824 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
825 use serde::de::{MapAccess, Visitor};
827 struct StructVisitor;
828 impl<'de> Visitor<'de> for StructVisitor {
829 type Value = CommitInfo;
830 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
831 f.write_str("a CommitInfo struct")
832 }
833 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
834 CommitInfo::internal_deserialize(map)
835 }
836 }
837 deserializer.deserialize_struct("CommitInfo", COMMIT_INFO_FIELDS, StructVisitor)
838 }
839}
840
841impl ::serde::ser::Serialize for CommitInfo {
842 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
843 use serde::ser::SerializeStruct;
845 let mut s = serializer.serialize_struct("CommitInfo", 7)?;
846 self.internal_serialize::<S>(&mut s)?;
847 s.end()
848 }
849}
850
851#[derive(Debug, Clone, PartialEq, Eq)]
852#[non_exhaustive] pub struct ContentSyncSetting {
854 pub id: FileId,
856 pub sync_setting: SyncSetting,
858}
859
860impl ContentSyncSetting {
861 pub fn new(id: FileId, sync_setting: SyncSetting) -> Self {
862 ContentSyncSetting {
863 id,
864 sync_setting,
865 }
866 }
867}
868
869const CONTENT_SYNC_SETTING_FIELDS: &[&str] = &["id",
870 "sync_setting"];
871impl ContentSyncSetting {
872 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
873 map: V,
874 ) -> Result<ContentSyncSetting, V::Error> {
875 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
876 }
877
878 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
879 mut map: V,
880 optional: bool,
881 ) -> Result<Option<ContentSyncSetting>, V::Error> {
882 let mut field_id = None;
883 let mut field_sync_setting = None;
884 let mut nothing = true;
885 while let Some(key) = map.next_key::<&str>()? {
886 nothing = false;
887 match key {
888 "id" => {
889 if field_id.is_some() {
890 return Err(::serde::de::Error::duplicate_field("id"));
891 }
892 field_id = Some(map.next_value()?);
893 }
894 "sync_setting" => {
895 if field_sync_setting.is_some() {
896 return Err(::serde::de::Error::duplicate_field("sync_setting"));
897 }
898 field_sync_setting = Some(map.next_value()?);
899 }
900 _ => {
901 map.next_value::<::serde_json::Value>()?;
903 }
904 }
905 }
906 if optional && nothing {
907 return Ok(None);
908 }
909 let result = ContentSyncSetting {
910 id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
911 sync_setting: field_sync_setting.ok_or_else(|| ::serde::de::Error::missing_field("sync_setting"))?,
912 };
913 Ok(Some(result))
914 }
915
916 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
917 &self,
918 s: &mut S::SerializeStruct,
919 ) -> Result<(), S::Error> {
920 use serde::ser::SerializeStruct;
921 s.serialize_field("id", &self.id)?;
922 s.serialize_field("sync_setting", &self.sync_setting)?;
923 Ok(())
924 }
925}
926
927impl<'de> ::serde::de::Deserialize<'de> for ContentSyncSetting {
928 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
929 use serde::de::{MapAccess, Visitor};
931 struct StructVisitor;
932 impl<'de> Visitor<'de> for StructVisitor {
933 type Value = ContentSyncSetting;
934 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
935 f.write_str("a ContentSyncSetting struct")
936 }
937 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
938 ContentSyncSetting::internal_deserialize(map)
939 }
940 }
941 deserializer.deserialize_struct("ContentSyncSetting", CONTENT_SYNC_SETTING_FIELDS, StructVisitor)
942 }
943}
944
945impl ::serde::ser::Serialize for ContentSyncSetting {
946 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
947 use serde::ser::SerializeStruct;
949 let mut s = serializer.serialize_struct("ContentSyncSetting", 2)?;
950 self.internal_serialize::<S>(&mut s)?;
951 s.end()
952 }
953}
954
955#[derive(Debug, Clone, PartialEq, Eq)]
956#[non_exhaustive] pub struct ContentSyncSettingArg {
958 pub id: FileId,
960 pub sync_setting: SyncSettingArg,
962}
963
964impl ContentSyncSettingArg {
965 pub fn new(id: FileId, sync_setting: SyncSettingArg) -> Self {
966 ContentSyncSettingArg {
967 id,
968 sync_setting,
969 }
970 }
971}
972
973const CONTENT_SYNC_SETTING_ARG_FIELDS: &[&str] = &["id",
974 "sync_setting"];
975impl ContentSyncSettingArg {
976 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
977 map: V,
978 ) -> Result<ContentSyncSettingArg, V::Error> {
979 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
980 }
981
982 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
983 mut map: V,
984 optional: bool,
985 ) -> Result<Option<ContentSyncSettingArg>, V::Error> {
986 let mut field_id = None;
987 let mut field_sync_setting = None;
988 let mut nothing = true;
989 while let Some(key) = map.next_key::<&str>()? {
990 nothing = false;
991 match key {
992 "id" => {
993 if field_id.is_some() {
994 return Err(::serde::de::Error::duplicate_field("id"));
995 }
996 field_id = Some(map.next_value()?);
997 }
998 "sync_setting" => {
999 if field_sync_setting.is_some() {
1000 return Err(::serde::de::Error::duplicate_field("sync_setting"));
1001 }
1002 field_sync_setting = Some(map.next_value()?);
1003 }
1004 _ => {
1005 map.next_value::<::serde_json::Value>()?;
1007 }
1008 }
1009 }
1010 if optional && nothing {
1011 return Ok(None);
1012 }
1013 let result = ContentSyncSettingArg {
1014 id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
1015 sync_setting: field_sync_setting.ok_or_else(|| ::serde::de::Error::missing_field("sync_setting"))?,
1016 };
1017 Ok(Some(result))
1018 }
1019
1020 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1021 &self,
1022 s: &mut S::SerializeStruct,
1023 ) -> Result<(), S::Error> {
1024 use serde::ser::SerializeStruct;
1025 s.serialize_field("id", &self.id)?;
1026 s.serialize_field("sync_setting", &self.sync_setting)?;
1027 Ok(())
1028 }
1029}
1030
1031impl<'de> ::serde::de::Deserialize<'de> for ContentSyncSettingArg {
1032 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1033 use serde::de::{MapAccess, Visitor};
1035 struct StructVisitor;
1036 impl<'de> Visitor<'de> for StructVisitor {
1037 type Value = ContentSyncSettingArg;
1038 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1039 f.write_str("a ContentSyncSettingArg struct")
1040 }
1041 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1042 ContentSyncSettingArg::internal_deserialize(map)
1043 }
1044 }
1045 deserializer.deserialize_struct("ContentSyncSettingArg", CONTENT_SYNC_SETTING_ARG_FIELDS, StructVisitor)
1046 }
1047}
1048
1049impl ::serde::ser::Serialize for ContentSyncSettingArg {
1050 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1051 use serde::ser::SerializeStruct;
1053 let mut s = serializer.serialize_struct("ContentSyncSettingArg", 2)?;
1054 self.internal_serialize::<S>(&mut s)?;
1055 s.end()
1056 }
1057}
1058
1059#[derive(Debug, Clone, PartialEq, Eq)]
1060#[non_exhaustive] pub struct CreateFolderArg {
1062 pub path: WritePath,
1064 pub autorename: bool,
1067}
1068
1069impl CreateFolderArg {
1070 pub fn new(path: WritePath) -> Self {
1071 CreateFolderArg {
1072 path,
1073 autorename: false,
1074 }
1075 }
1076
1077 pub fn with_autorename(mut self, value: bool) -> Self {
1078 self.autorename = value;
1079 self
1080 }
1081}
1082
1083const CREATE_FOLDER_ARG_FIELDS: &[&str] = &["path",
1084 "autorename"];
1085impl CreateFolderArg {
1086 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1087 map: V,
1088 ) -> Result<CreateFolderArg, V::Error> {
1089 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1090 }
1091
1092 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1093 mut map: V,
1094 optional: bool,
1095 ) -> Result<Option<CreateFolderArg>, V::Error> {
1096 let mut field_path = None;
1097 let mut field_autorename = None;
1098 let mut nothing = true;
1099 while let Some(key) = map.next_key::<&str>()? {
1100 nothing = false;
1101 match key {
1102 "path" => {
1103 if field_path.is_some() {
1104 return Err(::serde::de::Error::duplicate_field("path"));
1105 }
1106 field_path = Some(map.next_value()?);
1107 }
1108 "autorename" => {
1109 if field_autorename.is_some() {
1110 return Err(::serde::de::Error::duplicate_field("autorename"));
1111 }
1112 field_autorename = Some(map.next_value()?);
1113 }
1114 _ => {
1115 map.next_value::<::serde_json::Value>()?;
1117 }
1118 }
1119 }
1120 if optional && nothing {
1121 return Ok(None);
1122 }
1123 let result = CreateFolderArg {
1124 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
1125 autorename: field_autorename.unwrap_or(false),
1126 };
1127 Ok(Some(result))
1128 }
1129
1130 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1131 &self,
1132 s: &mut S::SerializeStruct,
1133 ) -> Result<(), S::Error> {
1134 use serde::ser::SerializeStruct;
1135 s.serialize_field("path", &self.path)?;
1136 if self.autorename {
1137 s.serialize_field("autorename", &self.autorename)?;
1138 }
1139 Ok(())
1140 }
1141}
1142
1143impl<'de> ::serde::de::Deserialize<'de> for CreateFolderArg {
1144 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1145 use serde::de::{MapAccess, Visitor};
1147 struct StructVisitor;
1148 impl<'de> Visitor<'de> for StructVisitor {
1149 type Value = CreateFolderArg;
1150 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1151 f.write_str("a CreateFolderArg struct")
1152 }
1153 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1154 CreateFolderArg::internal_deserialize(map)
1155 }
1156 }
1157 deserializer.deserialize_struct("CreateFolderArg", CREATE_FOLDER_ARG_FIELDS, StructVisitor)
1158 }
1159}
1160
1161impl ::serde::ser::Serialize for CreateFolderArg {
1162 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1163 use serde::ser::SerializeStruct;
1165 let mut s = serializer.serialize_struct("CreateFolderArg", 2)?;
1166 self.internal_serialize::<S>(&mut s)?;
1167 s.end()
1168 }
1169}
1170
1171#[derive(Debug, Clone, PartialEq, Eq)]
1172#[non_exhaustive] pub struct CreateFolderBatchArg {
1174 pub paths: Vec<WritePath>,
1177 pub autorename: bool,
1180 pub force_async: bool,
1182}
1183
1184impl CreateFolderBatchArg {
1185 pub fn new(paths: Vec<WritePath>) -> Self {
1186 CreateFolderBatchArg {
1187 paths,
1188 autorename: false,
1189 force_async: false,
1190 }
1191 }
1192
1193 pub fn with_autorename(mut self, value: bool) -> Self {
1194 self.autorename = value;
1195 self
1196 }
1197
1198 pub fn with_force_async(mut self, value: bool) -> Self {
1199 self.force_async = value;
1200 self
1201 }
1202}
1203
1204const CREATE_FOLDER_BATCH_ARG_FIELDS: &[&str] = &["paths",
1205 "autorename",
1206 "force_async"];
1207impl CreateFolderBatchArg {
1208 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1209 map: V,
1210 ) -> Result<CreateFolderBatchArg, V::Error> {
1211 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1212 }
1213
1214 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1215 mut map: V,
1216 optional: bool,
1217 ) -> Result<Option<CreateFolderBatchArg>, V::Error> {
1218 let mut field_paths = None;
1219 let mut field_autorename = None;
1220 let mut field_force_async = None;
1221 let mut nothing = true;
1222 while let Some(key) = map.next_key::<&str>()? {
1223 nothing = false;
1224 match key {
1225 "paths" => {
1226 if field_paths.is_some() {
1227 return Err(::serde::de::Error::duplicate_field("paths"));
1228 }
1229 field_paths = Some(map.next_value()?);
1230 }
1231 "autorename" => {
1232 if field_autorename.is_some() {
1233 return Err(::serde::de::Error::duplicate_field("autorename"));
1234 }
1235 field_autorename = Some(map.next_value()?);
1236 }
1237 "force_async" => {
1238 if field_force_async.is_some() {
1239 return Err(::serde::de::Error::duplicate_field("force_async"));
1240 }
1241 field_force_async = Some(map.next_value()?);
1242 }
1243 _ => {
1244 map.next_value::<::serde_json::Value>()?;
1246 }
1247 }
1248 }
1249 if optional && nothing {
1250 return Ok(None);
1251 }
1252 let result = CreateFolderBatchArg {
1253 paths: field_paths.ok_or_else(|| ::serde::de::Error::missing_field("paths"))?,
1254 autorename: field_autorename.unwrap_or(false),
1255 force_async: field_force_async.unwrap_or(false),
1256 };
1257 Ok(Some(result))
1258 }
1259
1260 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1261 &self,
1262 s: &mut S::SerializeStruct,
1263 ) -> Result<(), S::Error> {
1264 use serde::ser::SerializeStruct;
1265 s.serialize_field("paths", &self.paths)?;
1266 if self.autorename {
1267 s.serialize_field("autorename", &self.autorename)?;
1268 }
1269 if self.force_async {
1270 s.serialize_field("force_async", &self.force_async)?;
1271 }
1272 Ok(())
1273 }
1274}
1275
1276impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchArg {
1277 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1278 use serde::de::{MapAccess, Visitor};
1280 struct StructVisitor;
1281 impl<'de> Visitor<'de> for StructVisitor {
1282 type Value = CreateFolderBatchArg;
1283 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1284 f.write_str("a CreateFolderBatchArg struct")
1285 }
1286 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1287 CreateFolderBatchArg::internal_deserialize(map)
1288 }
1289 }
1290 deserializer.deserialize_struct("CreateFolderBatchArg", CREATE_FOLDER_BATCH_ARG_FIELDS, StructVisitor)
1291 }
1292}
1293
1294impl ::serde::ser::Serialize for CreateFolderBatchArg {
1295 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1296 use serde::ser::SerializeStruct;
1298 let mut s = serializer.serialize_struct("CreateFolderBatchArg", 3)?;
1299 self.internal_serialize::<S>(&mut s)?;
1300 s.end()
1301 }
1302}
1303
1304#[derive(Debug, Clone, PartialEq, Eq)]
1305#[non_exhaustive] pub enum CreateFolderBatchError {
1307 TooManyFiles,
1309 Other,
1312}
1313
1314impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchError {
1315 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1316 use serde::de::{self, MapAccess, Visitor};
1318 struct EnumVisitor;
1319 impl<'de> Visitor<'de> for EnumVisitor {
1320 type Value = CreateFolderBatchError;
1321 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1322 f.write_str("a CreateFolderBatchError structure")
1323 }
1324 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1325 let tag: &str = match map.next_key()? {
1326 Some(".tag") => map.next_value()?,
1327 _ => return Err(de::Error::missing_field(".tag"))
1328 };
1329 let value = match tag {
1330 "too_many_files" => CreateFolderBatchError::TooManyFiles,
1331 _ => CreateFolderBatchError::Other,
1332 };
1333 crate::eat_json_fields(&mut map)?;
1334 Ok(value)
1335 }
1336 }
1337 const VARIANTS: &[&str] = &["too_many_files",
1338 "other"];
1339 deserializer.deserialize_struct("CreateFolderBatchError", VARIANTS, EnumVisitor)
1340 }
1341}
1342
1343impl ::serde::ser::Serialize for CreateFolderBatchError {
1344 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1345 use serde::ser::SerializeStruct;
1347 match self {
1348 CreateFolderBatchError::TooManyFiles => {
1349 let mut s = serializer.serialize_struct("CreateFolderBatchError", 1)?;
1351 s.serialize_field(".tag", "too_many_files")?;
1352 s.end()
1353 }
1354 CreateFolderBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1355 }
1356 }
1357}
1358
1359impl ::std::error::Error for CreateFolderBatchError {
1360}
1361
1362impl ::std::fmt::Display for CreateFolderBatchError {
1363 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1364 match self {
1365 CreateFolderBatchError::TooManyFiles => f.write_str("The operation would involve too many files or folders."),
1366 _ => write!(f, "{:?}", *self),
1367 }
1368 }
1369}
1370
1371#[derive(Debug, Clone, PartialEq, Eq)]
1372#[non_exhaustive] pub enum CreateFolderBatchJobStatus {
1374 InProgress,
1376 Complete(CreateFolderBatchResult),
1378 Failed(CreateFolderBatchError),
1380 Other,
1383}
1384
1385impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchJobStatus {
1386 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1387 use serde::de::{self, MapAccess, Visitor};
1389 struct EnumVisitor;
1390 impl<'de> Visitor<'de> for EnumVisitor {
1391 type Value = CreateFolderBatchJobStatus;
1392 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1393 f.write_str("a CreateFolderBatchJobStatus structure")
1394 }
1395 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1396 let tag: &str = match map.next_key()? {
1397 Some(".tag") => map.next_value()?,
1398 _ => return Err(de::Error::missing_field(".tag"))
1399 };
1400 let value = match tag {
1401 "in_progress" => CreateFolderBatchJobStatus::InProgress,
1402 "complete" => CreateFolderBatchJobStatus::Complete(CreateFolderBatchResult::internal_deserialize(&mut map)?),
1403 "failed" => {
1404 match map.next_key()? {
1405 Some("failed") => CreateFolderBatchJobStatus::Failed(map.next_value()?),
1406 None => return Err(de::Error::missing_field("failed")),
1407 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1408 }
1409 }
1410 _ => CreateFolderBatchJobStatus::Other,
1411 };
1412 crate::eat_json_fields(&mut map)?;
1413 Ok(value)
1414 }
1415 }
1416 const VARIANTS: &[&str] = &["in_progress",
1417 "complete",
1418 "failed",
1419 "other"];
1420 deserializer.deserialize_struct("CreateFolderBatchJobStatus", VARIANTS, EnumVisitor)
1421 }
1422}
1423
1424impl ::serde::ser::Serialize for CreateFolderBatchJobStatus {
1425 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1426 use serde::ser::SerializeStruct;
1428 match self {
1429 CreateFolderBatchJobStatus::InProgress => {
1430 let mut s = serializer.serialize_struct("CreateFolderBatchJobStatus", 1)?;
1432 s.serialize_field(".tag", "in_progress")?;
1433 s.end()
1434 }
1435 CreateFolderBatchJobStatus::Complete(x) => {
1436 let mut s = serializer.serialize_struct("CreateFolderBatchJobStatus", 2)?;
1438 s.serialize_field(".tag", "complete")?;
1439 x.internal_serialize::<S>(&mut s)?;
1440 s.end()
1441 }
1442 CreateFolderBatchJobStatus::Failed(x) => {
1443 let mut s = serializer.serialize_struct("CreateFolderBatchJobStatus", 2)?;
1445 s.serialize_field(".tag", "failed")?;
1446 s.serialize_field("failed", x)?;
1447 s.end()
1448 }
1449 CreateFolderBatchJobStatus::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1450 }
1451 }
1452}
1453
1454impl From<crate::types::dbx_async::PollResultBase> for CreateFolderBatchJobStatus {
1456 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
1457 match parent {
1458 crate::types::dbx_async::PollResultBase::InProgress => CreateFolderBatchJobStatus::InProgress,
1459 }
1460 }
1461}
1462#[derive(Debug, Clone, PartialEq, Eq)]
1465#[non_exhaustive] pub enum CreateFolderBatchLaunch {
1467 AsyncJobId(crate::types::dbx_async::AsyncJobId),
1470 Complete(CreateFolderBatchResult),
1471 Other,
1474}
1475
1476impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchLaunch {
1477 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1478 use serde::de::{self, MapAccess, Visitor};
1480 struct EnumVisitor;
1481 impl<'de> Visitor<'de> for EnumVisitor {
1482 type Value = CreateFolderBatchLaunch;
1483 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1484 f.write_str("a CreateFolderBatchLaunch structure")
1485 }
1486 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1487 let tag: &str = match map.next_key()? {
1488 Some(".tag") => map.next_value()?,
1489 _ => return Err(de::Error::missing_field(".tag"))
1490 };
1491 let value = match tag {
1492 "async_job_id" => {
1493 match map.next_key()? {
1494 Some("async_job_id") => CreateFolderBatchLaunch::AsyncJobId(map.next_value()?),
1495 None => return Err(de::Error::missing_field("async_job_id")),
1496 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1497 }
1498 }
1499 "complete" => CreateFolderBatchLaunch::Complete(CreateFolderBatchResult::internal_deserialize(&mut map)?),
1500 _ => CreateFolderBatchLaunch::Other,
1501 };
1502 crate::eat_json_fields(&mut map)?;
1503 Ok(value)
1504 }
1505 }
1506 const VARIANTS: &[&str] = &["async_job_id",
1507 "complete",
1508 "other"];
1509 deserializer.deserialize_struct("CreateFolderBatchLaunch", VARIANTS, EnumVisitor)
1510 }
1511}
1512
1513impl ::serde::ser::Serialize for CreateFolderBatchLaunch {
1514 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1515 use serde::ser::SerializeStruct;
1517 match self {
1518 CreateFolderBatchLaunch::AsyncJobId(x) => {
1519 let mut s = serializer.serialize_struct("CreateFolderBatchLaunch", 2)?;
1521 s.serialize_field(".tag", "async_job_id")?;
1522 s.serialize_field("async_job_id", x)?;
1523 s.end()
1524 }
1525 CreateFolderBatchLaunch::Complete(x) => {
1526 let mut s = serializer.serialize_struct("CreateFolderBatchLaunch", 2)?;
1528 s.serialize_field(".tag", "complete")?;
1529 x.internal_serialize::<S>(&mut s)?;
1530 s.end()
1531 }
1532 CreateFolderBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1533 }
1534 }
1535}
1536
1537impl From<crate::types::dbx_async::LaunchResultBase> for CreateFolderBatchLaunch {
1539 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
1540 match parent {
1541 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => CreateFolderBatchLaunch::AsyncJobId(x),
1542 }
1543 }
1544}
1545#[derive(Debug, Clone, PartialEq, Eq)]
1546#[non_exhaustive] pub struct CreateFolderBatchResult {
1548 pub entries: Vec<CreateFolderBatchResultEntry>,
1551}
1552
1553impl CreateFolderBatchResult {
1554 pub fn new(entries: Vec<CreateFolderBatchResultEntry>) -> Self {
1555 CreateFolderBatchResult {
1556 entries,
1557 }
1558 }
1559}
1560
1561const CREATE_FOLDER_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
1562impl CreateFolderBatchResult {
1563 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1564 map: V,
1565 ) -> Result<CreateFolderBatchResult, V::Error> {
1566 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1567 }
1568
1569 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1570 mut map: V,
1571 optional: bool,
1572 ) -> Result<Option<CreateFolderBatchResult>, V::Error> {
1573 let mut field_entries = None;
1574 let mut nothing = true;
1575 while let Some(key) = map.next_key::<&str>()? {
1576 nothing = false;
1577 match key {
1578 "entries" => {
1579 if field_entries.is_some() {
1580 return Err(::serde::de::Error::duplicate_field("entries"));
1581 }
1582 field_entries = Some(map.next_value()?);
1583 }
1584 _ => {
1585 map.next_value::<::serde_json::Value>()?;
1587 }
1588 }
1589 }
1590 if optional && nothing {
1591 return Ok(None);
1592 }
1593 let result = CreateFolderBatchResult {
1594 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
1595 };
1596 Ok(Some(result))
1597 }
1598
1599 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1600 &self,
1601 s: &mut S::SerializeStruct,
1602 ) -> Result<(), S::Error> {
1603 use serde::ser::SerializeStruct;
1604 s.serialize_field("entries", &self.entries)?;
1605 Ok(())
1606 }
1607}
1608
1609impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchResult {
1610 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1611 use serde::de::{MapAccess, Visitor};
1613 struct StructVisitor;
1614 impl<'de> Visitor<'de> for StructVisitor {
1615 type Value = CreateFolderBatchResult;
1616 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1617 f.write_str("a CreateFolderBatchResult struct")
1618 }
1619 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1620 CreateFolderBatchResult::internal_deserialize(map)
1621 }
1622 }
1623 deserializer.deserialize_struct("CreateFolderBatchResult", CREATE_FOLDER_BATCH_RESULT_FIELDS, StructVisitor)
1624 }
1625}
1626
1627impl ::serde::ser::Serialize for CreateFolderBatchResult {
1628 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1629 use serde::ser::SerializeStruct;
1631 let mut s = serializer.serialize_struct("CreateFolderBatchResult", 1)?;
1632 self.internal_serialize::<S>(&mut s)?;
1633 s.end()
1634 }
1635}
1636
1637impl From<CreateFolderBatchResult> for FileOpsResult {
1639 fn from(_: CreateFolderBatchResult) -> Self {
1640 Self {}
1641 }
1642}
1643#[derive(Debug, Clone, PartialEq, Eq)]
1644pub enum CreateFolderBatchResultEntry {
1645 Success(CreateFolderEntryResult),
1646 Failure(CreateFolderEntryError),
1647}
1648
1649impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchResultEntry {
1650 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1651 use serde::de::{self, MapAccess, Visitor};
1653 struct EnumVisitor;
1654 impl<'de> Visitor<'de> for EnumVisitor {
1655 type Value = CreateFolderBatchResultEntry;
1656 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1657 f.write_str("a CreateFolderBatchResultEntry structure")
1658 }
1659 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1660 let tag: &str = match map.next_key()? {
1661 Some(".tag") => map.next_value()?,
1662 _ => return Err(de::Error::missing_field(".tag"))
1663 };
1664 let value = match tag {
1665 "success" => CreateFolderBatchResultEntry::Success(CreateFolderEntryResult::internal_deserialize(&mut map)?),
1666 "failure" => {
1667 match map.next_key()? {
1668 Some("failure") => CreateFolderBatchResultEntry::Failure(map.next_value()?),
1669 None => return Err(de::Error::missing_field("failure")),
1670 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1671 }
1672 }
1673 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
1674 };
1675 crate::eat_json_fields(&mut map)?;
1676 Ok(value)
1677 }
1678 }
1679 const VARIANTS: &[&str] = &["success",
1680 "failure"];
1681 deserializer.deserialize_struct("CreateFolderBatchResultEntry", VARIANTS, EnumVisitor)
1682 }
1683}
1684
1685impl ::serde::ser::Serialize for CreateFolderBatchResultEntry {
1686 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1687 use serde::ser::SerializeStruct;
1689 match self {
1690 CreateFolderBatchResultEntry::Success(x) => {
1691 let mut s = serializer.serialize_struct("CreateFolderBatchResultEntry", 2)?;
1693 s.serialize_field(".tag", "success")?;
1694 x.internal_serialize::<S>(&mut s)?;
1695 s.end()
1696 }
1697 CreateFolderBatchResultEntry::Failure(x) => {
1698 let mut s = serializer.serialize_struct("CreateFolderBatchResultEntry", 2)?;
1700 s.serialize_field(".tag", "failure")?;
1701 s.serialize_field("failure", x)?;
1702 s.end()
1703 }
1704 }
1705 }
1706}
1707
1708#[derive(Debug, Clone, PartialEq, Eq)]
1709#[non_exhaustive] pub enum CreateFolderEntryError {
1711 Path(WriteError),
1712 Other,
1715}
1716
1717impl<'de> ::serde::de::Deserialize<'de> for CreateFolderEntryError {
1718 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1719 use serde::de::{self, MapAccess, Visitor};
1721 struct EnumVisitor;
1722 impl<'de> Visitor<'de> for EnumVisitor {
1723 type Value = CreateFolderEntryError;
1724 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1725 f.write_str("a CreateFolderEntryError structure")
1726 }
1727 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1728 let tag: &str = match map.next_key()? {
1729 Some(".tag") => map.next_value()?,
1730 _ => return Err(de::Error::missing_field(".tag"))
1731 };
1732 let value = match tag {
1733 "path" => {
1734 match map.next_key()? {
1735 Some("path") => CreateFolderEntryError::Path(map.next_value()?),
1736 None => return Err(de::Error::missing_field("path")),
1737 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1738 }
1739 }
1740 _ => CreateFolderEntryError::Other,
1741 };
1742 crate::eat_json_fields(&mut map)?;
1743 Ok(value)
1744 }
1745 }
1746 const VARIANTS: &[&str] = &["path",
1747 "other"];
1748 deserializer.deserialize_struct("CreateFolderEntryError", VARIANTS, EnumVisitor)
1749 }
1750}
1751
1752impl ::serde::ser::Serialize for CreateFolderEntryError {
1753 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1754 use serde::ser::SerializeStruct;
1756 match self {
1757 CreateFolderEntryError::Path(x) => {
1758 let mut s = serializer.serialize_struct("CreateFolderEntryError", 2)?;
1760 s.serialize_field(".tag", "path")?;
1761 s.serialize_field("path", x)?;
1762 s.end()
1763 }
1764 CreateFolderEntryError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
1765 }
1766 }
1767}
1768
1769impl ::std::error::Error for CreateFolderEntryError {
1770 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
1771 match self {
1772 CreateFolderEntryError::Path(inner) => Some(inner),
1773 _ => None,
1774 }
1775 }
1776}
1777
1778impl ::std::fmt::Display for CreateFolderEntryError {
1779 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1780 match self {
1781 CreateFolderEntryError::Path(inner) => write!(f, "CreateFolderEntryError: {}", inner),
1782 _ => write!(f, "{:?}", *self),
1783 }
1784 }
1785}
1786
1787#[derive(Debug, Clone, PartialEq, Eq)]
1788#[non_exhaustive] pub struct CreateFolderEntryResult {
1790 pub metadata: FolderMetadata,
1792}
1793
1794impl CreateFolderEntryResult {
1795 pub fn new(metadata: FolderMetadata) -> Self {
1796 CreateFolderEntryResult {
1797 metadata,
1798 }
1799 }
1800}
1801
1802const CREATE_FOLDER_ENTRY_RESULT_FIELDS: &[&str] = &["metadata"];
1803impl CreateFolderEntryResult {
1804 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1805 map: V,
1806 ) -> Result<CreateFolderEntryResult, V::Error> {
1807 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1808 }
1809
1810 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1811 mut map: V,
1812 optional: bool,
1813 ) -> Result<Option<CreateFolderEntryResult>, V::Error> {
1814 let mut field_metadata = None;
1815 let mut nothing = true;
1816 while let Some(key) = map.next_key::<&str>()? {
1817 nothing = false;
1818 match key {
1819 "metadata" => {
1820 if field_metadata.is_some() {
1821 return Err(::serde::de::Error::duplicate_field("metadata"));
1822 }
1823 field_metadata = Some(map.next_value()?);
1824 }
1825 _ => {
1826 map.next_value::<::serde_json::Value>()?;
1828 }
1829 }
1830 }
1831 if optional && nothing {
1832 return Ok(None);
1833 }
1834 let result = CreateFolderEntryResult {
1835 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
1836 };
1837 Ok(Some(result))
1838 }
1839
1840 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
1841 &self,
1842 s: &mut S::SerializeStruct,
1843 ) -> Result<(), S::Error> {
1844 use serde::ser::SerializeStruct;
1845 s.serialize_field("metadata", &self.metadata)?;
1846 Ok(())
1847 }
1848}
1849
1850impl<'de> ::serde::de::Deserialize<'de> for CreateFolderEntryResult {
1851 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1852 use serde::de::{MapAccess, Visitor};
1854 struct StructVisitor;
1855 impl<'de> Visitor<'de> for StructVisitor {
1856 type Value = CreateFolderEntryResult;
1857 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1858 f.write_str("a CreateFolderEntryResult struct")
1859 }
1860 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
1861 CreateFolderEntryResult::internal_deserialize(map)
1862 }
1863 }
1864 deserializer.deserialize_struct("CreateFolderEntryResult", CREATE_FOLDER_ENTRY_RESULT_FIELDS, StructVisitor)
1865 }
1866}
1867
1868impl ::serde::ser::Serialize for CreateFolderEntryResult {
1869 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1870 use serde::ser::SerializeStruct;
1872 let mut s = serializer.serialize_struct("CreateFolderEntryResult", 1)?;
1873 self.internal_serialize::<S>(&mut s)?;
1874 s.end()
1875 }
1876}
1877
1878#[derive(Debug, Clone, PartialEq, Eq)]
1879pub enum CreateFolderError {
1880 Path(WriteError),
1881}
1882
1883impl<'de> ::serde::de::Deserialize<'de> for CreateFolderError {
1884 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1885 use serde::de::{self, MapAccess, Visitor};
1887 struct EnumVisitor;
1888 impl<'de> Visitor<'de> for EnumVisitor {
1889 type Value = CreateFolderError;
1890 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1891 f.write_str("a CreateFolderError structure")
1892 }
1893 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
1894 let tag: &str = match map.next_key()? {
1895 Some(".tag") => map.next_value()?,
1896 _ => return Err(de::Error::missing_field(".tag"))
1897 };
1898 let value = match tag {
1899 "path" => {
1900 match map.next_key()? {
1901 Some("path") => CreateFolderError::Path(map.next_value()?),
1902 None => return Err(de::Error::missing_field("path")),
1903 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
1904 }
1905 }
1906 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
1907 };
1908 crate::eat_json_fields(&mut map)?;
1909 Ok(value)
1910 }
1911 }
1912 const VARIANTS: &[&str] = &["path"];
1913 deserializer.deserialize_struct("CreateFolderError", VARIANTS, EnumVisitor)
1914 }
1915}
1916
1917impl ::serde::ser::Serialize for CreateFolderError {
1918 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
1919 use serde::ser::SerializeStruct;
1921 match self {
1922 CreateFolderError::Path(x) => {
1923 let mut s = serializer.serialize_struct("CreateFolderError", 2)?;
1925 s.serialize_field(".tag", "path")?;
1926 s.serialize_field("path", x)?;
1927 s.end()
1928 }
1929 }
1930 }
1931}
1932
1933impl ::std::error::Error for CreateFolderError {
1934 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
1935 match self {
1936 CreateFolderError::Path(inner) => Some(inner),
1937 }
1938 }
1939}
1940
1941impl ::std::fmt::Display for CreateFolderError {
1942 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1943 match self {
1944 CreateFolderError::Path(inner) => write!(f, "CreateFolderError: {}", inner),
1945 }
1946 }
1947}
1948
1949#[derive(Debug, Clone, PartialEq, Eq)]
1950#[non_exhaustive] pub struct CreateFolderResult {
1952 pub metadata: FolderMetadata,
1954}
1955
1956impl CreateFolderResult {
1957 pub fn new(metadata: FolderMetadata) -> Self {
1958 CreateFolderResult {
1959 metadata,
1960 }
1961 }
1962}
1963
1964const CREATE_FOLDER_RESULT_FIELDS: &[&str] = &["metadata"];
1965impl CreateFolderResult {
1966 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
1967 map: V,
1968 ) -> Result<CreateFolderResult, V::Error> {
1969 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
1970 }
1971
1972 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
1973 mut map: V,
1974 optional: bool,
1975 ) -> Result<Option<CreateFolderResult>, V::Error> {
1976 let mut field_metadata = None;
1977 let mut nothing = true;
1978 while let Some(key) = map.next_key::<&str>()? {
1979 nothing = false;
1980 match key {
1981 "metadata" => {
1982 if field_metadata.is_some() {
1983 return Err(::serde::de::Error::duplicate_field("metadata"));
1984 }
1985 field_metadata = Some(map.next_value()?);
1986 }
1987 _ => {
1988 map.next_value::<::serde_json::Value>()?;
1990 }
1991 }
1992 }
1993 if optional && nothing {
1994 return Ok(None);
1995 }
1996 let result = CreateFolderResult {
1997 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
1998 };
1999 Ok(Some(result))
2000 }
2001
2002 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2003 &self,
2004 s: &mut S::SerializeStruct,
2005 ) -> Result<(), S::Error> {
2006 use serde::ser::SerializeStruct;
2007 s.serialize_field("metadata", &self.metadata)?;
2008 Ok(())
2009 }
2010}
2011
2012impl<'de> ::serde::de::Deserialize<'de> for CreateFolderResult {
2013 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2014 use serde::de::{MapAccess, Visitor};
2016 struct StructVisitor;
2017 impl<'de> Visitor<'de> for StructVisitor {
2018 type Value = CreateFolderResult;
2019 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2020 f.write_str("a CreateFolderResult struct")
2021 }
2022 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2023 CreateFolderResult::internal_deserialize(map)
2024 }
2025 }
2026 deserializer.deserialize_struct("CreateFolderResult", CREATE_FOLDER_RESULT_FIELDS, StructVisitor)
2027 }
2028}
2029
2030impl ::serde::ser::Serialize for CreateFolderResult {
2031 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2032 use serde::ser::SerializeStruct;
2034 let mut s = serializer.serialize_struct("CreateFolderResult", 1)?;
2035 self.internal_serialize::<S>(&mut s)?;
2036 s.end()
2037 }
2038}
2039
2040impl From<CreateFolderResult> for FileOpsResult {
2042 fn from(_: CreateFolderResult) -> Self {
2043 Self {}
2044 }
2045}
2046#[derive(Debug, Clone, PartialEq, Eq)]
2047#[non_exhaustive] pub struct DeleteArg {
2049 pub path: WritePathOrId,
2051 pub parent_rev: Option<Rev>,
2054}
2055
2056impl DeleteArg {
2057 pub fn new(path: WritePathOrId) -> Self {
2058 DeleteArg {
2059 path,
2060 parent_rev: None,
2061 }
2062 }
2063
2064 pub fn with_parent_rev(mut self, value: Rev) -> Self {
2065 self.parent_rev = Some(value);
2066 self
2067 }
2068}
2069
2070const DELETE_ARG_FIELDS: &[&str] = &["path",
2071 "parent_rev"];
2072impl DeleteArg {
2073 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2074 map: V,
2075 ) -> Result<DeleteArg, V::Error> {
2076 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2077 }
2078
2079 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2080 mut map: V,
2081 optional: bool,
2082 ) -> Result<Option<DeleteArg>, V::Error> {
2083 let mut field_path = None;
2084 let mut field_parent_rev = None;
2085 let mut nothing = true;
2086 while let Some(key) = map.next_key::<&str>()? {
2087 nothing = false;
2088 match key {
2089 "path" => {
2090 if field_path.is_some() {
2091 return Err(::serde::de::Error::duplicate_field("path"));
2092 }
2093 field_path = Some(map.next_value()?);
2094 }
2095 "parent_rev" => {
2096 if field_parent_rev.is_some() {
2097 return Err(::serde::de::Error::duplicate_field("parent_rev"));
2098 }
2099 field_parent_rev = Some(map.next_value()?);
2100 }
2101 _ => {
2102 map.next_value::<::serde_json::Value>()?;
2104 }
2105 }
2106 }
2107 if optional && nothing {
2108 return Ok(None);
2109 }
2110 let result = DeleteArg {
2111 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
2112 parent_rev: field_parent_rev.and_then(Option::flatten),
2113 };
2114 Ok(Some(result))
2115 }
2116
2117 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2118 &self,
2119 s: &mut S::SerializeStruct,
2120 ) -> Result<(), S::Error> {
2121 use serde::ser::SerializeStruct;
2122 s.serialize_field("path", &self.path)?;
2123 if let Some(val) = &self.parent_rev {
2124 s.serialize_field("parent_rev", val)?;
2125 }
2126 Ok(())
2127 }
2128}
2129
2130impl<'de> ::serde::de::Deserialize<'de> for DeleteArg {
2131 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2132 use serde::de::{MapAccess, Visitor};
2134 struct StructVisitor;
2135 impl<'de> Visitor<'de> for StructVisitor {
2136 type Value = DeleteArg;
2137 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2138 f.write_str("a DeleteArg struct")
2139 }
2140 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2141 DeleteArg::internal_deserialize(map)
2142 }
2143 }
2144 deserializer.deserialize_struct("DeleteArg", DELETE_ARG_FIELDS, StructVisitor)
2145 }
2146}
2147
2148impl ::serde::ser::Serialize for DeleteArg {
2149 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2150 use serde::ser::SerializeStruct;
2152 let mut s = serializer.serialize_struct("DeleteArg", 2)?;
2153 self.internal_serialize::<S>(&mut s)?;
2154 s.end()
2155 }
2156}
2157
2158#[derive(Debug, Clone, PartialEq, Eq)]
2159#[non_exhaustive] pub struct DeleteBatchArg {
2161 pub entries: Vec<DeleteArg>,
2162}
2163
2164impl DeleteBatchArg {
2165 pub fn new(entries: Vec<DeleteArg>) -> Self {
2166 DeleteBatchArg {
2167 entries,
2168 }
2169 }
2170}
2171
2172const DELETE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
2173impl DeleteBatchArg {
2174 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2175 map: V,
2176 ) -> Result<DeleteBatchArg, V::Error> {
2177 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2178 }
2179
2180 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2181 mut map: V,
2182 optional: bool,
2183 ) -> Result<Option<DeleteBatchArg>, V::Error> {
2184 let mut field_entries = None;
2185 let mut nothing = true;
2186 while let Some(key) = map.next_key::<&str>()? {
2187 nothing = false;
2188 match key {
2189 "entries" => {
2190 if field_entries.is_some() {
2191 return Err(::serde::de::Error::duplicate_field("entries"));
2192 }
2193 field_entries = Some(map.next_value()?);
2194 }
2195 _ => {
2196 map.next_value::<::serde_json::Value>()?;
2198 }
2199 }
2200 }
2201 if optional && nothing {
2202 return Ok(None);
2203 }
2204 let result = DeleteBatchArg {
2205 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
2206 };
2207 Ok(Some(result))
2208 }
2209
2210 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2211 &self,
2212 s: &mut S::SerializeStruct,
2213 ) -> Result<(), S::Error> {
2214 use serde::ser::SerializeStruct;
2215 s.serialize_field("entries", &self.entries)?;
2216 Ok(())
2217 }
2218}
2219
2220impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchArg {
2221 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2222 use serde::de::{MapAccess, Visitor};
2224 struct StructVisitor;
2225 impl<'de> Visitor<'de> for StructVisitor {
2226 type Value = DeleteBatchArg;
2227 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2228 f.write_str("a DeleteBatchArg struct")
2229 }
2230 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2231 DeleteBatchArg::internal_deserialize(map)
2232 }
2233 }
2234 deserializer.deserialize_struct("DeleteBatchArg", DELETE_BATCH_ARG_FIELDS, StructVisitor)
2235 }
2236}
2237
2238impl ::serde::ser::Serialize for DeleteBatchArg {
2239 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2240 use serde::ser::SerializeStruct;
2242 let mut s = serializer.serialize_struct("DeleteBatchArg", 1)?;
2243 self.internal_serialize::<S>(&mut s)?;
2244 s.end()
2245 }
2246}
2247
2248#[derive(Debug, Clone, PartialEq, Eq)]
2249#[non_exhaustive] pub enum DeleteBatchError {
2251 #[deprecated]
2255 TooManyWriteOperations,
2256 Other,
2259}
2260
2261impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchError {
2262 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2263 use serde::de::{self, MapAccess, Visitor};
2265 struct EnumVisitor;
2266 impl<'de> Visitor<'de> for EnumVisitor {
2267 type Value = DeleteBatchError;
2268 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2269 f.write_str("a DeleteBatchError structure")
2270 }
2271 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2272 let tag: &str = match map.next_key()? {
2273 Some(".tag") => map.next_value()?,
2274 _ => return Err(de::Error::missing_field(".tag"))
2275 };
2276 let value = match tag {
2277 #[allow(deprecated)]
2278 "too_many_write_operations" => DeleteBatchError::TooManyWriteOperations,
2279 _ => DeleteBatchError::Other,
2280 };
2281 crate::eat_json_fields(&mut map)?;
2282 Ok(value)
2283 }
2284 }
2285 const VARIANTS: &[&str] = &["too_many_write_operations",
2286 "other"];
2287 deserializer.deserialize_struct("DeleteBatchError", VARIANTS, EnumVisitor)
2288 }
2289}
2290
2291impl ::serde::ser::Serialize for DeleteBatchError {
2292 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2293 use serde::ser::SerializeStruct;
2295 match self {
2296 #[allow(deprecated)]
2297 DeleteBatchError::TooManyWriteOperations => {
2298 let mut s = serializer.serialize_struct("DeleteBatchError", 1)?;
2300 s.serialize_field(".tag", "too_many_write_operations")?;
2301 s.end()
2302 }
2303 DeleteBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2304 }
2305 }
2306}
2307
2308impl ::std::error::Error for DeleteBatchError {
2309}
2310
2311impl ::std::fmt::Display for DeleteBatchError {
2312 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2313 write!(f, "{:?}", *self)
2314 }
2315}
2316
2317#[derive(Debug, Clone, PartialEq)]
2318#[non_exhaustive] pub enum DeleteBatchJobStatus {
2320 InProgress,
2322 Complete(DeleteBatchResult),
2324 Failed(DeleteBatchError),
2326 Other,
2329}
2330
2331impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchJobStatus {
2332 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2333 use serde::de::{self, MapAccess, Visitor};
2335 struct EnumVisitor;
2336 impl<'de> Visitor<'de> for EnumVisitor {
2337 type Value = DeleteBatchJobStatus;
2338 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2339 f.write_str("a DeleteBatchJobStatus structure")
2340 }
2341 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2342 let tag: &str = match map.next_key()? {
2343 Some(".tag") => map.next_value()?,
2344 _ => return Err(de::Error::missing_field(".tag"))
2345 };
2346 let value = match tag {
2347 "in_progress" => DeleteBatchJobStatus::InProgress,
2348 "complete" => DeleteBatchJobStatus::Complete(DeleteBatchResult::internal_deserialize(&mut map)?),
2349 "failed" => {
2350 match map.next_key()? {
2351 Some("failed") => DeleteBatchJobStatus::Failed(map.next_value()?),
2352 None => return Err(de::Error::missing_field("failed")),
2353 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2354 }
2355 }
2356 _ => DeleteBatchJobStatus::Other,
2357 };
2358 crate::eat_json_fields(&mut map)?;
2359 Ok(value)
2360 }
2361 }
2362 const VARIANTS: &[&str] = &["in_progress",
2363 "complete",
2364 "failed",
2365 "other"];
2366 deserializer.deserialize_struct("DeleteBatchJobStatus", VARIANTS, EnumVisitor)
2367 }
2368}
2369
2370impl ::serde::ser::Serialize for DeleteBatchJobStatus {
2371 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2372 use serde::ser::SerializeStruct;
2374 match self {
2375 DeleteBatchJobStatus::InProgress => {
2376 let mut s = serializer.serialize_struct("DeleteBatchJobStatus", 1)?;
2378 s.serialize_field(".tag", "in_progress")?;
2379 s.end()
2380 }
2381 DeleteBatchJobStatus::Complete(x) => {
2382 let mut s = serializer.serialize_struct("DeleteBatchJobStatus", 2)?;
2384 s.serialize_field(".tag", "complete")?;
2385 x.internal_serialize::<S>(&mut s)?;
2386 s.end()
2387 }
2388 DeleteBatchJobStatus::Failed(x) => {
2389 let mut s = serializer.serialize_struct("DeleteBatchJobStatus", 2)?;
2391 s.serialize_field(".tag", "failed")?;
2392 s.serialize_field("failed", x)?;
2393 s.end()
2394 }
2395 DeleteBatchJobStatus::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2396 }
2397 }
2398}
2399
2400impl From<crate::types::dbx_async::PollResultBase> for DeleteBatchJobStatus {
2402 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
2403 match parent {
2404 crate::types::dbx_async::PollResultBase::InProgress => DeleteBatchJobStatus::InProgress,
2405 }
2406 }
2407}
2408#[derive(Debug, Clone, PartialEq)]
2411#[non_exhaustive] pub enum DeleteBatchLaunch {
2413 AsyncJobId(crate::types::dbx_async::AsyncJobId),
2416 Complete(DeleteBatchResult),
2417 Other,
2420}
2421
2422impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchLaunch {
2423 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2424 use serde::de::{self, MapAccess, Visitor};
2426 struct EnumVisitor;
2427 impl<'de> Visitor<'de> for EnumVisitor {
2428 type Value = DeleteBatchLaunch;
2429 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2430 f.write_str("a DeleteBatchLaunch structure")
2431 }
2432 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2433 let tag: &str = match map.next_key()? {
2434 Some(".tag") => map.next_value()?,
2435 _ => return Err(de::Error::missing_field(".tag"))
2436 };
2437 let value = match tag {
2438 "async_job_id" => {
2439 match map.next_key()? {
2440 Some("async_job_id") => DeleteBatchLaunch::AsyncJobId(map.next_value()?),
2441 None => return Err(de::Error::missing_field("async_job_id")),
2442 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2443 }
2444 }
2445 "complete" => DeleteBatchLaunch::Complete(DeleteBatchResult::internal_deserialize(&mut map)?),
2446 _ => DeleteBatchLaunch::Other,
2447 };
2448 crate::eat_json_fields(&mut map)?;
2449 Ok(value)
2450 }
2451 }
2452 const VARIANTS: &[&str] = &["async_job_id",
2453 "complete",
2454 "other"];
2455 deserializer.deserialize_struct("DeleteBatchLaunch", VARIANTS, EnumVisitor)
2456 }
2457}
2458
2459impl ::serde::ser::Serialize for DeleteBatchLaunch {
2460 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2461 use serde::ser::SerializeStruct;
2463 match self {
2464 DeleteBatchLaunch::AsyncJobId(x) => {
2465 let mut s = serializer.serialize_struct("DeleteBatchLaunch", 2)?;
2467 s.serialize_field(".tag", "async_job_id")?;
2468 s.serialize_field("async_job_id", x)?;
2469 s.end()
2470 }
2471 DeleteBatchLaunch::Complete(x) => {
2472 let mut s = serializer.serialize_struct("DeleteBatchLaunch", 2)?;
2474 s.serialize_field(".tag", "complete")?;
2475 x.internal_serialize::<S>(&mut s)?;
2476 s.end()
2477 }
2478 DeleteBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2479 }
2480 }
2481}
2482
2483impl From<crate::types::dbx_async::LaunchResultBase> for DeleteBatchLaunch {
2485 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
2486 match parent {
2487 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => DeleteBatchLaunch::AsyncJobId(x),
2488 }
2489 }
2490}
2491#[derive(Debug, Clone, PartialEq)]
2492#[non_exhaustive] pub struct DeleteBatchResult {
2494 pub entries: Vec<DeleteBatchResultEntry>,
2497}
2498
2499impl DeleteBatchResult {
2500 pub fn new(entries: Vec<DeleteBatchResultEntry>) -> Self {
2501 DeleteBatchResult {
2502 entries,
2503 }
2504 }
2505}
2506
2507const DELETE_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
2508impl DeleteBatchResult {
2509 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2510 map: V,
2511 ) -> Result<DeleteBatchResult, V::Error> {
2512 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2513 }
2514
2515 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2516 mut map: V,
2517 optional: bool,
2518 ) -> Result<Option<DeleteBatchResult>, V::Error> {
2519 let mut field_entries = None;
2520 let mut nothing = true;
2521 while let Some(key) = map.next_key::<&str>()? {
2522 nothing = false;
2523 match key {
2524 "entries" => {
2525 if field_entries.is_some() {
2526 return Err(::serde::de::Error::duplicate_field("entries"));
2527 }
2528 field_entries = Some(map.next_value()?);
2529 }
2530 _ => {
2531 map.next_value::<::serde_json::Value>()?;
2533 }
2534 }
2535 }
2536 if optional && nothing {
2537 return Ok(None);
2538 }
2539 let result = DeleteBatchResult {
2540 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
2541 };
2542 Ok(Some(result))
2543 }
2544
2545 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2546 &self,
2547 s: &mut S::SerializeStruct,
2548 ) -> Result<(), S::Error> {
2549 use serde::ser::SerializeStruct;
2550 s.serialize_field("entries", &self.entries)?;
2551 Ok(())
2552 }
2553}
2554
2555impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchResult {
2556 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2557 use serde::de::{MapAccess, Visitor};
2559 struct StructVisitor;
2560 impl<'de> Visitor<'de> for StructVisitor {
2561 type Value = DeleteBatchResult;
2562 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2563 f.write_str("a DeleteBatchResult struct")
2564 }
2565 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2566 DeleteBatchResult::internal_deserialize(map)
2567 }
2568 }
2569 deserializer.deserialize_struct("DeleteBatchResult", DELETE_BATCH_RESULT_FIELDS, StructVisitor)
2570 }
2571}
2572
2573impl ::serde::ser::Serialize for DeleteBatchResult {
2574 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2575 use serde::ser::SerializeStruct;
2577 let mut s = serializer.serialize_struct("DeleteBatchResult", 1)?;
2578 self.internal_serialize::<S>(&mut s)?;
2579 s.end()
2580 }
2581}
2582
2583impl From<DeleteBatchResult> for FileOpsResult {
2585 fn from(_: DeleteBatchResult) -> Self {
2586 Self {}
2587 }
2588}
2589#[derive(Debug, Clone, PartialEq)]
2590#[non_exhaustive] pub struct DeleteBatchResultData {
2592 pub metadata: Metadata,
2594}
2595
2596impl DeleteBatchResultData {
2597 pub fn new(metadata: Metadata) -> Self {
2598 DeleteBatchResultData {
2599 metadata,
2600 }
2601 }
2602}
2603
2604const DELETE_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata"];
2605impl DeleteBatchResultData {
2606 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2607 map: V,
2608 ) -> Result<DeleteBatchResultData, V::Error> {
2609 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2610 }
2611
2612 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2613 mut map: V,
2614 optional: bool,
2615 ) -> Result<Option<DeleteBatchResultData>, V::Error> {
2616 let mut field_metadata = None;
2617 let mut nothing = true;
2618 while let Some(key) = map.next_key::<&str>()? {
2619 nothing = false;
2620 match key {
2621 "metadata" => {
2622 if field_metadata.is_some() {
2623 return Err(::serde::de::Error::duplicate_field("metadata"));
2624 }
2625 field_metadata = Some(map.next_value()?);
2626 }
2627 _ => {
2628 map.next_value::<::serde_json::Value>()?;
2630 }
2631 }
2632 }
2633 if optional && nothing {
2634 return Ok(None);
2635 }
2636 let result = DeleteBatchResultData {
2637 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
2638 };
2639 Ok(Some(result))
2640 }
2641
2642 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2643 &self,
2644 s: &mut S::SerializeStruct,
2645 ) -> Result<(), S::Error> {
2646 use serde::ser::SerializeStruct;
2647 s.serialize_field("metadata", &self.metadata)?;
2648 Ok(())
2649 }
2650}
2651
2652impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchResultData {
2653 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2654 use serde::de::{MapAccess, Visitor};
2656 struct StructVisitor;
2657 impl<'de> Visitor<'de> for StructVisitor {
2658 type Value = DeleteBatchResultData;
2659 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2660 f.write_str("a DeleteBatchResultData struct")
2661 }
2662 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2663 DeleteBatchResultData::internal_deserialize(map)
2664 }
2665 }
2666 deserializer.deserialize_struct("DeleteBatchResultData", DELETE_BATCH_RESULT_DATA_FIELDS, StructVisitor)
2667 }
2668}
2669
2670impl ::serde::ser::Serialize for DeleteBatchResultData {
2671 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2672 use serde::ser::SerializeStruct;
2674 let mut s = serializer.serialize_struct("DeleteBatchResultData", 1)?;
2675 self.internal_serialize::<S>(&mut s)?;
2676 s.end()
2677 }
2678}
2679
2680#[derive(Debug, Clone, PartialEq)]
2681pub enum DeleteBatchResultEntry {
2682 Success(DeleteBatchResultData),
2683 Failure(DeleteError),
2684}
2685
2686impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchResultEntry {
2687 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2688 use serde::de::{self, MapAccess, Visitor};
2690 struct EnumVisitor;
2691 impl<'de> Visitor<'de> for EnumVisitor {
2692 type Value = DeleteBatchResultEntry;
2693 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2694 f.write_str("a DeleteBatchResultEntry structure")
2695 }
2696 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2697 let tag: &str = match map.next_key()? {
2698 Some(".tag") => map.next_value()?,
2699 _ => return Err(de::Error::missing_field(".tag"))
2700 };
2701 let value = match tag {
2702 "success" => DeleteBatchResultEntry::Success(DeleteBatchResultData::internal_deserialize(&mut map)?),
2703 "failure" => {
2704 match map.next_key()? {
2705 Some("failure") => DeleteBatchResultEntry::Failure(map.next_value()?),
2706 None => return Err(de::Error::missing_field("failure")),
2707 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2708 }
2709 }
2710 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
2711 };
2712 crate::eat_json_fields(&mut map)?;
2713 Ok(value)
2714 }
2715 }
2716 const VARIANTS: &[&str] = &["success",
2717 "failure"];
2718 deserializer.deserialize_struct("DeleteBatchResultEntry", VARIANTS, EnumVisitor)
2719 }
2720}
2721
2722impl ::serde::ser::Serialize for DeleteBatchResultEntry {
2723 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2724 use serde::ser::SerializeStruct;
2726 match self {
2727 DeleteBatchResultEntry::Success(x) => {
2728 let mut s = serializer.serialize_struct("DeleteBatchResultEntry", 2)?;
2730 s.serialize_field(".tag", "success")?;
2731 x.internal_serialize::<S>(&mut s)?;
2732 s.end()
2733 }
2734 DeleteBatchResultEntry::Failure(x) => {
2735 let mut s = serializer.serialize_struct("DeleteBatchResultEntry", 2)?;
2737 s.serialize_field(".tag", "failure")?;
2738 s.serialize_field("failure", x)?;
2739 s.end()
2740 }
2741 }
2742 }
2743}
2744
2745#[derive(Debug, Clone, PartialEq, Eq)]
2746#[non_exhaustive] pub enum DeleteError {
2748 PathLookup(LookupError),
2749 PathWrite(WriteError),
2750 TooManyWriteOperations,
2752 TooManyFiles,
2754 Other,
2757}
2758
2759impl<'de> ::serde::de::Deserialize<'de> for DeleteError {
2760 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2761 use serde::de::{self, MapAccess, Visitor};
2763 struct EnumVisitor;
2764 impl<'de> Visitor<'de> for EnumVisitor {
2765 type Value = DeleteError;
2766 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2767 f.write_str("a DeleteError structure")
2768 }
2769 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
2770 let tag: &str = match map.next_key()? {
2771 Some(".tag") => map.next_value()?,
2772 _ => return Err(de::Error::missing_field(".tag"))
2773 };
2774 let value = match tag {
2775 "path_lookup" => {
2776 match map.next_key()? {
2777 Some("path_lookup") => DeleteError::PathLookup(map.next_value()?),
2778 None => return Err(de::Error::missing_field("path_lookup")),
2779 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2780 }
2781 }
2782 "path_write" => {
2783 match map.next_key()? {
2784 Some("path_write") => DeleteError::PathWrite(map.next_value()?),
2785 None => return Err(de::Error::missing_field("path_write")),
2786 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
2787 }
2788 }
2789 "too_many_write_operations" => DeleteError::TooManyWriteOperations,
2790 "too_many_files" => DeleteError::TooManyFiles,
2791 _ => DeleteError::Other,
2792 };
2793 crate::eat_json_fields(&mut map)?;
2794 Ok(value)
2795 }
2796 }
2797 const VARIANTS: &[&str] = &["path_lookup",
2798 "path_write",
2799 "too_many_write_operations",
2800 "too_many_files",
2801 "other"];
2802 deserializer.deserialize_struct("DeleteError", VARIANTS, EnumVisitor)
2803 }
2804}
2805
2806impl ::serde::ser::Serialize for DeleteError {
2807 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2808 use serde::ser::SerializeStruct;
2810 match self {
2811 DeleteError::PathLookup(x) => {
2812 let mut s = serializer.serialize_struct("DeleteError", 2)?;
2814 s.serialize_field(".tag", "path_lookup")?;
2815 s.serialize_field("path_lookup", x)?;
2816 s.end()
2817 }
2818 DeleteError::PathWrite(x) => {
2819 let mut s = serializer.serialize_struct("DeleteError", 2)?;
2821 s.serialize_field(".tag", "path_write")?;
2822 s.serialize_field("path_write", x)?;
2823 s.end()
2824 }
2825 DeleteError::TooManyWriteOperations => {
2826 let mut s = serializer.serialize_struct("DeleteError", 1)?;
2828 s.serialize_field(".tag", "too_many_write_operations")?;
2829 s.end()
2830 }
2831 DeleteError::TooManyFiles => {
2832 let mut s = serializer.serialize_struct("DeleteError", 1)?;
2834 s.serialize_field(".tag", "too_many_files")?;
2835 s.end()
2836 }
2837 DeleteError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
2838 }
2839 }
2840}
2841
2842impl ::std::error::Error for DeleteError {
2843 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
2844 match self {
2845 DeleteError::PathLookup(inner) => Some(inner),
2846 DeleteError::PathWrite(inner) => Some(inner),
2847 _ => None,
2848 }
2849 }
2850}
2851
2852impl ::std::fmt::Display for DeleteError {
2853 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2854 match self {
2855 DeleteError::PathLookup(inner) => write!(f, "DeleteError: {}", inner),
2856 DeleteError::PathWrite(inner) => write!(f, "DeleteError: {}", inner),
2857 DeleteError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
2858 DeleteError::TooManyFiles => f.write_str("There are too many files in one request. Please retry with fewer files."),
2859 _ => write!(f, "{:?}", *self),
2860 }
2861 }
2862}
2863
2864#[derive(Debug, Clone, PartialEq)]
2865#[non_exhaustive] pub struct DeleteResult {
2867 pub metadata: Metadata,
2869}
2870
2871impl DeleteResult {
2872 pub fn new(metadata: Metadata) -> Self {
2873 DeleteResult {
2874 metadata,
2875 }
2876 }
2877}
2878
2879const DELETE_RESULT_FIELDS: &[&str] = &["metadata"];
2880impl DeleteResult {
2881 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
2882 map: V,
2883 ) -> Result<DeleteResult, V::Error> {
2884 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
2885 }
2886
2887 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
2888 mut map: V,
2889 optional: bool,
2890 ) -> Result<Option<DeleteResult>, V::Error> {
2891 let mut field_metadata = None;
2892 let mut nothing = true;
2893 while let Some(key) = map.next_key::<&str>()? {
2894 nothing = false;
2895 match key {
2896 "metadata" => {
2897 if field_metadata.is_some() {
2898 return Err(::serde::de::Error::duplicate_field("metadata"));
2899 }
2900 field_metadata = Some(map.next_value()?);
2901 }
2902 _ => {
2903 map.next_value::<::serde_json::Value>()?;
2905 }
2906 }
2907 }
2908 if optional && nothing {
2909 return Ok(None);
2910 }
2911 let result = DeleteResult {
2912 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
2913 };
2914 Ok(Some(result))
2915 }
2916
2917 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
2918 &self,
2919 s: &mut S::SerializeStruct,
2920 ) -> Result<(), S::Error> {
2921 use serde::ser::SerializeStruct;
2922 s.serialize_field("metadata", &self.metadata)?;
2923 Ok(())
2924 }
2925}
2926
2927impl<'de> ::serde::de::Deserialize<'de> for DeleteResult {
2928 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2929 use serde::de::{MapAccess, Visitor};
2931 struct StructVisitor;
2932 impl<'de> Visitor<'de> for StructVisitor {
2933 type Value = DeleteResult;
2934 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2935 f.write_str("a DeleteResult struct")
2936 }
2937 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
2938 DeleteResult::internal_deserialize(map)
2939 }
2940 }
2941 deserializer.deserialize_struct("DeleteResult", DELETE_RESULT_FIELDS, StructVisitor)
2942 }
2943}
2944
2945impl ::serde::ser::Serialize for DeleteResult {
2946 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
2947 use serde::ser::SerializeStruct;
2949 let mut s = serializer.serialize_struct("DeleteResult", 1)?;
2950 self.internal_serialize::<S>(&mut s)?;
2951 s.end()
2952 }
2953}
2954
2955impl From<DeleteResult> for FileOpsResult {
2957 fn from(_: DeleteResult) -> Self {
2958 Self {}
2959 }
2960}
2961#[derive(Debug, Clone, PartialEq, Eq)]
2963#[non_exhaustive] pub struct DeletedMetadata {
2965 pub name: String,
2967 pub path_lower: Option<String>,
2970 pub path_display: Option<String>,
2977 #[deprecated]
2981 pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
2982 pub preview_url: Option<String>,
2984 pub is_restorable: Option<bool>,
2986}
2987
2988impl DeletedMetadata {
2989 pub fn new(name: String) -> Self {
2990 DeletedMetadata {
2991 name,
2992 path_lower: None,
2993 path_display: None,
2994 #[allow(deprecated)] parent_shared_folder_id: None,
2995 preview_url: None,
2996 is_restorable: None,
2997 }
2998 }
2999
3000 pub fn with_path_lower(mut self, value: String) -> Self {
3001 self.path_lower = Some(value);
3002 self
3003 }
3004
3005 pub fn with_path_display(mut self, value: String) -> Self {
3006 self.path_display = Some(value);
3007 self
3008 }
3009
3010 #[deprecated]
3011 #[allow(deprecated)]
3012 pub fn with_parent_shared_folder_id(
3013 mut self,
3014 value: crate::types::common::SharedFolderId,
3015 ) -> Self {
3016 self.parent_shared_folder_id = Some(value);
3017 self
3018 }
3019
3020 pub fn with_preview_url(mut self, value: String) -> Self {
3021 self.preview_url = Some(value);
3022 self
3023 }
3024
3025 pub fn with_is_restorable(mut self, value: bool) -> Self {
3026 self.is_restorable = Some(value);
3027 self
3028 }
3029}
3030
3031const DELETED_METADATA_FIELDS: &[&str] = &["name",
3032 "path_lower",
3033 "path_display",
3034 "parent_shared_folder_id",
3035 "preview_url",
3036 "is_restorable"];
3037impl DeletedMetadata {
3038 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3039 map: V,
3040 ) -> Result<DeletedMetadata, V::Error> {
3041 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3042 }
3043
3044 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3045 mut map: V,
3046 optional: bool,
3047 ) -> Result<Option<DeletedMetadata>, V::Error> {
3048 let mut field_name = None;
3049 let mut field_path_lower = None;
3050 let mut field_path_display = None;
3051 let mut field_parent_shared_folder_id = None;
3052 let mut field_preview_url = None;
3053 let mut field_is_restorable = None;
3054 let mut nothing = true;
3055 while let Some(key) = map.next_key::<&str>()? {
3056 nothing = false;
3057 match key {
3058 "name" => {
3059 if field_name.is_some() {
3060 return Err(::serde::de::Error::duplicate_field("name"));
3061 }
3062 field_name = Some(map.next_value()?);
3063 }
3064 "path_lower" => {
3065 if field_path_lower.is_some() {
3066 return Err(::serde::de::Error::duplicate_field("path_lower"));
3067 }
3068 field_path_lower = Some(map.next_value()?);
3069 }
3070 "path_display" => {
3071 if field_path_display.is_some() {
3072 return Err(::serde::de::Error::duplicate_field("path_display"));
3073 }
3074 field_path_display = Some(map.next_value()?);
3075 }
3076 "parent_shared_folder_id" => {
3077 if field_parent_shared_folder_id.is_some() {
3078 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
3079 }
3080 field_parent_shared_folder_id = Some(map.next_value()?);
3081 }
3082 "preview_url" => {
3083 if field_preview_url.is_some() {
3084 return Err(::serde::de::Error::duplicate_field("preview_url"));
3085 }
3086 field_preview_url = Some(map.next_value()?);
3087 }
3088 "is_restorable" => {
3089 if field_is_restorable.is_some() {
3090 return Err(::serde::de::Error::duplicate_field("is_restorable"));
3091 }
3092 field_is_restorable = Some(map.next_value()?);
3093 }
3094 _ => {
3095 map.next_value::<::serde_json::Value>()?;
3097 }
3098 }
3099 }
3100 if optional && nothing {
3101 return Ok(None);
3102 }
3103 let result = DeletedMetadata {
3104 name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
3105 path_lower: field_path_lower.and_then(Option::flatten),
3106 path_display: field_path_display.and_then(Option::flatten),
3107 #[allow(deprecated)] parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
3108 preview_url: field_preview_url.and_then(Option::flatten),
3109 is_restorable: field_is_restorable.and_then(Option::flatten),
3110 };
3111 Ok(Some(result))
3112 }
3113
3114 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3115 &self,
3116 s: &mut S::SerializeStruct,
3117 ) -> Result<(), S::Error> {
3118 use serde::ser::SerializeStruct;
3119 s.serialize_field("name", &self.name)?;
3120 if let Some(val) = &self.path_lower {
3121 s.serialize_field("path_lower", val)?;
3122 }
3123 if let Some(val) = &self.path_display {
3124 s.serialize_field("path_display", val)?;
3125 }
3126 #[allow(deprecated)]
3127 if let Some(val) = &self.parent_shared_folder_id {
3128 s.serialize_field("parent_shared_folder_id", val)?;
3129 }
3130 if let Some(val) = &self.preview_url {
3131 s.serialize_field("preview_url", val)?;
3132 }
3133 if let Some(val) = &self.is_restorable {
3134 s.serialize_field("is_restorable", val)?;
3135 }
3136 Ok(())
3137 }
3138}
3139
3140impl<'de> ::serde::de::Deserialize<'de> for DeletedMetadata {
3141 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3142 use serde::de::{MapAccess, Visitor};
3144 struct StructVisitor;
3145 impl<'de> Visitor<'de> for StructVisitor {
3146 type Value = DeletedMetadata;
3147 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3148 f.write_str("a DeletedMetadata struct")
3149 }
3150 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3151 DeletedMetadata::internal_deserialize(map)
3152 }
3153 }
3154 deserializer.deserialize_struct("DeletedMetadata", DELETED_METADATA_FIELDS, StructVisitor)
3155 }
3156}
3157
3158impl ::serde::ser::Serialize for DeletedMetadata {
3159 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3160 use serde::ser::SerializeStruct;
3162 let mut s = serializer.serialize_struct("DeletedMetadata", 6)?;
3163 self.internal_serialize::<S>(&mut s)?;
3164 s.end()
3165 }
3166}
3167
3168impl From<DeletedMetadata> for Metadata {
3170 fn from(subtype: DeletedMetadata) -> Self {
3171 Metadata::Deleted(subtype)
3172 }
3173}
3174#[derive(Debug, Clone, PartialEq, Eq)]
3176#[non_exhaustive] pub struct Dimensions {
3178 pub height: u64,
3180 pub width: u64,
3182}
3183
3184impl Dimensions {
3185 pub fn new(height: u64, width: u64) -> Self {
3186 Dimensions {
3187 height,
3188 width,
3189 }
3190 }
3191}
3192
3193const DIMENSIONS_FIELDS: &[&str] = &["height",
3194 "width"];
3195impl Dimensions {
3196 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3197 map: V,
3198 ) -> Result<Dimensions, V::Error> {
3199 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3200 }
3201
3202 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3203 mut map: V,
3204 optional: bool,
3205 ) -> Result<Option<Dimensions>, V::Error> {
3206 let mut field_height = None;
3207 let mut field_width = None;
3208 let mut nothing = true;
3209 while let Some(key) = map.next_key::<&str>()? {
3210 nothing = false;
3211 match key {
3212 "height" => {
3213 if field_height.is_some() {
3214 return Err(::serde::de::Error::duplicate_field("height"));
3215 }
3216 field_height = Some(map.next_value()?);
3217 }
3218 "width" => {
3219 if field_width.is_some() {
3220 return Err(::serde::de::Error::duplicate_field("width"));
3221 }
3222 field_width = Some(map.next_value()?);
3223 }
3224 _ => {
3225 map.next_value::<::serde_json::Value>()?;
3227 }
3228 }
3229 }
3230 if optional && nothing {
3231 return Ok(None);
3232 }
3233 let result = Dimensions {
3234 height: field_height.ok_or_else(|| ::serde::de::Error::missing_field("height"))?,
3235 width: field_width.ok_or_else(|| ::serde::de::Error::missing_field("width"))?,
3236 };
3237 Ok(Some(result))
3238 }
3239
3240 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3241 &self,
3242 s: &mut S::SerializeStruct,
3243 ) -> Result<(), S::Error> {
3244 use serde::ser::SerializeStruct;
3245 s.serialize_field("height", &self.height)?;
3246 s.serialize_field("width", &self.width)?;
3247 Ok(())
3248 }
3249}
3250
3251impl<'de> ::serde::de::Deserialize<'de> for Dimensions {
3252 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3253 use serde::de::{MapAccess, Visitor};
3255 struct StructVisitor;
3256 impl<'de> Visitor<'de> for StructVisitor {
3257 type Value = Dimensions;
3258 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3259 f.write_str("a Dimensions struct")
3260 }
3261 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3262 Dimensions::internal_deserialize(map)
3263 }
3264 }
3265 deserializer.deserialize_struct("Dimensions", DIMENSIONS_FIELDS, StructVisitor)
3266 }
3267}
3268
3269impl ::serde::ser::Serialize for Dimensions {
3270 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3271 use serde::ser::SerializeStruct;
3273 let mut s = serializer.serialize_struct("Dimensions", 2)?;
3274 self.internal_serialize::<S>(&mut s)?;
3275 s.end()
3276 }
3277}
3278
3279#[derive(Debug, Clone, PartialEq, Eq)]
3280#[non_exhaustive] pub struct DownloadArg {
3282 pub path: ReadPath,
3284 #[deprecated]
3286 pub rev: Option<Rev>,
3287}
3288
3289impl DownloadArg {
3290 pub fn new(path: ReadPath) -> Self {
3291 DownloadArg {
3292 path,
3293 #[allow(deprecated)] rev: None,
3294 }
3295 }
3296
3297 #[deprecated]
3298 #[allow(deprecated)]
3299 pub fn with_rev(mut self, value: Rev) -> Self {
3300 self.rev = Some(value);
3301 self
3302 }
3303}
3304
3305const DOWNLOAD_ARG_FIELDS: &[&str] = &["path",
3306 "rev"];
3307impl DownloadArg {
3308 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3309 map: V,
3310 ) -> Result<DownloadArg, V::Error> {
3311 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3312 }
3313
3314 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3315 mut map: V,
3316 optional: bool,
3317 ) -> Result<Option<DownloadArg>, V::Error> {
3318 let mut field_path = None;
3319 let mut field_rev = None;
3320 let mut nothing = true;
3321 while let Some(key) = map.next_key::<&str>()? {
3322 nothing = false;
3323 match key {
3324 "path" => {
3325 if field_path.is_some() {
3326 return Err(::serde::de::Error::duplicate_field("path"));
3327 }
3328 field_path = Some(map.next_value()?);
3329 }
3330 "rev" => {
3331 if field_rev.is_some() {
3332 return Err(::serde::de::Error::duplicate_field("rev"));
3333 }
3334 field_rev = Some(map.next_value()?);
3335 }
3336 _ => {
3337 map.next_value::<::serde_json::Value>()?;
3339 }
3340 }
3341 }
3342 if optional && nothing {
3343 return Ok(None);
3344 }
3345 let result = DownloadArg {
3346 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
3347 #[allow(deprecated)] rev: field_rev.and_then(Option::flatten),
3348 };
3349 Ok(Some(result))
3350 }
3351
3352 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3353 &self,
3354 s: &mut S::SerializeStruct,
3355 ) -> Result<(), S::Error> {
3356 use serde::ser::SerializeStruct;
3357 s.serialize_field("path", &self.path)?;
3358 #[allow(deprecated)]
3359 if let Some(val) = &self.rev {
3360 s.serialize_field("rev", val)?;
3361 }
3362 Ok(())
3363 }
3364}
3365
3366impl<'de> ::serde::de::Deserialize<'de> for DownloadArg {
3367 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3368 use serde::de::{MapAccess, Visitor};
3370 struct StructVisitor;
3371 impl<'de> Visitor<'de> for StructVisitor {
3372 type Value = DownloadArg;
3373 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3374 f.write_str("a DownloadArg struct")
3375 }
3376 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3377 DownloadArg::internal_deserialize(map)
3378 }
3379 }
3380 deserializer.deserialize_struct("DownloadArg", DOWNLOAD_ARG_FIELDS, StructVisitor)
3381 }
3382}
3383
3384impl ::serde::ser::Serialize for DownloadArg {
3385 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3386 use serde::ser::SerializeStruct;
3388 let mut s = serializer.serialize_struct("DownloadArg", 2)?;
3389 self.internal_serialize::<S>(&mut s)?;
3390 s.end()
3391 }
3392}
3393
3394#[derive(Debug, Clone, PartialEq, Eq)]
3395#[non_exhaustive] pub enum DownloadError {
3397 Path(LookupError),
3398 UnsupportedFile,
3401 Other,
3404}
3405
3406impl<'de> ::serde::de::Deserialize<'de> for DownloadError {
3407 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3408 use serde::de::{self, MapAccess, Visitor};
3410 struct EnumVisitor;
3411 impl<'de> Visitor<'de> for EnumVisitor {
3412 type Value = DownloadError;
3413 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3414 f.write_str("a DownloadError structure")
3415 }
3416 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3417 let tag: &str = match map.next_key()? {
3418 Some(".tag") => map.next_value()?,
3419 _ => return Err(de::Error::missing_field(".tag"))
3420 };
3421 let value = match tag {
3422 "path" => {
3423 match map.next_key()? {
3424 Some("path") => DownloadError::Path(map.next_value()?),
3425 None => return Err(de::Error::missing_field("path")),
3426 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3427 }
3428 }
3429 "unsupported_file" => DownloadError::UnsupportedFile,
3430 _ => DownloadError::Other,
3431 };
3432 crate::eat_json_fields(&mut map)?;
3433 Ok(value)
3434 }
3435 }
3436 const VARIANTS: &[&str] = &["path",
3437 "unsupported_file",
3438 "other"];
3439 deserializer.deserialize_struct("DownloadError", VARIANTS, EnumVisitor)
3440 }
3441}
3442
3443impl ::serde::ser::Serialize for DownloadError {
3444 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3445 use serde::ser::SerializeStruct;
3447 match self {
3448 DownloadError::Path(x) => {
3449 let mut s = serializer.serialize_struct("DownloadError", 2)?;
3451 s.serialize_field(".tag", "path")?;
3452 s.serialize_field("path", x)?;
3453 s.end()
3454 }
3455 DownloadError::UnsupportedFile => {
3456 let mut s = serializer.serialize_struct("DownloadError", 1)?;
3458 s.serialize_field(".tag", "unsupported_file")?;
3459 s.end()
3460 }
3461 DownloadError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3462 }
3463 }
3464}
3465
3466impl ::std::error::Error for DownloadError {
3467 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
3468 match self {
3469 DownloadError::Path(inner) => Some(inner),
3470 _ => None,
3471 }
3472 }
3473}
3474
3475impl ::std::fmt::Display for DownloadError {
3476 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3477 match self {
3478 DownloadError::Path(inner) => write!(f, "DownloadError: {}", inner),
3479 _ => write!(f, "{:?}", *self),
3480 }
3481 }
3482}
3483
3484#[derive(Debug, Clone, PartialEq, Eq)]
3485#[non_exhaustive] pub struct DownloadZipArg {
3487 pub path: ReadPath,
3489}
3490
3491impl DownloadZipArg {
3492 pub fn new(path: ReadPath) -> Self {
3493 DownloadZipArg {
3494 path,
3495 }
3496 }
3497}
3498
3499const DOWNLOAD_ZIP_ARG_FIELDS: &[&str] = &["path"];
3500impl DownloadZipArg {
3501 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3502 map: V,
3503 ) -> Result<DownloadZipArg, V::Error> {
3504 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3505 }
3506
3507 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3508 mut map: V,
3509 optional: bool,
3510 ) -> Result<Option<DownloadZipArg>, V::Error> {
3511 let mut field_path = None;
3512 let mut nothing = true;
3513 while let Some(key) = map.next_key::<&str>()? {
3514 nothing = false;
3515 match key {
3516 "path" => {
3517 if field_path.is_some() {
3518 return Err(::serde::de::Error::duplicate_field("path"));
3519 }
3520 field_path = Some(map.next_value()?);
3521 }
3522 _ => {
3523 map.next_value::<::serde_json::Value>()?;
3525 }
3526 }
3527 }
3528 if optional && nothing {
3529 return Ok(None);
3530 }
3531 let result = DownloadZipArg {
3532 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
3533 };
3534 Ok(Some(result))
3535 }
3536
3537 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3538 &self,
3539 s: &mut S::SerializeStruct,
3540 ) -> Result<(), S::Error> {
3541 use serde::ser::SerializeStruct;
3542 s.serialize_field("path", &self.path)?;
3543 Ok(())
3544 }
3545}
3546
3547impl<'de> ::serde::de::Deserialize<'de> for DownloadZipArg {
3548 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3549 use serde::de::{MapAccess, Visitor};
3551 struct StructVisitor;
3552 impl<'de> Visitor<'de> for StructVisitor {
3553 type Value = DownloadZipArg;
3554 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3555 f.write_str("a DownloadZipArg struct")
3556 }
3557 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3558 DownloadZipArg::internal_deserialize(map)
3559 }
3560 }
3561 deserializer.deserialize_struct("DownloadZipArg", DOWNLOAD_ZIP_ARG_FIELDS, StructVisitor)
3562 }
3563}
3564
3565impl ::serde::ser::Serialize for DownloadZipArg {
3566 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3567 use serde::ser::SerializeStruct;
3569 let mut s = serializer.serialize_struct("DownloadZipArg", 1)?;
3570 self.internal_serialize::<S>(&mut s)?;
3571 s.end()
3572 }
3573}
3574
3575#[derive(Debug, Clone, PartialEq, Eq)]
3576#[non_exhaustive] pub enum DownloadZipError {
3578 Path(LookupError),
3579 TooLarge,
3581 TooManyFiles,
3583 Other,
3586}
3587
3588impl<'de> ::serde::de::Deserialize<'de> for DownloadZipError {
3589 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3590 use serde::de::{self, MapAccess, Visitor};
3592 struct EnumVisitor;
3593 impl<'de> Visitor<'de> for EnumVisitor {
3594 type Value = DownloadZipError;
3595 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3596 f.write_str("a DownloadZipError structure")
3597 }
3598 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3599 let tag: &str = match map.next_key()? {
3600 Some(".tag") => map.next_value()?,
3601 _ => return Err(de::Error::missing_field(".tag"))
3602 };
3603 let value = match tag {
3604 "path" => {
3605 match map.next_key()? {
3606 Some("path") => DownloadZipError::Path(map.next_value()?),
3607 None => return Err(de::Error::missing_field("path")),
3608 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3609 }
3610 }
3611 "too_large" => DownloadZipError::TooLarge,
3612 "too_many_files" => DownloadZipError::TooManyFiles,
3613 _ => DownloadZipError::Other,
3614 };
3615 crate::eat_json_fields(&mut map)?;
3616 Ok(value)
3617 }
3618 }
3619 const VARIANTS: &[&str] = &["path",
3620 "too_large",
3621 "too_many_files",
3622 "other"];
3623 deserializer.deserialize_struct("DownloadZipError", VARIANTS, EnumVisitor)
3624 }
3625}
3626
3627impl ::serde::ser::Serialize for DownloadZipError {
3628 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3629 use serde::ser::SerializeStruct;
3631 match self {
3632 DownloadZipError::Path(x) => {
3633 let mut s = serializer.serialize_struct("DownloadZipError", 2)?;
3635 s.serialize_field(".tag", "path")?;
3636 s.serialize_field("path", x)?;
3637 s.end()
3638 }
3639 DownloadZipError::TooLarge => {
3640 let mut s = serializer.serialize_struct("DownloadZipError", 1)?;
3642 s.serialize_field(".tag", "too_large")?;
3643 s.end()
3644 }
3645 DownloadZipError::TooManyFiles => {
3646 let mut s = serializer.serialize_struct("DownloadZipError", 1)?;
3648 s.serialize_field(".tag", "too_many_files")?;
3649 s.end()
3650 }
3651 DownloadZipError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3652 }
3653 }
3654}
3655
3656impl ::std::error::Error for DownloadZipError {
3657 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
3658 match self {
3659 DownloadZipError::Path(inner) => Some(inner),
3660 _ => None,
3661 }
3662 }
3663}
3664
3665impl ::std::fmt::Display for DownloadZipError {
3666 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3667 match self {
3668 DownloadZipError::Path(inner) => write!(f, "DownloadZipError: {}", inner),
3669 DownloadZipError::TooLarge => f.write_str("The folder or a file is too large to download."),
3670 DownloadZipError::TooManyFiles => f.write_str("The folder has too many files to download."),
3671 _ => write!(f, "{:?}", *self),
3672 }
3673 }
3674}
3675
3676#[derive(Debug, Clone, PartialEq, Eq)]
3677#[non_exhaustive] pub struct DownloadZipResult {
3679 pub metadata: FolderMetadata,
3680}
3681
3682impl DownloadZipResult {
3683 pub fn new(metadata: FolderMetadata) -> Self {
3684 DownloadZipResult {
3685 metadata,
3686 }
3687 }
3688}
3689
3690const DOWNLOAD_ZIP_RESULT_FIELDS: &[&str] = &["metadata"];
3691impl DownloadZipResult {
3692 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3693 map: V,
3694 ) -> Result<DownloadZipResult, V::Error> {
3695 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3696 }
3697
3698 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3699 mut map: V,
3700 optional: bool,
3701 ) -> Result<Option<DownloadZipResult>, V::Error> {
3702 let mut field_metadata = None;
3703 let mut nothing = true;
3704 while let Some(key) = map.next_key::<&str>()? {
3705 nothing = false;
3706 match key {
3707 "metadata" => {
3708 if field_metadata.is_some() {
3709 return Err(::serde::de::Error::duplicate_field("metadata"));
3710 }
3711 field_metadata = Some(map.next_value()?);
3712 }
3713 _ => {
3714 map.next_value::<::serde_json::Value>()?;
3716 }
3717 }
3718 }
3719 if optional && nothing {
3720 return Ok(None);
3721 }
3722 let result = DownloadZipResult {
3723 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
3724 };
3725 Ok(Some(result))
3726 }
3727
3728 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3729 &self,
3730 s: &mut S::SerializeStruct,
3731 ) -> Result<(), S::Error> {
3732 use serde::ser::SerializeStruct;
3733 s.serialize_field("metadata", &self.metadata)?;
3734 Ok(())
3735 }
3736}
3737
3738impl<'de> ::serde::de::Deserialize<'de> for DownloadZipResult {
3739 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3740 use serde::de::{MapAccess, Visitor};
3742 struct StructVisitor;
3743 impl<'de> Visitor<'de> for StructVisitor {
3744 type Value = DownloadZipResult;
3745 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3746 f.write_str("a DownloadZipResult struct")
3747 }
3748 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3749 DownloadZipResult::internal_deserialize(map)
3750 }
3751 }
3752 deserializer.deserialize_struct("DownloadZipResult", DOWNLOAD_ZIP_RESULT_FIELDS, StructVisitor)
3753 }
3754}
3755
3756impl ::serde::ser::Serialize for DownloadZipResult {
3757 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3758 use serde::ser::SerializeStruct;
3760 let mut s = serializer.serialize_struct("DownloadZipResult", 1)?;
3761 self.internal_serialize::<S>(&mut s)?;
3762 s.end()
3763 }
3764}
3765
3766#[derive(Debug, Clone, PartialEq, Eq)]
3767#[non_exhaustive] pub struct ExportArg {
3769 pub path: ReadPath,
3771 pub export_format: Option<String>,
3776}
3777
3778impl ExportArg {
3779 pub fn new(path: ReadPath) -> Self {
3780 ExportArg {
3781 path,
3782 export_format: None,
3783 }
3784 }
3785
3786 pub fn with_export_format(mut self, value: String) -> Self {
3787 self.export_format = Some(value);
3788 self
3789 }
3790}
3791
3792const EXPORT_ARG_FIELDS: &[&str] = &["path",
3793 "export_format"];
3794impl ExportArg {
3795 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3796 map: V,
3797 ) -> Result<ExportArg, V::Error> {
3798 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3799 }
3800
3801 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3802 mut map: V,
3803 optional: bool,
3804 ) -> Result<Option<ExportArg>, V::Error> {
3805 let mut field_path = None;
3806 let mut field_export_format = None;
3807 let mut nothing = true;
3808 while let Some(key) = map.next_key::<&str>()? {
3809 nothing = false;
3810 match key {
3811 "path" => {
3812 if field_path.is_some() {
3813 return Err(::serde::de::Error::duplicate_field("path"));
3814 }
3815 field_path = Some(map.next_value()?);
3816 }
3817 "export_format" => {
3818 if field_export_format.is_some() {
3819 return Err(::serde::de::Error::duplicate_field("export_format"));
3820 }
3821 field_export_format = Some(map.next_value()?);
3822 }
3823 _ => {
3824 map.next_value::<::serde_json::Value>()?;
3826 }
3827 }
3828 }
3829 if optional && nothing {
3830 return Ok(None);
3831 }
3832 let result = ExportArg {
3833 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
3834 export_format: field_export_format.and_then(Option::flatten),
3835 };
3836 Ok(Some(result))
3837 }
3838
3839 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3840 &self,
3841 s: &mut S::SerializeStruct,
3842 ) -> Result<(), S::Error> {
3843 use serde::ser::SerializeStruct;
3844 s.serialize_field("path", &self.path)?;
3845 if let Some(val) = &self.export_format {
3846 s.serialize_field("export_format", val)?;
3847 }
3848 Ok(())
3849 }
3850}
3851
3852impl<'de> ::serde::de::Deserialize<'de> for ExportArg {
3853 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3854 use serde::de::{MapAccess, Visitor};
3856 struct StructVisitor;
3857 impl<'de> Visitor<'de> for StructVisitor {
3858 type Value = ExportArg;
3859 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3860 f.write_str("a ExportArg struct")
3861 }
3862 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3863 ExportArg::internal_deserialize(map)
3864 }
3865 }
3866 deserializer.deserialize_struct("ExportArg", EXPORT_ARG_FIELDS, StructVisitor)
3867 }
3868}
3869
3870impl ::serde::ser::Serialize for ExportArg {
3871 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3872 use serde::ser::SerializeStruct;
3874 let mut s = serializer.serialize_struct("ExportArg", 2)?;
3875 self.internal_serialize::<S>(&mut s)?;
3876 s.end()
3877 }
3878}
3879
3880#[derive(Debug, Clone, PartialEq, Eq)]
3881#[non_exhaustive] pub enum ExportError {
3883 Path(LookupError),
3884 NonExportable,
3886 InvalidExportFormat,
3888 RetryError,
3890 Other,
3893}
3894
3895impl<'de> ::serde::de::Deserialize<'de> for ExportError {
3896 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3897 use serde::de::{self, MapAccess, Visitor};
3899 struct EnumVisitor;
3900 impl<'de> Visitor<'de> for EnumVisitor {
3901 type Value = ExportError;
3902 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3903 f.write_str("a ExportError structure")
3904 }
3905 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3906 let tag: &str = match map.next_key()? {
3907 Some(".tag") => map.next_value()?,
3908 _ => return Err(de::Error::missing_field(".tag"))
3909 };
3910 let value = match tag {
3911 "path" => {
3912 match map.next_key()? {
3913 Some("path") => ExportError::Path(map.next_value()?),
3914 None => return Err(de::Error::missing_field("path")),
3915 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3916 }
3917 }
3918 "non_exportable" => ExportError::NonExportable,
3919 "invalid_export_format" => ExportError::InvalidExportFormat,
3920 "retry_error" => ExportError::RetryError,
3921 _ => ExportError::Other,
3922 };
3923 crate::eat_json_fields(&mut map)?;
3924 Ok(value)
3925 }
3926 }
3927 const VARIANTS: &[&str] = &["path",
3928 "non_exportable",
3929 "invalid_export_format",
3930 "retry_error",
3931 "other"];
3932 deserializer.deserialize_struct("ExportError", VARIANTS, EnumVisitor)
3933 }
3934}
3935
3936impl ::serde::ser::Serialize for ExportError {
3937 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3938 use serde::ser::SerializeStruct;
3940 match self {
3941 ExportError::Path(x) => {
3942 let mut s = serializer.serialize_struct("ExportError", 2)?;
3944 s.serialize_field(".tag", "path")?;
3945 s.serialize_field("path", x)?;
3946 s.end()
3947 }
3948 ExportError::NonExportable => {
3949 let mut s = serializer.serialize_struct("ExportError", 1)?;
3951 s.serialize_field(".tag", "non_exportable")?;
3952 s.end()
3953 }
3954 ExportError::InvalidExportFormat => {
3955 let mut s = serializer.serialize_struct("ExportError", 1)?;
3957 s.serialize_field(".tag", "invalid_export_format")?;
3958 s.end()
3959 }
3960 ExportError::RetryError => {
3961 let mut s = serializer.serialize_struct("ExportError", 1)?;
3963 s.serialize_field(".tag", "retry_error")?;
3964 s.end()
3965 }
3966 ExportError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3967 }
3968 }
3969}
3970
3971impl ::std::error::Error for ExportError {
3972 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
3973 match self {
3974 ExportError::Path(inner) => Some(inner),
3975 _ => None,
3976 }
3977 }
3978}
3979
3980impl ::std::fmt::Display for ExportError {
3981 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3982 match self {
3983 ExportError::Path(inner) => write!(f, "ExportError: {}", inner),
3984 ExportError::InvalidExportFormat => f.write_str("The specified export format is not a valid option for this file type."),
3985 ExportError::RetryError => f.write_str("The exportable content is not yet available. Please retry later."),
3986 _ => write!(f, "{:?}", *self),
3987 }
3988 }
3989}
3990
3991#[derive(Debug, Clone, PartialEq, Eq, Default)]
3993#[non_exhaustive] pub struct ExportInfo {
3995 pub export_as: Option<String>,
3997 pub export_options: Option<Vec<String>>,
4000}
4001
4002impl ExportInfo {
4003 pub fn with_export_as(mut self, value: String) -> Self {
4004 self.export_as = Some(value);
4005 self
4006 }
4007
4008 pub fn with_export_options(mut self, value: Vec<String>) -> Self {
4009 self.export_options = Some(value);
4010 self
4011 }
4012}
4013
4014const EXPORT_INFO_FIELDS: &[&str] = &["export_as",
4015 "export_options"];
4016impl ExportInfo {
4017 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4019 mut map: V,
4020 ) -> Result<ExportInfo, V::Error> {
4021 let mut field_export_as = None;
4022 let mut field_export_options = None;
4023 while let Some(key) = map.next_key::<&str>()? {
4024 match key {
4025 "export_as" => {
4026 if field_export_as.is_some() {
4027 return Err(::serde::de::Error::duplicate_field("export_as"));
4028 }
4029 field_export_as = Some(map.next_value()?);
4030 }
4031 "export_options" => {
4032 if field_export_options.is_some() {
4033 return Err(::serde::de::Error::duplicate_field("export_options"));
4034 }
4035 field_export_options = Some(map.next_value()?);
4036 }
4037 _ => {
4038 map.next_value::<::serde_json::Value>()?;
4040 }
4041 }
4042 }
4043 let result = ExportInfo {
4044 export_as: field_export_as.and_then(Option::flatten),
4045 export_options: field_export_options.and_then(Option::flatten),
4046 };
4047 Ok(result)
4048 }
4049
4050 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4051 &self,
4052 s: &mut S::SerializeStruct,
4053 ) -> Result<(), S::Error> {
4054 use serde::ser::SerializeStruct;
4055 if let Some(val) = &self.export_as {
4056 s.serialize_field("export_as", val)?;
4057 }
4058 if let Some(val) = &self.export_options {
4059 s.serialize_field("export_options", val)?;
4060 }
4061 Ok(())
4062 }
4063}
4064
4065impl<'de> ::serde::de::Deserialize<'de> for ExportInfo {
4066 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4067 use serde::de::{MapAccess, Visitor};
4069 struct StructVisitor;
4070 impl<'de> Visitor<'de> for StructVisitor {
4071 type Value = ExportInfo;
4072 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4073 f.write_str("a ExportInfo struct")
4074 }
4075 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4076 ExportInfo::internal_deserialize(map)
4077 }
4078 }
4079 deserializer.deserialize_struct("ExportInfo", EXPORT_INFO_FIELDS, StructVisitor)
4080 }
4081}
4082
4083impl ::serde::ser::Serialize for ExportInfo {
4084 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4085 use serde::ser::SerializeStruct;
4087 let mut s = serializer.serialize_struct("ExportInfo", 2)?;
4088 self.internal_serialize::<S>(&mut s)?;
4089 s.end()
4090 }
4091}
4092
4093#[derive(Debug, Clone, PartialEq, Eq)]
4094#[non_exhaustive] pub struct ExportMetadata {
4096 pub name: String,
4098 pub size: u64,
4100 pub export_hash: Option<Sha256HexHash>,
4104 pub paper_revision: Option<i64>,
4107}
4108
4109impl ExportMetadata {
4110 pub fn new(name: String, size: u64) -> Self {
4111 ExportMetadata {
4112 name,
4113 size,
4114 export_hash: None,
4115 paper_revision: None,
4116 }
4117 }
4118
4119 pub fn with_export_hash(mut self, value: Sha256HexHash) -> Self {
4120 self.export_hash = Some(value);
4121 self
4122 }
4123
4124 pub fn with_paper_revision(mut self, value: i64) -> Self {
4125 self.paper_revision = Some(value);
4126 self
4127 }
4128}
4129
4130const EXPORT_METADATA_FIELDS: &[&str] = &["name",
4131 "size",
4132 "export_hash",
4133 "paper_revision"];
4134impl ExportMetadata {
4135 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4136 map: V,
4137 ) -> Result<ExportMetadata, V::Error> {
4138 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4139 }
4140
4141 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4142 mut map: V,
4143 optional: bool,
4144 ) -> Result<Option<ExportMetadata>, V::Error> {
4145 let mut field_name = None;
4146 let mut field_size = None;
4147 let mut field_export_hash = None;
4148 let mut field_paper_revision = None;
4149 let mut nothing = true;
4150 while let Some(key) = map.next_key::<&str>()? {
4151 nothing = false;
4152 match key {
4153 "name" => {
4154 if field_name.is_some() {
4155 return Err(::serde::de::Error::duplicate_field("name"));
4156 }
4157 field_name = Some(map.next_value()?);
4158 }
4159 "size" => {
4160 if field_size.is_some() {
4161 return Err(::serde::de::Error::duplicate_field("size"));
4162 }
4163 field_size = Some(map.next_value()?);
4164 }
4165 "export_hash" => {
4166 if field_export_hash.is_some() {
4167 return Err(::serde::de::Error::duplicate_field("export_hash"));
4168 }
4169 field_export_hash = Some(map.next_value()?);
4170 }
4171 "paper_revision" => {
4172 if field_paper_revision.is_some() {
4173 return Err(::serde::de::Error::duplicate_field("paper_revision"));
4174 }
4175 field_paper_revision = Some(map.next_value()?);
4176 }
4177 _ => {
4178 map.next_value::<::serde_json::Value>()?;
4180 }
4181 }
4182 }
4183 if optional && nothing {
4184 return Ok(None);
4185 }
4186 let result = ExportMetadata {
4187 name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
4188 size: field_size.ok_or_else(|| ::serde::de::Error::missing_field("size"))?,
4189 export_hash: field_export_hash.and_then(Option::flatten),
4190 paper_revision: field_paper_revision.and_then(Option::flatten),
4191 };
4192 Ok(Some(result))
4193 }
4194
4195 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4196 &self,
4197 s: &mut S::SerializeStruct,
4198 ) -> Result<(), S::Error> {
4199 use serde::ser::SerializeStruct;
4200 s.serialize_field("name", &self.name)?;
4201 s.serialize_field("size", &self.size)?;
4202 if let Some(val) = &self.export_hash {
4203 s.serialize_field("export_hash", val)?;
4204 }
4205 if let Some(val) = &self.paper_revision {
4206 s.serialize_field("paper_revision", val)?;
4207 }
4208 Ok(())
4209 }
4210}
4211
4212impl<'de> ::serde::de::Deserialize<'de> for ExportMetadata {
4213 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4214 use serde::de::{MapAccess, Visitor};
4216 struct StructVisitor;
4217 impl<'de> Visitor<'de> for StructVisitor {
4218 type Value = ExportMetadata;
4219 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4220 f.write_str("a ExportMetadata struct")
4221 }
4222 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4223 ExportMetadata::internal_deserialize(map)
4224 }
4225 }
4226 deserializer.deserialize_struct("ExportMetadata", EXPORT_METADATA_FIELDS, StructVisitor)
4227 }
4228}
4229
4230impl ::serde::ser::Serialize for ExportMetadata {
4231 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4232 use serde::ser::SerializeStruct;
4234 let mut s = serializer.serialize_struct("ExportMetadata", 4)?;
4235 self.internal_serialize::<S>(&mut s)?;
4236 s.end()
4237 }
4238}
4239
4240#[derive(Debug, Clone, PartialEq)]
4241#[non_exhaustive] pub struct ExportResult {
4243 pub export_metadata: ExportMetadata,
4245 pub file_metadata: FileMetadata,
4247}
4248
4249impl ExportResult {
4250 pub fn new(export_metadata: ExportMetadata, file_metadata: FileMetadata) -> Self {
4251 ExportResult {
4252 export_metadata,
4253 file_metadata,
4254 }
4255 }
4256}
4257
4258const EXPORT_RESULT_FIELDS: &[&str] = &["export_metadata",
4259 "file_metadata"];
4260impl ExportResult {
4261 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4262 map: V,
4263 ) -> Result<ExportResult, V::Error> {
4264 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4265 }
4266
4267 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4268 mut map: V,
4269 optional: bool,
4270 ) -> Result<Option<ExportResult>, V::Error> {
4271 let mut field_export_metadata = None;
4272 let mut field_file_metadata = None;
4273 let mut nothing = true;
4274 while let Some(key) = map.next_key::<&str>()? {
4275 nothing = false;
4276 match key {
4277 "export_metadata" => {
4278 if field_export_metadata.is_some() {
4279 return Err(::serde::de::Error::duplicate_field("export_metadata"));
4280 }
4281 field_export_metadata = Some(map.next_value()?);
4282 }
4283 "file_metadata" => {
4284 if field_file_metadata.is_some() {
4285 return Err(::serde::de::Error::duplicate_field("file_metadata"));
4286 }
4287 field_file_metadata = Some(map.next_value()?);
4288 }
4289 _ => {
4290 map.next_value::<::serde_json::Value>()?;
4292 }
4293 }
4294 }
4295 if optional && nothing {
4296 return Ok(None);
4297 }
4298 let result = ExportResult {
4299 export_metadata: field_export_metadata.ok_or_else(|| ::serde::de::Error::missing_field("export_metadata"))?,
4300 file_metadata: field_file_metadata.ok_or_else(|| ::serde::de::Error::missing_field("file_metadata"))?,
4301 };
4302 Ok(Some(result))
4303 }
4304
4305 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4306 &self,
4307 s: &mut S::SerializeStruct,
4308 ) -> Result<(), S::Error> {
4309 use serde::ser::SerializeStruct;
4310 s.serialize_field("export_metadata", &self.export_metadata)?;
4311 s.serialize_field("file_metadata", &self.file_metadata)?;
4312 Ok(())
4313 }
4314}
4315
4316impl<'de> ::serde::de::Deserialize<'de> for ExportResult {
4317 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4318 use serde::de::{MapAccess, Visitor};
4320 struct StructVisitor;
4321 impl<'de> Visitor<'de> for StructVisitor {
4322 type Value = ExportResult;
4323 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4324 f.write_str("a ExportResult struct")
4325 }
4326 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4327 ExportResult::internal_deserialize(map)
4328 }
4329 }
4330 deserializer.deserialize_struct("ExportResult", EXPORT_RESULT_FIELDS, StructVisitor)
4331 }
4332}
4333
4334impl ::serde::ser::Serialize for ExportResult {
4335 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4336 use serde::ser::SerializeStruct;
4338 let mut s = serializer.serialize_struct("ExportResult", 2)?;
4339 self.internal_serialize::<S>(&mut s)?;
4340 s.end()
4341 }
4342}
4343
4344#[derive(Debug, Clone, PartialEq, Eq)]
4345#[non_exhaustive] pub enum FileCategory {
4347 Image,
4349 Document,
4351 Pdf,
4353 Spreadsheet,
4355 Presentation,
4357 Audio,
4359 Video,
4361 Folder,
4363 Paper,
4365 Others,
4367 Other,
4370}
4371
4372impl<'de> ::serde::de::Deserialize<'de> for FileCategory {
4373 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4374 use serde::de::{self, MapAccess, Visitor};
4376 struct EnumVisitor;
4377 impl<'de> Visitor<'de> for EnumVisitor {
4378 type Value = FileCategory;
4379 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4380 f.write_str("a FileCategory structure")
4381 }
4382 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
4383 let tag: &str = match map.next_key()? {
4384 Some(".tag") => map.next_value()?,
4385 _ => return Err(de::Error::missing_field(".tag"))
4386 };
4387 let value = match tag {
4388 "image" => FileCategory::Image,
4389 "document" => FileCategory::Document,
4390 "pdf" => FileCategory::Pdf,
4391 "spreadsheet" => FileCategory::Spreadsheet,
4392 "presentation" => FileCategory::Presentation,
4393 "audio" => FileCategory::Audio,
4394 "video" => FileCategory::Video,
4395 "folder" => FileCategory::Folder,
4396 "paper" => FileCategory::Paper,
4397 "others" => FileCategory::Others,
4398 _ => FileCategory::Other,
4399 };
4400 crate::eat_json_fields(&mut map)?;
4401 Ok(value)
4402 }
4403 }
4404 const VARIANTS: &[&str] = &["image",
4405 "document",
4406 "pdf",
4407 "spreadsheet",
4408 "presentation",
4409 "audio",
4410 "video",
4411 "folder",
4412 "paper",
4413 "others",
4414 "other"];
4415 deserializer.deserialize_struct("FileCategory", VARIANTS, EnumVisitor)
4416 }
4417}
4418
4419impl ::serde::ser::Serialize for FileCategory {
4420 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4421 use serde::ser::SerializeStruct;
4423 match self {
4424 FileCategory::Image => {
4425 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4427 s.serialize_field(".tag", "image")?;
4428 s.end()
4429 }
4430 FileCategory::Document => {
4431 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4433 s.serialize_field(".tag", "document")?;
4434 s.end()
4435 }
4436 FileCategory::Pdf => {
4437 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4439 s.serialize_field(".tag", "pdf")?;
4440 s.end()
4441 }
4442 FileCategory::Spreadsheet => {
4443 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4445 s.serialize_field(".tag", "spreadsheet")?;
4446 s.end()
4447 }
4448 FileCategory::Presentation => {
4449 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4451 s.serialize_field(".tag", "presentation")?;
4452 s.end()
4453 }
4454 FileCategory::Audio => {
4455 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4457 s.serialize_field(".tag", "audio")?;
4458 s.end()
4459 }
4460 FileCategory::Video => {
4461 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4463 s.serialize_field(".tag", "video")?;
4464 s.end()
4465 }
4466 FileCategory::Folder => {
4467 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4469 s.serialize_field(".tag", "folder")?;
4470 s.end()
4471 }
4472 FileCategory::Paper => {
4473 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4475 s.serialize_field(".tag", "paper")?;
4476 s.end()
4477 }
4478 FileCategory::Others => {
4479 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4481 s.serialize_field(".tag", "others")?;
4482 s.end()
4483 }
4484 FileCategory::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
4485 }
4486 }
4487}
4488
4489#[derive(Debug, Clone, PartialEq, Eq)]
4490#[non_exhaustive] pub struct FileLock {
4492 pub content: FileLockContent,
4494}
4495
4496impl FileLock {
4497 pub fn new(content: FileLockContent) -> Self {
4498 FileLock {
4499 content,
4500 }
4501 }
4502}
4503
4504const FILE_LOCK_FIELDS: &[&str] = &["content"];
4505impl FileLock {
4506 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4507 map: V,
4508 ) -> Result<FileLock, V::Error> {
4509 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4510 }
4511
4512 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4513 mut map: V,
4514 optional: bool,
4515 ) -> Result<Option<FileLock>, V::Error> {
4516 let mut field_content = None;
4517 let mut nothing = true;
4518 while let Some(key) = map.next_key::<&str>()? {
4519 nothing = false;
4520 match key {
4521 "content" => {
4522 if field_content.is_some() {
4523 return Err(::serde::de::Error::duplicate_field("content"));
4524 }
4525 field_content = Some(map.next_value()?);
4526 }
4527 _ => {
4528 map.next_value::<::serde_json::Value>()?;
4530 }
4531 }
4532 }
4533 if optional && nothing {
4534 return Ok(None);
4535 }
4536 let result = FileLock {
4537 content: field_content.ok_or_else(|| ::serde::de::Error::missing_field("content"))?,
4538 };
4539 Ok(Some(result))
4540 }
4541
4542 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4543 &self,
4544 s: &mut S::SerializeStruct,
4545 ) -> Result<(), S::Error> {
4546 use serde::ser::SerializeStruct;
4547 s.serialize_field("content", &self.content)?;
4548 Ok(())
4549 }
4550}
4551
4552impl<'de> ::serde::de::Deserialize<'de> for FileLock {
4553 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4554 use serde::de::{MapAccess, Visitor};
4556 struct StructVisitor;
4557 impl<'de> Visitor<'de> for StructVisitor {
4558 type Value = FileLock;
4559 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4560 f.write_str("a FileLock struct")
4561 }
4562 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4563 FileLock::internal_deserialize(map)
4564 }
4565 }
4566 deserializer.deserialize_struct("FileLock", FILE_LOCK_FIELDS, StructVisitor)
4567 }
4568}
4569
4570impl ::serde::ser::Serialize for FileLock {
4571 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4572 use serde::ser::SerializeStruct;
4574 let mut s = serializer.serialize_struct("FileLock", 1)?;
4575 self.internal_serialize::<S>(&mut s)?;
4576 s.end()
4577 }
4578}
4579
4580#[derive(Debug, Clone, PartialEq, Eq)]
4581#[non_exhaustive] pub enum FileLockContent {
4583 Unlocked,
4585 SingleUser(SingleUserLock),
4587 Other,
4590}
4591
4592impl<'de> ::serde::de::Deserialize<'de> for FileLockContent {
4593 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4594 use serde::de::{self, MapAccess, Visitor};
4596 struct EnumVisitor;
4597 impl<'de> Visitor<'de> for EnumVisitor {
4598 type Value = FileLockContent;
4599 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4600 f.write_str("a FileLockContent structure")
4601 }
4602 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
4603 let tag: &str = match map.next_key()? {
4604 Some(".tag") => map.next_value()?,
4605 _ => return Err(de::Error::missing_field(".tag"))
4606 };
4607 let value = match tag {
4608 "unlocked" => FileLockContent::Unlocked,
4609 "single_user" => FileLockContent::SingleUser(SingleUserLock::internal_deserialize(&mut map)?),
4610 _ => FileLockContent::Other,
4611 };
4612 crate::eat_json_fields(&mut map)?;
4613 Ok(value)
4614 }
4615 }
4616 const VARIANTS: &[&str] = &["unlocked",
4617 "single_user",
4618 "other"];
4619 deserializer.deserialize_struct("FileLockContent", VARIANTS, EnumVisitor)
4620 }
4621}
4622
4623impl ::serde::ser::Serialize for FileLockContent {
4624 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4625 use serde::ser::SerializeStruct;
4627 match self {
4628 FileLockContent::Unlocked => {
4629 let mut s = serializer.serialize_struct("FileLockContent", 1)?;
4631 s.serialize_field(".tag", "unlocked")?;
4632 s.end()
4633 }
4634 FileLockContent::SingleUser(x) => {
4635 let mut s = serializer.serialize_struct("FileLockContent", 4)?;
4637 s.serialize_field(".tag", "single_user")?;
4638 x.internal_serialize::<S>(&mut s)?;
4639 s.end()
4640 }
4641 FileLockContent::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
4642 }
4643 }
4644}
4645
4646#[derive(Debug, Clone, PartialEq, Eq, Default)]
4647#[non_exhaustive] pub struct FileLockMetadata {
4649 pub is_lockholder: Option<bool>,
4651 pub lockholder_name: Option<String>,
4653 pub lockholder_account_id: Option<crate::types::users_common::AccountId>,
4655 pub created: Option<crate::types::common::DropboxTimestamp>,
4657}
4658
4659impl FileLockMetadata {
4660 pub fn with_is_lockholder(mut self, value: bool) -> Self {
4661 self.is_lockholder = Some(value);
4662 self
4663 }
4664
4665 pub fn with_lockholder_name(mut self, value: String) -> Self {
4666 self.lockholder_name = Some(value);
4667 self
4668 }
4669
4670 pub fn with_lockholder_account_id(
4671 mut self,
4672 value: crate::types::users_common::AccountId,
4673 ) -> Self {
4674 self.lockholder_account_id = Some(value);
4675 self
4676 }
4677
4678 pub fn with_created(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
4679 self.created = Some(value);
4680 self
4681 }
4682}
4683
4684const FILE_LOCK_METADATA_FIELDS: &[&str] = &["is_lockholder",
4685 "lockholder_name",
4686 "lockholder_account_id",
4687 "created"];
4688impl FileLockMetadata {
4689 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4691 mut map: V,
4692 ) -> Result<FileLockMetadata, V::Error> {
4693 let mut field_is_lockholder = None;
4694 let mut field_lockholder_name = None;
4695 let mut field_lockholder_account_id = None;
4696 let mut field_created = None;
4697 while let Some(key) = map.next_key::<&str>()? {
4698 match key {
4699 "is_lockholder" => {
4700 if field_is_lockholder.is_some() {
4701 return Err(::serde::de::Error::duplicate_field("is_lockholder"));
4702 }
4703 field_is_lockholder = Some(map.next_value()?);
4704 }
4705 "lockholder_name" => {
4706 if field_lockholder_name.is_some() {
4707 return Err(::serde::de::Error::duplicate_field("lockholder_name"));
4708 }
4709 field_lockholder_name = Some(map.next_value()?);
4710 }
4711 "lockholder_account_id" => {
4712 if field_lockholder_account_id.is_some() {
4713 return Err(::serde::de::Error::duplicate_field("lockholder_account_id"));
4714 }
4715 field_lockholder_account_id = Some(map.next_value()?);
4716 }
4717 "created" => {
4718 if field_created.is_some() {
4719 return Err(::serde::de::Error::duplicate_field("created"));
4720 }
4721 field_created = Some(map.next_value()?);
4722 }
4723 _ => {
4724 map.next_value::<::serde_json::Value>()?;
4726 }
4727 }
4728 }
4729 let result = FileLockMetadata {
4730 is_lockholder: field_is_lockholder.and_then(Option::flatten),
4731 lockholder_name: field_lockholder_name.and_then(Option::flatten),
4732 lockholder_account_id: field_lockholder_account_id.and_then(Option::flatten),
4733 created: field_created.and_then(Option::flatten),
4734 };
4735 Ok(result)
4736 }
4737
4738 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4739 &self,
4740 s: &mut S::SerializeStruct,
4741 ) -> Result<(), S::Error> {
4742 use serde::ser::SerializeStruct;
4743 if let Some(val) = &self.is_lockholder {
4744 s.serialize_field("is_lockholder", val)?;
4745 }
4746 if let Some(val) = &self.lockholder_name {
4747 s.serialize_field("lockholder_name", val)?;
4748 }
4749 if let Some(val) = &self.lockholder_account_id {
4750 s.serialize_field("lockholder_account_id", val)?;
4751 }
4752 if let Some(val) = &self.created {
4753 s.serialize_field("created", val)?;
4754 }
4755 Ok(())
4756 }
4757}
4758
4759impl<'de> ::serde::de::Deserialize<'de> for FileLockMetadata {
4760 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4761 use serde::de::{MapAccess, Visitor};
4763 struct StructVisitor;
4764 impl<'de> Visitor<'de> for StructVisitor {
4765 type Value = FileLockMetadata;
4766 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4767 f.write_str("a FileLockMetadata struct")
4768 }
4769 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4770 FileLockMetadata::internal_deserialize(map)
4771 }
4772 }
4773 deserializer.deserialize_struct("FileLockMetadata", FILE_LOCK_METADATA_FIELDS, StructVisitor)
4774 }
4775}
4776
4777impl ::serde::ser::Serialize for FileLockMetadata {
4778 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4779 use serde::ser::SerializeStruct;
4781 let mut s = serializer.serialize_struct("FileLockMetadata", 4)?;
4782 self.internal_serialize::<S>(&mut s)?;
4783 s.end()
4784 }
4785}
4786
4787#[derive(Debug, Clone, PartialEq)]
4788#[non_exhaustive] pub struct FileMetadata {
4790 pub name: String,
4792 pub id: Id,
4794 pub client_modified: crate::types::common::DropboxTimestamp,
4799 pub server_modified: crate::types::common::DropboxTimestamp,
4801 pub rev: Rev,
4804 pub size: u64,
4806 pub path_lower: Option<String>,
4809 pub path_display: Option<String>,
4816 #[deprecated]
4820 pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
4821 pub preview_url: Option<String>,
4823 pub media_info: Option<MediaInfo>,
4828 pub symlink_info: Option<SymlinkInfo>,
4830 pub sharing_info: Option<FileSharingInfo>,
4832 pub is_downloadable: bool,
4834 pub export_info: Option<ExportInfo>,
4837 pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
4840 pub has_explicit_shared_members: Option<bool>,
4847 pub content_hash: Option<Sha256HexHash>,
4851 pub file_lock_info: Option<FileLockMetadata>,
4853 pub is_restorable: Option<bool>,
4855}
4856
4857impl FileMetadata {
4858 pub fn new(
4859 name: String,
4860 id: Id,
4861 client_modified: crate::types::common::DropboxTimestamp,
4862 server_modified: crate::types::common::DropboxTimestamp,
4863 rev: Rev,
4864 size: u64,
4865 ) -> Self {
4866 FileMetadata {
4867 name,
4868 id,
4869 client_modified,
4870 server_modified,
4871 rev,
4872 size,
4873 path_lower: None,
4874 path_display: None,
4875 #[allow(deprecated)] parent_shared_folder_id: None,
4876 preview_url: None,
4877 media_info: None,
4878 symlink_info: None,
4879 sharing_info: None,
4880 is_downloadable: true,
4881 export_info: None,
4882 property_groups: None,
4883 has_explicit_shared_members: None,
4884 content_hash: None,
4885 file_lock_info: None,
4886 is_restorable: None,
4887 }
4888 }
4889
4890 pub fn with_path_lower(mut self, value: String) -> Self {
4891 self.path_lower = Some(value);
4892 self
4893 }
4894
4895 pub fn with_path_display(mut self, value: String) -> Self {
4896 self.path_display = Some(value);
4897 self
4898 }
4899
4900 #[deprecated]
4901 #[allow(deprecated)]
4902 pub fn with_parent_shared_folder_id(
4903 mut self,
4904 value: crate::types::common::SharedFolderId,
4905 ) -> Self {
4906 self.parent_shared_folder_id = Some(value);
4907 self
4908 }
4909
4910 pub fn with_preview_url(mut self, value: String) -> Self {
4911 self.preview_url = Some(value);
4912 self
4913 }
4914
4915 pub fn with_media_info(mut self, value: MediaInfo) -> Self {
4916 self.media_info = Some(value);
4917 self
4918 }
4919
4920 pub fn with_symlink_info(mut self, value: SymlinkInfo) -> Self {
4921 self.symlink_info = Some(value);
4922 self
4923 }
4924
4925 pub fn with_sharing_info(mut self, value: FileSharingInfo) -> Self {
4926 self.sharing_info = Some(value);
4927 self
4928 }
4929
4930 pub fn with_is_downloadable(mut self, value: bool) -> Self {
4931 self.is_downloadable = value;
4932 self
4933 }
4934
4935 pub fn with_export_info(mut self, value: ExportInfo) -> Self {
4936 self.export_info = Some(value);
4937 self
4938 }
4939
4940 pub fn with_property_groups(
4941 mut self,
4942 value: Vec<crate::types::file_properties::PropertyGroup>,
4943 ) -> Self {
4944 self.property_groups = Some(value);
4945 self
4946 }
4947
4948 pub fn with_has_explicit_shared_members(mut self, value: bool) -> Self {
4949 self.has_explicit_shared_members = Some(value);
4950 self
4951 }
4952
4953 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
4954 self.content_hash = Some(value);
4955 self
4956 }
4957
4958 pub fn with_file_lock_info(mut self, value: FileLockMetadata) -> Self {
4959 self.file_lock_info = Some(value);
4960 self
4961 }
4962
4963 pub fn with_is_restorable(mut self, value: bool) -> Self {
4964 self.is_restorable = Some(value);
4965 self
4966 }
4967}
4968
4969const FILE_METADATA_FIELDS: &[&str] = &["name",
4970 "id",
4971 "client_modified",
4972 "server_modified",
4973 "rev",
4974 "size",
4975 "path_lower",
4976 "path_display",
4977 "parent_shared_folder_id",
4978 "preview_url",
4979 "media_info",
4980 "symlink_info",
4981 "sharing_info",
4982 "is_downloadable",
4983 "export_info",
4984 "property_groups",
4985 "has_explicit_shared_members",
4986 "content_hash",
4987 "file_lock_info",
4988 "is_restorable"];
4989impl FileMetadata {
4990 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4991 map: V,
4992 ) -> Result<FileMetadata, V::Error> {
4993 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4994 }
4995
4996 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4997 mut map: V,
4998 optional: bool,
4999 ) -> Result<Option<FileMetadata>, V::Error> {
5000 let mut field_name = None;
5001 let mut field_id = None;
5002 let mut field_client_modified = None;
5003 let mut field_server_modified = None;
5004 let mut field_rev = None;
5005 let mut field_size = None;
5006 let mut field_path_lower = None;
5007 let mut field_path_display = None;
5008 let mut field_parent_shared_folder_id = None;
5009 let mut field_preview_url = None;
5010 let mut field_media_info = None;
5011 let mut field_symlink_info = None;
5012 let mut field_sharing_info = None;
5013 let mut field_is_downloadable = None;
5014 let mut field_export_info = None;
5015 let mut field_property_groups = None;
5016 let mut field_has_explicit_shared_members = None;
5017 let mut field_content_hash = None;
5018 let mut field_file_lock_info = None;
5019 let mut field_is_restorable = None;
5020 let mut nothing = true;
5021 while let Some(key) = map.next_key::<&str>()? {
5022 nothing = false;
5023 match key {
5024 "name" => {
5025 if field_name.is_some() {
5026 return Err(::serde::de::Error::duplicate_field("name"));
5027 }
5028 field_name = Some(map.next_value()?);
5029 }
5030 "id" => {
5031 if field_id.is_some() {
5032 return Err(::serde::de::Error::duplicate_field("id"));
5033 }
5034 field_id = Some(map.next_value()?);
5035 }
5036 "client_modified" => {
5037 if field_client_modified.is_some() {
5038 return Err(::serde::de::Error::duplicate_field("client_modified"));
5039 }
5040 field_client_modified = Some(map.next_value()?);
5041 }
5042 "server_modified" => {
5043 if field_server_modified.is_some() {
5044 return Err(::serde::de::Error::duplicate_field("server_modified"));
5045 }
5046 field_server_modified = Some(map.next_value()?);
5047 }
5048 "rev" => {
5049 if field_rev.is_some() {
5050 return Err(::serde::de::Error::duplicate_field("rev"));
5051 }
5052 field_rev = Some(map.next_value()?);
5053 }
5054 "size" => {
5055 if field_size.is_some() {
5056 return Err(::serde::de::Error::duplicate_field("size"));
5057 }
5058 field_size = Some(map.next_value()?);
5059 }
5060 "path_lower" => {
5061 if field_path_lower.is_some() {
5062 return Err(::serde::de::Error::duplicate_field("path_lower"));
5063 }
5064 field_path_lower = Some(map.next_value()?);
5065 }
5066 "path_display" => {
5067 if field_path_display.is_some() {
5068 return Err(::serde::de::Error::duplicate_field("path_display"));
5069 }
5070 field_path_display = Some(map.next_value()?);
5071 }
5072 "parent_shared_folder_id" => {
5073 if field_parent_shared_folder_id.is_some() {
5074 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5075 }
5076 field_parent_shared_folder_id = Some(map.next_value()?);
5077 }
5078 "preview_url" => {
5079 if field_preview_url.is_some() {
5080 return Err(::serde::de::Error::duplicate_field("preview_url"));
5081 }
5082 field_preview_url = Some(map.next_value()?);
5083 }
5084 "media_info" => {
5085 if field_media_info.is_some() {
5086 return Err(::serde::de::Error::duplicate_field("media_info"));
5087 }
5088 field_media_info = Some(map.next_value()?);
5089 }
5090 "symlink_info" => {
5091 if field_symlink_info.is_some() {
5092 return Err(::serde::de::Error::duplicate_field("symlink_info"));
5093 }
5094 field_symlink_info = Some(map.next_value()?);
5095 }
5096 "sharing_info" => {
5097 if field_sharing_info.is_some() {
5098 return Err(::serde::de::Error::duplicate_field("sharing_info"));
5099 }
5100 field_sharing_info = Some(map.next_value()?);
5101 }
5102 "is_downloadable" => {
5103 if field_is_downloadable.is_some() {
5104 return Err(::serde::de::Error::duplicate_field("is_downloadable"));
5105 }
5106 field_is_downloadable = Some(map.next_value()?);
5107 }
5108 "export_info" => {
5109 if field_export_info.is_some() {
5110 return Err(::serde::de::Error::duplicate_field("export_info"));
5111 }
5112 field_export_info = Some(map.next_value()?);
5113 }
5114 "property_groups" => {
5115 if field_property_groups.is_some() {
5116 return Err(::serde::de::Error::duplicate_field("property_groups"));
5117 }
5118 field_property_groups = Some(map.next_value()?);
5119 }
5120 "has_explicit_shared_members" => {
5121 if field_has_explicit_shared_members.is_some() {
5122 return Err(::serde::de::Error::duplicate_field("has_explicit_shared_members"));
5123 }
5124 field_has_explicit_shared_members = Some(map.next_value()?);
5125 }
5126 "content_hash" => {
5127 if field_content_hash.is_some() {
5128 return Err(::serde::de::Error::duplicate_field("content_hash"));
5129 }
5130 field_content_hash = Some(map.next_value()?);
5131 }
5132 "file_lock_info" => {
5133 if field_file_lock_info.is_some() {
5134 return Err(::serde::de::Error::duplicate_field("file_lock_info"));
5135 }
5136 field_file_lock_info = Some(map.next_value()?);
5137 }
5138 "is_restorable" => {
5139 if field_is_restorable.is_some() {
5140 return Err(::serde::de::Error::duplicate_field("is_restorable"));
5141 }
5142 field_is_restorable = Some(map.next_value()?);
5143 }
5144 _ => {
5145 map.next_value::<::serde_json::Value>()?;
5147 }
5148 }
5149 }
5150 if optional && nothing {
5151 return Ok(None);
5152 }
5153 let result = FileMetadata {
5154 name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
5155 id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
5156 client_modified: field_client_modified.ok_or_else(|| ::serde::de::Error::missing_field("client_modified"))?,
5157 server_modified: field_server_modified.ok_or_else(|| ::serde::de::Error::missing_field("server_modified"))?,
5158 rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
5159 size: field_size.ok_or_else(|| ::serde::de::Error::missing_field("size"))?,
5160 path_lower: field_path_lower.and_then(Option::flatten),
5161 path_display: field_path_display.and_then(Option::flatten),
5162 #[allow(deprecated)] parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
5163 preview_url: field_preview_url.and_then(Option::flatten),
5164 media_info: field_media_info.and_then(Option::flatten),
5165 symlink_info: field_symlink_info.and_then(Option::flatten),
5166 sharing_info: field_sharing_info.and_then(Option::flatten),
5167 is_downloadable: field_is_downloadable.unwrap_or(true),
5168 export_info: field_export_info.and_then(Option::flatten),
5169 property_groups: field_property_groups.and_then(Option::flatten),
5170 has_explicit_shared_members: field_has_explicit_shared_members.and_then(Option::flatten),
5171 content_hash: field_content_hash.and_then(Option::flatten),
5172 file_lock_info: field_file_lock_info.and_then(Option::flatten),
5173 is_restorable: field_is_restorable.and_then(Option::flatten),
5174 };
5175 Ok(Some(result))
5176 }
5177
5178 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5179 &self,
5180 s: &mut S::SerializeStruct,
5181 ) -> Result<(), S::Error> {
5182 use serde::ser::SerializeStruct;
5183 s.serialize_field("name", &self.name)?;
5184 s.serialize_field("id", &self.id)?;
5185 s.serialize_field("client_modified", &self.client_modified)?;
5186 s.serialize_field("server_modified", &self.server_modified)?;
5187 s.serialize_field("rev", &self.rev)?;
5188 s.serialize_field("size", &self.size)?;
5189 if let Some(val) = &self.path_lower {
5190 s.serialize_field("path_lower", val)?;
5191 }
5192 if let Some(val) = &self.path_display {
5193 s.serialize_field("path_display", val)?;
5194 }
5195 #[allow(deprecated)]
5196 if let Some(val) = &self.parent_shared_folder_id {
5197 s.serialize_field("parent_shared_folder_id", val)?;
5198 }
5199 if let Some(val) = &self.preview_url {
5200 s.serialize_field("preview_url", val)?;
5201 }
5202 if let Some(val) = &self.media_info {
5203 s.serialize_field("media_info", val)?;
5204 }
5205 if let Some(val) = &self.symlink_info {
5206 s.serialize_field("symlink_info", val)?;
5207 }
5208 if let Some(val) = &self.sharing_info {
5209 s.serialize_field("sharing_info", val)?;
5210 }
5211 if !self.is_downloadable {
5212 s.serialize_field("is_downloadable", &self.is_downloadable)?;
5213 }
5214 if let Some(val) = &self.export_info {
5215 s.serialize_field("export_info", val)?;
5216 }
5217 if let Some(val) = &self.property_groups {
5218 s.serialize_field("property_groups", val)?;
5219 }
5220 if let Some(val) = &self.has_explicit_shared_members {
5221 s.serialize_field("has_explicit_shared_members", val)?;
5222 }
5223 if let Some(val) = &self.content_hash {
5224 s.serialize_field("content_hash", val)?;
5225 }
5226 if let Some(val) = &self.file_lock_info {
5227 s.serialize_field("file_lock_info", val)?;
5228 }
5229 if let Some(val) = &self.is_restorable {
5230 s.serialize_field("is_restorable", val)?;
5231 }
5232 Ok(())
5233 }
5234}
5235
5236impl<'de> ::serde::de::Deserialize<'de> for FileMetadata {
5237 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5238 use serde::de::{MapAccess, Visitor};
5240 struct StructVisitor;
5241 impl<'de> Visitor<'de> for StructVisitor {
5242 type Value = FileMetadata;
5243 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5244 f.write_str("a FileMetadata struct")
5245 }
5246 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5247 FileMetadata::internal_deserialize(map)
5248 }
5249 }
5250 deserializer.deserialize_struct("FileMetadata", FILE_METADATA_FIELDS, StructVisitor)
5251 }
5252}
5253
5254impl ::serde::ser::Serialize for FileMetadata {
5255 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5256 use serde::ser::SerializeStruct;
5258 let mut s = serializer.serialize_struct("FileMetadata", 20)?;
5259 self.internal_serialize::<S>(&mut s)?;
5260 s.end()
5261 }
5262}
5263
5264impl From<FileMetadata> for Metadata {
5266 fn from(subtype: FileMetadata) -> Self {
5267 Metadata::File(subtype)
5268 }
5269}
5270#[derive(Debug, Clone, PartialEq, Eq, Default)]
5272#[non_exhaustive] pub struct FileOpsResult {
5274}
5275
5276const FILE_OPS_RESULT_FIELDS: &[&str] = &[];
5277impl FileOpsResult {
5278 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5280 mut map: V,
5281 ) -> Result<FileOpsResult, V::Error> {
5282 crate::eat_json_fields(&mut map)?;
5284 Ok(FileOpsResult {})
5285 }
5286}
5287
5288impl<'de> ::serde::de::Deserialize<'de> for FileOpsResult {
5289 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5290 use serde::de::{MapAccess, Visitor};
5292 struct StructVisitor;
5293 impl<'de> Visitor<'de> for StructVisitor {
5294 type Value = FileOpsResult;
5295 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5296 f.write_str("a FileOpsResult struct")
5297 }
5298 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5299 FileOpsResult::internal_deserialize(map)
5300 }
5301 }
5302 deserializer.deserialize_struct("FileOpsResult", FILE_OPS_RESULT_FIELDS, StructVisitor)
5303 }
5304}
5305
5306impl ::serde::ser::Serialize for FileOpsResult {
5307 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5308 use serde::ser::SerializeStruct;
5310 serializer.serialize_struct("FileOpsResult", 0)?.end()
5311 }
5312}
5313
5314#[derive(Debug, Clone, PartialEq, Eq)]
5316#[non_exhaustive] pub struct FileSharingInfo {
5318 pub read_only: bool,
5320 pub parent_shared_folder_id: crate::types::common::SharedFolderId,
5322 pub modified_by: Option<crate::types::users_common::AccountId>,
5325}
5326
5327impl FileSharingInfo {
5328 pub fn new(
5329 read_only: bool,
5330 parent_shared_folder_id: crate::types::common::SharedFolderId,
5331 ) -> Self {
5332 FileSharingInfo {
5333 read_only,
5334 parent_shared_folder_id,
5335 modified_by: None,
5336 }
5337 }
5338
5339 pub fn with_modified_by(mut self, value: crate::types::users_common::AccountId) -> Self {
5340 self.modified_by = Some(value);
5341 self
5342 }
5343}
5344
5345const FILE_SHARING_INFO_FIELDS: &[&str] = &["read_only",
5346 "parent_shared_folder_id",
5347 "modified_by"];
5348impl FileSharingInfo {
5349 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5350 map: V,
5351 ) -> Result<FileSharingInfo, V::Error> {
5352 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5353 }
5354
5355 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5356 mut map: V,
5357 optional: bool,
5358 ) -> Result<Option<FileSharingInfo>, V::Error> {
5359 let mut field_read_only = None;
5360 let mut field_parent_shared_folder_id = None;
5361 let mut field_modified_by = None;
5362 let mut nothing = true;
5363 while let Some(key) = map.next_key::<&str>()? {
5364 nothing = false;
5365 match key {
5366 "read_only" => {
5367 if field_read_only.is_some() {
5368 return Err(::serde::de::Error::duplicate_field("read_only"));
5369 }
5370 field_read_only = Some(map.next_value()?);
5371 }
5372 "parent_shared_folder_id" => {
5373 if field_parent_shared_folder_id.is_some() {
5374 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5375 }
5376 field_parent_shared_folder_id = Some(map.next_value()?);
5377 }
5378 "modified_by" => {
5379 if field_modified_by.is_some() {
5380 return Err(::serde::de::Error::duplicate_field("modified_by"));
5381 }
5382 field_modified_by = Some(map.next_value()?);
5383 }
5384 _ => {
5385 map.next_value::<::serde_json::Value>()?;
5387 }
5388 }
5389 }
5390 if optional && nothing {
5391 return Ok(None);
5392 }
5393 let result = FileSharingInfo {
5394 read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
5395 parent_shared_folder_id: field_parent_shared_folder_id.ok_or_else(|| ::serde::de::Error::missing_field("parent_shared_folder_id"))?,
5396 modified_by: field_modified_by.and_then(Option::flatten),
5397 };
5398 Ok(Some(result))
5399 }
5400
5401 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5402 &self,
5403 s: &mut S::SerializeStruct,
5404 ) -> Result<(), S::Error> {
5405 use serde::ser::SerializeStruct;
5406 s.serialize_field("read_only", &self.read_only)?;
5407 s.serialize_field("parent_shared_folder_id", &self.parent_shared_folder_id)?;
5408 if let Some(val) = &self.modified_by {
5409 s.serialize_field("modified_by", val)?;
5410 }
5411 Ok(())
5412 }
5413}
5414
5415impl<'de> ::serde::de::Deserialize<'de> for FileSharingInfo {
5416 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5417 use serde::de::{MapAccess, Visitor};
5419 struct StructVisitor;
5420 impl<'de> Visitor<'de> for StructVisitor {
5421 type Value = FileSharingInfo;
5422 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5423 f.write_str("a FileSharingInfo struct")
5424 }
5425 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5426 FileSharingInfo::internal_deserialize(map)
5427 }
5428 }
5429 deserializer.deserialize_struct("FileSharingInfo", FILE_SHARING_INFO_FIELDS, StructVisitor)
5430 }
5431}
5432
5433impl ::serde::ser::Serialize for FileSharingInfo {
5434 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5435 use serde::ser::SerializeStruct;
5437 let mut s = serializer.serialize_struct("FileSharingInfo", 3)?;
5438 self.internal_serialize::<S>(&mut s)?;
5439 s.end()
5440 }
5441}
5442
5443impl From<FileSharingInfo> for SharingInfo {
5445 fn from(subtype: FileSharingInfo) -> Self {
5446 Self {
5447 read_only: subtype.read_only,
5448 }
5449 }
5450}
5451#[derive(Debug, Clone, PartialEq, Eq)]
5452#[non_exhaustive] pub enum FileStatus {
5454 Active,
5455 Deleted,
5456 Other,
5459}
5460
5461impl<'de> ::serde::de::Deserialize<'de> for FileStatus {
5462 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5463 use serde::de::{self, MapAccess, Visitor};
5465 struct EnumVisitor;
5466 impl<'de> Visitor<'de> for EnumVisitor {
5467 type Value = FileStatus;
5468 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5469 f.write_str("a FileStatus structure")
5470 }
5471 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
5472 let tag: &str = match map.next_key()? {
5473 Some(".tag") => map.next_value()?,
5474 _ => return Err(de::Error::missing_field(".tag"))
5475 };
5476 let value = match tag {
5477 "active" => FileStatus::Active,
5478 "deleted" => FileStatus::Deleted,
5479 _ => FileStatus::Other,
5480 };
5481 crate::eat_json_fields(&mut map)?;
5482 Ok(value)
5483 }
5484 }
5485 const VARIANTS: &[&str] = &["active",
5486 "deleted",
5487 "other"];
5488 deserializer.deserialize_struct("FileStatus", VARIANTS, EnumVisitor)
5489 }
5490}
5491
5492impl ::serde::ser::Serialize for FileStatus {
5493 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5494 use serde::ser::SerializeStruct;
5496 match self {
5497 FileStatus::Active => {
5498 let mut s = serializer.serialize_struct("FileStatus", 1)?;
5500 s.serialize_field(".tag", "active")?;
5501 s.end()
5502 }
5503 FileStatus::Deleted => {
5504 let mut s = serializer.serialize_struct("FileStatus", 1)?;
5506 s.serialize_field(".tag", "deleted")?;
5507 s.end()
5508 }
5509 FileStatus::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
5510 }
5511 }
5512}
5513
5514#[derive(Debug, Clone, PartialEq, Eq)]
5515#[non_exhaustive] pub struct FolderMetadata {
5517 pub name: String,
5519 pub id: Id,
5521 pub path_lower: Option<String>,
5524 pub path_display: Option<String>,
5531 #[deprecated]
5535 pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
5536 pub preview_url: Option<String>,
5538 #[deprecated]
5540 pub shared_folder_id: Option<crate::types::common::SharedFolderId>,
5541 pub sharing_info: Option<FolderSharingInfo>,
5543 pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
5547}
5548
5549impl FolderMetadata {
5550 pub fn new(name: String, id: Id) -> Self {
5551 FolderMetadata {
5552 name,
5553 id,
5554 path_lower: None,
5555 path_display: None,
5556 #[allow(deprecated)] parent_shared_folder_id: None,
5557 preview_url: None,
5558 #[allow(deprecated)] shared_folder_id: None,
5559 sharing_info: None,
5560 property_groups: None,
5561 }
5562 }
5563
5564 pub fn with_path_lower(mut self, value: String) -> Self {
5565 self.path_lower = Some(value);
5566 self
5567 }
5568
5569 pub fn with_path_display(mut self, value: String) -> Self {
5570 self.path_display = Some(value);
5571 self
5572 }
5573
5574 #[deprecated]
5575 #[allow(deprecated)]
5576 pub fn with_parent_shared_folder_id(
5577 mut self,
5578 value: crate::types::common::SharedFolderId,
5579 ) -> Self {
5580 self.parent_shared_folder_id = Some(value);
5581 self
5582 }
5583
5584 pub fn with_preview_url(mut self, value: String) -> Self {
5585 self.preview_url = Some(value);
5586 self
5587 }
5588
5589 #[deprecated]
5590 #[allow(deprecated)]
5591 pub fn with_shared_folder_id(mut self, value: crate::types::common::SharedFolderId) -> Self {
5592 self.shared_folder_id = Some(value);
5593 self
5594 }
5595
5596 pub fn with_sharing_info(mut self, value: FolderSharingInfo) -> Self {
5597 self.sharing_info = Some(value);
5598 self
5599 }
5600
5601 pub fn with_property_groups(
5602 mut self,
5603 value: Vec<crate::types::file_properties::PropertyGroup>,
5604 ) -> Self {
5605 self.property_groups = Some(value);
5606 self
5607 }
5608}
5609
5610const FOLDER_METADATA_FIELDS: &[&str] = &["name",
5611 "id",
5612 "path_lower",
5613 "path_display",
5614 "parent_shared_folder_id",
5615 "preview_url",
5616 "shared_folder_id",
5617 "sharing_info",
5618 "property_groups"];
5619impl FolderMetadata {
5620 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5621 map: V,
5622 ) -> Result<FolderMetadata, V::Error> {
5623 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5624 }
5625
5626 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5627 mut map: V,
5628 optional: bool,
5629 ) -> Result<Option<FolderMetadata>, V::Error> {
5630 let mut field_name = None;
5631 let mut field_id = None;
5632 let mut field_path_lower = None;
5633 let mut field_path_display = None;
5634 let mut field_parent_shared_folder_id = None;
5635 let mut field_preview_url = None;
5636 let mut field_shared_folder_id = None;
5637 let mut field_sharing_info = None;
5638 let mut field_property_groups = None;
5639 let mut nothing = true;
5640 while let Some(key) = map.next_key::<&str>()? {
5641 nothing = false;
5642 match key {
5643 "name" => {
5644 if field_name.is_some() {
5645 return Err(::serde::de::Error::duplicate_field("name"));
5646 }
5647 field_name = Some(map.next_value()?);
5648 }
5649 "id" => {
5650 if field_id.is_some() {
5651 return Err(::serde::de::Error::duplicate_field("id"));
5652 }
5653 field_id = Some(map.next_value()?);
5654 }
5655 "path_lower" => {
5656 if field_path_lower.is_some() {
5657 return Err(::serde::de::Error::duplicate_field("path_lower"));
5658 }
5659 field_path_lower = Some(map.next_value()?);
5660 }
5661 "path_display" => {
5662 if field_path_display.is_some() {
5663 return Err(::serde::de::Error::duplicate_field("path_display"));
5664 }
5665 field_path_display = Some(map.next_value()?);
5666 }
5667 "parent_shared_folder_id" => {
5668 if field_parent_shared_folder_id.is_some() {
5669 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5670 }
5671 field_parent_shared_folder_id = Some(map.next_value()?);
5672 }
5673 "preview_url" => {
5674 if field_preview_url.is_some() {
5675 return Err(::serde::de::Error::duplicate_field("preview_url"));
5676 }
5677 field_preview_url = Some(map.next_value()?);
5678 }
5679 "shared_folder_id" => {
5680 if field_shared_folder_id.is_some() {
5681 return Err(::serde::de::Error::duplicate_field("shared_folder_id"));
5682 }
5683 field_shared_folder_id = Some(map.next_value()?);
5684 }
5685 "sharing_info" => {
5686 if field_sharing_info.is_some() {
5687 return Err(::serde::de::Error::duplicate_field("sharing_info"));
5688 }
5689 field_sharing_info = Some(map.next_value()?);
5690 }
5691 "property_groups" => {
5692 if field_property_groups.is_some() {
5693 return Err(::serde::de::Error::duplicate_field("property_groups"));
5694 }
5695 field_property_groups = Some(map.next_value()?);
5696 }
5697 _ => {
5698 map.next_value::<::serde_json::Value>()?;
5700 }
5701 }
5702 }
5703 if optional && nothing {
5704 return Ok(None);
5705 }
5706 let result = FolderMetadata {
5707 name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
5708 id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
5709 path_lower: field_path_lower.and_then(Option::flatten),
5710 path_display: field_path_display.and_then(Option::flatten),
5711 #[allow(deprecated)] parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
5712 preview_url: field_preview_url.and_then(Option::flatten),
5713 #[allow(deprecated)] shared_folder_id: field_shared_folder_id.and_then(Option::flatten),
5714 sharing_info: field_sharing_info.and_then(Option::flatten),
5715 property_groups: field_property_groups.and_then(Option::flatten),
5716 };
5717 Ok(Some(result))
5718 }
5719
5720 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5721 &self,
5722 s: &mut S::SerializeStruct,
5723 ) -> Result<(), S::Error> {
5724 use serde::ser::SerializeStruct;
5725 s.serialize_field("name", &self.name)?;
5726 s.serialize_field("id", &self.id)?;
5727 if let Some(val) = &self.path_lower {
5728 s.serialize_field("path_lower", val)?;
5729 }
5730 if let Some(val) = &self.path_display {
5731 s.serialize_field("path_display", val)?;
5732 }
5733 #[allow(deprecated)]
5734 if let Some(val) = &self.parent_shared_folder_id {
5735 s.serialize_field("parent_shared_folder_id", val)?;
5736 }
5737 if let Some(val) = &self.preview_url {
5738 s.serialize_field("preview_url", val)?;
5739 }
5740 #[allow(deprecated)]
5741 if let Some(val) = &self.shared_folder_id {
5742 s.serialize_field("shared_folder_id", val)?;
5743 }
5744 if let Some(val) = &self.sharing_info {
5745 s.serialize_field("sharing_info", val)?;
5746 }
5747 if let Some(val) = &self.property_groups {
5748 s.serialize_field("property_groups", val)?;
5749 }
5750 Ok(())
5751 }
5752}
5753
5754impl<'de> ::serde::de::Deserialize<'de> for FolderMetadata {
5755 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5756 use serde::de::{MapAccess, Visitor};
5758 struct StructVisitor;
5759 impl<'de> Visitor<'de> for StructVisitor {
5760 type Value = FolderMetadata;
5761 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5762 f.write_str("a FolderMetadata struct")
5763 }
5764 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5765 FolderMetadata::internal_deserialize(map)
5766 }
5767 }
5768 deserializer.deserialize_struct("FolderMetadata", FOLDER_METADATA_FIELDS, StructVisitor)
5769 }
5770}
5771
5772impl ::serde::ser::Serialize for FolderMetadata {
5773 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5774 use serde::ser::SerializeStruct;
5776 let mut s = serializer.serialize_struct("FolderMetadata", 9)?;
5777 self.internal_serialize::<S>(&mut s)?;
5778 s.end()
5779 }
5780}
5781
5782impl From<FolderMetadata> for Metadata {
5784 fn from(subtype: FolderMetadata) -> Self {
5785 Metadata::Folder(subtype)
5786 }
5787}
5788#[derive(Debug, Clone, PartialEq, Eq)]
5791#[non_exhaustive] pub struct FolderSharingInfo {
5793 pub read_only: bool,
5795 pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
5797 pub shared_folder_id: Option<crate::types::common::SharedFolderId>,
5800 pub traverse_only: bool,
5804 pub no_access: bool,
5806}
5807
5808impl FolderSharingInfo {
5809 pub fn new(read_only: bool) -> Self {
5810 FolderSharingInfo {
5811 read_only,
5812 parent_shared_folder_id: None,
5813 shared_folder_id: None,
5814 traverse_only: false,
5815 no_access: false,
5816 }
5817 }
5818
5819 pub fn with_parent_shared_folder_id(
5820 mut self,
5821 value: crate::types::common::SharedFolderId,
5822 ) -> Self {
5823 self.parent_shared_folder_id = Some(value);
5824 self
5825 }
5826
5827 pub fn with_shared_folder_id(mut self, value: crate::types::common::SharedFolderId) -> Self {
5828 self.shared_folder_id = Some(value);
5829 self
5830 }
5831
5832 pub fn with_traverse_only(mut self, value: bool) -> Self {
5833 self.traverse_only = value;
5834 self
5835 }
5836
5837 pub fn with_no_access(mut self, value: bool) -> Self {
5838 self.no_access = value;
5839 self
5840 }
5841}
5842
5843const FOLDER_SHARING_INFO_FIELDS: &[&str] = &["read_only",
5844 "parent_shared_folder_id",
5845 "shared_folder_id",
5846 "traverse_only",
5847 "no_access"];
5848impl FolderSharingInfo {
5849 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5850 map: V,
5851 ) -> Result<FolderSharingInfo, V::Error> {
5852 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5853 }
5854
5855 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5856 mut map: V,
5857 optional: bool,
5858 ) -> Result<Option<FolderSharingInfo>, V::Error> {
5859 let mut field_read_only = None;
5860 let mut field_parent_shared_folder_id = None;
5861 let mut field_shared_folder_id = None;
5862 let mut field_traverse_only = None;
5863 let mut field_no_access = None;
5864 let mut nothing = true;
5865 while let Some(key) = map.next_key::<&str>()? {
5866 nothing = false;
5867 match key {
5868 "read_only" => {
5869 if field_read_only.is_some() {
5870 return Err(::serde::de::Error::duplicate_field("read_only"));
5871 }
5872 field_read_only = Some(map.next_value()?);
5873 }
5874 "parent_shared_folder_id" => {
5875 if field_parent_shared_folder_id.is_some() {
5876 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5877 }
5878 field_parent_shared_folder_id = Some(map.next_value()?);
5879 }
5880 "shared_folder_id" => {
5881 if field_shared_folder_id.is_some() {
5882 return Err(::serde::de::Error::duplicate_field("shared_folder_id"));
5883 }
5884 field_shared_folder_id = Some(map.next_value()?);
5885 }
5886 "traverse_only" => {
5887 if field_traverse_only.is_some() {
5888 return Err(::serde::de::Error::duplicate_field("traverse_only"));
5889 }
5890 field_traverse_only = Some(map.next_value()?);
5891 }
5892 "no_access" => {
5893 if field_no_access.is_some() {
5894 return Err(::serde::de::Error::duplicate_field("no_access"));
5895 }
5896 field_no_access = Some(map.next_value()?);
5897 }
5898 _ => {
5899 map.next_value::<::serde_json::Value>()?;
5901 }
5902 }
5903 }
5904 if optional && nothing {
5905 return Ok(None);
5906 }
5907 let result = FolderSharingInfo {
5908 read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
5909 parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
5910 shared_folder_id: field_shared_folder_id.and_then(Option::flatten),
5911 traverse_only: field_traverse_only.unwrap_or(false),
5912 no_access: field_no_access.unwrap_or(false),
5913 };
5914 Ok(Some(result))
5915 }
5916
5917 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5918 &self,
5919 s: &mut S::SerializeStruct,
5920 ) -> Result<(), S::Error> {
5921 use serde::ser::SerializeStruct;
5922 s.serialize_field("read_only", &self.read_only)?;
5923 if let Some(val) = &self.parent_shared_folder_id {
5924 s.serialize_field("parent_shared_folder_id", val)?;
5925 }
5926 if let Some(val) = &self.shared_folder_id {
5927 s.serialize_field("shared_folder_id", val)?;
5928 }
5929 if self.traverse_only {
5930 s.serialize_field("traverse_only", &self.traverse_only)?;
5931 }
5932 if self.no_access {
5933 s.serialize_field("no_access", &self.no_access)?;
5934 }
5935 Ok(())
5936 }
5937}
5938
5939impl<'de> ::serde::de::Deserialize<'de> for FolderSharingInfo {
5940 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5941 use serde::de::{MapAccess, Visitor};
5943 struct StructVisitor;
5944 impl<'de> Visitor<'de> for StructVisitor {
5945 type Value = FolderSharingInfo;
5946 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5947 f.write_str("a FolderSharingInfo struct")
5948 }
5949 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5950 FolderSharingInfo::internal_deserialize(map)
5951 }
5952 }
5953 deserializer.deserialize_struct("FolderSharingInfo", FOLDER_SHARING_INFO_FIELDS, StructVisitor)
5954 }
5955}
5956
5957impl ::serde::ser::Serialize for FolderSharingInfo {
5958 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5959 use serde::ser::SerializeStruct;
5961 let mut s = serializer.serialize_struct("FolderSharingInfo", 5)?;
5962 self.internal_serialize::<S>(&mut s)?;
5963 s.end()
5964 }
5965}
5966
5967impl From<FolderSharingInfo> for SharingInfo {
5969 fn from(subtype: FolderSharingInfo) -> Self {
5970 Self {
5971 read_only: subtype.read_only,
5972 }
5973 }
5974}
5975#[derive(Debug, Clone, PartialEq, Eq)]
5976#[non_exhaustive] pub struct GetCopyReferenceArg {
5978 pub path: ReadPath,
5980}
5981
5982impl GetCopyReferenceArg {
5983 pub fn new(path: ReadPath) -> Self {
5984 GetCopyReferenceArg {
5985 path,
5986 }
5987 }
5988}
5989
5990const GET_COPY_REFERENCE_ARG_FIELDS: &[&str] = &["path"];
5991impl GetCopyReferenceArg {
5992 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5993 map: V,
5994 ) -> Result<GetCopyReferenceArg, V::Error> {
5995 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5996 }
5997
5998 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5999 mut map: V,
6000 optional: bool,
6001 ) -> Result<Option<GetCopyReferenceArg>, V::Error> {
6002 let mut field_path = None;
6003 let mut nothing = true;
6004 while let Some(key) = map.next_key::<&str>()? {
6005 nothing = false;
6006 match key {
6007 "path" => {
6008 if field_path.is_some() {
6009 return Err(::serde::de::Error::duplicate_field("path"));
6010 }
6011 field_path = Some(map.next_value()?);
6012 }
6013 _ => {
6014 map.next_value::<::serde_json::Value>()?;
6016 }
6017 }
6018 }
6019 if optional && nothing {
6020 return Ok(None);
6021 }
6022 let result = GetCopyReferenceArg {
6023 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
6024 };
6025 Ok(Some(result))
6026 }
6027
6028 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6029 &self,
6030 s: &mut S::SerializeStruct,
6031 ) -> Result<(), S::Error> {
6032 use serde::ser::SerializeStruct;
6033 s.serialize_field("path", &self.path)?;
6034 Ok(())
6035 }
6036}
6037
6038impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceArg {
6039 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6040 use serde::de::{MapAccess, Visitor};
6042 struct StructVisitor;
6043 impl<'de> Visitor<'de> for StructVisitor {
6044 type Value = GetCopyReferenceArg;
6045 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6046 f.write_str("a GetCopyReferenceArg struct")
6047 }
6048 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6049 GetCopyReferenceArg::internal_deserialize(map)
6050 }
6051 }
6052 deserializer.deserialize_struct("GetCopyReferenceArg", GET_COPY_REFERENCE_ARG_FIELDS, StructVisitor)
6053 }
6054}
6055
6056impl ::serde::ser::Serialize for GetCopyReferenceArg {
6057 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6058 use serde::ser::SerializeStruct;
6060 let mut s = serializer.serialize_struct("GetCopyReferenceArg", 1)?;
6061 self.internal_serialize::<S>(&mut s)?;
6062 s.end()
6063 }
6064}
6065
6066#[derive(Debug, Clone, PartialEq, Eq)]
6067#[non_exhaustive] pub enum GetCopyReferenceError {
6069 Path(LookupError),
6070 Other,
6073}
6074
6075impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceError {
6076 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6077 use serde::de::{self, MapAccess, Visitor};
6079 struct EnumVisitor;
6080 impl<'de> Visitor<'de> for EnumVisitor {
6081 type Value = GetCopyReferenceError;
6082 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6083 f.write_str("a GetCopyReferenceError structure")
6084 }
6085 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
6086 let tag: &str = match map.next_key()? {
6087 Some(".tag") => map.next_value()?,
6088 _ => return Err(de::Error::missing_field(".tag"))
6089 };
6090 let value = match tag {
6091 "path" => {
6092 match map.next_key()? {
6093 Some("path") => GetCopyReferenceError::Path(map.next_value()?),
6094 None => return Err(de::Error::missing_field("path")),
6095 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
6096 }
6097 }
6098 _ => GetCopyReferenceError::Other,
6099 };
6100 crate::eat_json_fields(&mut map)?;
6101 Ok(value)
6102 }
6103 }
6104 const VARIANTS: &[&str] = &["path",
6105 "other"];
6106 deserializer.deserialize_struct("GetCopyReferenceError", VARIANTS, EnumVisitor)
6107 }
6108}
6109
6110impl ::serde::ser::Serialize for GetCopyReferenceError {
6111 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6112 use serde::ser::SerializeStruct;
6114 match self {
6115 GetCopyReferenceError::Path(x) => {
6116 let mut s = serializer.serialize_struct("GetCopyReferenceError", 2)?;
6118 s.serialize_field(".tag", "path")?;
6119 s.serialize_field("path", x)?;
6120 s.end()
6121 }
6122 GetCopyReferenceError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
6123 }
6124 }
6125}
6126
6127impl ::std::error::Error for GetCopyReferenceError {
6128 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
6129 match self {
6130 GetCopyReferenceError::Path(inner) => Some(inner),
6131 _ => None,
6132 }
6133 }
6134}
6135
6136impl ::std::fmt::Display for GetCopyReferenceError {
6137 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6138 match self {
6139 GetCopyReferenceError::Path(inner) => write!(f, "GetCopyReferenceError: {}", inner),
6140 _ => write!(f, "{:?}", *self),
6141 }
6142 }
6143}
6144
6145#[derive(Debug, Clone, PartialEq)]
6146#[non_exhaustive] pub struct GetCopyReferenceResult {
6148 pub metadata: Metadata,
6150 pub copy_reference: String,
6152 pub expires: crate::types::common::DropboxTimestamp,
6155}
6156
6157impl GetCopyReferenceResult {
6158 pub fn new(
6159 metadata: Metadata,
6160 copy_reference: String,
6161 expires: crate::types::common::DropboxTimestamp,
6162 ) -> Self {
6163 GetCopyReferenceResult {
6164 metadata,
6165 copy_reference,
6166 expires,
6167 }
6168 }
6169}
6170
6171const GET_COPY_REFERENCE_RESULT_FIELDS: &[&str] = &["metadata",
6172 "copy_reference",
6173 "expires"];
6174impl GetCopyReferenceResult {
6175 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6176 map: V,
6177 ) -> Result<GetCopyReferenceResult, V::Error> {
6178 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6179 }
6180
6181 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6182 mut map: V,
6183 optional: bool,
6184 ) -> Result<Option<GetCopyReferenceResult>, V::Error> {
6185 let mut field_metadata = None;
6186 let mut field_copy_reference = None;
6187 let mut field_expires = None;
6188 let mut nothing = true;
6189 while let Some(key) = map.next_key::<&str>()? {
6190 nothing = false;
6191 match key {
6192 "metadata" => {
6193 if field_metadata.is_some() {
6194 return Err(::serde::de::Error::duplicate_field("metadata"));
6195 }
6196 field_metadata = Some(map.next_value()?);
6197 }
6198 "copy_reference" => {
6199 if field_copy_reference.is_some() {
6200 return Err(::serde::de::Error::duplicate_field("copy_reference"));
6201 }
6202 field_copy_reference = Some(map.next_value()?);
6203 }
6204 "expires" => {
6205 if field_expires.is_some() {
6206 return Err(::serde::de::Error::duplicate_field("expires"));
6207 }
6208 field_expires = Some(map.next_value()?);
6209 }
6210 _ => {
6211 map.next_value::<::serde_json::Value>()?;
6213 }
6214 }
6215 }
6216 if optional && nothing {
6217 return Ok(None);
6218 }
6219 let result = GetCopyReferenceResult {
6220 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
6221 copy_reference: field_copy_reference.ok_or_else(|| ::serde::de::Error::missing_field("copy_reference"))?,
6222 expires: field_expires.ok_or_else(|| ::serde::de::Error::missing_field("expires"))?,
6223 };
6224 Ok(Some(result))
6225 }
6226
6227 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6228 &self,
6229 s: &mut S::SerializeStruct,
6230 ) -> Result<(), S::Error> {
6231 use serde::ser::SerializeStruct;
6232 s.serialize_field("metadata", &self.metadata)?;
6233 s.serialize_field("copy_reference", &self.copy_reference)?;
6234 s.serialize_field("expires", &self.expires)?;
6235 Ok(())
6236 }
6237}
6238
6239impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceResult {
6240 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6241 use serde::de::{MapAccess, Visitor};
6243 struct StructVisitor;
6244 impl<'de> Visitor<'de> for StructVisitor {
6245 type Value = GetCopyReferenceResult;
6246 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6247 f.write_str("a GetCopyReferenceResult struct")
6248 }
6249 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6250 GetCopyReferenceResult::internal_deserialize(map)
6251 }
6252 }
6253 deserializer.deserialize_struct("GetCopyReferenceResult", GET_COPY_REFERENCE_RESULT_FIELDS, StructVisitor)
6254 }
6255}
6256
6257impl ::serde::ser::Serialize for GetCopyReferenceResult {
6258 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6259 use serde::ser::SerializeStruct;
6261 let mut s = serializer.serialize_struct("GetCopyReferenceResult", 3)?;
6262 self.internal_serialize::<S>(&mut s)?;
6263 s.end()
6264 }
6265}
6266
6267#[derive(Debug, Clone, PartialEq, Eq)]
6268#[non_exhaustive] pub struct GetMetadataArg {
6270 pub path: ReadPath,
6272 pub include_media_info: bool,
6274 pub include_deleted: bool,
6277 pub include_has_explicit_shared_members: bool,
6280 pub include_property_groups: Option<crate::types::file_properties::TemplateFilterBase>,
6283}
6284
6285impl GetMetadataArg {
6286 pub fn new(path: ReadPath) -> Self {
6287 GetMetadataArg {
6288 path,
6289 include_media_info: false,
6290 include_deleted: false,
6291 include_has_explicit_shared_members: false,
6292 include_property_groups: None,
6293 }
6294 }
6295
6296 pub fn with_include_media_info(mut self, value: bool) -> Self {
6297 self.include_media_info = value;
6298 self
6299 }
6300
6301 pub fn with_include_deleted(mut self, value: bool) -> Self {
6302 self.include_deleted = value;
6303 self
6304 }
6305
6306 pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
6307 self.include_has_explicit_shared_members = value;
6308 self
6309 }
6310
6311 pub fn with_include_property_groups(
6312 mut self,
6313 value: crate::types::file_properties::TemplateFilterBase,
6314 ) -> Self {
6315 self.include_property_groups = Some(value);
6316 self
6317 }
6318}
6319
6320const GET_METADATA_ARG_FIELDS: &[&str] = &["path",
6321 "include_media_info",
6322 "include_deleted",
6323 "include_has_explicit_shared_members",
6324 "include_property_groups"];
6325impl GetMetadataArg {
6326 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6327 map: V,
6328 ) -> Result<GetMetadataArg, V::Error> {
6329 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6330 }
6331
6332 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6333 mut map: V,
6334 optional: bool,
6335 ) -> Result<Option<GetMetadataArg>, V::Error> {
6336 let mut field_path = None;
6337 let mut field_include_media_info = None;
6338 let mut field_include_deleted = None;
6339 let mut field_include_has_explicit_shared_members = None;
6340 let mut field_include_property_groups = None;
6341 let mut nothing = true;
6342 while let Some(key) = map.next_key::<&str>()? {
6343 nothing = false;
6344 match key {
6345 "path" => {
6346 if field_path.is_some() {
6347 return Err(::serde::de::Error::duplicate_field("path"));
6348 }
6349 field_path = Some(map.next_value()?);
6350 }
6351 "include_media_info" => {
6352 if field_include_media_info.is_some() {
6353 return Err(::serde::de::Error::duplicate_field("include_media_info"));
6354 }
6355 field_include_media_info = Some(map.next_value()?);
6356 }
6357 "include_deleted" => {
6358 if field_include_deleted.is_some() {
6359 return Err(::serde::de::Error::duplicate_field("include_deleted"));
6360 }
6361 field_include_deleted = Some(map.next_value()?);
6362 }
6363 "include_has_explicit_shared_members" => {
6364 if field_include_has_explicit_shared_members.is_some() {
6365 return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
6366 }
6367 field_include_has_explicit_shared_members = Some(map.next_value()?);
6368 }
6369 "include_property_groups" => {
6370 if field_include_property_groups.is_some() {
6371 return Err(::serde::de::Error::duplicate_field("include_property_groups"));
6372 }
6373 field_include_property_groups = Some(map.next_value()?);
6374 }
6375 _ => {
6376 map.next_value::<::serde_json::Value>()?;
6378 }
6379 }
6380 }
6381 if optional && nothing {
6382 return Ok(None);
6383 }
6384 let result = GetMetadataArg {
6385 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
6386 include_media_info: field_include_media_info.unwrap_or(false),
6387 include_deleted: field_include_deleted.unwrap_or(false),
6388 include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
6389 include_property_groups: field_include_property_groups.and_then(Option::flatten),
6390 };
6391 Ok(Some(result))
6392 }
6393
6394 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6395 &self,
6396 s: &mut S::SerializeStruct,
6397 ) -> Result<(), S::Error> {
6398 use serde::ser::SerializeStruct;
6399 s.serialize_field("path", &self.path)?;
6400 if self.include_media_info {
6401 s.serialize_field("include_media_info", &self.include_media_info)?;
6402 }
6403 if self.include_deleted {
6404 s.serialize_field("include_deleted", &self.include_deleted)?;
6405 }
6406 if self.include_has_explicit_shared_members {
6407 s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
6408 }
6409 if let Some(val) = &self.include_property_groups {
6410 s.serialize_field("include_property_groups", val)?;
6411 }
6412 Ok(())
6413 }
6414}
6415
6416impl<'de> ::serde::de::Deserialize<'de> for GetMetadataArg {
6417 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6418 use serde::de::{MapAccess, Visitor};
6420 struct StructVisitor;
6421 impl<'de> Visitor<'de> for StructVisitor {
6422 type Value = GetMetadataArg;
6423 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6424 f.write_str("a GetMetadataArg struct")
6425 }
6426 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6427 GetMetadataArg::internal_deserialize(map)
6428 }
6429 }
6430 deserializer.deserialize_struct("GetMetadataArg", GET_METADATA_ARG_FIELDS, StructVisitor)
6431 }
6432}
6433
6434impl ::serde::ser::Serialize for GetMetadataArg {
6435 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6436 use serde::ser::SerializeStruct;
6438 let mut s = serializer.serialize_struct("GetMetadataArg", 5)?;
6439 self.internal_serialize::<S>(&mut s)?;
6440 s.end()
6441 }
6442}
6443
6444#[derive(Debug, Clone, PartialEq, Eq)]
6445pub enum GetMetadataError {
6446 Path(LookupError),
6447}
6448
6449impl<'de> ::serde::de::Deserialize<'de> for GetMetadataError {
6450 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6451 use serde::de::{self, MapAccess, Visitor};
6453 struct EnumVisitor;
6454 impl<'de> Visitor<'de> for EnumVisitor {
6455 type Value = GetMetadataError;
6456 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6457 f.write_str("a GetMetadataError structure")
6458 }
6459 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
6460 let tag: &str = match map.next_key()? {
6461 Some(".tag") => map.next_value()?,
6462 _ => return Err(de::Error::missing_field(".tag"))
6463 };
6464 let value = match tag {
6465 "path" => {
6466 match map.next_key()? {
6467 Some("path") => GetMetadataError::Path(map.next_value()?),
6468 None => return Err(de::Error::missing_field("path")),
6469 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
6470 }
6471 }
6472 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
6473 };
6474 crate::eat_json_fields(&mut map)?;
6475 Ok(value)
6476 }
6477 }
6478 const VARIANTS: &[&str] = &["path"];
6479 deserializer.deserialize_struct("GetMetadataError", VARIANTS, EnumVisitor)
6480 }
6481}
6482
6483impl ::serde::ser::Serialize for GetMetadataError {
6484 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6485 use serde::ser::SerializeStruct;
6487 match self {
6488 GetMetadataError::Path(x) => {
6489 let mut s = serializer.serialize_struct("GetMetadataError", 2)?;
6491 s.serialize_field(".tag", "path")?;
6492 s.serialize_field("path", x)?;
6493 s.end()
6494 }
6495 }
6496 }
6497}
6498
6499impl ::std::error::Error for GetMetadataError {
6500 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
6501 match self {
6502 GetMetadataError::Path(inner) => Some(inner),
6503 }
6504 }
6505}
6506
6507impl ::std::fmt::Display for GetMetadataError {
6508 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6509 match self {
6510 GetMetadataError::Path(inner) => write!(f, "GetMetadataError: {}", inner),
6511 }
6512 }
6513}
6514
6515#[derive(Debug, Clone, PartialEq, Eq)]
6516#[non_exhaustive] pub struct GetTagsArg {
6518 pub paths: Vec<Path>,
6520}
6521
6522impl GetTagsArg {
6523 pub fn new(paths: Vec<Path>) -> Self {
6524 GetTagsArg {
6525 paths,
6526 }
6527 }
6528}
6529
6530const GET_TAGS_ARG_FIELDS: &[&str] = &["paths"];
6531impl GetTagsArg {
6532 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6533 map: V,
6534 ) -> Result<GetTagsArg, V::Error> {
6535 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6536 }
6537
6538 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6539 mut map: V,
6540 optional: bool,
6541 ) -> Result<Option<GetTagsArg>, V::Error> {
6542 let mut field_paths = None;
6543 let mut nothing = true;
6544 while let Some(key) = map.next_key::<&str>()? {
6545 nothing = false;
6546 match key {
6547 "paths" => {
6548 if field_paths.is_some() {
6549 return Err(::serde::de::Error::duplicate_field("paths"));
6550 }
6551 field_paths = Some(map.next_value()?);
6552 }
6553 _ => {
6554 map.next_value::<::serde_json::Value>()?;
6556 }
6557 }
6558 }
6559 if optional && nothing {
6560 return Ok(None);
6561 }
6562 let result = GetTagsArg {
6563 paths: field_paths.ok_or_else(|| ::serde::de::Error::missing_field("paths"))?,
6564 };
6565 Ok(Some(result))
6566 }
6567
6568 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6569 &self,
6570 s: &mut S::SerializeStruct,
6571 ) -> Result<(), S::Error> {
6572 use serde::ser::SerializeStruct;
6573 s.serialize_field("paths", &self.paths)?;
6574 Ok(())
6575 }
6576}
6577
6578impl<'de> ::serde::de::Deserialize<'de> for GetTagsArg {
6579 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6580 use serde::de::{MapAccess, Visitor};
6582 struct StructVisitor;
6583 impl<'de> Visitor<'de> for StructVisitor {
6584 type Value = GetTagsArg;
6585 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6586 f.write_str("a GetTagsArg struct")
6587 }
6588 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6589 GetTagsArg::internal_deserialize(map)
6590 }
6591 }
6592 deserializer.deserialize_struct("GetTagsArg", GET_TAGS_ARG_FIELDS, StructVisitor)
6593 }
6594}
6595
6596impl ::serde::ser::Serialize for GetTagsArg {
6597 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6598 use serde::ser::SerializeStruct;
6600 let mut s = serializer.serialize_struct("GetTagsArg", 1)?;
6601 self.internal_serialize::<S>(&mut s)?;
6602 s.end()
6603 }
6604}
6605
6606#[derive(Debug, Clone, PartialEq, Eq)]
6607#[non_exhaustive] pub struct GetTagsResult {
6609 pub paths_to_tags: Vec<PathToTags>,
6611}
6612
6613impl GetTagsResult {
6614 pub fn new(paths_to_tags: Vec<PathToTags>) -> Self {
6615 GetTagsResult {
6616 paths_to_tags,
6617 }
6618 }
6619}
6620
6621const GET_TAGS_RESULT_FIELDS: &[&str] = &["paths_to_tags"];
6622impl GetTagsResult {
6623 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6624 map: V,
6625 ) -> Result<GetTagsResult, V::Error> {
6626 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6627 }
6628
6629 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6630 mut map: V,
6631 optional: bool,
6632 ) -> Result<Option<GetTagsResult>, V::Error> {
6633 let mut field_paths_to_tags = None;
6634 let mut nothing = true;
6635 while let Some(key) = map.next_key::<&str>()? {
6636 nothing = false;
6637 match key {
6638 "paths_to_tags" => {
6639 if field_paths_to_tags.is_some() {
6640 return Err(::serde::de::Error::duplicate_field("paths_to_tags"));
6641 }
6642 field_paths_to_tags = Some(map.next_value()?);
6643 }
6644 _ => {
6645 map.next_value::<::serde_json::Value>()?;
6647 }
6648 }
6649 }
6650 if optional && nothing {
6651 return Ok(None);
6652 }
6653 let result = GetTagsResult {
6654 paths_to_tags: field_paths_to_tags.ok_or_else(|| ::serde::de::Error::missing_field("paths_to_tags"))?,
6655 };
6656 Ok(Some(result))
6657 }
6658
6659 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6660 &self,
6661 s: &mut S::SerializeStruct,
6662 ) -> Result<(), S::Error> {
6663 use serde::ser::SerializeStruct;
6664 s.serialize_field("paths_to_tags", &self.paths_to_tags)?;
6665 Ok(())
6666 }
6667}
6668
6669impl<'de> ::serde::de::Deserialize<'de> for GetTagsResult {
6670 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6671 use serde::de::{MapAccess, Visitor};
6673 struct StructVisitor;
6674 impl<'de> Visitor<'de> for StructVisitor {
6675 type Value = GetTagsResult;
6676 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6677 f.write_str("a GetTagsResult struct")
6678 }
6679 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6680 GetTagsResult::internal_deserialize(map)
6681 }
6682 }
6683 deserializer.deserialize_struct("GetTagsResult", GET_TAGS_RESULT_FIELDS, StructVisitor)
6684 }
6685}
6686
6687impl ::serde::ser::Serialize for GetTagsResult {
6688 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6689 use serde::ser::SerializeStruct;
6691 let mut s = serializer.serialize_struct("GetTagsResult", 1)?;
6692 self.internal_serialize::<S>(&mut s)?;
6693 s.end()
6694 }
6695}
6696
6697#[derive(Debug, Clone, PartialEq, Eq)]
6698#[non_exhaustive] pub struct GetTemporaryLinkArg {
6700 pub path: ReadPath,
6702}
6703
6704impl GetTemporaryLinkArg {
6705 pub fn new(path: ReadPath) -> Self {
6706 GetTemporaryLinkArg {
6707 path,
6708 }
6709 }
6710}
6711
6712const GET_TEMPORARY_LINK_ARG_FIELDS: &[&str] = &["path"];
6713impl GetTemporaryLinkArg {
6714 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6715 map: V,
6716 ) -> Result<GetTemporaryLinkArg, V::Error> {
6717 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6718 }
6719
6720 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6721 mut map: V,
6722 optional: bool,
6723 ) -> Result<Option<GetTemporaryLinkArg>, V::Error> {
6724 let mut field_path = None;
6725 let mut nothing = true;
6726 while let Some(key) = map.next_key::<&str>()? {
6727 nothing = false;
6728 match key {
6729 "path" => {
6730 if field_path.is_some() {
6731 return Err(::serde::de::Error::duplicate_field("path"));
6732 }
6733 field_path = Some(map.next_value()?);
6734 }
6735 _ => {
6736 map.next_value::<::serde_json::Value>()?;
6738 }
6739 }
6740 }
6741 if optional && nothing {
6742 return Ok(None);
6743 }
6744 let result = GetTemporaryLinkArg {
6745 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
6746 };
6747 Ok(Some(result))
6748 }
6749
6750 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6751 &self,
6752 s: &mut S::SerializeStruct,
6753 ) -> Result<(), S::Error> {
6754 use serde::ser::SerializeStruct;
6755 s.serialize_field("path", &self.path)?;
6756 Ok(())
6757 }
6758}
6759
6760impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkArg {
6761 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6762 use serde::de::{MapAccess, Visitor};
6764 struct StructVisitor;
6765 impl<'de> Visitor<'de> for StructVisitor {
6766 type Value = GetTemporaryLinkArg;
6767 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6768 f.write_str("a GetTemporaryLinkArg struct")
6769 }
6770 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6771 GetTemporaryLinkArg::internal_deserialize(map)
6772 }
6773 }
6774 deserializer.deserialize_struct("GetTemporaryLinkArg", GET_TEMPORARY_LINK_ARG_FIELDS, StructVisitor)
6775 }
6776}
6777
6778impl ::serde::ser::Serialize for GetTemporaryLinkArg {
6779 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6780 use serde::ser::SerializeStruct;
6782 let mut s = serializer.serialize_struct("GetTemporaryLinkArg", 1)?;
6783 self.internal_serialize::<S>(&mut s)?;
6784 s.end()
6785 }
6786}
6787
6788#[derive(Debug, Clone, PartialEq, Eq)]
6789#[non_exhaustive] pub enum GetTemporaryLinkError {
6791 Path(LookupError),
6792 EmailNotVerified,
6796 UnsupportedFile,
6798 NotAllowed,
6802 Other,
6805}
6806
6807impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkError {
6808 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6809 use serde::de::{self, MapAccess, Visitor};
6811 struct EnumVisitor;
6812 impl<'de> Visitor<'de> for EnumVisitor {
6813 type Value = GetTemporaryLinkError;
6814 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6815 f.write_str("a GetTemporaryLinkError structure")
6816 }
6817 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
6818 let tag: &str = match map.next_key()? {
6819 Some(".tag") => map.next_value()?,
6820 _ => return Err(de::Error::missing_field(".tag"))
6821 };
6822 let value = match tag {
6823 "path" => {
6824 match map.next_key()? {
6825 Some("path") => GetTemporaryLinkError::Path(map.next_value()?),
6826 None => return Err(de::Error::missing_field("path")),
6827 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
6828 }
6829 }
6830 "email_not_verified" => GetTemporaryLinkError::EmailNotVerified,
6831 "unsupported_file" => GetTemporaryLinkError::UnsupportedFile,
6832 "not_allowed" => GetTemporaryLinkError::NotAllowed,
6833 _ => GetTemporaryLinkError::Other,
6834 };
6835 crate::eat_json_fields(&mut map)?;
6836 Ok(value)
6837 }
6838 }
6839 const VARIANTS: &[&str] = &["path",
6840 "email_not_verified",
6841 "unsupported_file",
6842 "not_allowed",
6843 "other"];
6844 deserializer.deserialize_struct("GetTemporaryLinkError", VARIANTS, EnumVisitor)
6845 }
6846}
6847
6848impl ::serde::ser::Serialize for GetTemporaryLinkError {
6849 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6850 use serde::ser::SerializeStruct;
6852 match self {
6853 GetTemporaryLinkError::Path(x) => {
6854 let mut s = serializer.serialize_struct("GetTemporaryLinkError", 2)?;
6856 s.serialize_field(".tag", "path")?;
6857 s.serialize_field("path", x)?;
6858 s.end()
6859 }
6860 GetTemporaryLinkError::EmailNotVerified => {
6861 let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
6863 s.serialize_field(".tag", "email_not_verified")?;
6864 s.end()
6865 }
6866 GetTemporaryLinkError::UnsupportedFile => {
6867 let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
6869 s.serialize_field(".tag", "unsupported_file")?;
6870 s.end()
6871 }
6872 GetTemporaryLinkError::NotAllowed => {
6873 let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
6875 s.serialize_field(".tag", "not_allowed")?;
6876 s.end()
6877 }
6878 GetTemporaryLinkError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
6879 }
6880 }
6881}
6882
6883impl ::std::error::Error for GetTemporaryLinkError {
6884 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
6885 match self {
6886 GetTemporaryLinkError::Path(inner) => Some(inner),
6887 _ => None,
6888 }
6889 }
6890}
6891
6892impl ::std::fmt::Display for GetTemporaryLinkError {
6893 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6894 match self {
6895 GetTemporaryLinkError::Path(inner) => write!(f, "GetTemporaryLinkError: {}", inner),
6896 _ => write!(f, "{:?}", *self),
6897 }
6898 }
6899}
6900
6901#[derive(Debug, Clone, PartialEq)]
6902#[non_exhaustive] pub struct GetTemporaryLinkResult {
6904 pub metadata: FileMetadata,
6906 pub link: String,
6908}
6909
6910impl GetTemporaryLinkResult {
6911 pub fn new(metadata: FileMetadata, link: String) -> Self {
6912 GetTemporaryLinkResult {
6913 metadata,
6914 link,
6915 }
6916 }
6917}
6918
6919const GET_TEMPORARY_LINK_RESULT_FIELDS: &[&str] = &["metadata",
6920 "link"];
6921impl GetTemporaryLinkResult {
6922 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6923 map: V,
6924 ) -> Result<GetTemporaryLinkResult, V::Error> {
6925 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6926 }
6927
6928 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6929 mut map: V,
6930 optional: bool,
6931 ) -> Result<Option<GetTemporaryLinkResult>, V::Error> {
6932 let mut field_metadata = None;
6933 let mut field_link = None;
6934 let mut nothing = true;
6935 while let Some(key) = map.next_key::<&str>()? {
6936 nothing = false;
6937 match key {
6938 "metadata" => {
6939 if field_metadata.is_some() {
6940 return Err(::serde::de::Error::duplicate_field("metadata"));
6941 }
6942 field_metadata = Some(map.next_value()?);
6943 }
6944 "link" => {
6945 if field_link.is_some() {
6946 return Err(::serde::de::Error::duplicate_field("link"));
6947 }
6948 field_link = Some(map.next_value()?);
6949 }
6950 _ => {
6951 map.next_value::<::serde_json::Value>()?;
6953 }
6954 }
6955 }
6956 if optional && nothing {
6957 return Ok(None);
6958 }
6959 let result = GetTemporaryLinkResult {
6960 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
6961 link: field_link.ok_or_else(|| ::serde::de::Error::missing_field("link"))?,
6962 };
6963 Ok(Some(result))
6964 }
6965
6966 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6967 &self,
6968 s: &mut S::SerializeStruct,
6969 ) -> Result<(), S::Error> {
6970 use serde::ser::SerializeStruct;
6971 s.serialize_field("metadata", &self.metadata)?;
6972 s.serialize_field("link", &self.link)?;
6973 Ok(())
6974 }
6975}
6976
6977impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkResult {
6978 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6979 use serde::de::{MapAccess, Visitor};
6981 struct StructVisitor;
6982 impl<'de> Visitor<'de> for StructVisitor {
6983 type Value = GetTemporaryLinkResult;
6984 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6985 f.write_str("a GetTemporaryLinkResult struct")
6986 }
6987 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6988 GetTemporaryLinkResult::internal_deserialize(map)
6989 }
6990 }
6991 deserializer.deserialize_struct("GetTemporaryLinkResult", GET_TEMPORARY_LINK_RESULT_FIELDS, StructVisitor)
6992 }
6993}
6994
6995impl ::serde::ser::Serialize for GetTemporaryLinkResult {
6996 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6997 use serde::ser::SerializeStruct;
6999 let mut s = serializer.serialize_struct("GetTemporaryLinkResult", 2)?;
7000 self.internal_serialize::<S>(&mut s)?;
7001 s.end()
7002 }
7003}
7004
7005#[derive(Debug, Clone, PartialEq)]
7006#[non_exhaustive] pub struct GetTemporaryUploadLinkArg {
7008 pub commit_info: CommitInfo,
7011 pub duration: f64,
7014}
7015
7016impl GetTemporaryUploadLinkArg {
7017 pub fn new(commit_info: CommitInfo) -> Self {
7018 GetTemporaryUploadLinkArg {
7019 commit_info,
7020 duration: 14400.0,
7021 }
7022 }
7023
7024 pub fn with_duration(mut self, value: f64) -> Self {
7025 self.duration = value;
7026 self
7027 }
7028}
7029
7030const GET_TEMPORARY_UPLOAD_LINK_ARG_FIELDS: &[&str] = &["commit_info",
7031 "duration"];
7032impl GetTemporaryUploadLinkArg {
7033 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7034 map: V,
7035 ) -> Result<GetTemporaryUploadLinkArg, V::Error> {
7036 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7037 }
7038
7039 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7040 mut map: V,
7041 optional: bool,
7042 ) -> Result<Option<GetTemporaryUploadLinkArg>, V::Error> {
7043 let mut field_commit_info = None;
7044 let mut field_duration = None;
7045 let mut nothing = true;
7046 while let Some(key) = map.next_key::<&str>()? {
7047 nothing = false;
7048 match key {
7049 "commit_info" => {
7050 if field_commit_info.is_some() {
7051 return Err(::serde::de::Error::duplicate_field("commit_info"));
7052 }
7053 field_commit_info = Some(map.next_value()?);
7054 }
7055 "duration" => {
7056 if field_duration.is_some() {
7057 return Err(::serde::de::Error::duplicate_field("duration"));
7058 }
7059 field_duration = Some(map.next_value()?);
7060 }
7061 _ => {
7062 map.next_value::<::serde_json::Value>()?;
7064 }
7065 }
7066 }
7067 if optional && nothing {
7068 return Ok(None);
7069 }
7070 let result = GetTemporaryUploadLinkArg {
7071 commit_info: field_commit_info.ok_or_else(|| ::serde::de::Error::missing_field("commit_info"))?,
7072 duration: field_duration.unwrap_or(14400.0),
7073 };
7074 Ok(Some(result))
7075 }
7076
7077 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7078 &self,
7079 s: &mut S::SerializeStruct,
7080 ) -> Result<(), S::Error> {
7081 use serde::ser::SerializeStruct;
7082 s.serialize_field("commit_info", &self.commit_info)?;
7083 if self.duration != 14400.0 {
7084 s.serialize_field("duration", &self.duration)?;
7085 }
7086 Ok(())
7087 }
7088}
7089
7090impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryUploadLinkArg {
7091 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7092 use serde::de::{MapAccess, Visitor};
7094 struct StructVisitor;
7095 impl<'de> Visitor<'de> for StructVisitor {
7096 type Value = GetTemporaryUploadLinkArg;
7097 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7098 f.write_str("a GetTemporaryUploadLinkArg struct")
7099 }
7100 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7101 GetTemporaryUploadLinkArg::internal_deserialize(map)
7102 }
7103 }
7104 deserializer.deserialize_struct("GetTemporaryUploadLinkArg", GET_TEMPORARY_UPLOAD_LINK_ARG_FIELDS, StructVisitor)
7105 }
7106}
7107
7108impl ::serde::ser::Serialize for GetTemporaryUploadLinkArg {
7109 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7110 use serde::ser::SerializeStruct;
7112 let mut s = serializer.serialize_struct("GetTemporaryUploadLinkArg", 2)?;
7113 self.internal_serialize::<S>(&mut s)?;
7114 s.end()
7115 }
7116}
7117
7118#[derive(Debug, Clone, PartialEq, Eq)]
7119#[non_exhaustive] pub struct GetTemporaryUploadLinkResult {
7121 pub link: String,
7123}
7124
7125impl GetTemporaryUploadLinkResult {
7126 pub fn new(link: String) -> Self {
7127 GetTemporaryUploadLinkResult {
7128 link,
7129 }
7130 }
7131}
7132
7133const GET_TEMPORARY_UPLOAD_LINK_RESULT_FIELDS: &[&str] = &["link"];
7134impl GetTemporaryUploadLinkResult {
7135 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7136 map: V,
7137 ) -> Result<GetTemporaryUploadLinkResult, V::Error> {
7138 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7139 }
7140
7141 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7142 mut map: V,
7143 optional: bool,
7144 ) -> Result<Option<GetTemporaryUploadLinkResult>, V::Error> {
7145 let mut field_link = None;
7146 let mut nothing = true;
7147 while let Some(key) = map.next_key::<&str>()? {
7148 nothing = false;
7149 match key {
7150 "link" => {
7151 if field_link.is_some() {
7152 return Err(::serde::de::Error::duplicate_field("link"));
7153 }
7154 field_link = Some(map.next_value()?);
7155 }
7156 _ => {
7157 map.next_value::<::serde_json::Value>()?;
7159 }
7160 }
7161 }
7162 if optional && nothing {
7163 return Ok(None);
7164 }
7165 let result = GetTemporaryUploadLinkResult {
7166 link: field_link.ok_or_else(|| ::serde::de::Error::missing_field("link"))?,
7167 };
7168 Ok(Some(result))
7169 }
7170
7171 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7172 &self,
7173 s: &mut S::SerializeStruct,
7174 ) -> Result<(), S::Error> {
7175 use serde::ser::SerializeStruct;
7176 s.serialize_field("link", &self.link)?;
7177 Ok(())
7178 }
7179}
7180
7181impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryUploadLinkResult {
7182 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7183 use serde::de::{MapAccess, Visitor};
7185 struct StructVisitor;
7186 impl<'de> Visitor<'de> for StructVisitor {
7187 type Value = GetTemporaryUploadLinkResult;
7188 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7189 f.write_str("a GetTemporaryUploadLinkResult struct")
7190 }
7191 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7192 GetTemporaryUploadLinkResult::internal_deserialize(map)
7193 }
7194 }
7195 deserializer.deserialize_struct("GetTemporaryUploadLinkResult", GET_TEMPORARY_UPLOAD_LINK_RESULT_FIELDS, StructVisitor)
7196 }
7197}
7198
7199impl ::serde::ser::Serialize for GetTemporaryUploadLinkResult {
7200 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7201 use serde::ser::SerializeStruct;
7203 let mut s = serializer.serialize_struct("GetTemporaryUploadLinkResult", 1)?;
7204 self.internal_serialize::<S>(&mut s)?;
7205 s.end()
7206 }
7207}
7208
7209#[derive(Debug, Clone, PartialEq, Eq)]
7211#[non_exhaustive] pub struct GetThumbnailBatchArg {
7213 pub entries: Vec<ThumbnailArg>,
7215}
7216
7217impl GetThumbnailBatchArg {
7218 pub fn new(entries: Vec<ThumbnailArg>) -> Self {
7219 GetThumbnailBatchArg {
7220 entries,
7221 }
7222 }
7223}
7224
7225const GET_THUMBNAIL_BATCH_ARG_FIELDS: &[&str] = &["entries"];
7226impl GetThumbnailBatchArg {
7227 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7228 map: V,
7229 ) -> Result<GetThumbnailBatchArg, V::Error> {
7230 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7231 }
7232
7233 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7234 mut map: V,
7235 optional: bool,
7236 ) -> Result<Option<GetThumbnailBatchArg>, V::Error> {
7237 let mut field_entries = None;
7238 let mut nothing = true;
7239 while let Some(key) = map.next_key::<&str>()? {
7240 nothing = false;
7241 match key {
7242 "entries" => {
7243 if field_entries.is_some() {
7244 return Err(::serde::de::Error::duplicate_field("entries"));
7245 }
7246 field_entries = Some(map.next_value()?);
7247 }
7248 _ => {
7249 map.next_value::<::serde_json::Value>()?;
7251 }
7252 }
7253 }
7254 if optional && nothing {
7255 return Ok(None);
7256 }
7257 let result = GetThumbnailBatchArg {
7258 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
7259 };
7260 Ok(Some(result))
7261 }
7262
7263 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7264 &self,
7265 s: &mut S::SerializeStruct,
7266 ) -> Result<(), S::Error> {
7267 use serde::ser::SerializeStruct;
7268 s.serialize_field("entries", &self.entries)?;
7269 Ok(())
7270 }
7271}
7272
7273impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchArg {
7274 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7275 use serde::de::{MapAccess, Visitor};
7277 struct StructVisitor;
7278 impl<'de> Visitor<'de> for StructVisitor {
7279 type Value = GetThumbnailBatchArg;
7280 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7281 f.write_str("a GetThumbnailBatchArg struct")
7282 }
7283 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7284 GetThumbnailBatchArg::internal_deserialize(map)
7285 }
7286 }
7287 deserializer.deserialize_struct("GetThumbnailBatchArg", GET_THUMBNAIL_BATCH_ARG_FIELDS, StructVisitor)
7288 }
7289}
7290
7291impl ::serde::ser::Serialize for GetThumbnailBatchArg {
7292 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7293 use serde::ser::SerializeStruct;
7295 let mut s = serializer.serialize_struct("GetThumbnailBatchArg", 1)?;
7296 self.internal_serialize::<S>(&mut s)?;
7297 s.end()
7298 }
7299}
7300
7301#[derive(Debug, Clone, PartialEq, Eq)]
7302#[non_exhaustive] pub enum GetThumbnailBatchError {
7304 TooManyFiles,
7306 Other,
7309}
7310
7311impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchError {
7312 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7313 use serde::de::{self, MapAccess, Visitor};
7315 struct EnumVisitor;
7316 impl<'de> Visitor<'de> for EnumVisitor {
7317 type Value = GetThumbnailBatchError;
7318 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7319 f.write_str("a GetThumbnailBatchError structure")
7320 }
7321 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
7322 let tag: &str = match map.next_key()? {
7323 Some(".tag") => map.next_value()?,
7324 _ => return Err(de::Error::missing_field(".tag"))
7325 };
7326 let value = match tag {
7327 "too_many_files" => GetThumbnailBatchError::TooManyFiles,
7328 _ => GetThumbnailBatchError::Other,
7329 };
7330 crate::eat_json_fields(&mut map)?;
7331 Ok(value)
7332 }
7333 }
7334 const VARIANTS: &[&str] = &["too_many_files",
7335 "other"];
7336 deserializer.deserialize_struct("GetThumbnailBatchError", VARIANTS, EnumVisitor)
7337 }
7338}
7339
7340impl ::serde::ser::Serialize for GetThumbnailBatchError {
7341 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7342 use serde::ser::SerializeStruct;
7344 match self {
7345 GetThumbnailBatchError::TooManyFiles => {
7346 let mut s = serializer.serialize_struct("GetThumbnailBatchError", 1)?;
7348 s.serialize_field(".tag", "too_many_files")?;
7349 s.end()
7350 }
7351 GetThumbnailBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
7352 }
7353 }
7354}
7355
7356impl ::std::error::Error for GetThumbnailBatchError {
7357}
7358
7359impl ::std::fmt::Display for GetThumbnailBatchError {
7360 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7361 match self {
7362 GetThumbnailBatchError::TooManyFiles => f.write_str("The operation involves more than 25 files."),
7363 _ => write!(f, "{:?}", *self),
7364 }
7365 }
7366}
7367
7368#[derive(Debug, Clone, PartialEq)]
7369#[non_exhaustive] pub struct GetThumbnailBatchResult {
7371 pub entries: Vec<GetThumbnailBatchResultEntry>,
7373}
7374
7375impl GetThumbnailBatchResult {
7376 pub fn new(entries: Vec<GetThumbnailBatchResultEntry>) -> Self {
7377 GetThumbnailBatchResult {
7378 entries,
7379 }
7380 }
7381}
7382
7383const GET_THUMBNAIL_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
7384impl GetThumbnailBatchResult {
7385 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7386 map: V,
7387 ) -> Result<GetThumbnailBatchResult, V::Error> {
7388 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7389 }
7390
7391 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7392 mut map: V,
7393 optional: bool,
7394 ) -> Result<Option<GetThumbnailBatchResult>, V::Error> {
7395 let mut field_entries = None;
7396 let mut nothing = true;
7397 while let Some(key) = map.next_key::<&str>()? {
7398 nothing = false;
7399 match key {
7400 "entries" => {
7401 if field_entries.is_some() {
7402 return Err(::serde::de::Error::duplicate_field("entries"));
7403 }
7404 field_entries = Some(map.next_value()?);
7405 }
7406 _ => {
7407 map.next_value::<::serde_json::Value>()?;
7409 }
7410 }
7411 }
7412 if optional && nothing {
7413 return Ok(None);
7414 }
7415 let result = GetThumbnailBatchResult {
7416 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
7417 };
7418 Ok(Some(result))
7419 }
7420
7421 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7422 &self,
7423 s: &mut S::SerializeStruct,
7424 ) -> Result<(), S::Error> {
7425 use serde::ser::SerializeStruct;
7426 s.serialize_field("entries", &self.entries)?;
7427 Ok(())
7428 }
7429}
7430
7431impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResult {
7432 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7433 use serde::de::{MapAccess, Visitor};
7435 struct StructVisitor;
7436 impl<'de> Visitor<'de> for StructVisitor {
7437 type Value = GetThumbnailBatchResult;
7438 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7439 f.write_str("a GetThumbnailBatchResult struct")
7440 }
7441 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7442 GetThumbnailBatchResult::internal_deserialize(map)
7443 }
7444 }
7445 deserializer.deserialize_struct("GetThumbnailBatchResult", GET_THUMBNAIL_BATCH_RESULT_FIELDS, StructVisitor)
7446 }
7447}
7448
7449impl ::serde::ser::Serialize for GetThumbnailBatchResult {
7450 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7451 use serde::ser::SerializeStruct;
7453 let mut s = serializer.serialize_struct("GetThumbnailBatchResult", 1)?;
7454 self.internal_serialize::<S>(&mut s)?;
7455 s.end()
7456 }
7457}
7458
7459#[derive(Debug, Clone, PartialEq)]
7460#[non_exhaustive] pub struct GetThumbnailBatchResultData {
7462 pub metadata: FileMetadata,
7463 pub thumbnail: String,
7465}
7466
7467impl GetThumbnailBatchResultData {
7468 pub fn new(metadata: FileMetadata, thumbnail: String) -> Self {
7469 GetThumbnailBatchResultData {
7470 metadata,
7471 thumbnail,
7472 }
7473 }
7474}
7475
7476const GET_THUMBNAIL_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata",
7477 "thumbnail"];
7478impl GetThumbnailBatchResultData {
7479 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7480 map: V,
7481 ) -> Result<GetThumbnailBatchResultData, V::Error> {
7482 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7483 }
7484
7485 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7486 mut map: V,
7487 optional: bool,
7488 ) -> Result<Option<GetThumbnailBatchResultData>, V::Error> {
7489 let mut field_metadata = None;
7490 let mut field_thumbnail = None;
7491 let mut nothing = true;
7492 while let Some(key) = map.next_key::<&str>()? {
7493 nothing = false;
7494 match key {
7495 "metadata" => {
7496 if field_metadata.is_some() {
7497 return Err(::serde::de::Error::duplicate_field("metadata"));
7498 }
7499 field_metadata = Some(map.next_value()?);
7500 }
7501 "thumbnail" => {
7502 if field_thumbnail.is_some() {
7503 return Err(::serde::de::Error::duplicate_field("thumbnail"));
7504 }
7505 field_thumbnail = Some(map.next_value()?);
7506 }
7507 _ => {
7508 map.next_value::<::serde_json::Value>()?;
7510 }
7511 }
7512 }
7513 if optional && nothing {
7514 return Ok(None);
7515 }
7516 let result = GetThumbnailBatchResultData {
7517 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
7518 thumbnail: field_thumbnail.ok_or_else(|| ::serde::de::Error::missing_field("thumbnail"))?,
7519 };
7520 Ok(Some(result))
7521 }
7522
7523 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7524 &self,
7525 s: &mut S::SerializeStruct,
7526 ) -> Result<(), S::Error> {
7527 use serde::ser::SerializeStruct;
7528 s.serialize_field("metadata", &self.metadata)?;
7529 s.serialize_field("thumbnail", &self.thumbnail)?;
7530 Ok(())
7531 }
7532}
7533
7534impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResultData {
7535 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7536 use serde::de::{MapAccess, Visitor};
7538 struct StructVisitor;
7539 impl<'de> Visitor<'de> for StructVisitor {
7540 type Value = GetThumbnailBatchResultData;
7541 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7542 f.write_str("a GetThumbnailBatchResultData struct")
7543 }
7544 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7545 GetThumbnailBatchResultData::internal_deserialize(map)
7546 }
7547 }
7548 deserializer.deserialize_struct("GetThumbnailBatchResultData", GET_THUMBNAIL_BATCH_RESULT_DATA_FIELDS, StructVisitor)
7549 }
7550}
7551
7552impl ::serde::ser::Serialize for GetThumbnailBatchResultData {
7553 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7554 use serde::ser::SerializeStruct;
7556 let mut s = serializer.serialize_struct("GetThumbnailBatchResultData", 2)?;
7557 self.internal_serialize::<S>(&mut s)?;
7558 s.end()
7559 }
7560}
7561
7562#[derive(Debug, Clone, PartialEq)]
7563#[non_exhaustive] pub enum GetThumbnailBatchResultEntry {
7565 Success(GetThumbnailBatchResultData),
7566 Failure(ThumbnailError),
7568 Other,
7571}
7572
7573impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResultEntry {
7574 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7575 use serde::de::{self, MapAccess, Visitor};
7577 struct EnumVisitor;
7578 impl<'de> Visitor<'de> for EnumVisitor {
7579 type Value = GetThumbnailBatchResultEntry;
7580 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7581 f.write_str("a GetThumbnailBatchResultEntry structure")
7582 }
7583 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
7584 let tag: &str = match map.next_key()? {
7585 Some(".tag") => map.next_value()?,
7586 _ => return Err(de::Error::missing_field(".tag"))
7587 };
7588 let value = match tag {
7589 "success" => GetThumbnailBatchResultEntry::Success(GetThumbnailBatchResultData::internal_deserialize(&mut map)?),
7590 "failure" => {
7591 match map.next_key()? {
7592 Some("failure") => GetThumbnailBatchResultEntry::Failure(map.next_value()?),
7593 None => return Err(de::Error::missing_field("failure")),
7594 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
7595 }
7596 }
7597 _ => GetThumbnailBatchResultEntry::Other,
7598 };
7599 crate::eat_json_fields(&mut map)?;
7600 Ok(value)
7601 }
7602 }
7603 const VARIANTS: &[&str] = &["success",
7604 "failure",
7605 "other"];
7606 deserializer.deserialize_struct("GetThumbnailBatchResultEntry", VARIANTS, EnumVisitor)
7607 }
7608}
7609
7610impl ::serde::ser::Serialize for GetThumbnailBatchResultEntry {
7611 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7612 use serde::ser::SerializeStruct;
7614 match self {
7615 GetThumbnailBatchResultEntry::Success(x) => {
7616 let mut s = serializer.serialize_struct("GetThumbnailBatchResultEntry", 3)?;
7618 s.serialize_field(".tag", "success")?;
7619 x.internal_serialize::<S>(&mut s)?;
7620 s.end()
7621 }
7622 GetThumbnailBatchResultEntry::Failure(x) => {
7623 let mut s = serializer.serialize_struct("GetThumbnailBatchResultEntry", 2)?;
7625 s.serialize_field(".tag", "failure")?;
7626 s.serialize_field("failure", x)?;
7627 s.end()
7628 }
7629 GetThumbnailBatchResultEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
7630 }
7631 }
7632}
7633
7634#[derive(Debug, Clone, PartialEq)]
7636#[non_exhaustive] pub struct GpsCoordinates {
7638 pub latitude: f64,
7640 pub longitude: f64,
7642}
7643
7644impl GpsCoordinates {
7645 pub fn new(latitude: f64, longitude: f64) -> Self {
7646 GpsCoordinates {
7647 latitude,
7648 longitude,
7649 }
7650 }
7651}
7652
7653const GPS_COORDINATES_FIELDS: &[&str] = &["latitude",
7654 "longitude"];
7655impl GpsCoordinates {
7656 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7657 map: V,
7658 ) -> Result<GpsCoordinates, V::Error> {
7659 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7660 }
7661
7662 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7663 mut map: V,
7664 optional: bool,
7665 ) -> Result<Option<GpsCoordinates>, V::Error> {
7666 let mut field_latitude = None;
7667 let mut field_longitude = None;
7668 let mut nothing = true;
7669 while let Some(key) = map.next_key::<&str>()? {
7670 nothing = false;
7671 match key {
7672 "latitude" => {
7673 if field_latitude.is_some() {
7674 return Err(::serde::de::Error::duplicate_field("latitude"));
7675 }
7676 field_latitude = Some(map.next_value()?);
7677 }
7678 "longitude" => {
7679 if field_longitude.is_some() {
7680 return Err(::serde::de::Error::duplicate_field("longitude"));
7681 }
7682 field_longitude = Some(map.next_value()?);
7683 }
7684 _ => {
7685 map.next_value::<::serde_json::Value>()?;
7687 }
7688 }
7689 }
7690 if optional && nothing {
7691 return Ok(None);
7692 }
7693 let result = GpsCoordinates {
7694 latitude: field_latitude.ok_or_else(|| ::serde::de::Error::missing_field("latitude"))?,
7695 longitude: field_longitude.ok_or_else(|| ::serde::de::Error::missing_field("longitude"))?,
7696 };
7697 Ok(Some(result))
7698 }
7699
7700 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7701 &self,
7702 s: &mut S::SerializeStruct,
7703 ) -> Result<(), S::Error> {
7704 use serde::ser::SerializeStruct;
7705 s.serialize_field("latitude", &self.latitude)?;
7706 s.serialize_field("longitude", &self.longitude)?;
7707 Ok(())
7708 }
7709}
7710
7711impl<'de> ::serde::de::Deserialize<'de> for GpsCoordinates {
7712 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7713 use serde::de::{MapAccess, Visitor};
7715 struct StructVisitor;
7716 impl<'de> Visitor<'de> for StructVisitor {
7717 type Value = GpsCoordinates;
7718 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7719 f.write_str("a GpsCoordinates struct")
7720 }
7721 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7722 GpsCoordinates::internal_deserialize(map)
7723 }
7724 }
7725 deserializer.deserialize_struct("GpsCoordinates", GPS_COORDINATES_FIELDS, StructVisitor)
7726 }
7727}
7728
7729impl ::serde::ser::Serialize for GpsCoordinates {
7730 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7731 use serde::ser::SerializeStruct;
7733 let mut s = serializer.serialize_struct("GpsCoordinates", 2)?;
7734 self.internal_serialize::<S>(&mut s)?;
7735 s.end()
7736 }
7737}
7738
7739#[derive(Debug, Clone, PartialEq, Eq)]
7740#[non_exhaustive] pub struct HighlightSpan {
7742 pub highlight_str: String,
7744 pub is_highlighted: bool,
7746}
7747
7748impl HighlightSpan {
7749 pub fn new(highlight_str: String, is_highlighted: bool) -> Self {
7750 HighlightSpan {
7751 highlight_str,
7752 is_highlighted,
7753 }
7754 }
7755}
7756
7757const HIGHLIGHT_SPAN_FIELDS: &[&str] = &["highlight_str",
7758 "is_highlighted"];
7759impl HighlightSpan {
7760 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7761 map: V,
7762 ) -> Result<HighlightSpan, V::Error> {
7763 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7764 }
7765
7766 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7767 mut map: V,
7768 optional: bool,
7769 ) -> Result<Option<HighlightSpan>, V::Error> {
7770 let mut field_highlight_str = None;
7771 let mut field_is_highlighted = None;
7772 let mut nothing = true;
7773 while let Some(key) = map.next_key::<&str>()? {
7774 nothing = false;
7775 match key {
7776 "highlight_str" => {
7777 if field_highlight_str.is_some() {
7778 return Err(::serde::de::Error::duplicate_field("highlight_str"));
7779 }
7780 field_highlight_str = Some(map.next_value()?);
7781 }
7782 "is_highlighted" => {
7783 if field_is_highlighted.is_some() {
7784 return Err(::serde::de::Error::duplicate_field("is_highlighted"));
7785 }
7786 field_is_highlighted = Some(map.next_value()?);
7787 }
7788 _ => {
7789 map.next_value::<::serde_json::Value>()?;
7791 }
7792 }
7793 }
7794 if optional && nothing {
7795 return Ok(None);
7796 }
7797 let result = HighlightSpan {
7798 highlight_str: field_highlight_str.ok_or_else(|| ::serde::de::Error::missing_field("highlight_str"))?,
7799 is_highlighted: field_is_highlighted.ok_or_else(|| ::serde::de::Error::missing_field("is_highlighted"))?,
7800 };
7801 Ok(Some(result))
7802 }
7803
7804 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7805 &self,
7806 s: &mut S::SerializeStruct,
7807 ) -> Result<(), S::Error> {
7808 use serde::ser::SerializeStruct;
7809 s.serialize_field("highlight_str", &self.highlight_str)?;
7810 s.serialize_field("is_highlighted", &self.is_highlighted)?;
7811 Ok(())
7812 }
7813}
7814
7815impl<'de> ::serde::de::Deserialize<'de> for HighlightSpan {
7816 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7817 use serde::de::{MapAccess, Visitor};
7819 struct StructVisitor;
7820 impl<'de> Visitor<'de> for StructVisitor {
7821 type Value = HighlightSpan;
7822 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7823 f.write_str("a HighlightSpan struct")
7824 }
7825 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7826 HighlightSpan::internal_deserialize(map)
7827 }
7828 }
7829 deserializer.deserialize_struct("HighlightSpan", HIGHLIGHT_SPAN_FIELDS, StructVisitor)
7830 }
7831}
7832
7833impl ::serde::ser::Serialize for HighlightSpan {
7834 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7835 use serde::ser::SerializeStruct;
7837 let mut s = serializer.serialize_struct("HighlightSpan", 2)?;
7838 self.internal_serialize::<S>(&mut s)?;
7839 s.end()
7840 }
7841}
7842
7843#[derive(Debug, Clone, PartialEq, Eq)]
7845#[non_exhaustive] pub enum ImportFormat {
7847 Html,
7849 Markdown,
7851 PlainText,
7853 Other,
7856}
7857
7858impl<'de> ::serde::de::Deserialize<'de> for ImportFormat {
7859 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7860 use serde::de::{self, MapAccess, Visitor};
7862 struct EnumVisitor;
7863 impl<'de> Visitor<'de> for EnumVisitor {
7864 type Value = ImportFormat;
7865 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7866 f.write_str("a ImportFormat structure")
7867 }
7868 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
7869 let tag: &str = match map.next_key()? {
7870 Some(".tag") => map.next_value()?,
7871 _ => return Err(de::Error::missing_field(".tag"))
7872 };
7873 let value = match tag {
7874 "html" => ImportFormat::Html,
7875 "markdown" => ImportFormat::Markdown,
7876 "plain_text" => ImportFormat::PlainText,
7877 _ => ImportFormat::Other,
7878 };
7879 crate::eat_json_fields(&mut map)?;
7880 Ok(value)
7881 }
7882 }
7883 const VARIANTS: &[&str] = &["html",
7884 "markdown",
7885 "plain_text",
7886 "other"];
7887 deserializer.deserialize_struct("ImportFormat", VARIANTS, EnumVisitor)
7888 }
7889}
7890
7891impl ::serde::ser::Serialize for ImportFormat {
7892 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7893 use serde::ser::SerializeStruct;
7895 match self {
7896 ImportFormat::Html => {
7897 let mut s = serializer.serialize_struct("ImportFormat", 1)?;
7899 s.serialize_field(".tag", "html")?;
7900 s.end()
7901 }
7902 ImportFormat::Markdown => {
7903 let mut s = serializer.serialize_struct("ImportFormat", 1)?;
7905 s.serialize_field(".tag", "markdown")?;
7906 s.end()
7907 }
7908 ImportFormat::PlainText => {
7909 let mut s = serializer.serialize_struct("ImportFormat", 1)?;
7911 s.serialize_field(".tag", "plain_text")?;
7912 s.end()
7913 }
7914 ImportFormat::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
7915 }
7916 }
7917}
7918
7919#[derive(Debug, Clone, PartialEq, Eq)]
7920#[non_exhaustive] pub struct ListFolderArg {
7922 pub path: PathROrId,
7924 pub recursive: bool,
7931 #[deprecated]
7934 pub include_media_info: bool,
7935 pub include_deleted: bool,
7938 pub include_has_explicit_shared_members: bool,
7941 pub include_mounted_folders: bool,
7944 pub limit: Option<u32>,
7947 pub shared_link: Option<SharedLink>,
7951 pub include_property_groups: Option<crate::types::file_properties::TemplateFilterBase>,
7954 pub include_non_downloadable_files: bool,
7956 pub include_restorable_info: bool,
7958}
7959
7960impl ListFolderArg {
7961 pub fn new(path: PathROrId) -> Self {
7962 ListFolderArg {
7963 path,
7964 recursive: false,
7965 #[allow(deprecated)] include_media_info: false,
7966 include_deleted: false,
7967 include_has_explicit_shared_members: false,
7968 include_mounted_folders: true,
7969 limit: None,
7970 shared_link: None,
7971 include_property_groups: None,
7972 include_non_downloadable_files: true,
7973 include_restorable_info: false,
7974 }
7975 }
7976
7977 pub fn with_recursive(mut self, value: bool) -> Self {
7978 self.recursive = value;
7979 self
7980 }
7981
7982 #[deprecated]
7983 #[allow(deprecated)]
7984 pub fn with_include_media_info(mut self, value: bool) -> Self {
7985 self.include_media_info = value;
7986 self
7987 }
7988
7989 pub fn with_include_deleted(mut self, value: bool) -> Self {
7990 self.include_deleted = value;
7991 self
7992 }
7993
7994 pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
7995 self.include_has_explicit_shared_members = value;
7996 self
7997 }
7998
7999 pub fn with_include_mounted_folders(mut self, value: bool) -> Self {
8000 self.include_mounted_folders = value;
8001 self
8002 }
8003
8004 pub fn with_limit(mut self, value: u32) -> Self {
8005 self.limit = Some(value);
8006 self
8007 }
8008
8009 pub fn with_shared_link(mut self, value: SharedLink) -> Self {
8010 self.shared_link = Some(value);
8011 self
8012 }
8013
8014 pub fn with_include_property_groups(
8015 mut self,
8016 value: crate::types::file_properties::TemplateFilterBase,
8017 ) -> Self {
8018 self.include_property_groups = Some(value);
8019 self
8020 }
8021
8022 pub fn with_include_non_downloadable_files(mut self, value: bool) -> Self {
8023 self.include_non_downloadable_files = value;
8024 self
8025 }
8026
8027 pub fn with_include_restorable_info(mut self, value: bool) -> Self {
8028 self.include_restorable_info = value;
8029 self
8030 }
8031}
8032
8033const LIST_FOLDER_ARG_FIELDS: &[&str] = &["path",
8034 "recursive",
8035 "include_media_info",
8036 "include_deleted",
8037 "include_has_explicit_shared_members",
8038 "include_mounted_folders",
8039 "limit",
8040 "shared_link",
8041 "include_property_groups",
8042 "include_non_downloadable_files",
8043 "include_restorable_info"];
8044impl ListFolderArg {
8045 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8046 map: V,
8047 ) -> Result<ListFolderArg, V::Error> {
8048 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8049 }
8050
8051 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8052 mut map: V,
8053 optional: bool,
8054 ) -> Result<Option<ListFolderArg>, V::Error> {
8055 let mut field_path = None;
8056 let mut field_recursive = None;
8057 let mut field_include_media_info = None;
8058 let mut field_include_deleted = None;
8059 let mut field_include_has_explicit_shared_members = None;
8060 let mut field_include_mounted_folders = None;
8061 let mut field_limit = None;
8062 let mut field_shared_link = None;
8063 let mut field_include_property_groups = None;
8064 let mut field_include_non_downloadable_files = None;
8065 let mut field_include_restorable_info = None;
8066 let mut nothing = true;
8067 while let Some(key) = map.next_key::<&str>()? {
8068 nothing = false;
8069 match key {
8070 "path" => {
8071 if field_path.is_some() {
8072 return Err(::serde::de::Error::duplicate_field("path"));
8073 }
8074 field_path = Some(map.next_value()?);
8075 }
8076 "recursive" => {
8077 if field_recursive.is_some() {
8078 return Err(::serde::de::Error::duplicate_field("recursive"));
8079 }
8080 field_recursive = Some(map.next_value()?);
8081 }
8082 "include_media_info" => {
8083 if field_include_media_info.is_some() {
8084 return Err(::serde::de::Error::duplicate_field("include_media_info"));
8085 }
8086 field_include_media_info = Some(map.next_value()?);
8087 }
8088 "include_deleted" => {
8089 if field_include_deleted.is_some() {
8090 return Err(::serde::de::Error::duplicate_field("include_deleted"));
8091 }
8092 field_include_deleted = Some(map.next_value()?);
8093 }
8094 "include_has_explicit_shared_members" => {
8095 if field_include_has_explicit_shared_members.is_some() {
8096 return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
8097 }
8098 field_include_has_explicit_shared_members = Some(map.next_value()?);
8099 }
8100 "include_mounted_folders" => {
8101 if field_include_mounted_folders.is_some() {
8102 return Err(::serde::de::Error::duplicate_field("include_mounted_folders"));
8103 }
8104 field_include_mounted_folders = Some(map.next_value()?);
8105 }
8106 "limit" => {
8107 if field_limit.is_some() {
8108 return Err(::serde::de::Error::duplicate_field("limit"));
8109 }
8110 field_limit = Some(map.next_value()?);
8111 }
8112 "shared_link" => {
8113 if field_shared_link.is_some() {
8114 return Err(::serde::de::Error::duplicate_field("shared_link"));
8115 }
8116 field_shared_link = Some(map.next_value()?);
8117 }
8118 "include_property_groups" => {
8119 if field_include_property_groups.is_some() {
8120 return Err(::serde::de::Error::duplicate_field("include_property_groups"));
8121 }
8122 field_include_property_groups = Some(map.next_value()?);
8123 }
8124 "include_non_downloadable_files" => {
8125 if field_include_non_downloadable_files.is_some() {
8126 return Err(::serde::de::Error::duplicate_field("include_non_downloadable_files"));
8127 }
8128 field_include_non_downloadable_files = Some(map.next_value()?);
8129 }
8130 "include_restorable_info" => {
8131 if field_include_restorable_info.is_some() {
8132 return Err(::serde::de::Error::duplicate_field("include_restorable_info"));
8133 }
8134 field_include_restorable_info = Some(map.next_value()?);
8135 }
8136 _ => {
8137 map.next_value::<::serde_json::Value>()?;
8139 }
8140 }
8141 }
8142 if optional && nothing {
8143 return Ok(None);
8144 }
8145 let result = ListFolderArg {
8146 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
8147 recursive: field_recursive.unwrap_or(false),
8148 #[allow(deprecated)] include_media_info: field_include_media_info.unwrap_or(false),
8149 include_deleted: field_include_deleted.unwrap_or(false),
8150 include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
8151 include_mounted_folders: field_include_mounted_folders.unwrap_or(true),
8152 limit: field_limit.and_then(Option::flatten),
8153 shared_link: field_shared_link.and_then(Option::flatten),
8154 include_property_groups: field_include_property_groups.and_then(Option::flatten),
8155 include_non_downloadable_files: field_include_non_downloadable_files.unwrap_or(true),
8156 include_restorable_info: field_include_restorable_info.unwrap_or(false),
8157 };
8158 Ok(Some(result))
8159 }
8160
8161 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8162 &self,
8163 s: &mut S::SerializeStruct,
8164 ) -> Result<(), S::Error> {
8165 use serde::ser::SerializeStruct;
8166 s.serialize_field("path", &self.path)?;
8167 if self.recursive {
8168 s.serialize_field("recursive", &self.recursive)?;
8169 }
8170 #[allow(deprecated)]
8171 if self.include_media_info {
8172 s.serialize_field("include_media_info", &self.include_media_info)?;
8173 }
8174 if self.include_deleted {
8175 s.serialize_field("include_deleted", &self.include_deleted)?;
8176 }
8177 if self.include_has_explicit_shared_members {
8178 s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
8179 }
8180 if !self.include_mounted_folders {
8181 s.serialize_field("include_mounted_folders", &self.include_mounted_folders)?;
8182 }
8183 if let Some(val) = &self.limit {
8184 s.serialize_field("limit", val)?;
8185 }
8186 if let Some(val) = &self.shared_link {
8187 s.serialize_field("shared_link", val)?;
8188 }
8189 if let Some(val) = &self.include_property_groups {
8190 s.serialize_field("include_property_groups", val)?;
8191 }
8192 if !self.include_non_downloadable_files {
8193 s.serialize_field("include_non_downloadable_files", &self.include_non_downloadable_files)?;
8194 }
8195 if self.include_restorable_info {
8196 s.serialize_field("include_restorable_info", &self.include_restorable_info)?;
8197 }
8198 Ok(())
8199 }
8200}
8201
8202impl<'de> ::serde::de::Deserialize<'de> for ListFolderArg {
8203 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8204 use serde::de::{MapAccess, Visitor};
8206 struct StructVisitor;
8207 impl<'de> Visitor<'de> for StructVisitor {
8208 type Value = ListFolderArg;
8209 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8210 f.write_str("a ListFolderArg struct")
8211 }
8212 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8213 ListFolderArg::internal_deserialize(map)
8214 }
8215 }
8216 deserializer.deserialize_struct("ListFolderArg", LIST_FOLDER_ARG_FIELDS, StructVisitor)
8217 }
8218}
8219
8220impl ::serde::ser::Serialize for ListFolderArg {
8221 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8222 use serde::ser::SerializeStruct;
8224 let mut s = serializer.serialize_struct("ListFolderArg", 11)?;
8225 self.internal_serialize::<S>(&mut s)?;
8226 s.end()
8227 }
8228}
8229
8230#[derive(Debug, Clone, PartialEq, Eq)]
8231#[non_exhaustive] pub struct ListFolderContinueArg {
8233 pub cursor: ListFolderCursor,
8236}
8237
8238impl ListFolderContinueArg {
8239 pub fn new(cursor: ListFolderCursor) -> Self {
8240 ListFolderContinueArg {
8241 cursor,
8242 }
8243 }
8244}
8245
8246const LIST_FOLDER_CONTINUE_ARG_FIELDS: &[&str] = &["cursor"];
8247impl ListFolderContinueArg {
8248 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8249 map: V,
8250 ) -> Result<ListFolderContinueArg, V::Error> {
8251 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8252 }
8253
8254 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8255 mut map: V,
8256 optional: bool,
8257 ) -> Result<Option<ListFolderContinueArg>, V::Error> {
8258 let mut field_cursor = None;
8259 let mut nothing = true;
8260 while let Some(key) = map.next_key::<&str>()? {
8261 nothing = false;
8262 match key {
8263 "cursor" => {
8264 if field_cursor.is_some() {
8265 return Err(::serde::de::Error::duplicate_field("cursor"));
8266 }
8267 field_cursor = Some(map.next_value()?);
8268 }
8269 _ => {
8270 map.next_value::<::serde_json::Value>()?;
8272 }
8273 }
8274 }
8275 if optional && nothing {
8276 return Ok(None);
8277 }
8278 let result = ListFolderContinueArg {
8279 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8280 };
8281 Ok(Some(result))
8282 }
8283
8284 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8285 &self,
8286 s: &mut S::SerializeStruct,
8287 ) -> Result<(), S::Error> {
8288 use serde::ser::SerializeStruct;
8289 s.serialize_field("cursor", &self.cursor)?;
8290 Ok(())
8291 }
8292}
8293
8294impl<'de> ::serde::de::Deserialize<'de> for ListFolderContinueArg {
8295 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8296 use serde::de::{MapAccess, Visitor};
8298 struct StructVisitor;
8299 impl<'de> Visitor<'de> for StructVisitor {
8300 type Value = ListFolderContinueArg;
8301 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8302 f.write_str("a ListFolderContinueArg struct")
8303 }
8304 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8305 ListFolderContinueArg::internal_deserialize(map)
8306 }
8307 }
8308 deserializer.deserialize_struct("ListFolderContinueArg", LIST_FOLDER_CONTINUE_ARG_FIELDS, StructVisitor)
8309 }
8310}
8311
8312impl ::serde::ser::Serialize for ListFolderContinueArg {
8313 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8314 use serde::ser::SerializeStruct;
8316 let mut s = serializer.serialize_struct("ListFolderContinueArg", 1)?;
8317 self.internal_serialize::<S>(&mut s)?;
8318 s.end()
8319 }
8320}
8321
8322#[derive(Debug, Clone, PartialEq, Eq)]
8323#[non_exhaustive] pub enum ListFolderContinueError {
8325 Path(LookupError),
8326 Reset,
8329 Other,
8332}
8333
8334impl<'de> ::serde::de::Deserialize<'de> for ListFolderContinueError {
8335 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8336 use serde::de::{self, MapAccess, Visitor};
8338 struct EnumVisitor;
8339 impl<'de> Visitor<'de> for EnumVisitor {
8340 type Value = ListFolderContinueError;
8341 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8342 f.write_str("a ListFolderContinueError structure")
8343 }
8344 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
8345 let tag: &str = match map.next_key()? {
8346 Some(".tag") => map.next_value()?,
8347 _ => return Err(de::Error::missing_field(".tag"))
8348 };
8349 let value = match tag {
8350 "path" => {
8351 match map.next_key()? {
8352 Some("path") => ListFolderContinueError::Path(map.next_value()?),
8353 None => return Err(de::Error::missing_field("path")),
8354 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
8355 }
8356 }
8357 "reset" => ListFolderContinueError::Reset,
8358 _ => ListFolderContinueError::Other,
8359 };
8360 crate::eat_json_fields(&mut map)?;
8361 Ok(value)
8362 }
8363 }
8364 const VARIANTS: &[&str] = &["path",
8365 "reset",
8366 "other"];
8367 deserializer.deserialize_struct("ListFolderContinueError", VARIANTS, EnumVisitor)
8368 }
8369}
8370
8371impl ::serde::ser::Serialize for ListFolderContinueError {
8372 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8373 use serde::ser::SerializeStruct;
8375 match self {
8376 ListFolderContinueError::Path(x) => {
8377 let mut s = serializer.serialize_struct("ListFolderContinueError", 2)?;
8379 s.serialize_field(".tag", "path")?;
8380 s.serialize_field("path", x)?;
8381 s.end()
8382 }
8383 ListFolderContinueError::Reset => {
8384 let mut s = serializer.serialize_struct("ListFolderContinueError", 1)?;
8386 s.serialize_field(".tag", "reset")?;
8387 s.end()
8388 }
8389 ListFolderContinueError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
8390 }
8391 }
8392}
8393
8394impl ::std::error::Error for ListFolderContinueError {
8395 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
8396 match self {
8397 ListFolderContinueError::Path(inner) => Some(inner),
8398 _ => None,
8399 }
8400 }
8401}
8402
8403impl ::std::fmt::Display for ListFolderContinueError {
8404 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8405 match self {
8406 ListFolderContinueError::Path(inner) => write!(f, "ListFolderContinueError: {}", inner),
8407 _ => write!(f, "{:?}", *self),
8408 }
8409 }
8410}
8411
8412#[derive(Debug, Clone, PartialEq, Eq)]
8413#[non_exhaustive] pub enum ListFolderError {
8415 Path(LookupError),
8416 TemplateError(crate::types::file_properties::TemplateError),
8417 Other,
8420}
8421
8422impl<'de> ::serde::de::Deserialize<'de> for ListFolderError {
8423 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8424 use serde::de::{self, MapAccess, Visitor};
8426 struct EnumVisitor;
8427 impl<'de> Visitor<'de> for EnumVisitor {
8428 type Value = ListFolderError;
8429 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8430 f.write_str("a ListFolderError structure")
8431 }
8432 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
8433 let tag: &str = match map.next_key()? {
8434 Some(".tag") => map.next_value()?,
8435 _ => return Err(de::Error::missing_field(".tag"))
8436 };
8437 let value = match tag {
8438 "path" => {
8439 match map.next_key()? {
8440 Some("path") => ListFolderError::Path(map.next_value()?),
8441 None => return Err(de::Error::missing_field("path")),
8442 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
8443 }
8444 }
8445 "template_error" => {
8446 match map.next_key()? {
8447 Some("template_error") => ListFolderError::TemplateError(map.next_value()?),
8448 None => return Err(de::Error::missing_field("template_error")),
8449 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
8450 }
8451 }
8452 _ => ListFolderError::Other,
8453 };
8454 crate::eat_json_fields(&mut map)?;
8455 Ok(value)
8456 }
8457 }
8458 const VARIANTS: &[&str] = &["path",
8459 "template_error",
8460 "other"];
8461 deserializer.deserialize_struct("ListFolderError", VARIANTS, EnumVisitor)
8462 }
8463}
8464
8465impl ::serde::ser::Serialize for ListFolderError {
8466 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8467 use serde::ser::SerializeStruct;
8469 match self {
8470 ListFolderError::Path(x) => {
8471 let mut s = serializer.serialize_struct("ListFolderError", 2)?;
8473 s.serialize_field(".tag", "path")?;
8474 s.serialize_field("path", x)?;
8475 s.end()
8476 }
8477 ListFolderError::TemplateError(x) => {
8478 let mut s = serializer.serialize_struct("ListFolderError", 2)?;
8480 s.serialize_field(".tag", "template_error")?;
8481 s.serialize_field("template_error", x)?;
8482 s.end()
8483 }
8484 ListFolderError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
8485 }
8486 }
8487}
8488
8489impl ::std::error::Error for ListFolderError {
8490 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
8491 match self {
8492 ListFolderError::Path(inner) => Some(inner),
8493 ListFolderError::TemplateError(inner) => Some(inner),
8494 _ => None,
8495 }
8496 }
8497}
8498
8499impl ::std::fmt::Display for ListFolderError {
8500 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8501 match self {
8502 ListFolderError::Path(inner) => write!(f, "ListFolderError: {}", inner),
8503 ListFolderError::TemplateError(inner) => write!(f, "ListFolderError: {}", inner),
8504 _ => write!(f, "{:?}", *self),
8505 }
8506 }
8507}
8508
8509#[derive(Debug, Clone, PartialEq, Eq)]
8510#[non_exhaustive] pub struct ListFolderGetLatestCursorResult {
8512 pub cursor: ListFolderCursor,
8515}
8516
8517impl ListFolderGetLatestCursorResult {
8518 pub fn new(cursor: ListFolderCursor) -> Self {
8519 ListFolderGetLatestCursorResult {
8520 cursor,
8521 }
8522 }
8523}
8524
8525const LIST_FOLDER_GET_LATEST_CURSOR_RESULT_FIELDS: &[&str] = &["cursor"];
8526impl ListFolderGetLatestCursorResult {
8527 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8528 map: V,
8529 ) -> Result<ListFolderGetLatestCursorResult, V::Error> {
8530 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8531 }
8532
8533 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8534 mut map: V,
8535 optional: bool,
8536 ) -> Result<Option<ListFolderGetLatestCursorResult>, V::Error> {
8537 let mut field_cursor = None;
8538 let mut nothing = true;
8539 while let Some(key) = map.next_key::<&str>()? {
8540 nothing = false;
8541 match key {
8542 "cursor" => {
8543 if field_cursor.is_some() {
8544 return Err(::serde::de::Error::duplicate_field("cursor"));
8545 }
8546 field_cursor = Some(map.next_value()?);
8547 }
8548 _ => {
8549 map.next_value::<::serde_json::Value>()?;
8551 }
8552 }
8553 }
8554 if optional && nothing {
8555 return Ok(None);
8556 }
8557 let result = ListFolderGetLatestCursorResult {
8558 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8559 };
8560 Ok(Some(result))
8561 }
8562
8563 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8564 &self,
8565 s: &mut S::SerializeStruct,
8566 ) -> Result<(), S::Error> {
8567 use serde::ser::SerializeStruct;
8568 s.serialize_field("cursor", &self.cursor)?;
8569 Ok(())
8570 }
8571}
8572
8573impl<'de> ::serde::de::Deserialize<'de> for ListFolderGetLatestCursorResult {
8574 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8575 use serde::de::{MapAccess, Visitor};
8577 struct StructVisitor;
8578 impl<'de> Visitor<'de> for StructVisitor {
8579 type Value = ListFolderGetLatestCursorResult;
8580 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8581 f.write_str("a ListFolderGetLatestCursorResult struct")
8582 }
8583 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8584 ListFolderGetLatestCursorResult::internal_deserialize(map)
8585 }
8586 }
8587 deserializer.deserialize_struct("ListFolderGetLatestCursorResult", LIST_FOLDER_GET_LATEST_CURSOR_RESULT_FIELDS, StructVisitor)
8588 }
8589}
8590
8591impl ::serde::ser::Serialize for ListFolderGetLatestCursorResult {
8592 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8593 use serde::ser::SerializeStruct;
8595 let mut s = serializer.serialize_struct("ListFolderGetLatestCursorResult", 1)?;
8596 self.internal_serialize::<S>(&mut s)?;
8597 s.end()
8598 }
8599}
8600
8601#[derive(Debug, Clone, PartialEq, Eq)]
8602#[non_exhaustive] pub struct ListFolderLongpollArg {
8604 pub cursor: ListFolderCursor,
8608 pub timeout: u64,
8612}
8613
8614impl ListFolderLongpollArg {
8615 pub fn new(cursor: ListFolderCursor) -> Self {
8616 ListFolderLongpollArg {
8617 cursor,
8618 timeout: 30,
8619 }
8620 }
8621
8622 pub fn with_timeout(mut self, value: u64) -> Self {
8623 self.timeout = value;
8624 self
8625 }
8626}
8627
8628const LIST_FOLDER_LONGPOLL_ARG_FIELDS: &[&str] = &["cursor",
8629 "timeout"];
8630impl ListFolderLongpollArg {
8631 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8632 map: V,
8633 ) -> Result<ListFolderLongpollArg, V::Error> {
8634 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8635 }
8636
8637 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8638 mut map: V,
8639 optional: bool,
8640 ) -> Result<Option<ListFolderLongpollArg>, V::Error> {
8641 let mut field_cursor = None;
8642 let mut field_timeout = None;
8643 let mut nothing = true;
8644 while let Some(key) = map.next_key::<&str>()? {
8645 nothing = false;
8646 match key {
8647 "cursor" => {
8648 if field_cursor.is_some() {
8649 return Err(::serde::de::Error::duplicate_field("cursor"));
8650 }
8651 field_cursor = Some(map.next_value()?);
8652 }
8653 "timeout" => {
8654 if field_timeout.is_some() {
8655 return Err(::serde::de::Error::duplicate_field("timeout"));
8656 }
8657 field_timeout = Some(map.next_value()?);
8658 }
8659 _ => {
8660 map.next_value::<::serde_json::Value>()?;
8662 }
8663 }
8664 }
8665 if optional && nothing {
8666 return Ok(None);
8667 }
8668 let result = ListFolderLongpollArg {
8669 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8670 timeout: field_timeout.unwrap_or(30),
8671 };
8672 Ok(Some(result))
8673 }
8674
8675 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8676 &self,
8677 s: &mut S::SerializeStruct,
8678 ) -> Result<(), S::Error> {
8679 use serde::ser::SerializeStruct;
8680 s.serialize_field("cursor", &self.cursor)?;
8681 if self.timeout != 30 {
8682 s.serialize_field("timeout", &self.timeout)?;
8683 }
8684 Ok(())
8685 }
8686}
8687
8688impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollArg {
8689 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8690 use serde::de::{MapAccess, Visitor};
8692 struct StructVisitor;
8693 impl<'de> Visitor<'de> for StructVisitor {
8694 type Value = ListFolderLongpollArg;
8695 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8696 f.write_str("a ListFolderLongpollArg struct")
8697 }
8698 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8699 ListFolderLongpollArg::internal_deserialize(map)
8700 }
8701 }
8702 deserializer.deserialize_struct("ListFolderLongpollArg", LIST_FOLDER_LONGPOLL_ARG_FIELDS, StructVisitor)
8703 }
8704}
8705
8706impl ::serde::ser::Serialize for ListFolderLongpollArg {
8707 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8708 use serde::ser::SerializeStruct;
8710 let mut s = serializer.serialize_struct("ListFolderLongpollArg", 2)?;
8711 self.internal_serialize::<S>(&mut s)?;
8712 s.end()
8713 }
8714}
8715
8716#[derive(Debug, Clone, PartialEq, Eq)]
8717#[non_exhaustive] pub enum ListFolderLongpollError {
8719 Reset,
8722 Other,
8725}
8726
8727impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollError {
8728 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8729 use serde::de::{self, MapAccess, Visitor};
8731 struct EnumVisitor;
8732 impl<'de> Visitor<'de> for EnumVisitor {
8733 type Value = ListFolderLongpollError;
8734 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8735 f.write_str("a ListFolderLongpollError structure")
8736 }
8737 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
8738 let tag: &str = match map.next_key()? {
8739 Some(".tag") => map.next_value()?,
8740 _ => return Err(de::Error::missing_field(".tag"))
8741 };
8742 let value = match tag {
8743 "reset" => ListFolderLongpollError::Reset,
8744 _ => ListFolderLongpollError::Other,
8745 };
8746 crate::eat_json_fields(&mut map)?;
8747 Ok(value)
8748 }
8749 }
8750 const VARIANTS: &[&str] = &["reset",
8751 "other"];
8752 deserializer.deserialize_struct("ListFolderLongpollError", VARIANTS, EnumVisitor)
8753 }
8754}
8755
8756impl ::serde::ser::Serialize for ListFolderLongpollError {
8757 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8758 use serde::ser::SerializeStruct;
8760 match self {
8761 ListFolderLongpollError::Reset => {
8762 let mut s = serializer.serialize_struct("ListFolderLongpollError", 1)?;
8764 s.serialize_field(".tag", "reset")?;
8765 s.end()
8766 }
8767 ListFolderLongpollError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
8768 }
8769 }
8770}
8771
8772impl ::std::error::Error for ListFolderLongpollError {
8773}
8774
8775impl ::std::fmt::Display for ListFolderLongpollError {
8776 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8777 write!(f, "{:?}", *self)
8778 }
8779}
8780
8781#[derive(Debug, Clone, PartialEq, Eq)]
8782#[non_exhaustive] pub struct ListFolderLongpollResult {
8784 pub changes: bool,
8787 pub backoff: Option<u64>,
8790}
8791
8792impl ListFolderLongpollResult {
8793 pub fn new(changes: bool) -> Self {
8794 ListFolderLongpollResult {
8795 changes,
8796 backoff: None,
8797 }
8798 }
8799
8800 pub fn with_backoff(mut self, value: u64) -> Self {
8801 self.backoff = Some(value);
8802 self
8803 }
8804}
8805
8806const LIST_FOLDER_LONGPOLL_RESULT_FIELDS: &[&str] = &["changes",
8807 "backoff"];
8808impl ListFolderLongpollResult {
8809 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8810 map: V,
8811 ) -> Result<ListFolderLongpollResult, V::Error> {
8812 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8813 }
8814
8815 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8816 mut map: V,
8817 optional: bool,
8818 ) -> Result<Option<ListFolderLongpollResult>, V::Error> {
8819 let mut field_changes = None;
8820 let mut field_backoff = None;
8821 let mut nothing = true;
8822 while let Some(key) = map.next_key::<&str>()? {
8823 nothing = false;
8824 match key {
8825 "changes" => {
8826 if field_changes.is_some() {
8827 return Err(::serde::de::Error::duplicate_field("changes"));
8828 }
8829 field_changes = Some(map.next_value()?);
8830 }
8831 "backoff" => {
8832 if field_backoff.is_some() {
8833 return Err(::serde::de::Error::duplicate_field("backoff"));
8834 }
8835 field_backoff = Some(map.next_value()?);
8836 }
8837 _ => {
8838 map.next_value::<::serde_json::Value>()?;
8840 }
8841 }
8842 }
8843 if optional && nothing {
8844 return Ok(None);
8845 }
8846 let result = ListFolderLongpollResult {
8847 changes: field_changes.ok_or_else(|| ::serde::de::Error::missing_field("changes"))?,
8848 backoff: field_backoff.and_then(Option::flatten),
8849 };
8850 Ok(Some(result))
8851 }
8852
8853 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8854 &self,
8855 s: &mut S::SerializeStruct,
8856 ) -> Result<(), S::Error> {
8857 use serde::ser::SerializeStruct;
8858 s.serialize_field("changes", &self.changes)?;
8859 if let Some(val) = &self.backoff {
8860 s.serialize_field("backoff", val)?;
8861 }
8862 Ok(())
8863 }
8864}
8865
8866impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollResult {
8867 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8868 use serde::de::{MapAccess, Visitor};
8870 struct StructVisitor;
8871 impl<'de> Visitor<'de> for StructVisitor {
8872 type Value = ListFolderLongpollResult;
8873 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8874 f.write_str("a ListFolderLongpollResult struct")
8875 }
8876 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8877 ListFolderLongpollResult::internal_deserialize(map)
8878 }
8879 }
8880 deserializer.deserialize_struct("ListFolderLongpollResult", LIST_FOLDER_LONGPOLL_RESULT_FIELDS, StructVisitor)
8881 }
8882}
8883
8884impl ::serde::ser::Serialize for ListFolderLongpollResult {
8885 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8886 use serde::ser::SerializeStruct;
8888 let mut s = serializer.serialize_struct("ListFolderLongpollResult", 2)?;
8889 self.internal_serialize::<S>(&mut s)?;
8890 s.end()
8891 }
8892}
8893
8894#[derive(Debug, Clone, PartialEq)]
8895#[non_exhaustive] pub struct ListFolderResult {
8897 pub entries: Vec<Metadata>,
8899 pub cursor: ListFolderCursor,
8902 pub has_more: bool,
8905}
8906
8907impl ListFolderResult {
8908 pub fn new(entries: Vec<Metadata>, cursor: ListFolderCursor, has_more: bool) -> Self {
8909 ListFolderResult {
8910 entries,
8911 cursor,
8912 has_more,
8913 }
8914 }
8915}
8916
8917const LIST_FOLDER_RESULT_FIELDS: &[&str] = &["entries",
8918 "cursor",
8919 "has_more"];
8920impl ListFolderResult {
8921 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8922 map: V,
8923 ) -> Result<ListFolderResult, V::Error> {
8924 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8925 }
8926
8927 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8928 mut map: V,
8929 optional: bool,
8930 ) -> Result<Option<ListFolderResult>, V::Error> {
8931 let mut field_entries = None;
8932 let mut field_cursor = None;
8933 let mut field_has_more = None;
8934 let mut nothing = true;
8935 while let Some(key) = map.next_key::<&str>()? {
8936 nothing = false;
8937 match key {
8938 "entries" => {
8939 if field_entries.is_some() {
8940 return Err(::serde::de::Error::duplicate_field("entries"));
8941 }
8942 field_entries = Some(map.next_value()?);
8943 }
8944 "cursor" => {
8945 if field_cursor.is_some() {
8946 return Err(::serde::de::Error::duplicate_field("cursor"));
8947 }
8948 field_cursor = Some(map.next_value()?);
8949 }
8950 "has_more" => {
8951 if field_has_more.is_some() {
8952 return Err(::serde::de::Error::duplicate_field("has_more"));
8953 }
8954 field_has_more = Some(map.next_value()?);
8955 }
8956 _ => {
8957 map.next_value::<::serde_json::Value>()?;
8959 }
8960 }
8961 }
8962 if optional && nothing {
8963 return Ok(None);
8964 }
8965 let result = ListFolderResult {
8966 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
8967 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8968 has_more: field_has_more.ok_or_else(|| ::serde::de::Error::missing_field("has_more"))?,
8969 };
8970 Ok(Some(result))
8971 }
8972
8973 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8974 &self,
8975 s: &mut S::SerializeStruct,
8976 ) -> Result<(), S::Error> {
8977 use serde::ser::SerializeStruct;
8978 s.serialize_field("entries", &self.entries)?;
8979 s.serialize_field("cursor", &self.cursor)?;
8980 s.serialize_field("has_more", &self.has_more)?;
8981 Ok(())
8982 }
8983}
8984
8985impl<'de> ::serde::de::Deserialize<'de> for ListFolderResult {
8986 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8987 use serde::de::{MapAccess, Visitor};
8989 struct StructVisitor;
8990 impl<'de> Visitor<'de> for StructVisitor {
8991 type Value = ListFolderResult;
8992 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8993 f.write_str("a ListFolderResult struct")
8994 }
8995 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8996 ListFolderResult::internal_deserialize(map)
8997 }
8998 }
8999 deserializer.deserialize_struct("ListFolderResult", LIST_FOLDER_RESULT_FIELDS, StructVisitor)
9000 }
9001}
9002
9003impl ::serde::ser::Serialize for ListFolderResult {
9004 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9005 use serde::ser::SerializeStruct;
9007 let mut s = serializer.serialize_struct("ListFolderResult", 3)?;
9008 self.internal_serialize::<S>(&mut s)?;
9009 s.end()
9010 }
9011}
9012
9013#[derive(Debug, Clone, PartialEq, Eq)]
9014#[non_exhaustive] pub struct ListRevisionsArg {
9016 pub path: PathOrId,
9018 pub mode: ListRevisionsMode,
9020 pub limit: u64,
9022 pub before_rev: Option<Rev>,
9026 pub include_restorable_info: bool,
9028}
9029
9030impl ListRevisionsArg {
9031 pub fn new(path: PathOrId) -> Self {
9032 ListRevisionsArg {
9033 path,
9034 mode: ListRevisionsMode::Path,
9035 limit: 10,
9036 before_rev: None,
9037 include_restorable_info: false,
9038 }
9039 }
9040
9041 pub fn with_mode(mut self, value: ListRevisionsMode) -> Self {
9042 self.mode = value;
9043 self
9044 }
9045
9046 pub fn with_limit(mut self, value: u64) -> Self {
9047 self.limit = value;
9048 self
9049 }
9050
9051 pub fn with_before_rev(mut self, value: Rev) -> Self {
9052 self.before_rev = Some(value);
9053 self
9054 }
9055
9056 pub fn with_include_restorable_info(mut self, value: bool) -> Self {
9057 self.include_restorable_info = value;
9058 self
9059 }
9060}
9061
9062const LIST_REVISIONS_ARG_FIELDS: &[&str] = &["path",
9063 "mode",
9064 "limit",
9065 "before_rev",
9066 "include_restorable_info"];
9067impl ListRevisionsArg {
9068 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9069 map: V,
9070 ) -> Result<ListRevisionsArg, V::Error> {
9071 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9072 }
9073
9074 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9075 mut map: V,
9076 optional: bool,
9077 ) -> Result<Option<ListRevisionsArg>, V::Error> {
9078 let mut field_path = None;
9079 let mut field_mode = None;
9080 let mut field_limit = None;
9081 let mut field_before_rev = None;
9082 let mut field_include_restorable_info = None;
9083 let mut nothing = true;
9084 while let Some(key) = map.next_key::<&str>()? {
9085 nothing = false;
9086 match key {
9087 "path" => {
9088 if field_path.is_some() {
9089 return Err(::serde::de::Error::duplicate_field("path"));
9090 }
9091 field_path = Some(map.next_value()?);
9092 }
9093 "mode" => {
9094 if field_mode.is_some() {
9095 return Err(::serde::de::Error::duplicate_field("mode"));
9096 }
9097 field_mode = Some(map.next_value()?);
9098 }
9099 "limit" => {
9100 if field_limit.is_some() {
9101 return Err(::serde::de::Error::duplicate_field("limit"));
9102 }
9103 field_limit = Some(map.next_value()?);
9104 }
9105 "before_rev" => {
9106 if field_before_rev.is_some() {
9107 return Err(::serde::de::Error::duplicate_field("before_rev"));
9108 }
9109 field_before_rev = Some(map.next_value()?);
9110 }
9111 "include_restorable_info" => {
9112 if field_include_restorable_info.is_some() {
9113 return Err(::serde::de::Error::duplicate_field("include_restorable_info"));
9114 }
9115 field_include_restorable_info = Some(map.next_value()?);
9116 }
9117 _ => {
9118 map.next_value::<::serde_json::Value>()?;
9120 }
9121 }
9122 }
9123 if optional && nothing {
9124 return Ok(None);
9125 }
9126 let result = ListRevisionsArg {
9127 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
9128 mode: field_mode.unwrap_or(ListRevisionsMode::Path),
9129 limit: field_limit.unwrap_or(10),
9130 before_rev: field_before_rev.and_then(Option::flatten),
9131 include_restorable_info: field_include_restorable_info.unwrap_or(false),
9132 };
9133 Ok(Some(result))
9134 }
9135
9136 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9137 &self,
9138 s: &mut S::SerializeStruct,
9139 ) -> Result<(), S::Error> {
9140 use serde::ser::SerializeStruct;
9141 s.serialize_field("path", &self.path)?;
9142 if self.mode != ListRevisionsMode::Path {
9143 s.serialize_field("mode", &self.mode)?;
9144 }
9145 if self.limit != 10 {
9146 s.serialize_field("limit", &self.limit)?;
9147 }
9148 if let Some(val) = &self.before_rev {
9149 s.serialize_field("before_rev", val)?;
9150 }
9151 if self.include_restorable_info {
9152 s.serialize_field("include_restorable_info", &self.include_restorable_info)?;
9153 }
9154 Ok(())
9155 }
9156}
9157
9158impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsArg {
9159 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9160 use serde::de::{MapAccess, Visitor};
9162 struct StructVisitor;
9163 impl<'de> Visitor<'de> for StructVisitor {
9164 type Value = ListRevisionsArg;
9165 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9166 f.write_str("a ListRevisionsArg struct")
9167 }
9168 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9169 ListRevisionsArg::internal_deserialize(map)
9170 }
9171 }
9172 deserializer.deserialize_struct("ListRevisionsArg", LIST_REVISIONS_ARG_FIELDS, StructVisitor)
9173 }
9174}
9175
9176impl ::serde::ser::Serialize for ListRevisionsArg {
9177 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9178 use serde::ser::SerializeStruct;
9180 let mut s = serializer.serialize_struct("ListRevisionsArg", 5)?;
9181 self.internal_serialize::<S>(&mut s)?;
9182 s.end()
9183 }
9184}
9185
9186#[derive(Debug, Clone, PartialEq, Eq)]
9187#[non_exhaustive] pub enum ListRevisionsError {
9189 Path(LookupError),
9190 InvalidBeforeRev,
9192 BeforeRevNotSupported,
9194 Other,
9197}
9198
9199impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsError {
9200 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9201 use serde::de::{self, MapAccess, Visitor};
9203 struct EnumVisitor;
9204 impl<'de> Visitor<'de> for EnumVisitor {
9205 type Value = ListRevisionsError;
9206 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9207 f.write_str("a ListRevisionsError structure")
9208 }
9209 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
9210 let tag: &str = match map.next_key()? {
9211 Some(".tag") => map.next_value()?,
9212 _ => return Err(de::Error::missing_field(".tag"))
9213 };
9214 let value = match tag {
9215 "path" => {
9216 match map.next_key()? {
9217 Some("path") => ListRevisionsError::Path(map.next_value()?),
9218 None => return Err(de::Error::missing_field("path")),
9219 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
9220 }
9221 }
9222 "invalid_before_rev" => ListRevisionsError::InvalidBeforeRev,
9223 "before_rev_not_supported" => ListRevisionsError::BeforeRevNotSupported,
9224 _ => ListRevisionsError::Other,
9225 };
9226 crate::eat_json_fields(&mut map)?;
9227 Ok(value)
9228 }
9229 }
9230 const VARIANTS: &[&str] = &["path",
9231 "invalid_before_rev",
9232 "before_rev_not_supported",
9233 "other"];
9234 deserializer.deserialize_struct("ListRevisionsError", VARIANTS, EnumVisitor)
9235 }
9236}
9237
9238impl ::serde::ser::Serialize for ListRevisionsError {
9239 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9240 use serde::ser::SerializeStruct;
9242 match self {
9243 ListRevisionsError::Path(x) => {
9244 let mut s = serializer.serialize_struct("ListRevisionsError", 2)?;
9246 s.serialize_field(".tag", "path")?;
9247 s.serialize_field("path", x)?;
9248 s.end()
9249 }
9250 ListRevisionsError::InvalidBeforeRev => {
9251 let mut s = serializer.serialize_struct("ListRevisionsError", 1)?;
9253 s.serialize_field(".tag", "invalid_before_rev")?;
9254 s.end()
9255 }
9256 ListRevisionsError::BeforeRevNotSupported => {
9257 let mut s = serializer.serialize_struct("ListRevisionsError", 1)?;
9259 s.serialize_field(".tag", "before_rev_not_supported")?;
9260 s.end()
9261 }
9262 ListRevisionsError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
9263 }
9264 }
9265}
9266
9267impl ::std::error::Error for ListRevisionsError {
9268 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
9269 match self {
9270 ListRevisionsError::Path(inner) => Some(inner),
9271 _ => None,
9272 }
9273 }
9274}
9275
9276impl ::std::fmt::Display for ListRevisionsError {
9277 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9278 match self {
9279 ListRevisionsError::Path(inner) => write!(f, "ListRevisionsError: {}", inner),
9280 ListRevisionsError::InvalidBeforeRev => f.write_str("The revision in before_rev is invalid."),
9281 ListRevisionsError::BeforeRevNotSupported => f.write_str("The before_rev argument is only supported in path mode."),
9282 _ => write!(f, "{:?}", *self),
9283 }
9284 }
9285}
9286
9287#[derive(Debug, Clone, PartialEq, Eq)]
9288#[non_exhaustive] pub enum ListRevisionsMode {
9290 Path,
9293 Id,
9296 Other,
9299}
9300
9301impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsMode {
9302 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9303 use serde::de::{self, MapAccess, Visitor};
9305 struct EnumVisitor;
9306 impl<'de> Visitor<'de> for EnumVisitor {
9307 type Value = ListRevisionsMode;
9308 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9309 f.write_str("a ListRevisionsMode structure")
9310 }
9311 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
9312 let tag: &str = match map.next_key()? {
9313 Some(".tag") => map.next_value()?,
9314 _ => return Err(de::Error::missing_field(".tag"))
9315 };
9316 let value = match tag {
9317 "path" => ListRevisionsMode::Path,
9318 "id" => ListRevisionsMode::Id,
9319 _ => ListRevisionsMode::Other,
9320 };
9321 crate::eat_json_fields(&mut map)?;
9322 Ok(value)
9323 }
9324 }
9325 const VARIANTS: &[&str] = &["path",
9326 "id",
9327 "other"];
9328 deserializer.deserialize_struct("ListRevisionsMode", VARIANTS, EnumVisitor)
9329 }
9330}
9331
9332impl ::serde::ser::Serialize for ListRevisionsMode {
9333 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9334 use serde::ser::SerializeStruct;
9336 match self {
9337 ListRevisionsMode::Path => {
9338 let mut s = serializer.serialize_struct("ListRevisionsMode", 1)?;
9340 s.serialize_field(".tag", "path")?;
9341 s.end()
9342 }
9343 ListRevisionsMode::Id => {
9344 let mut s = serializer.serialize_struct("ListRevisionsMode", 1)?;
9346 s.serialize_field(".tag", "id")?;
9347 s.end()
9348 }
9349 ListRevisionsMode::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
9350 }
9351 }
9352}
9353
9354#[derive(Debug, Clone, PartialEq)]
9355#[non_exhaustive] pub struct ListRevisionsResult {
9357 pub is_deleted: bool,
9360 pub entries: Vec<FileMetadata>,
9362 pub has_more: bool,
9365 pub server_deleted: Option<crate::types::common::DropboxTimestamp>,
9367}
9368
9369impl ListRevisionsResult {
9370 pub fn new(is_deleted: bool, entries: Vec<FileMetadata>, has_more: bool) -> Self {
9371 ListRevisionsResult {
9372 is_deleted,
9373 entries,
9374 has_more,
9375 server_deleted: None,
9376 }
9377 }
9378
9379 pub fn with_server_deleted(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
9380 self.server_deleted = Some(value);
9381 self
9382 }
9383}
9384
9385const LIST_REVISIONS_RESULT_FIELDS: &[&str] = &["is_deleted",
9386 "entries",
9387 "has_more",
9388 "server_deleted"];
9389impl ListRevisionsResult {
9390 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9391 map: V,
9392 ) -> Result<ListRevisionsResult, V::Error> {
9393 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9394 }
9395
9396 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9397 mut map: V,
9398 optional: bool,
9399 ) -> Result<Option<ListRevisionsResult>, V::Error> {
9400 let mut field_is_deleted = None;
9401 let mut field_entries = None;
9402 let mut field_has_more = None;
9403 let mut field_server_deleted = None;
9404 let mut nothing = true;
9405 while let Some(key) = map.next_key::<&str>()? {
9406 nothing = false;
9407 match key {
9408 "is_deleted" => {
9409 if field_is_deleted.is_some() {
9410 return Err(::serde::de::Error::duplicate_field("is_deleted"));
9411 }
9412 field_is_deleted = Some(map.next_value()?);
9413 }
9414 "entries" => {
9415 if field_entries.is_some() {
9416 return Err(::serde::de::Error::duplicate_field("entries"));
9417 }
9418 field_entries = Some(map.next_value()?);
9419 }
9420 "has_more" => {
9421 if field_has_more.is_some() {
9422 return Err(::serde::de::Error::duplicate_field("has_more"));
9423 }
9424 field_has_more = Some(map.next_value()?);
9425 }
9426 "server_deleted" => {
9427 if field_server_deleted.is_some() {
9428 return Err(::serde::de::Error::duplicate_field("server_deleted"));
9429 }
9430 field_server_deleted = Some(map.next_value()?);
9431 }
9432 _ => {
9433 map.next_value::<::serde_json::Value>()?;
9435 }
9436 }
9437 }
9438 if optional && nothing {
9439 return Ok(None);
9440 }
9441 let result = ListRevisionsResult {
9442 is_deleted: field_is_deleted.ok_or_else(|| ::serde::de::Error::missing_field("is_deleted"))?,
9443 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
9444 has_more: field_has_more.ok_or_else(|| ::serde::de::Error::missing_field("has_more"))?,
9445 server_deleted: field_server_deleted.and_then(Option::flatten),
9446 };
9447 Ok(Some(result))
9448 }
9449
9450 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9451 &self,
9452 s: &mut S::SerializeStruct,
9453 ) -> Result<(), S::Error> {
9454 use serde::ser::SerializeStruct;
9455 s.serialize_field("is_deleted", &self.is_deleted)?;
9456 s.serialize_field("entries", &self.entries)?;
9457 s.serialize_field("has_more", &self.has_more)?;
9458 if let Some(val) = &self.server_deleted {
9459 s.serialize_field("server_deleted", val)?;
9460 }
9461 Ok(())
9462 }
9463}
9464
9465impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsResult {
9466 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9467 use serde::de::{MapAccess, Visitor};
9469 struct StructVisitor;
9470 impl<'de> Visitor<'de> for StructVisitor {
9471 type Value = ListRevisionsResult;
9472 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9473 f.write_str("a ListRevisionsResult struct")
9474 }
9475 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9476 ListRevisionsResult::internal_deserialize(map)
9477 }
9478 }
9479 deserializer.deserialize_struct("ListRevisionsResult", LIST_REVISIONS_RESULT_FIELDS, StructVisitor)
9480 }
9481}
9482
9483impl ::serde::ser::Serialize for ListRevisionsResult {
9484 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9485 use serde::ser::SerializeStruct;
9487 let mut s = serializer.serialize_struct("ListRevisionsResult", 4)?;
9488 self.internal_serialize::<S>(&mut s)?;
9489 s.end()
9490 }
9491}
9492
9493#[derive(Debug, Clone, PartialEq, Eq)]
9494#[non_exhaustive] pub struct LockConflictError {
9496 pub lock: FileLock,
9498}
9499
9500impl LockConflictError {
9501 pub fn new(lock: FileLock) -> Self {
9502 LockConflictError {
9503 lock,
9504 }
9505 }
9506}
9507
9508const LOCK_CONFLICT_ERROR_FIELDS: &[&str] = &["lock"];
9509impl LockConflictError {
9510 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9511 map: V,
9512 ) -> Result<LockConflictError, V::Error> {
9513 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9514 }
9515
9516 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9517 mut map: V,
9518 optional: bool,
9519 ) -> Result<Option<LockConflictError>, V::Error> {
9520 let mut field_lock = None;
9521 let mut nothing = true;
9522 while let Some(key) = map.next_key::<&str>()? {
9523 nothing = false;
9524 match key {
9525 "lock" => {
9526 if field_lock.is_some() {
9527 return Err(::serde::de::Error::duplicate_field("lock"));
9528 }
9529 field_lock = Some(map.next_value()?);
9530 }
9531 _ => {
9532 map.next_value::<::serde_json::Value>()?;
9534 }
9535 }
9536 }
9537 if optional && nothing {
9538 return Ok(None);
9539 }
9540 let result = LockConflictError {
9541 lock: field_lock.ok_or_else(|| ::serde::de::Error::missing_field("lock"))?,
9542 };
9543 Ok(Some(result))
9544 }
9545
9546 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9547 &self,
9548 s: &mut S::SerializeStruct,
9549 ) -> Result<(), S::Error> {
9550 use serde::ser::SerializeStruct;
9551 s.serialize_field("lock", &self.lock)?;
9552 Ok(())
9553 }
9554}
9555
9556impl<'de> ::serde::de::Deserialize<'de> for LockConflictError {
9557 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9558 use serde::de::{MapAccess, Visitor};
9560 struct StructVisitor;
9561 impl<'de> Visitor<'de> for StructVisitor {
9562 type Value = LockConflictError;
9563 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9564 f.write_str("a LockConflictError struct")
9565 }
9566 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9567 LockConflictError::internal_deserialize(map)
9568 }
9569 }
9570 deserializer.deserialize_struct("LockConflictError", LOCK_CONFLICT_ERROR_FIELDS, StructVisitor)
9571 }
9572}
9573
9574impl ::serde::ser::Serialize for LockConflictError {
9575 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9576 use serde::ser::SerializeStruct;
9578 let mut s = serializer.serialize_struct("LockConflictError", 1)?;
9579 self.internal_serialize::<S>(&mut s)?;
9580 s.end()
9581 }
9582}
9583
9584#[derive(Debug, Clone, PartialEq, Eq)]
9585#[non_exhaustive] pub struct LockFileArg {
9587 pub path: WritePathOrId,
9589}
9590
9591impl LockFileArg {
9592 pub fn new(path: WritePathOrId) -> Self {
9593 LockFileArg {
9594 path,
9595 }
9596 }
9597}
9598
9599const LOCK_FILE_ARG_FIELDS: &[&str] = &["path"];
9600impl LockFileArg {
9601 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9602 map: V,
9603 ) -> Result<LockFileArg, V::Error> {
9604 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9605 }
9606
9607 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9608 mut map: V,
9609 optional: bool,
9610 ) -> Result<Option<LockFileArg>, V::Error> {
9611 let mut field_path = None;
9612 let mut nothing = true;
9613 while let Some(key) = map.next_key::<&str>()? {
9614 nothing = false;
9615 match key {
9616 "path" => {
9617 if field_path.is_some() {
9618 return Err(::serde::de::Error::duplicate_field("path"));
9619 }
9620 field_path = Some(map.next_value()?);
9621 }
9622 _ => {
9623 map.next_value::<::serde_json::Value>()?;
9625 }
9626 }
9627 }
9628 if optional && nothing {
9629 return Ok(None);
9630 }
9631 let result = LockFileArg {
9632 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
9633 };
9634 Ok(Some(result))
9635 }
9636
9637 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9638 &self,
9639 s: &mut S::SerializeStruct,
9640 ) -> Result<(), S::Error> {
9641 use serde::ser::SerializeStruct;
9642 s.serialize_field("path", &self.path)?;
9643 Ok(())
9644 }
9645}
9646
9647impl<'de> ::serde::de::Deserialize<'de> for LockFileArg {
9648 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9649 use serde::de::{MapAccess, Visitor};
9651 struct StructVisitor;
9652 impl<'de> Visitor<'de> for StructVisitor {
9653 type Value = LockFileArg;
9654 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9655 f.write_str("a LockFileArg struct")
9656 }
9657 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9658 LockFileArg::internal_deserialize(map)
9659 }
9660 }
9661 deserializer.deserialize_struct("LockFileArg", LOCK_FILE_ARG_FIELDS, StructVisitor)
9662 }
9663}
9664
9665impl ::serde::ser::Serialize for LockFileArg {
9666 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9667 use serde::ser::SerializeStruct;
9669 let mut s = serializer.serialize_struct("LockFileArg", 1)?;
9670 self.internal_serialize::<S>(&mut s)?;
9671 s.end()
9672 }
9673}
9674
9675#[derive(Debug, Clone, PartialEq, Eq)]
9676#[non_exhaustive] pub struct LockFileBatchArg {
9678 pub entries: Vec<LockFileArg>,
9681}
9682
9683impl LockFileBatchArg {
9684 pub fn new(entries: Vec<LockFileArg>) -> Self {
9685 LockFileBatchArg {
9686 entries,
9687 }
9688 }
9689}
9690
9691const LOCK_FILE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
9692impl LockFileBatchArg {
9693 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9694 map: V,
9695 ) -> Result<LockFileBatchArg, V::Error> {
9696 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9697 }
9698
9699 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9700 mut map: V,
9701 optional: bool,
9702 ) -> Result<Option<LockFileBatchArg>, V::Error> {
9703 let mut field_entries = None;
9704 let mut nothing = true;
9705 while let Some(key) = map.next_key::<&str>()? {
9706 nothing = false;
9707 match key {
9708 "entries" => {
9709 if field_entries.is_some() {
9710 return Err(::serde::de::Error::duplicate_field("entries"));
9711 }
9712 field_entries = Some(map.next_value()?);
9713 }
9714 _ => {
9715 map.next_value::<::serde_json::Value>()?;
9717 }
9718 }
9719 }
9720 if optional && nothing {
9721 return Ok(None);
9722 }
9723 let result = LockFileBatchArg {
9724 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
9725 };
9726 Ok(Some(result))
9727 }
9728
9729 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9730 &self,
9731 s: &mut S::SerializeStruct,
9732 ) -> Result<(), S::Error> {
9733 use serde::ser::SerializeStruct;
9734 s.serialize_field("entries", &self.entries)?;
9735 Ok(())
9736 }
9737}
9738
9739impl<'de> ::serde::de::Deserialize<'de> for LockFileBatchArg {
9740 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9741 use serde::de::{MapAccess, Visitor};
9743 struct StructVisitor;
9744 impl<'de> Visitor<'de> for StructVisitor {
9745 type Value = LockFileBatchArg;
9746 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9747 f.write_str("a LockFileBatchArg struct")
9748 }
9749 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9750 LockFileBatchArg::internal_deserialize(map)
9751 }
9752 }
9753 deserializer.deserialize_struct("LockFileBatchArg", LOCK_FILE_BATCH_ARG_FIELDS, StructVisitor)
9754 }
9755}
9756
9757impl ::serde::ser::Serialize for LockFileBatchArg {
9758 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9759 use serde::ser::SerializeStruct;
9761 let mut s = serializer.serialize_struct("LockFileBatchArg", 1)?;
9762 self.internal_serialize::<S>(&mut s)?;
9763 s.end()
9764 }
9765}
9766
9767#[derive(Debug, Clone, PartialEq)]
9768#[non_exhaustive] pub struct LockFileBatchResult {
9770 pub entries: Vec<LockFileResultEntry>,
9773}
9774
9775impl LockFileBatchResult {
9776 pub fn new(entries: Vec<LockFileResultEntry>) -> Self {
9777 LockFileBatchResult {
9778 entries,
9779 }
9780 }
9781}
9782
9783const LOCK_FILE_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
9784impl LockFileBatchResult {
9785 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9786 map: V,
9787 ) -> Result<LockFileBatchResult, V::Error> {
9788 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9789 }
9790
9791 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9792 mut map: V,
9793 optional: bool,
9794 ) -> Result<Option<LockFileBatchResult>, V::Error> {
9795 let mut field_entries = None;
9796 let mut nothing = true;
9797 while let Some(key) = map.next_key::<&str>()? {
9798 nothing = false;
9799 match key {
9800 "entries" => {
9801 if field_entries.is_some() {
9802 return Err(::serde::de::Error::duplicate_field("entries"));
9803 }
9804 field_entries = Some(map.next_value()?);
9805 }
9806 _ => {
9807 map.next_value::<::serde_json::Value>()?;
9809 }
9810 }
9811 }
9812 if optional && nothing {
9813 return Ok(None);
9814 }
9815 let result = LockFileBatchResult {
9816 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
9817 };
9818 Ok(Some(result))
9819 }
9820
9821 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9822 &self,
9823 s: &mut S::SerializeStruct,
9824 ) -> Result<(), S::Error> {
9825 use serde::ser::SerializeStruct;
9826 s.serialize_field("entries", &self.entries)?;
9827 Ok(())
9828 }
9829}
9830
9831impl<'de> ::serde::de::Deserialize<'de> for LockFileBatchResult {
9832 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9833 use serde::de::{MapAccess, Visitor};
9835 struct StructVisitor;
9836 impl<'de> Visitor<'de> for StructVisitor {
9837 type Value = LockFileBatchResult;
9838 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9839 f.write_str("a LockFileBatchResult struct")
9840 }
9841 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9842 LockFileBatchResult::internal_deserialize(map)
9843 }
9844 }
9845 deserializer.deserialize_struct("LockFileBatchResult", LOCK_FILE_BATCH_RESULT_FIELDS, StructVisitor)
9846 }
9847}
9848
9849impl ::serde::ser::Serialize for LockFileBatchResult {
9850 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9851 use serde::ser::SerializeStruct;
9853 let mut s = serializer.serialize_struct("LockFileBatchResult", 1)?;
9854 self.internal_serialize::<S>(&mut s)?;
9855 s.end()
9856 }
9857}
9858
9859impl From<LockFileBatchResult> for FileOpsResult {
9861 fn from(_: LockFileBatchResult) -> Self {
9862 Self {}
9863 }
9864}
9865#[derive(Debug, Clone, PartialEq, Eq)]
9866#[non_exhaustive] pub enum LockFileError {
9868 PathLookup(LookupError),
9870 TooManyWriteOperations,
9872 TooManyFiles,
9874 NoWritePermission,
9876 CannotBeLocked,
9878 FileNotShared,
9880 LockConflict(LockConflictError),
9882 InternalError,
9885 Other,
9888}
9889
9890impl<'de> ::serde::de::Deserialize<'de> for LockFileError {
9891 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9892 use serde::de::{self, MapAccess, Visitor};
9894 struct EnumVisitor;
9895 impl<'de> Visitor<'de> for EnumVisitor {
9896 type Value = LockFileError;
9897 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9898 f.write_str("a LockFileError structure")
9899 }
9900 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
9901 let tag: &str = match map.next_key()? {
9902 Some(".tag") => map.next_value()?,
9903 _ => return Err(de::Error::missing_field(".tag"))
9904 };
9905 let value = match tag {
9906 "path_lookup" => {
9907 match map.next_key()? {
9908 Some("path_lookup") => LockFileError::PathLookup(map.next_value()?),
9909 None => return Err(de::Error::missing_field("path_lookup")),
9910 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
9911 }
9912 }
9913 "too_many_write_operations" => LockFileError::TooManyWriteOperations,
9914 "too_many_files" => LockFileError::TooManyFiles,
9915 "no_write_permission" => LockFileError::NoWritePermission,
9916 "cannot_be_locked" => LockFileError::CannotBeLocked,
9917 "file_not_shared" => LockFileError::FileNotShared,
9918 "lock_conflict" => LockFileError::LockConflict(LockConflictError::internal_deserialize(&mut map)?),
9919 "internal_error" => LockFileError::InternalError,
9920 _ => LockFileError::Other,
9921 };
9922 crate::eat_json_fields(&mut map)?;
9923 Ok(value)
9924 }
9925 }
9926 const VARIANTS: &[&str] = &["path_lookup",
9927 "too_many_write_operations",
9928 "too_many_files",
9929 "no_write_permission",
9930 "cannot_be_locked",
9931 "file_not_shared",
9932 "lock_conflict",
9933 "internal_error",
9934 "other"];
9935 deserializer.deserialize_struct("LockFileError", VARIANTS, EnumVisitor)
9936 }
9937}
9938
9939impl ::serde::ser::Serialize for LockFileError {
9940 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9941 use serde::ser::SerializeStruct;
9943 match self {
9944 LockFileError::PathLookup(x) => {
9945 let mut s = serializer.serialize_struct("LockFileError", 2)?;
9947 s.serialize_field(".tag", "path_lookup")?;
9948 s.serialize_field("path_lookup", x)?;
9949 s.end()
9950 }
9951 LockFileError::TooManyWriteOperations => {
9952 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9954 s.serialize_field(".tag", "too_many_write_operations")?;
9955 s.end()
9956 }
9957 LockFileError::TooManyFiles => {
9958 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9960 s.serialize_field(".tag", "too_many_files")?;
9961 s.end()
9962 }
9963 LockFileError::NoWritePermission => {
9964 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9966 s.serialize_field(".tag", "no_write_permission")?;
9967 s.end()
9968 }
9969 LockFileError::CannotBeLocked => {
9970 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9972 s.serialize_field(".tag", "cannot_be_locked")?;
9973 s.end()
9974 }
9975 LockFileError::FileNotShared => {
9976 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9978 s.serialize_field(".tag", "file_not_shared")?;
9979 s.end()
9980 }
9981 LockFileError::LockConflict(x) => {
9982 let mut s = serializer.serialize_struct("LockFileError", 2)?;
9984 s.serialize_field(".tag", "lock_conflict")?;
9985 x.internal_serialize::<S>(&mut s)?;
9986 s.end()
9987 }
9988 LockFileError::InternalError => {
9989 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9991 s.serialize_field(".tag", "internal_error")?;
9992 s.end()
9993 }
9994 LockFileError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
9995 }
9996 }
9997}
9998
9999impl ::std::error::Error for LockFileError {
10000 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
10001 match self {
10002 LockFileError::PathLookup(inner) => Some(inner),
10003 _ => None,
10004 }
10005 }
10006}
10007
10008impl ::std::fmt::Display for LockFileError {
10009 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10010 match self {
10011 LockFileError::PathLookup(inner) => write!(f, "Could not find the specified resource: {}", inner),
10012 LockFileError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
10013 LockFileError::TooManyFiles => f.write_str("There are too many files in one request. Please retry with fewer files."),
10014 LockFileError::NoWritePermission => f.write_str("The user does not have permissions to change the lock state or access the file."),
10015 LockFileError::CannotBeLocked => f.write_str("Item is a type that cannot be locked."),
10016 LockFileError::FileNotShared => f.write_str("Requested file is not currently shared."),
10017 LockFileError::LockConflict(inner) => write!(f, "The user action conflicts with an existing lock on the file: {:?}", inner),
10018 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."),
10019 _ => write!(f, "{:?}", *self),
10020 }
10021 }
10022}
10023
10024#[derive(Debug, Clone, PartialEq)]
10025#[non_exhaustive] pub struct LockFileResult {
10027 pub metadata: Metadata,
10029 #[deprecated]
10031 pub lock: FileLock,
10032}
10033
10034impl LockFileResult {
10035 pub fn new(metadata: Metadata, lock: FileLock) -> Self {
10036 LockFileResult {
10037 metadata,
10038 #[allow(deprecated)] lock,
10039 }
10040 }
10041}
10042
10043const LOCK_FILE_RESULT_FIELDS: &[&str] = &["metadata",
10044 "lock"];
10045impl LockFileResult {
10046 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
10047 map: V,
10048 ) -> Result<LockFileResult, V::Error> {
10049 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
10050 }
10051
10052 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
10053 mut map: V,
10054 optional: bool,
10055 ) -> Result<Option<LockFileResult>, V::Error> {
10056 let mut field_metadata = None;
10057 let mut field_lock = None;
10058 let mut nothing = true;
10059 while let Some(key) = map.next_key::<&str>()? {
10060 nothing = false;
10061 match key {
10062 "metadata" => {
10063 if field_metadata.is_some() {
10064 return Err(::serde::de::Error::duplicate_field("metadata"));
10065 }
10066 field_metadata = Some(map.next_value()?);
10067 }
10068 "lock" => {
10069 if field_lock.is_some() {
10070 return Err(::serde::de::Error::duplicate_field("lock"));
10071 }
10072 field_lock = Some(map.next_value()?);
10073 }
10074 _ => {
10075 map.next_value::<::serde_json::Value>()?;
10077 }
10078 }
10079 }
10080 if optional && nothing {
10081 return Ok(None);
10082 }
10083 let result = LockFileResult {
10084 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
10085 #[allow(deprecated)] lock: field_lock.ok_or_else(|| ::serde::de::Error::missing_field("lock"))?,
10086 };
10087 Ok(Some(result))
10088 }
10089
10090 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
10091 &self,
10092 s: &mut S::SerializeStruct,
10093 ) -> Result<(), S::Error> {
10094 use serde::ser::SerializeStruct;
10095 s.serialize_field("metadata", &self.metadata)?;
10096 #[allow(deprecated)]
10097 s.serialize_field("lock", &self.lock)?;
10098 Ok(())
10099 }
10100}
10101
10102impl<'de> ::serde::de::Deserialize<'de> for LockFileResult {
10103 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10104 use serde::de::{MapAccess, Visitor};
10106 struct StructVisitor;
10107 impl<'de> Visitor<'de> for StructVisitor {
10108 type Value = LockFileResult;
10109 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10110 f.write_str("a LockFileResult struct")
10111 }
10112 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
10113 LockFileResult::internal_deserialize(map)
10114 }
10115 }
10116 deserializer.deserialize_struct("LockFileResult", LOCK_FILE_RESULT_FIELDS, StructVisitor)
10117 }
10118}
10119
10120impl ::serde::ser::Serialize for LockFileResult {
10121 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10122 use serde::ser::SerializeStruct;
10124 let mut s = serializer.serialize_struct("LockFileResult", 2)?;
10125 self.internal_serialize::<S>(&mut s)?;
10126 s.end()
10127 }
10128}
10129
10130#[derive(Debug, Clone, PartialEq)]
10131pub enum LockFileResultEntry {
10132 Success(LockFileResult),
10133 Failure(LockFileError),
10134}
10135
10136impl<'de> ::serde::de::Deserialize<'de> for LockFileResultEntry {
10137 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10138 use serde::de::{self, MapAccess, Visitor};
10140 struct EnumVisitor;
10141 impl<'de> Visitor<'de> for EnumVisitor {
10142 type Value = LockFileResultEntry;
10143 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10144 f.write_str("a LockFileResultEntry structure")
10145 }
10146 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10147 let tag: &str = match map.next_key()? {
10148 Some(".tag") => map.next_value()?,
10149 _ => return Err(de::Error::missing_field(".tag"))
10150 };
10151 let value = match tag {
10152 "success" => LockFileResultEntry::Success(LockFileResult::internal_deserialize(&mut map)?),
10153 "failure" => {
10154 match map.next_key()? {
10155 Some("failure") => LockFileResultEntry::Failure(map.next_value()?),
10156 None => return Err(de::Error::missing_field("failure")),
10157 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10158 }
10159 }
10160 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
10161 };
10162 crate::eat_json_fields(&mut map)?;
10163 Ok(value)
10164 }
10165 }
10166 const VARIANTS: &[&str] = &["success",
10167 "failure"];
10168 deserializer.deserialize_struct("LockFileResultEntry", VARIANTS, EnumVisitor)
10169 }
10170}
10171
10172impl ::serde::ser::Serialize for LockFileResultEntry {
10173 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10174 use serde::ser::SerializeStruct;
10176 match self {
10177 LockFileResultEntry::Success(x) => {
10178 let mut s = serializer.serialize_struct("LockFileResultEntry", 3)?;
10180 s.serialize_field(".tag", "success")?;
10181 x.internal_serialize::<S>(&mut s)?;
10182 s.end()
10183 }
10184 LockFileResultEntry::Failure(x) => {
10185 let mut s = serializer.serialize_struct("LockFileResultEntry", 2)?;
10187 s.serialize_field(".tag", "failure")?;
10188 s.serialize_field("failure", x)?;
10189 s.end()
10190 }
10191 }
10192 }
10193}
10194
10195#[derive(Debug, Clone, PartialEq, Eq)]
10196#[non_exhaustive] pub enum LookupError {
10198 MalformedPath(MalformedPathError),
10202 NotFound,
10204 NotFile,
10206 NotFolder,
10208 RestrictedContent,
10211 UnsupportedContentType,
10213 Locked,
10215 Other,
10218}
10219
10220impl<'de> ::serde::de::Deserialize<'de> for LookupError {
10221 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10222 use serde::de::{self, MapAccess, Visitor};
10224 struct EnumVisitor;
10225 impl<'de> Visitor<'de> for EnumVisitor {
10226 type Value = LookupError;
10227 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10228 f.write_str("a LookupError structure")
10229 }
10230 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10231 let tag: &str = match map.next_key()? {
10232 Some(".tag") => map.next_value()?,
10233 _ => return Err(de::Error::missing_field(".tag"))
10234 };
10235 let value = match tag {
10236 "malformed_path" => {
10237 match map.next_key()? {
10238 Some("malformed_path") => LookupError::MalformedPath(map.next_value()?),
10239 None => LookupError::MalformedPath(None),
10240 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10241 }
10242 }
10243 "not_found" => LookupError::NotFound,
10244 "not_file" => LookupError::NotFile,
10245 "not_folder" => LookupError::NotFolder,
10246 "restricted_content" => LookupError::RestrictedContent,
10247 "unsupported_content_type" => LookupError::UnsupportedContentType,
10248 "locked" => LookupError::Locked,
10249 _ => LookupError::Other,
10250 };
10251 crate::eat_json_fields(&mut map)?;
10252 Ok(value)
10253 }
10254 }
10255 const VARIANTS: &[&str] = &["malformed_path",
10256 "not_found",
10257 "not_file",
10258 "not_folder",
10259 "restricted_content",
10260 "unsupported_content_type",
10261 "locked",
10262 "other"];
10263 deserializer.deserialize_struct("LookupError", VARIANTS, EnumVisitor)
10264 }
10265}
10266
10267impl ::serde::ser::Serialize for LookupError {
10268 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10269 use serde::ser::SerializeStruct;
10271 match self {
10272 LookupError::MalformedPath(x) => {
10273 let n = if x.is_some() { 2 } else { 1 };
10275 let mut s = serializer.serialize_struct("LookupError", n)?;
10276 s.serialize_field(".tag", "malformed_path")?;
10277 if let Some(x) = x {
10278 s.serialize_field("malformed_path", &x)?;
10279 }
10280 s.end()
10281 }
10282 LookupError::NotFound => {
10283 let mut s = serializer.serialize_struct("LookupError", 1)?;
10285 s.serialize_field(".tag", "not_found")?;
10286 s.end()
10287 }
10288 LookupError::NotFile => {
10289 let mut s = serializer.serialize_struct("LookupError", 1)?;
10291 s.serialize_field(".tag", "not_file")?;
10292 s.end()
10293 }
10294 LookupError::NotFolder => {
10295 let mut s = serializer.serialize_struct("LookupError", 1)?;
10297 s.serialize_field(".tag", "not_folder")?;
10298 s.end()
10299 }
10300 LookupError::RestrictedContent => {
10301 let mut s = serializer.serialize_struct("LookupError", 1)?;
10303 s.serialize_field(".tag", "restricted_content")?;
10304 s.end()
10305 }
10306 LookupError::UnsupportedContentType => {
10307 let mut s = serializer.serialize_struct("LookupError", 1)?;
10309 s.serialize_field(".tag", "unsupported_content_type")?;
10310 s.end()
10311 }
10312 LookupError::Locked => {
10313 let mut s = serializer.serialize_struct("LookupError", 1)?;
10315 s.serialize_field(".tag", "locked")?;
10316 s.end()
10317 }
10318 LookupError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10319 }
10320 }
10321}
10322
10323impl ::std::error::Error for LookupError {
10324}
10325
10326impl ::std::fmt::Display for LookupError {
10327 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10328 match self {
10329 LookupError::MalformedPath(inner) => write!(f, "malformed_path: {:?}", inner),
10330 LookupError::NotFound => f.write_str("There is nothing at the given path."),
10331 LookupError::NotFile => f.write_str("We were expecting a file, but the given path refers to something that isn't a file."),
10332 LookupError::NotFolder => f.write_str("We were expecting a folder, but the given path refers to something that isn't a folder."),
10333 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."),
10334 LookupError::UnsupportedContentType => f.write_str("This operation is not supported for this content type."),
10335 LookupError::Locked => f.write_str("The given path is locked."),
10336 _ => write!(f, "{:?}", *self),
10337 }
10338 }
10339}
10340
10341#[derive(Debug, Clone, PartialEq)]
10342pub enum MediaInfo {
10343 Pending,
10345 Metadata(MediaMetadata),
10348}
10349
10350impl<'de> ::serde::de::Deserialize<'de> for MediaInfo {
10351 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10352 use serde::de::{self, MapAccess, Visitor};
10354 struct EnumVisitor;
10355 impl<'de> Visitor<'de> for EnumVisitor {
10356 type Value = MediaInfo;
10357 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10358 f.write_str("a MediaInfo structure")
10359 }
10360 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10361 let tag: &str = match map.next_key()? {
10362 Some(".tag") => map.next_value()?,
10363 _ => return Err(de::Error::missing_field(".tag"))
10364 };
10365 let value = match tag {
10366 "pending" => MediaInfo::Pending,
10367 "metadata" => {
10368 match map.next_key()? {
10369 Some("metadata") => MediaInfo::Metadata(map.next_value()?),
10370 None => return Err(de::Error::missing_field("metadata")),
10371 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10372 }
10373 }
10374 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
10375 };
10376 crate::eat_json_fields(&mut map)?;
10377 Ok(value)
10378 }
10379 }
10380 const VARIANTS: &[&str] = &["pending",
10381 "metadata"];
10382 deserializer.deserialize_struct("MediaInfo", VARIANTS, EnumVisitor)
10383 }
10384}
10385
10386impl ::serde::ser::Serialize for MediaInfo {
10387 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10388 use serde::ser::SerializeStruct;
10390 match self {
10391 MediaInfo::Pending => {
10392 let mut s = serializer.serialize_struct("MediaInfo", 1)?;
10394 s.serialize_field(".tag", "pending")?;
10395 s.end()
10396 }
10397 MediaInfo::Metadata(x) => {
10398 let mut s = serializer.serialize_struct("MediaInfo", 2)?;
10400 s.serialize_field(".tag", "metadata")?;
10401 s.serialize_field("metadata", x)?;
10402 s.end()
10403 }
10404 }
10405 }
10406}
10407
10408#[derive(Debug, Clone, PartialEq)]
10410pub enum MediaMetadata {
10411 Photo(PhotoMetadata),
10412 Video(VideoMetadata),
10413}
10414
10415impl<'de> ::serde::de::Deserialize<'de> for MediaMetadata {
10416 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10417 use serde::de::{self, MapAccess, Visitor};
10419 struct EnumVisitor;
10420 impl<'de> Visitor<'de> for EnumVisitor {
10421 type Value = MediaMetadata;
10422 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10423 f.write_str("a MediaMetadata structure")
10424 }
10425 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10426 let tag = match map.next_key()? {
10427 Some(".tag") => map.next_value()?,
10428 _ => return Err(de::Error::missing_field(".tag"))
10429 };
10430 match tag {
10431 "photo" => Ok(MediaMetadata::Photo(PhotoMetadata::internal_deserialize(map)?)),
10432 "video" => Ok(MediaMetadata::Video(VideoMetadata::internal_deserialize(map)?)),
10433 _ => Err(de::Error::unknown_variant(tag, VARIANTS))
10434 }
10435 }
10436 }
10437 const VARIANTS: &[&str] = &["photo",
10438 "video"];
10439 deserializer.deserialize_struct("MediaMetadata", VARIANTS, EnumVisitor)
10440 }
10441}
10442
10443impl ::serde::ser::Serialize for MediaMetadata {
10444 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10445 use serde::ser::SerializeStruct;
10447 match self {
10448 MediaMetadata::Photo(x) => {
10449 let mut s = serializer.serialize_struct("MediaMetadata", 4)?;
10450 s.serialize_field(".tag", "photo")?;
10451 x.internal_serialize::<S>(&mut s)?;
10452 s.end()
10453 }
10454 MediaMetadata::Video(x) => {
10455 let mut s = serializer.serialize_struct("MediaMetadata", 5)?;
10456 s.serialize_field(".tag", "video")?;
10457 x.internal_serialize::<S>(&mut s)?;
10458 s.end()
10459 }
10460 }
10461 }
10462}
10463
10464#[derive(Debug, Clone, PartialEq)]
10466pub enum Metadata {
10467 File(FileMetadata),
10468 Folder(FolderMetadata),
10469 Deleted(DeletedMetadata),
10470}
10471
10472impl<'de> ::serde::de::Deserialize<'de> for Metadata {
10473 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10474 use serde::de::{self, MapAccess, Visitor};
10476 struct EnumVisitor;
10477 impl<'de> Visitor<'de> for EnumVisitor {
10478 type Value = Metadata;
10479 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10480 f.write_str("a Metadata structure")
10481 }
10482 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10483 let tag = match map.next_key()? {
10484 Some(".tag") => map.next_value()?,
10485 _ => return Err(de::Error::missing_field(".tag"))
10486 };
10487 match tag {
10488 "file" => Ok(Metadata::File(FileMetadata::internal_deserialize(map)?)),
10489 "folder" => Ok(Metadata::Folder(FolderMetadata::internal_deserialize(map)?)),
10490 "deleted" => Ok(Metadata::Deleted(DeletedMetadata::internal_deserialize(map)?)),
10491 _ => Err(de::Error::unknown_variant(tag, VARIANTS))
10492 }
10493 }
10494 }
10495 const VARIANTS: &[&str] = &["file",
10496 "folder",
10497 "deleted"];
10498 deserializer.deserialize_struct("Metadata", VARIANTS, EnumVisitor)
10499 }
10500}
10501
10502impl ::serde::ser::Serialize for Metadata {
10503 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10504 use serde::ser::SerializeStruct;
10506 match self {
10507 Metadata::File(x) => {
10508 let mut s = serializer.serialize_struct("Metadata", 21)?;
10509 s.serialize_field(".tag", "file")?;
10510 x.internal_serialize::<S>(&mut s)?;
10511 s.end()
10512 }
10513 Metadata::Folder(x) => {
10514 let mut s = serializer.serialize_struct("Metadata", 10)?;
10515 s.serialize_field(".tag", "folder")?;
10516 x.internal_serialize::<S>(&mut s)?;
10517 s.end()
10518 }
10519 Metadata::Deleted(x) => {
10520 let mut s = serializer.serialize_struct("Metadata", 7)?;
10521 s.serialize_field(".tag", "deleted")?;
10522 x.internal_serialize::<S>(&mut s)?;
10523 s.end()
10524 }
10525 }
10526 }
10527}
10528
10529#[derive(Debug, Clone, PartialEq)]
10531#[non_exhaustive] pub enum MetadataV2 {
10533 Metadata(Metadata),
10534 Other,
10537}
10538
10539impl<'de> ::serde::de::Deserialize<'de> for MetadataV2 {
10540 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10541 use serde::de::{self, MapAccess, Visitor};
10543 struct EnumVisitor;
10544 impl<'de> Visitor<'de> for EnumVisitor {
10545 type Value = MetadataV2;
10546 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10547 f.write_str("a MetadataV2 structure")
10548 }
10549 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10550 let tag: &str = match map.next_key()? {
10551 Some(".tag") => map.next_value()?,
10552 _ => return Err(de::Error::missing_field(".tag"))
10553 };
10554 let value = match tag {
10555 "metadata" => {
10556 match map.next_key()? {
10557 Some("metadata") => MetadataV2::Metadata(map.next_value()?),
10558 None => return Err(de::Error::missing_field("metadata")),
10559 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10560 }
10561 }
10562 _ => MetadataV2::Other,
10563 };
10564 crate::eat_json_fields(&mut map)?;
10565 Ok(value)
10566 }
10567 }
10568 const VARIANTS: &[&str] = &["metadata",
10569 "other"];
10570 deserializer.deserialize_struct("MetadataV2", VARIANTS, EnumVisitor)
10571 }
10572}
10573
10574impl ::serde::ser::Serialize for MetadataV2 {
10575 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10576 use serde::ser::SerializeStruct;
10578 match self {
10579 MetadataV2::Metadata(x) => {
10580 let mut s = serializer.serialize_struct("MetadataV2", 2)?;
10582 s.serialize_field(".tag", "metadata")?;
10583 s.serialize_field("metadata", x)?;
10584 s.end()
10585 }
10586 MetadataV2::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10587 }
10588 }
10589}
10590
10591#[derive(Debug, Clone, PartialEq, Eq)]
10592#[non_exhaustive] pub struct MinimalFileLinkMetadata {
10594 pub url: String,
10596 pub rev: Rev,
10599 pub id: Option<Id>,
10601 pub path: Option<String>,
10604}
10605
10606impl MinimalFileLinkMetadata {
10607 pub fn new(url: String, rev: Rev) -> Self {
10608 MinimalFileLinkMetadata {
10609 url,
10610 rev,
10611 id: None,
10612 path: None,
10613 }
10614 }
10615
10616 pub fn with_id(mut self, value: Id) -> Self {
10617 self.id = Some(value);
10618 self
10619 }
10620
10621 pub fn with_path(mut self, value: String) -> Self {
10622 self.path = Some(value);
10623 self
10624 }
10625}
10626
10627const MINIMAL_FILE_LINK_METADATA_FIELDS: &[&str] = &["url",
10628 "rev",
10629 "id",
10630 "path"];
10631impl MinimalFileLinkMetadata {
10632 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
10633 map: V,
10634 ) -> Result<MinimalFileLinkMetadata, V::Error> {
10635 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
10636 }
10637
10638 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
10639 mut map: V,
10640 optional: bool,
10641 ) -> Result<Option<MinimalFileLinkMetadata>, V::Error> {
10642 let mut field_url = None;
10643 let mut field_rev = None;
10644 let mut field_id = None;
10645 let mut field_path = None;
10646 let mut nothing = true;
10647 while let Some(key) = map.next_key::<&str>()? {
10648 nothing = false;
10649 match key {
10650 "url" => {
10651 if field_url.is_some() {
10652 return Err(::serde::de::Error::duplicate_field("url"));
10653 }
10654 field_url = Some(map.next_value()?);
10655 }
10656 "rev" => {
10657 if field_rev.is_some() {
10658 return Err(::serde::de::Error::duplicate_field("rev"));
10659 }
10660 field_rev = Some(map.next_value()?);
10661 }
10662 "id" => {
10663 if field_id.is_some() {
10664 return Err(::serde::de::Error::duplicate_field("id"));
10665 }
10666 field_id = Some(map.next_value()?);
10667 }
10668 "path" => {
10669 if field_path.is_some() {
10670 return Err(::serde::de::Error::duplicate_field("path"));
10671 }
10672 field_path = Some(map.next_value()?);
10673 }
10674 _ => {
10675 map.next_value::<::serde_json::Value>()?;
10677 }
10678 }
10679 }
10680 if optional && nothing {
10681 return Ok(None);
10682 }
10683 let result = MinimalFileLinkMetadata {
10684 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
10685 rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
10686 id: field_id.and_then(Option::flatten),
10687 path: field_path.and_then(Option::flatten),
10688 };
10689 Ok(Some(result))
10690 }
10691
10692 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
10693 &self,
10694 s: &mut S::SerializeStruct,
10695 ) -> Result<(), S::Error> {
10696 use serde::ser::SerializeStruct;
10697 s.serialize_field("url", &self.url)?;
10698 s.serialize_field("rev", &self.rev)?;
10699 if let Some(val) = &self.id {
10700 s.serialize_field("id", val)?;
10701 }
10702 if let Some(val) = &self.path {
10703 s.serialize_field("path", val)?;
10704 }
10705 Ok(())
10706 }
10707}
10708
10709impl<'de> ::serde::de::Deserialize<'de> for MinimalFileLinkMetadata {
10710 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10711 use serde::de::{MapAccess, Visitor};
10713 struct StructVisitor;
10714 impl<'de> Visitor<'de> for StructVisitor {
10715 type Value = MinimalFileLinkMetadata;
10716 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10717 f.write_str("a MinimalFileLinkMetadata struct")
10718 }
10719 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
10720 MinimalFileLinkMetadata::internal_deserialize(map)
10721 }
10722 }
10723 deserializer.deserialize_struct("MinimalFileLinkMetadata", MINIMAL_FILE_LINK_METADATA_FIELDS, StructVisitor)
10724 }
10725}
10726
10727impl ::serde::ser::Serialize for MinimalFileLinkMetadata {
10728 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10729 use serde::ser::SerializeStruct;
10731 let mut s = serializer.serialize_struct("MinimalFileLinkMetadata", 4)?;
10732 self.internal_serialize::<S>(&mut s)?;
10733 s.end()
10734 }
10735}
10736
10737#[derive(Debug, Clone, PartialEq, Eq)]
10738#[non_exhaustive] pub struct MoveBatchArg {
10740 pub entries: Vec<RelocationPath>,
10742 pub autorename: bool,
10745 pub allow_ownership_transfer: bool,
10748}
10749
10750impl MoveBatchArg {
10751 pub fn new(entries: Vec<RelocationPath>) -> Self {
10752 MoveBatchArg {
10753 entries,
10754 autorename: false,
10755 allow_ownership_transfer: false,
10756 }
10757 }
10758
10759 pub fn with_autorename(mut self, value: bool) -> Self {
10760 self.autorename = value;
10761 self
10762 }
10763
10764 pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
10765 self.allow_ownership_transfer = value;
10766 self
10767 }
10768}
10769
10770const MOVE_BATCH_ARG_FIELDS: &[&str] = &["entries",
10771 "autorename",
10772 "allow_ownership_transfer"];
10773impl MoveBatchArg {
10774 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
10775 map: V,
10776 ) -> Result<MoveBatchArg, V::Error> {
10777 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
10778 }
10779
10780 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
10781 mut map: V,
10782 optional: bool,
10783 ) -> Result<Option<MoveBatchArg>, V::Error> {
10784 let mut field_entries = None;
10785 let mut field_autorename = None;
10786 let mut field_allow_ownership_transfer = None;
10787 let mut nothing = true;
10788 while let Some(key) = map.next_key::<&str>()? {
10789 nothing = false;
10790 match key {
10791 "entries" => {
10792 if field_entries.is_some() {
10793 return Err(::serde::de::Error::duplicate_field("entries"));
10794 }
10795 field_entries = Some(map.next_value()?);
10796 }
10797 "autorename" => {
10798 if field_autorename.is_some() {
10799 return Err(::serde::de::Error::duplicate_field("autorename"));
10800 }
10801 field_autorename = Some(map.next_value()?);
10802 }
10803 "allow_ownership_transfer" => {
10804 if field_allow_ownership_transfer.is_some() {
10805 return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
10806 }
10807 field_allow_ownership_transfer = Some(map.next_value()?);
10808 }
10809 _ => {
10810 map.next_value::<::serde_json::Value>()?;
10812 }
10813 }
10814 }
10815 if optional && nothing {
10816 return Ok(None);
10817 }
10818 let result = MoveBatchArg {
10819 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
10820 autorename: field_autorename.unwrap_or(false),
10821 allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
10822 };
10823 Ok(Some(result))
10824 }
10825
10826 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
10827 &self,
10828 s: &mut S::SerializeStruct,
10829 ) -> Result<(), S::Error> {
10830 use serde::ser::SerializeStruct;
10831 s.serialize_field("entries", &self.entries)?;
10832 if self.autorename {
10833 s.serialize_field("autorename", &self.autorename)?;
10834 }
10835 if self.allow_ownership_transfer {
10836 s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
10837 }
10838 Ok(())
10839 }
10840}
10841
10842impl<'de> ::serde::de::Deserialize<'de> for MoveBatchArg {
10843 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10844 use serde::de::{MapAccess, Visitor};
10846 struct StructVisitor;
10847 impl<'de> Visitor<'de> for StructVisitor {
10848 type Value = MoveBatchArg;
10849 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10850 f.write_str("a MoveBatchArg struct")
10851 }
10852 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
10853 MoveBatchArg::internal_deserialize(map)
10854 }
10855 }
10856 deserializer.deserialize_struct("MoveBatchArg", MOVE_BATCH_ARG_FIELDS, StructVisitor)
10857 }
10858}
10859
10860impl ::serde::ser::Serialize for MoveBatchArg {
10861 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10862 use serde::ser::SerializeStruct;
10864 let mut s = serializer.serialize_struct("MoveBatchArg", 3)?;
10865 self.internal_serialize::<S>(&mut s)?;
10866 s.end()
10867 }
10868}
10869
10870impl From<MoveBatchArg> for RelocationBatchArgBase {
10872 fn from(subtype: MoveBatchArg) -> Self {
10873 Self {
10874 entries: subtype.entries,
10875 autorename: subtype.autorename,
10876 }
10877 }
10878}
10879#[derive(Debug, Clone, PartialEq, Eq)]
10880#[non_exhaustive] pub enum MoveIntoFamilyError {
10882 IsSharedFolder,
10884 Other,
10887}
10888
10889impl<'de> ::serde::de::Deserialize<'de> for MoveIntoFamilyError {
10890 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10891 use serde::de::{self, MapAccess, Visitor};
10893 struct EnumVisitor;
10894 impl<'de> Visitor<'de> for EnumVisitor {
10895 type Value = MoveIntoFamilyError;
10896 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10897 f.write_str("a MoveIntoFamilyError structure")
10898 }
10899 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10900 let tag: &str = match map.next_key()? {
10901 Some(".tag") => map.next_value()?,
10902 _ => return Err(de::Error::missing_field(".tag"))
10903 };
10904 let value = match tag {
10905 "is_shared_folder" => MoveIntoFamilyError::IsSharedFolder,
10906 _ => MoveIntoFamilyError::Other,
10907 };
10908 crate::eat_json_fields(&mut map)?;
10909 Ok(value)
10910 }
10911 }
10912 const VARIANTS: &[&str] = &["is_shared_folder",
10913 "other"];
10914 deserializer.deserialize_struct("MoveIntoFamilyError", VARIANTS, EnumVisitor)
10915 }
10916}
10917
10918impl ::serde::ser::Serialize for MoveIntoFamilyError {
10919 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10920 use serde::ser::SerializeStruct;
10922 match self {
10923 MoveIntoFamilyError::IsSharedFolder => {
10924 let mut s = serializer.serialize_struct("MoveIntoFamilyError", 1)?;
10926 s.serialize_field(".tag", "is_shared_folder")?;
10927 s.end()
10928 }
10929 MoveIntoFamilyError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10930 }
10931 }
10932}
10933
10934impl ::std::error::Error for MoveIntoFamilyError {
10935}
10936
10937impl ::std::fmt::Display for MoveIntoFamilyError {
10938 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10939 match self {
10940 MoveIntoFamilyError::IsSharedFolder => f.write_str("Moving shared folder into Family Room folder is not allowed."),
10941 _ => write!(f, "{:?}", *self),
10942 }
10943 }
10944}
10945
10946#[derive(Debug, Clone, PartialEq, Eq)]
10947#[non_exhaustive] pub enum MoveIntoVaultError {
10949 IsSharedFolder,
10951 Other,
10954}
10955
10956impl<'de> ::serde::de::Deserialize<'de> for MoveIntoVaultError {
10957 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10958 use serde::de::{self, MapAccess, Visitor};
10960 struct EnumVisitor;
10961 impl<'de> Visitor<'de> for EnumVisitor {
10962 type Value = MoveIntoVaultError;
10963 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10964 f.write_str("a MoveIntoVaultError structure")
10965 }
10966 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10967 let tag: &str = match map.next_key()? {
10968 Some(".tag") => map.next_value()?,
10969 _ => return Err(de::Error::missing_field(".tag"))
10970 };
10971 let value = match tag {
10972 "is_shared_folder" => MoveIntoVaultError::IsSharedFolder,
10973 _ => MoveIntoVaultError::Other,
10974 };
10975 crate::eat_json_fields(&mut map)?;
10976 Ok(value)
10977 }
10978 }
10979 const VARIANTS: &[&str] = &["is_shared_folder",
10980 "other"];
10981 deserializer.deserialize_struct("MoveIntoVaultError", VARIANTS, EnumVisitor)
10982 }
10983}
10984
10985impl ::serde::ser::Serialize for MoveIntoVaultError {
10986 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10987 use serde::ser::SerializeStruct;
10989 match self {
10990 MoveIntoVaultError::IsSharedFolder => {
10991 let mut s = serializer.serialize_struct("MoveIntoVaultError", 1)?;
10993 s.serialize_field(".tag", "is_shared_folder")?;
10994 s.end()
10995 }
10996 MoveIntoVaultError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10997 }
10998 }
10999}
11000
11001impl ::std::error::Error for MoveIntoVaultError {
11002}
11003
11004impl ::std::fmt::Display for MoveIntoVaultError {
11005 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11006 match self {
11007 MoveIntoVaultError::IsSharedFolder => f.write_str("Moving shared folder into Vault is not allowed."),
11008 _ => write!(f, "{:?}", *self),
11009 }
11010 }
11011}
11012
11013#[derive(Debug, Clone, PartialEq, Eq)]
11014#[non_exhaustive] pub enum PaperContentError {
11016 InsufficientPermissions,
11018 ContentMalformed,
11020 DocLengthExceeded,
11022 ImageSizeExceeded,
11025 Other,
11028}
11029
11030impl<'de> ::serde::de::Deserialize<'de> for PaperContentError {
11031 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11032 use serde::de::{self, MapAccess, Visitor};
11034 struct EnumVisitor;
11035 impl<'de> Visitor<'de> for EnumVisitor {
11036 type Value = PaperContentError;
11037 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11038 f.write_str("a PaperContentError structure")
11039 }
11040 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11041 let tag: &str = match map.next_key()? {
11042 Some(".tag") => map.next_value()?,
11043 _ => return Err(de::Error::missing_field(".tag"))
11044 };
11045 let value = match tag {
11046 "insufficient_permissions" => PaperContentError::InsufficientPermissions,
11047 "content_malformed" => PaperContentError::ContentMalformed,
11048 "doc_length_exceeded" => PaperContentError::DocLengthExceeded,
11049 "image_size_exceeded" => PaperContentError::ImageSizeExceeded,
11050 _ => PaperContentError::Other,
11051 };
11052 crate::eat_json_fields(&mut map)?;
11053 Ok(value)
11054 }
11055 }
11056 const VARIANTS: &[&str] = &["insufficient_permissions",
11057 "content_malformed",
11058 "doc_length_exceeded",
11059 "image_size_exceeded",
11060 "other"];
11061 deserializer.deserialize_struct("PaperContentError", VARIANTS, EnumVisitor)
11062 }
11063}
11064
11065impl ::serde::ser::Serialize for PaperContentError {
11066 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11067 use serde::ser::SerializeStruct;
11069 match self {
11070 PaperContentError::InsufficientPermissions => {
11071 let mut s = serializer.serialize_struct("PaperContentError", 1)?;
11073 s.serialize_field(".tag", "insufficient_permissions")?;
11074 s.end()
11075 }
11076 PaperContentError::ContentMalformed => {
11077 let mut s = serializer.serialize_struct("PaperContentError", 1)?;
11079 s.serialize_field(".tag", "content_malformed")?;
11080 s.end()
11081 }
11082 PaperContentError::DocLengthExceeded => {
11083 let mut s = serializer.serialize_struct("PaperContentError", 1)?;
11085 s.serialize_field(".tag", "doc_length_exceeded")?;
11086 s.end()
11087 }
11088 PaperContentError::ImageSizeExceeded => {
11089 let mut s = serializer.serialize_struct("PaperContentError", 1)?;
11091 s.serialize_field(".tag", "image_size_exceeded")?;
11092 s.end()
11093 }
11094 PaperContentError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11095 }
11096 }
11097}
11098
11099impl ::std::error::Error for PaperContentError {
11100}
11101
11102impl ::std::fmt::Display for PaperContentError {
11103 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11104 match self {
11105 PaperContentError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
11106 PaperContentError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
11107 PaperContentError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
11108 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."),
11109 _ => write!(f, "{:?}", *self),
11110 }
11111 }
11112}
11113
11114#[derive(Debug, Clone, PartialEq, Eq)]
11115#[non_exhaustive] pub struct PaperCreateArg {
11117 pub path: Path,
11120 pub import_format: ImportFormat,
11122}
11123
11124impl PaperCreateArg {
11125 pub fn new(path: Path, import_format: ImportFormat) -> Self {
11126 PaperCreateArg {
11127 path,
11128 import_format,
11129 }
11130 }
11131}
11132
11133const PAPER_CREATE_ARG_FIELDS: &[&str] = &["path",
11134 "import_format"];
11135impl PaperCreateArg {
11136 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11137 map: V,
11138 ) -> Result<PaperCreateArg, V::Error> {
11139 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11140 }
11141
11142 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11143 mut map: V,
11144 optional: bool,
11145 ) -> Result<Option<PaperCreateArg>, V::Error> {
11146 let mut field_path = None;
11147 let mut field_import_format = None;
11148 let mut nothing = true;
11149 while let Some(key) = map.next_key::<&str>()? {
11150 nothing = false;
11151 match key {
11152 "path" => {
11153 if field_path.is_some() {
11154 return Err(::serde::de::Error::duplicate_field("path"));
11155 }
11156 field_path = Some(map.next_value()?);
11157 }
11158 "import_format" => {
11159 if field_import_format.is_some() {
11160 return Err(::serde::de::Error::duplicate_field("import_format"));
11161 }
11162 field_import_format = Some(map.next_value()?);
11163 }
11164 _ => {
11165 map.next_value::<::serde_json::Value>()?;
11167 }
11168 }
11169 }
11170 if optional && nothing {
11171 return Ok(None);
11172 }
11173 let result = PaperCreateArg {
11174 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
11175 import_format: field_import_format.ok_or_else(|| ::serde::de::Error::missing_field("import_format"))?,
11176 };
11177 Ok(Some(result))
11178 }
11179
11180 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11181 &self,
11182 s: &mut S::SerializeStruct,
11183 ) -> Result<(), S::Error> {
11184 use serde::ser::SerializeStruct;
11185 s.serialize_field("path", &self.path)?;
11186 s.serialize_field("import_format", &self.import_format)?;
11187 Ok(())
11188 }
11189}
11190
11191impl<'de> ::serde::de::Deserialize<'de> for PaperCreateArg {
11192 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11193 use serde::de::{MapAccess, Visitor};
11195 struct StructVisitor;
11196 impl<'de> Visitor<'de> for StructVisitor {
11197 type Value = PaperCreateArg;
11198 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11199 f.write_str("a PaperCreateArg struct")
11200 }
11201 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11202 PaperCreateArg::internal_deserialize(map)
11203 }
11204 }
11205 deserializer.deserialize_struct("PaperCreateArg", PAPER_CREATE_ARG_FIELDS, StructVisitor)
11206 }
11207}
11208
11209impl ::serde::ser::Serialize for PaperCreateArg {
11210 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11211 use serde::ser::SerializeStruct;
11213 let mut s = serializer.serialize_struct("PaperCreateArg", 2)?;
11214 self.internal_serialize::<S>(&mut s)?;
11215 s.end()
11216 }
11217}
11218
11219#[derive(Debug, Clone, PartialEq, Eq)]
11220#[non_exhaustive] pub enum PaperCreateError {
11222 InsufficientPermissions,
11224 ContentMalformed,
11226 DocLengthExceeded,
11228 ImageSizeExceeded,
11231 InvalidPath,
11233 EmailUnverified,
11235 InvalidFileExtension,
11237 PaperDisabled,
11239 Other,
11242}
11243
11244impl<'de> ::serde::de::Deserialize<'de> for PaperCreateError {
11245 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11246 use serde::de::{self, MapAccess, Visitor};
11248 struct EnumVisitor;
11249 impl<'de> Visitor<'de> for EnumVisitor {
11250 type Value = PaperCreateError;
11251 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11252 f.write_str("a PaperCreateError structure")
11253 }
11254 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11255 let tag: &str = match map.next_key()? {
11256 Some(".tag") => map.next_value()?,
11257 _ => return Err(de::Error::missing_field(".tag"))
11258 };
11259 let value = match tag {
11260 "insufficient_permissions" => PaperCreateError::InsufficientPermissions,
11261 "content_malformed" => PaperCreateError::ContentMalformed,
11262 "doc_length_exceeded" => PaperCreateError::DocLengthExceeded,
11263 "image_size_exceeded" => PaperCreateError::ImageSizeExceeded,
11264 "invalid_path" => PaperCreateError::InvalidPath,
11265 "email_unverified" => PaperCreateError::EmailUnverified,
11266 "invalid_file_extension" => PaperCreateError::InvalidFileExtension,
11267 "paper_disabled" => PaperCreateError::PaperDisabled,
11268 _ => PaperCreateError::Other,
11269 };
11270 crate::eat_json_fields(&mut map)?;
11271 Ok(value)
11272 }
11273 }
11274 const VARIANTS: &[&str] = &["insufficient_permissions",
11275 "content_malformed",
11276 "doc_length_exceeded",
11277 "image_size_exceeded",
11278 "other",
11279 "invalid_path",
11280 "email_unverified",
11281 "invalid_file_extension",
11282 "paper_disabled"];
11283 deserializer.deserialize_struct("PaperCreateError", VARIANTS, EnumVisitor)
11284 }
11285}
11286
11287impl ::serde::ser::Serialize for PaperCreateError {
11288 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11289 use serde::ser::SerializeStruct;
11291 match self {
11292 PaperCreateError::InsufficientPermissions => {
11293 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11295 s.serialize_field(".tag", "insufficient_permissions")?;
11296 s.end()
11297 }
11298 PaperCreateError::ContentMalformed => {
11299 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11301 s.serialize_field(".tag", "content_malformed")?;
11302 s.end()
11303 }
11304 PaperCreateError::DocLengthExceeded => {
11305 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11307 s.serialize_field(".tag", "doc_length_exceeded")?;
11308 s.end()
11309 }
11310 PaperCreateError::ImageSizeExceeded => {
11311 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11313 s.serialize_field(".tag", "image_size_exceeded")?;
11314 s.end()
11315 }
11316 PaperCreateError::InvalidPath => {
11317 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11319 s.serialize_field(".tag", "invalid_path")?;
11320 s.end()
11321 }
11322 PaperCreateError::EmailUnverified => {
11323 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11325 s.serialize_field(".tag", "email_unverified")?;
11326 s.end()
11327 }
11328 PaperCreateError::InvalidFileExtension => {
11329 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11331 s.serialize_field(".tag", "invalid_file_extension")?;
11332 s.end()
11333 }
11334 PaperCreateError::PaperDisabled => {
11335 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11337 s.serialize_field(".tag", "paper_disabled")?;
11338 s.end()
11339 }
11340 PaperCreateError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11341 }
11342 }
11343}
11344
11345impl ::std::error::Error for PaperCreateError {
11346}
11347
11348impl ::std::fmt::Display for PaperCreateError {
11349 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11350 match self {
11351 PaperCreateError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
11352 PaperCreateError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
11353 PaperCreateError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
11354 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."),
11355 PaperCreateError::InvalidPath => f.write_str("The file could not be saved to the specified location."),
11356 PaperCreateError::EmailUnverified => f.write_str("The user's email must be verified to create Paper docs."),
11357 PaperCreateError::InvalidFileExtension => f.write_str("The file path must end in .paper."),
11358 PaperCreateError::PaperDisabled => f.write_str("Paper is disabled for your team."),
11359 _ => write!(f, "{:?}", *self),
11360 }
11361 }
11362}
11363
11364impl From<PaperContentError> for PaperCreateError {
11366 fn from(parent: PaperContentError) -> Self {
11367 match parent {
11368 PaperContentError::InsufficientPermissions => PaperCreateError::InsufficientPermissions,
11369 PaperContentError::ContentMalformed => PaperCreateError::ContentMalformed,
11370 PaperContentError::DocLengthExceeded => PaperCreateError::DocLengthExceeded,
11371 PaperContentError::ImageSizeExceeded => PaperCreateError::ImageSizeExceeded,
11372 PaperContentError::Other => PaperCreateError::Other,
11373 }
11374 }
11375}
11376#[derive(Debug, Clone, PartialEq, Eq)]
11377#[non_exhaustive] pub struct PaperCreateResult {
11379 pub url: String,
11381 pub result_path: String,
11383 pub file_id: FileId,
11385 pub paper_revision: i64,
11387}
11388
11389impl PaperCreateResult {
11390 pub fn new(url: String, result_path: String, file_id: FileId, paper_revision: i64) -> Self {
11391 PaperCreateResult {
11392 url,
11393 result_path,
11394 file_id,
11395 paper_revision,
11396 }
11397 }
11398}
11399
11400const PAPER_CREATE_RESULT_FIELDS: &[&str] = &["url",
11401 "result_path",
11402 "file_id",
11403 "paper_revision"];
11404impl PaperCreateResult {
11405 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11406 map: V,
11407 ) -> Result<PaperCreateResult, V::Error> {
11408 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11409 }
11410
11411 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11412 mut map: V,
11413 optional: bool,
11414 ) -> Result<Option<PaperCreateResult>, V::Error> {
11415 let mut field_url = None;
11416 let mut field_result_path = None;
11417 let mut field_file_id = None;
11418 let mut field_paper_revision = None;
11419 let mut nothing = true;
11420 while let Some(key) = map.next_key::<&str>()? {
11421 nothing = false;
11422 match key {
11423 "url" => {
11424 if field_url.is_some() {
11425 return Err(::serde::de::Error::duplicate_field("url"));
11426 }
11427 field_url = Some(map.next_value()?);
11428 }
11429 "result_path" => {
11430 if field_result_path.is_some() {
11431 return Err(::serde::de::Error::duplicate_field("result_path"));
11432 }
11433 field_result_path = Some(map.next_value()?);
11434 }
11435 "file_id" => {
11436 if field_file_id.is_some() {
11437 return Err(::serde::de::Error::duplicate_field("file_id"));
11438 }
11439 field_file_id = Some(map.next_value()?);
11440 }
11441 "paper_revision" => {
11442 if field_paper_revision.is_some() {
11443 return Err(::serde::de::Error::duplicate_field("paper_revision"));
11444 }
11445 field_paper_revision = Some(map.next_value()?);
11446 }
11447 _ => {
11448 map.next_value::<::serde_json::Value>()?;
11450 }
11451 }
11452 }
11453 if optional && nothing {
11454 return Ok(None);
11455 }
11456 let result = PaperCreateResult {
11457 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
11458 result_path: field_result_path.ok_or_else(|| ::serde::de::Error::missing_field("result_path"))?,
11459 file_id: field_file_id.ok_or_else(|| ::serde::de::Error::missing_field("file_id"))?,
11460 paper_revision: field_paper_revision.ok_or_else(|| ::serde::de::Error::missing_field("paper_revision"))?,
11461 };
11462 Ok(Some(result))
11463 }
11464
11465 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11466 &self,
11467 s: &mut S::SerializeStruct,
11468 ) -> Result<(), S::Error> {
11469 use serde::ser::SerializeStruct;
11470 s.serialize_field("url", &self.url)?;
11471 s.serialize_field("result_path", &self.result_path)?;
11472 s.serialize_field("file_id", &self.file_id)?;
11473 s.serialize_field("paper_revision", &self.paper_revision)?;
11474 Ok(())
11475 }
11476}
11477
11478impl<'de> ::serde::de::Deserialize<'de> for PaperCreateResult {
11479 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11480 use serde::de::{MapAccess, Visitor};
11482 struct StructVisitor;
11483 impl<'de> Visitor<'de> for StructVisitor {
11484 type Value = PaperCreateResult;
11485 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11486 f.write_str("a PaperCreateResult struct")
11487 }
11488 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11489 PaperCreateResult::internal_deserialize(map)
11490 }
11491 }
11492 deserializer.deserialize_struct("PaperCreateResult", PAPER_CREATE_RESULT_FIELDS, StructVisitor)
11493 }
11494}
11495
11496impl ::serde::ser::Serialize for PaperCreateResult {
11497 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11498 use serde::ser::SerializeStruct;
11500 let mut s = serializer.serialize_struct("PaperCreateResult", 4)?;
11501 self.internal_serialize::<S>(&mut s)?;
11502 s.end()
11503 }
11504}
11505
11506#[derive(Debug, Clone, PartialEq, Eq)]
11507#[non_exhaustive] pub enum PaperDocUpdatePolicy {
11509 Update,
11512 Overwrite,
11514 Prepend,
11516 Append,
11518 Other,
11521}
11522
11523impl<'de> ::serde::de::Deserialize<'de> for PaperDocUpdatePolicy {
11524 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11525 use serde::de::{self, MapAccess, Visitor};
11527 struct EnumVisitor;
11528 impl<'de> Visitor<'de> for EnumVisitor {
11529 type Value = PaperDocUpdatePolicy;
11530 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11531 f.write_str("a PaperDocUpdatePolicy structure")
11532 }
11533 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11534 let tag: &str = match map.next_key()? {
11535 Some(".tag") => map.next_value()?,
11536 _ => return Err(de::Error::missing_field(".tag"))
11537 };
11538 let value = match tag {
11539 "update" => PaperDocUpdatePolicy::Update,
11540 "overwrite" => PaperDocUpdatePolicy::Overwrite,
11541 "prepend" => PaperDocUpdatePolicy::Prepend,
11542 "append" => PaperDocUpdatePolicy::Append,
11543 _ => PaperDocUpdatePolicy::Other,
11544 };
11545 crate::eat_json_fields(&mut map)?;
11546 Ok(value)
11547 }
11548 }
11549 const VARIANTS: &[&str] = &["update",
11550 "overwrite",
11551 "prepend",
11552 "append",
11553 "other"];
11554 deserializer.deserialize_struct("PaperDocUpdatePolicy", VARIANTS, EnumVisitor)
11555 }
11556}
11557
11558impl ::serde::ser::Serialize for PaperDocUpdatePolicy {
11559 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11560 use serde::ser::SerializeStruct;
11562 match self {
11563 PaperDocUpdatePolicy::Update => {
11564 let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11566 s.serialize_field(".tag", "update")?;
11567 s.end()
11568 }
11569 PaperDocUpdatePolicy::Overwrite => {
11570 let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11572 s.serialize_field(".tag", "overwrite")?;
11573 s.end()
11574 }
11575 PaperDocUpdatePolicy::Prepend => {
11576 let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11578 s.serialize_field(".tag", "prepend")?;
11579 s.end()
11580 }
11581 PaperDocUpdatePolicy::Append => {
11582 let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11584 s.serialize_field(".tag", "append")?;
11585 s.end()
11586 }
11587 PaperDocUpdatePolicy::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11588 }
11589 }
11590}
11591
11592#[derive(Debug, Clone, PartialEq, Eq)]
11593#[non_exhaustive] pub struct PaperUpdateArg {
11595 pub path: WritePathOrId,
11598 pub import_format: ImportFormat,
11600 pub doc_update_policy: PaperDocUpdatePolicy,
11602 pub paper_revision: Option<i64>,
11605}
11606
11607impl PaperUpdateArg {
11608 pub fn new(
11609 path: WritePathOrId,
11610 import_format: ImportFormat,
11611 doc_update_policy: PaperDocUpdatePolicy,
11612 ) -> Self {
11613 PaperUpdateArg {
11614 path,
11615 import_format,
11616 doc_update_policy,
11617 paper_revision: None,
11618 }
11619 }
11620
11621 pub fn with_paper_revision(mut self, value: i64) -> Self {
11622 self.paper_revision = Some(value);
11623 self
11624 }
11625}
11626
11627const PAPER_UPDATE_ARG_FIELDS: &[&str] = &["path",
11628 "import_format",
11629 "doc_update_policy",
11630 "paper_revision"];
11631impl PaperUpdateArg {
11632 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11633 map: V,
11634 ) -> Result<PaperUpdateArg, V::Error> {
11635 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11636 }
11637
11638 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11639 mut map: V,
11640 optional: bool,
11641 ) -> Result<Option<PaperUpdateArg>, V::Error> {
11642 let mut field_path = None;
11643 let mut field_import_format = None;
11644 let mut field_doc_update_policy = None;
11645 let mut field_paper_revision = None;
11646 let mut nothing = true;
11647 while let Some(key) = map.next_key::<&str>()? {
11648 nothing = false;
11649 match key {
11650 "path" => {
11651 if field_path.is_some() {
11652 return Err(::serde::de::Error::duplicate_field("path"));
11653 }
11654 field_path = Some(map.next_value()?);
11655 }
11656 "import_format" => {
11657 if field_import_format.is_some() {
11658 return Err(::serde::de::Error::duplicate_field("import_format"));
11659 }
11660 field_import_format = Some(map.next_value()?);
11661 }
11662 "doc_update_policy" => {
11663 if field_doc_update_policy.is_some() {
11664 return Err(::serde::de::Error::duplicate_field("doc_update_policy"));
11665 }
11666 field_doc_update_policy = Some(map.next_value()?);
11667 }
11668 "paper_revision" => {
11669 if field_paper_revision.is_some() {
11670 return Err(::serde::de::Error::duplicate_field("paper_revision"));
11671 }
11672 field_paper_revision = Some(map.next_value()?);
11673 }
11674 _ => {
11675 map.next_value::<::serde_json::Value>()?;
11677 }
11678 }
11679 }
11680 if optional && nothing {
11681 return Ok(None);
11682 }
11683 let result = PaperUpdateArg {
11684 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
11685 import_format: field_import_format.ok_or_else(|| ::serde::de::Error::missing_field("import_format"))?,
11686 doc_update_policy: field_doc_update_policy.ok_or_else(|| ::serde::de::Error::missing_field("doc_update_policy"))?,
11687 paper_revision: field_paper_revision.and_then(Option::flatten),
11688 };
11689 Ok(Some(result))
11690 }
11691
11692 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11693 &self,
11694 s: &mut S::SerializeStruct,
11695 ) -> Result<(), S::Error> {
11696 use serde::ser::SerializeStruct;
11697 s.serialize_field("path", &self.path)?;
11698 s.serialize_field("import_format", &self.import_format)?;
11699 s.serialize_field("doc_update_policy", &self.doc_update_policy)?;
11700 if let Some(val) = &self.paper_revision {
11701 s.serialize_field("paper_revision", val)?;
11702 }
11703 Ok(())
11704 }
11705}
11706
11707impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateArg {
11708 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11709 use serde::de::{MapAccess, Visitor};
11711 struct StructVisitor;
11712 impl<'de> Visitor<'de> for StructVisitor {
11713 type Value = PaperUpdateArg;
11714 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11715 f.write_str("a PaperUpdateArg struct")
11716 }
11717 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11718 PaperUpdateArg::internal_deserialize(map)
11719 }
11720 }
11721 deserializer.deserialize_struct("PaperUpdateArg", PAPER_UPDATE_ARG_FIELDS, StructVisitor)
11722 }
11723}
11724
11725impl ::serde::ser::Serialize for PaperUpdateArg {
11726 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11727 use serde::ser::SerializeStruct;
11729 let mut s = serializer.serialize_struct("PaperUpdateArg", 4)?;
11730 self.internal_serialize::<S>(&mut s)?;
11731 s.end()
11732 }
11733}
11734
11735#[derive(Debug, Clone, PartialEq, Eq)]
11736#[non_exhaustive] pub enum PaperUpdateError {
11738 InsufficientPermissions,
11740 ContentMalformed,
11742 DocLengthExceeded,
11744 ImageSizeExceeded,
11747 Path(LookupError),
11748 RevisionMismatch,
11750 DocArchived,
11752 DocDeleted,
11754 Other,
11757}
11758
11759impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateError {
11760 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11761 use serde::de::{self, MapAccess, Visitor};
11763 struct EnumVisitor;
11764 impl<'de> Visitor<'de> for EnumVisitor {
11765 type Value = PaperUpdateError;
11766 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11767 f.write_str("a PaperUpdateError structure")
11768 }
11769 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11770 let tag: &str = match map.next_key()? {
11771 Some(".tag") => map.next_value()?,
11772 _ => return Err(de::Error::missing_field(".tag"))
11773 };
11774 let value = match tag {
11775 "insufficient_permissions" => PaperUpdateError::InsufficientPermissions,
11776 "content_malformed" => PaperUpdateError::ContentMalformed,
11777 "doc_length_exceeded" => PaperUpdateError::DocLengthExceeded,
11778 "image_size_exceeded" => PaperUpdateError::ImageSizeExceeded,
11779 "path" => {
11780 match map.next_key()? {
11781 Some("path") => PaperUpdateError::Path(map.next_value()?),
11782 None => return Err(de::Error::missing_field("path")),
11783 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
11784 }
11785 }
11786 "revision_mismatch" => PaperUpdateError::RevisionMismatch,
11787 "doc_archived" => PaperUpdateError::DocArchived,
11788 "doc_deleted" => PaperUpdateError::DocDeleted,
11789 _ => PaperUpdateError::Other,
11790 };
11791 crate::eat_json_fields(&mut map)?;
11792 Ok(value)
11793 }
11794 }
11795 const VARIANTS: &[&str] = &["insufficient_permissions",
11796 "content_malformed",
11797 "doc_length_exceeded",
11798 "image_size_exceeded",
11799 "other",
11800 "path",
11801 "revision_mismatch",
11802 "doc_archived",
11803 "doc_deleted"];
11804 deserializer.deserialize_struct("PaperUpdateError", VARIANTS, EnumVisitor)
11805 }
11806}
11807
11808impl ::serde::ser::Serialize for PaperUpdateError {
11809 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11810 use serde::ser::SerializeStruct;
11812 match self {
11813 PaperUpdateError::InsufficientPermissions => {
11814 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11816 s.serialize_field(".tag", "insufficient_permissions")?;
11817 s.end()
11818 }
11819 PaperUpdateError::ContentMalformed => {
11820 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11822 s.serialize_field(".tag", "content_malformed")?;
11823 s.end()
11824 }
11825 PaperUpdateError::DocLengthExceeded => {
11826 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11828 s.serialize_field(".tag", "doc_length_exceeded")?;
11829 s.end()
11830 }
11831 PaperUpdateError::ImageSizeExceeded => {
11832 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11834 s.serialize_field(".tag", "image_size_exceeded")?;
11835 s.end()
11836 }
11837 PaperUpdateError::Path(x) => {
11838 let mut s = serializer.serialize_struct("PaperUpdateError", 2)?;
11840 s.serialize_field(".tag", "path")?;
11841 s.serialize_field("path", x)?;
11842 s.end()
11843 }
11844 PaperUpdateError::RevisionMismatch => {
11845 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11847 s.serialize_field(".tag", "revision_mismatch")?;
11848 s.end()
11849 }
11850 PaperUpdateError::DocArchived => {
11851 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11853 s.serialize_field(".tag", "doc_archived")?;
11854 s.end()
11855 }
11856 PaperUpdateError::DocDeleted => {
11857 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11859 s.serialize_field(".tag", "doc_deleted")?;
11860 s.end()
11861 }
11862 PaperUpdateError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11863 }
11864 }
11865}
11866
11867impl ::std::error::Error for PaperUpdateError {
11868 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
11869 match self {
11870 PaperUpdateError::Path(inner) => Some(inner),
11871 _ => None,
11872 }
11873 }
11874}
11875
11876impl ::std::fmt::Display for PaperUpdateError {
11877 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11878 match self {
11879 PaperUpdateError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
11880 PaperUpdateError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
11881 PaperUpdateError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
11882 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."),
11883 PaperUpdateError::Path(inner) => write!(f, "PaperUpdateError: {}", inner),
11884 PaperUpdateError::RevisionMismatch => f.write_str("The provided revision does not match the document head."),
11885 PaperUpdateError::DocArchived => f.write_str("This operation is not allowed on archived Paper docs."),
11886 PaperUpdateError::DocDeleted => f.write_str("This operation is not allowed on deleted Paper docs."),
11887 _ => write!(f, "{:?}", *self),
11888 }
11889 }
11890}
11891
11892impl From<PaperContentError> for PaperUpdateError {
11894 fn from(parent: PaperContentError) -> Self {
11895 match parent {
11896 PaperContentError::InsufficientPermissions => PaperUpdateError::InsufficientPermissions,
11897 PaperContentError::ContentMalformed => PaperUpdateError::ContentMalformed,
11898 PaperContentError::DocLengthExceeded => PaperUpdateError::DocLengthExceeded,
11899 PaperContentError::ImageSizeExceeded => PaperUpdateError::ImageSizeExceeded,
11900 PaperContentError::Other => PaperUpdateError::Other,
11901 }
11902 }
11903}
11904#[derive(Debug, Clone, PartialEq, Eq)]
11905#[non_exhaustive] pub struct PaperUpdateResult {
11907 pub paper_revision: i64,
11909}
11910
11911impl PaperUpdateResult {
11912 pub fn new(paper_revision: i64) -> Self {
11913 PaperUpdateResult {
11914 paper_revision,
11915 }
11916 }
11917}
11918
11919const PAPER_UPDATE_RESULT_FIELDS: &[&str] = &["paper_revision"];
11920impl PaperUpdateResult {
11921 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11922 map: V,
11923 ) -> Result<PaperUpdateResult, V::Error> {
11924 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11925 }
11926
11927 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11928 mut map: V,
11929 optional: bool,
11930 ) -> Result<Option<PaperUpdateResult>, V::Error> {
11931 let mut field_paper_revision = None;
11932 let mut nothing = true;
11933 while let Some(key) = map.next_key::<&str>()? {
11934 nothing = false;
11935 match key {
11936 "paper_revision" => {
11937 if field_paper_revision.is_some() {
11938 return Err(::serde::de::Error::duplicate_field("paper_revision"));
11939 }
11940 field_paper_revision = Some(map.next_value()?);
11941 }
11942 _ => {
11943 map.next_value::<::serde_json::Value>()?;
11945 }
11946 }
11947 }
11948 if optional && nothing {
11949 return Ok(None);
11950 }
11951 let result = PaperUpdateResult {
11952 paper_revision: field_paper_revision.ok_or_else(|| ::serde::de::Error::missing_field("paper_revision"))?,
11953 };
11954 Ok(Some(result))
11955 }
11956
11957 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11958 &self,
11959 s: &mut S::SerializeStruct,
11960 ) -> Result<(), S::Error> {
11961 use serde::ser::SerializeStruct;
11962 s.serialize_field("paper_revision", &self.paper_revision)?;
11963 Ok(())
11964 }
11965}
11966
11967impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateResult {
11968 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11969 use serde::de::{MapAccess, Visitor};
11971 struct StructVisitor;
11972 impl<'de> Visitor<'de> for StructVisitor {
11973 type Value = PaperUpdateResult;
11974 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11975 f.write_str("a PaperUpdateResult struct")
11976 }
11977 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11978 PaperUpdateResult::internal_deserialize(map)
11979 }
11980 }
11981 deserializer.deserialize_struct("PaperUpdateResult", PAPER_UPDATE_RESULT_FIELDS, StructVisitor)
11982 }
11983}
11984
11985impl ::serde::ser::Serialize for PaperUpdateResult {
11986 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11987 use serde::ser::SerializeStruct;
11989 let mut s = serializer.serialize_struct("PaperUpdateResult", 1)?;
11990 self.internal_serialize::<S>(&mut s)?;
11991 s.end()
11992 }
11993}
11994
11995#[derive(Debug, Clone, PartialEq, Eq)]
11996#[non_exhaustive] pub enum PathOrLink {
11998 Path(ReadPath),
11999 Link(SharedLinkFileInfo),
12000 Other,
12003}
12004
12005impl<'de> ::serde::de::Deserialize<'de> for PathOrLink {
12006 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12007 use serde::de::{self, MapAccess, Visitor};
12009 struct EnumVisitor;
12010 impl<'de> Visitor<'de> for EnumVisitor {
12011 type Value = PathOrLink;
12012 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12013 f.write_str("a PathOrLink structure")
12014 }
12015 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
12016 let tag: &str = match map.next_key()? {
12017 Some(".tag") => map.next_value()?,
12018 _ => return Err(de::Error::missing_field(".tag"))
12019 };
12020 let value = match tag {
12021 "path" => {
12022 match map.next_key()? {
12023 Some("path") => PathOrLink::Path(map.next_value()?),
12024 None => return Err(de::Error::missing_field("path")),
12025 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
12026 }
12027 }
12028 "link" => PathOrLink::Link(SharedLinkFileInfo::internal_deserialize(&mut map)?),
12029 _ => PathOrLink::Other,
12030 };
12031 crate::eat_json_fields(&mut map)?;
12032 Ok(value)
12033 }
12034 }
12035 const VARIANTS: &[&str] = &["path",
12036 "link",
12037 "other"];
12038 deserializer.deserialize_struct("PathOrLink", VARIANTS, EnumVisitor)
12039 }
12040}
12041
12042impl ::serde::ser::Serialize for PathOrLink {
12043 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12044 use serde::ser::SerializeStruct;
12046 match self {
12047 PathOrLink::Path(x) => {
12048 let mut s = serializer.serialize_struct("PathOrLink", 2)?;
12050 s.serialize_field(".tag", "path")?;
12051 s.serialize_field("path", x)?;
12052 s.end()
12053 }
12054 PathOrLink::Link(x) => {
12055 let mut s = serializer.serialize_struct("PathOrLink", 4)?;
12057 s.serialize_field(".tag", "link")?;
12058 x.internal_serialize::<S>(&mut s)?;
12059 s.end()
12060 }
12061 PathOrLink::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
12062 }
12063 }
12064}
12065
12066#[derive(Debug, Clone, PartialEq, Eq)]
12067#[non_exhaustive] pub struct PathToTags {
12069 pub path: Path,
12071 pub tags: Vec<Tag>,
12073}
12074
12075impl PathToTags {
12076 pub fn new(path: Path, tags: Vec<Tag>) -> Self {
12077 PathToTags {
12078 path,
12079 tags,
12080 }
12081 }
12082}
12083
12084const PATH_TO_TAGS_FIELDS: &[&str] = &["path",
12085 "tags"];
12086impl PathToTags {
12087 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12088 map: V,
12089 ) -> Result<PathToTags, V::Error> {
12090 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12091 }
12092
12093 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12094 mut map: V,
12095 optional: bool,
12096 ) -> Result<Option<PathToTags>, V::Error> {
12097 let mut field_path = None;
12098 let mut field_tags = None;
12099 let mut nothing = true;
12100 while let Some(key) = map.next_key::<&str>()? {
12101 nothing = false;
12102 match key {
12103 "path" => {
12104 if field_path.is_some() {
12105 return Err(::serde::de::Error::duplicate_field("path"));
12106 }
12107 field_path = Some(map.next_value()?);
12108 }
12109 "tags" => {
12110 if field_tags.is_some() {
12111 return Err(::serde::de::Error::duplicate_field("tags"));
12112 }
12113 field_tags = Some(map.next_value()?);
12114 }
12115 _ => {
12116 map.next_value::<::serde_json::Value>()?;
12118 }
12119 }
12120 }
12121 if optional && nothing {
12122 return Ok(None);
12123 }
12124 let result = PathToTags {
12125 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
12126 tags: field_tags.ok_or_else(|| ::serde::de::Error::missing_field("tags"))?,
12127 };
12128 Ok(Some(result))
12129 }
12130
12131 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12132 &self,
12133 s: &mut S::SerializeStruct,
12134 ) -> Result<(), S::Error> {
12135 use serde::ser::SerializeStruct;
12136 s.serialize_field("path", &self.path)?;
12137 s.serialize_field("tags", &self.tags)?;
12138 Ok(())
12139 }
12140}
12141
12142impl<'de> ::serde::de::Deserialize<'de> for PathToTags {
12143 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12144 use serde::de::{MapAccess, Visitor};
12146 struct StructVisitor;
12147 impl<'de> Visitor<'de> for StructVisitor {
12148 type Value = PathToTags;
12149 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12150 f.write_str("a PathToTags struct")
12151 }
12152 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12153 PathToTags::internal_deserialize(map)
12154 }
12155 }
12156 deserializer.deserialize_struct("PathToTags", PATH_TO_TAGS_FIELDS, StructVisitor)
12157 }
12158}
12159
12160impl ::serde::ser::Serialize for PathToTags {
12161 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12162 use serde::ser::SerializeStruct;
12164 let mut s = serializer.serialize_struct("PathToTags", 2)?;
12165 self.internal_serialize::<S>(&mut s)?;
12166 s.end()
12167 }
12168}
12169
12170#[derive(Debug, Clone, PartialEq, Default)]
12172#[non_exhaustive] pub struct PhotoMetadata {
12174 pub dimensions: Option<Dimensions>,
12176 pub location: Option<GpsCoordinates>,
12178 pub time_taken: Option<crate::types::common::DropboxTimestamp>,
12180}
12181
12182impl PhotoMetadata {
12183 pub fn with_dimensions(mut self, value: Dimensions) -> Self {
12184 self.dimensions = Some(value);
12185 self
12186 }
12187
12188 pub fn with_location(mut self, value: GpsCoordinates) -> Self {
12189 self.location = Some(value);
12190 self
12191 }
12192
12193 pub fn with_time_taken(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
12194 self.time_taken = Some(value);
12195 self
12196 }
12197}
12198
12199const PHOTO_METADATA_FIELDS: &[&str] = &["dimensions",
12200 "location",
12201 "time_taken"];
12202impl PhotoMetadata {
12203 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12205 mut map: V,
12206 ) -> Result<PhotoMetadata, V::Error> {
12207 let mut field_dimensions = None;
12208 let mut field_location = None;
12209 let mut field_time_taken = None;
12210 while let Some(key) = map.next_key::<&str>()? {
12211 match key {
12212 "dimensions" => {
12213 if field_dimensions.is_some() {
12214 return Err(::serde::de::Error::duplicate_field("dimensions"));
12215 }
12216 field_dimensions = Some(map.next_value()?);
12217 }
12218 "location" => {
12219 if field_location.is_some() {
12220 return Err(::serde::de::Error::duplicate_field("location"));
12221 }
12222 field_location = Some(map.next_value()?);
12223 }
12224 "time_taken" => {
12225 if field_time_taken.is_some() {
12226 return Err(::serde::de::Error::duplicate_field("time_taken"));
12227 }
12228 field_time_taken = Some(map.next_value()?);
12229 }
12230 _ => {
12231 map.next_value::<::serde_json::Value>()?;
12233 }
12234 }
12235 }
12236 let result = PhotoMetadata {
12237 dimensions: field_dimensions.and_then(Option::flatten),
12238 location: field_location.and_then(Option::flatten),
12239 time_taken: field_time_taken.and_then(Option::flatten),
12240 };
12241 Ok(result)
12242 }
12243
12244 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12245 &self,
12246 s: &mut S::SerializeStruct,
12247 ) -> Result<(), S::Error> {
12248 use serde::ser::SerializeStruct;
12249 if let Some(val) = &self.dimensions {
12250 s.serialize_field("dimensions", val)?;
12251 }
12252 if let Some(val) = &self.location {
12253 s.serialize_field("location", val)?;
12254 }
12255 if let Some(val) = &self.time_taken {
12256 s.serialize_field("time_taken", val)?;
12257 }
12258 Ok(())
12259 }
12260}
12261
12262impl<'de> ::serde::de::Deserialize<'de> for PhotoMetadata {
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 = PhotoMetadata;
12269 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12270 f.write_str("a PhotoMetadata struct")
12271 }
12272 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12273 PhotoMetadata::internal_deserialize(map)
12274 }
12275 }
12276 deserializer.deserialize_struct("PhotoMetadata", PHOTO_METADATA_FIELDS, StructVisitor)
12277 }
12278}
12279
12280impl ::serde::ser::Serialize for PhotoMetadata {
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("PhotoMetadata", 3)?;
12285 self.internal_serialize::<S>(&mut s)?;
12286 s.end()
12287 }
12288}
12289
12290impl From<PhotoMetadata> for MediaMetadata {
12292 fn from(subtype: PhotoMetadata) -> Self {
12293 MediaMetadata::Photo(subtype)
12294 }
12295}
12296#[derive(Debug, Clone, PartialEq, Eq)]
12297#[non_exhaustive] pub struct PreviewArg {
12299 pub path: ReadPath,
12301 #[deprecated]
12303 pub rev: Option<Rev>,
12304}
12305
12306impl PreviewArg {
12307 pub fn new(path: ReadPath) -> Self {
12308 PreviewArg {
12309 path,
12310 #[allow(deprecated)] rev: None,
12311 }
12312 }
12313
12314 #[deprecated]
12315 #[allow(deprecated)]
12316 pub fn with_rev(mut self, value: Rev) -> Self {
12317 self.rev = Some(value);
12318 self
12319 }
12320}
12321
12322const PREVIEW_ARG_FIELDS: &[&str] = &["path",
12323 "rev"];
12324impl PreviewArg {
12325 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12326 map: V,
12327 ) -> Result<PreviewArg, V::Error> {
12328 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12329 }
12330
12331 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12332 mut map: V,
12333 optional: bool,
12334 ) -> Result<Option<PreviewArg>, V::Error> {
12335 let mut field_path = None;
12336 let mut field_rev = None;
12337 let mut nothing = true;
12338 while let Some(key) = map.next_key::<&str>()? {
12339 nothing = false;
12340 match key {
12341 "path" => {
12342 if field_path.is_some() {
12343 return Err(::serde::de::Error::duplicate_field("path"));
12344 }
12345 field_path = Some(map.next_value()?);
12346 }
12347 "rev" => {
12348 if field_rev.is_some() {
12349 return Err(::serde::de::Error::duplicate_field("rev"));
12350 }
12351 field_rev = Some(map.next_value()?);
12352 }
12353 _ => {
12354 map.next_value::<::serde_json::Value>()?;
12356 }
12357 }
12358 }
12359 if optional && nothing {
12360 return Ok(None);
12361 }
12362 let result = PreviewArg {
12363 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
12364 #[allow(deprecated)] rev: field_rev.and_then(Option::flatten),
12365 };
12366 Ok(Some(result))
12367 }
12368
12369 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12370 &self,
12371 s: &mut S::SerializeStruct,
12372 ) -> Result<(), S::Error> {
12373 use serde::ser::SerializeStruct;
12374 s.serialize_field("path", &self.path)?;
12375 #[allow(deprecated)]
12376 if let Some(val) = &self.rev {
12377 s.serialize_field("rev", val)?;
12378 }
12379 Ok(())
12380 }
12381}
12382
12383impl<'de> ::serde::de::Deserialize<'de> for PreviewArg {
12384 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12385 use serde::de::{MapAccess, Visitor};
12387 struct StructVisitor;
12388 impl<'de> Visitor<'de> for StructVisitor {
12389 type Value = PreviewArg;
12390 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12391 f.write_str("a PreviewArg struct")
12392 }
12393 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12394 PreviewArg::internal_deserialize(map)
12395 }
12396 }
12397 deserializer.deserialize_struct("PreviewArg", PREVIEW_ARG_FIELDS, StructVisitor)
12398 }
12399}
12400
12401impl ::serde::ser::Serialize for PreviewArg {
12402 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12403 use serde::ser::SerializeStruct;
12405 let mut s = serializer.serialize_struct("PreviewArg", 2)?;
12406 self.internal_serialize::<S>(&mut s)?;
12407 s.end()
12408 }
12409}
12410
12411#[derive(Debug, Clone, PartialEq, Eq)]
12412pub enum PreviewError {
12413 Path(LookupError),
12415 InProgress,
12417 UnsupportedExtension,
12419 UnsupportedContent,
12421}
12422
12423impl<'de> ::serde::de::Deserialize<'de> for PreviewError {
12424 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12425 use serde::de::{self, MapAccess, Visitor};
12427 struct EnumVisitor;
12428 impl<'de> Visitor<'de> for EnumVisitor {
12429 type Value = PreviewError;
12430 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12431 f.write_str("a PreviewError structure")
12432 }
12433 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
12434 let tag: &str = match map.next_key()? {
12435 Some(".tag") => map.next_value()?,
12436 _ => return Err(de::Error::missing_field(".tag"))
12437 };
12438 let value = match tag {
12439 "path" => {
12440 match map.next_key()? {
12441 Some("path") => PreviewError::Path(map.next_value()?),
12442 None => return Err(de::Error::missing_field("path")),
12443 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
12444 }
12445 }
12446 "in_progress" => PreviewError::InProgress,
12447 "unsupported_extension" => PreviewError::UnsupportedExtension,
12448 "unsupported_content" => PreviewError::UnsupportedContent,
12449 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
12450 };
12451 crate::eat_json_fields(&mut map)?;
12452 Ok(value)
12453 }
12454 }
12455 const VARIANTS: &[&str] = &["path",
12456 "in_progress",
12457 "unsupported_extension",
12458 "unsupported_content"];
12459 deserializer.deserialize_struct("PreviewError", VARIANTS, EnumVisitor)
12460 }
12461}
12462
12463impl ::serde::ser::Serialize for PreviewError {
12464 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12465 use serde::ser::SerializeStruct;
12467 match self {
12468 PreviewError::Path(x) => {
12469 let mut s = serializer.serialize_struct("PreviewError", 2)?;
12471 s.serialize_field(".tag", "path")?;
12472 s.serialize_field("path", x)?;
12473 s.end()
12474 }
12475 PreviewError::InProgress => {
12476 let mut s = serializer.serialize_struct("PreviewError", 1)?;
12478 s.serialize_field(".tag", "in_progress")?;
12479 s.end()
12480 }
12481 PreviewError::UnsupportedExtension => {
12482 let mut s = serializer.serialize_struct("PreviewError", 1)?;
12484 s.serialize_field(".tag", "unsupported_extension")?;
12485 s.end()
12486 }
12487 PreviewError::UnsupportedContent => {
12488 let mut s = serializer.serialize_struct("PreviewError", 1)?;
12490 s.serialize_field(".tag", "unsupported_content")?;
12491 s.end()
12492 }
12493 }
12494 }
12495}
12496
12497impl ::std::error::Error for PreviewError {
12498 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
12499 match self {
12500 PreviewError::Path(inner) => Some(inner),
12501 _ => None,
12502 }
12503 }
12504}
12505
12506impl ::std::fmt::Display for PreviewError {
12507 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12508 match self {
12509 PreviewError::Path(inner) => write!(f, "An error occurs when downloading metadata for the file: {}", inner),
12510 PreviewError::InProgress => f.write_str("This preview generation is still in progress and the file is not ready for preview yet."),
12511 PreviewError::UnsupportedExtension => f.write_str("The file extension is not supported preview generation."),
12512 PreviewError::UnsupportedContent => f.write_str("The file content is not supported for preview generation."),
12513 }
12514 }
12515}
12516
12517#[derive(Debug, Clone, PartialEq, Default)]
12518#[non_exhaustive] pub struct PreviewResult {
12520 pub file_metadata: Option<FileMetadata>,
12523 pub link_metadata: Option<MinimalFileLinkMetadata>,
12526}
12527
12528impl PreviewResult {
12529 pub fn with_file_metadata(mut self, value: FileMetadata) -> Self {
12530 self.file_metadata = Some(value);
12531 self
12532 }
12533
12534 pub fn with_link_metadata(mut self, value: MinimalFileLinkMetadata) -> Self {
12535 self.link_metadata = Some(value);
12536 self
12537 }
12538}
12539
12540const PREVIEW_RESULT_FIELDS: &[&str] = &["file_metadata",
12541 "link_metadata"];
12542impl PreviewResult {
12543 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12545 mut map: V,
12546 ) -> Result<PreviewResult, V::Error> {
12547 let mut field_file_metadata = None;
12548 let mut field_link_metadata = None;
12549 while let Some(key) = map.next_key::<&str>()? {
12550 match key {
12551 "file_metadata" => {
12552 if field_file_metadata.is_some() {
12553 return Err(::serde::de::Error::duplicate_field("file_metadata"));
12554 }
12555 field_file_metadata = Some(map.next_value()?);
12556 }
12557 "link_metadata" => {
12558 if field_link_metadata.is_some() {
12559 return Err(::serde::de::Error::duplicate_field("link_metadata"));
12560 }
12561 field_link_metadata = Some(map.next_value()?);
12562 }
12563 _ => {
12564 map.next_value::<::serde_json::Value>()?;
12566 }
12567 }
12568 }
12569 let result = PreviewResult {
12570 file_metadata: field_file_metadata.and_then(Option::flatten),
12571 link_metadata: field_link_metadata.and_then(Option::flatten),
12572 };
12573 Ok(result)
12574 }
12575
12576 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12577 &self,
12578 s: &mut S::SerializeStruct,
12579 ) -> Result<(), S::Error> {
12580 use serde::ser::SerializeStruct;
12581 if let Some(val) = &self.file_metadata {
12582 s.serialize_field("file_metadata", val)?;
12583 }
12584 if let Some(val) = &self.link_metadata {
12585 s.serialize_field("link_metadata", val)?;
12586 }
12587 Ok(())
12588 }
12589}
12590
12591impl<'de> ::serde::de::Deserialize<'de> for PreviewResult {
12592 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12593 use serde::de::{MapAccess, Visitor};
12595 struct StructVisitor;
12596 impl<'de> Visitor<'de> for StructVisitor {
12597 type Value = PreviewResult;
12598 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12599 f.write_str("a PreviewResult struct")
12600 }
12601 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12602 PreviewResult::internal_deserialize(map)
12603 }
12604 }
12605 deserializer.deserialize_struct("PreviewResult", PREVIEW_RESULT_FIELDS, StructVisitor)
12606 }
12607}
12608
12609impl ::serde::ser::Serialize for PreviewResult {
12610 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12611 use serde::ser::SerializeStruct;
12613 let mut s = serializer.serialize_struct("PreviewResult", 2)?;
12614 self.internal_serialize::<S>(&mut s)?;
12615 s.end()
12616 }
12617}
12618
12619#[derive(Debug, Clone, PartialEq, Eq)]
12620#[non_exhaustive] pub struct RelocationArg {
12622 pub from_path: WritePathOrId,
12624 pub to_path: WritePathOrId,
12626 #[deprecated]
12628 pub allow_shared_folder: bool,
12629 pub autorename: bool,
12632 pub allow_ownership_transfer: bool,
12635}
12636
12637impl RelocationArg {
12638 pub fn new(from_path: WritePathOrId, to_path: WritePathOrId) -> Self {
12639 RelocationArg {
12640 from_path,
12641 to_path,
12642 #[allow(deprecated)] allow_shared_folder: false,
12643 autorename: false,
12644 allow_ownership_transfer: false,
12645 }
12646 }
12647
12648 #[deprecated]
12649 #[allow(deprecated)]
12650 pub fn with_allow_shared_folder(mut self, value: bool) -> Self {
12651 self.allow_shared_folder = value;
12652 self
12653 }
12654
12655 pub fn with_autorename(mut self, value: bool) -> Self {
12656 self.autorename = value;
12657 self
12658 }
12659
12660 pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
12661 self.allow_ownership_transfer = value;
12662 self
12663 }
12664}
12665
12666const RELOCATION_ARG_FIELDS: &[&str] = &["from_path",
12667 "to_path",
12668 "allow_shared_folder",
12669 "autorename",
12670 "allow_ownership_transfer"];
12671impl RelocationArg {
12672 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12673 map: V,
12674 ) -> Result<RelocationArg, V::Error> {
12675 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12676 }
12677
12678 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12679 mut map: V,
12680 optional: bool,
12681 ) -> Result<Option<RelocationArg>, V::Error> {
12682 let mut field_from_path = None;
12683 let mut field_to_path = None;
12684 let mut field_allow_shared_folder = None;
12685 let mut field_autorename = None;
12686 let mut field_allow_ownership_transfer = None;
12687 let mut nothing = true;
12688 while let Some(key) = map.next_key::<&str>()? {
12689 nothing = false;
12690 match key {
12691 "from_path" => {
12692 if field_from_path.is_some() {
12693 return Err(::serde::de::Error::duplicate_field("from_path"));
12694 }
12695 field_from_path = Some(map.next_value()?);
12696 }
12697 "to_path" => {
12698 if field_to_path.is_some() {
12699 return Err(::serde::de::Error::duplicate_field("to_path"));
12700 }
12701 field_to_path = Some(map.next_value()?);
12702 }
12703 "allow_shared_folder" => {
12704 if field_allow_shared_folder.is_some() {
12705 return Err(::serde::de::Error::duplicate_field("allow_shared_folder"));
12706 }
12707 field_allow_shared_folder = Some(map.next_value()?);
12708 }
12709 "autorename" => {
12710 if field_autorename.is_some() {
12711 return Err(::serde::de::Error::duplicate_field("autorename"));
12712 }
12713 field_autorename = Some(map.next_value()?);
12714 }
12715 "allow_ownership_transfer" => {
12716 if field_allow_ownership_transfer.is_some() {
12717 return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
12718 }
12719 field_allow_ownership_transfer = Some(map.next_value()?);
12720 }
12721 _ => {
12722 map.next_value::<::serde_json::Value>()?;
12724 }
12725 }
12726 }
12727 if optional && nothing {
12728 return Ok(None);
12729 }
12730 let result = RelocationArg {
12731 from_path: field_from_path.ok_or_else(|| ::serde::de::Error::missing_field("from_path"))?,
12732 to_path: field_to_path.ok_or_else(|| ::serde::de::Error::missing_field("to_path"))?,
12733 #[allow(deprecated)] allow_shared_folder: field_allow_shared_folder.unwrap_or(false),
12734 autorename: field_autorename.unwrap_or(false),
12735 allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
12736 };
12737 Ok(Some(result))
12738 }
12739
12740 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12741 &self,
12742 s: &mut S::SerializeStruct,
12743 ) -> Result<(), S::Error> {
12744 use serde::ser::SerializeStruct;
12745 s.serialize_field("from_path", &self.from_path)?;
12746 s.serialize_field("to_path", &self.to_path)?;
12747 #[allow(deprecated)]
12748 if self.allow_shared_folder {
12749 s.serialize_field("allow_shared_folder", &self.allow_shared_folder)?;
12750 }
12751 if self.autorename {
12752 s.serialize_field("autorename", &self.autorename)?;
12753 }
12754 if self.allow_ownership_transfer {
12755 s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
12756 }
12757 Ok(())
12758 }
12759}
12760
12761impl<'de> ::serde::de::Deserialize<'de> for RelocationArg {
12762 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12763 use serde::de::{MapAccess, Visitor};
12765 struct StructVisitor;
12766 impl<'de> Visitor<'de> for StructVisitor {
12767 type Value = RelocationArg;
12768 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12769 f.write_str("a RelocationArg struct")
12770 }
12771 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12772 RelocationArg::internal_deserialize(map)
12773 }
12774 }
12775 deserializer.deserialize_struct("RelocationArg", RELOCATION_ARG_FIELDS, StructVisitor)
12776 }
12777}
12778
12779impl ::serde::ser::Serialize for RelocationArg {
12780 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12781 use serde::ser::SerializeStruct;
12783 let mut s = serializer.serialize_struct("RelocationArg", 5)?;
12784 self.internal_serialize::<S>(&mut s)?;
12785 s.end()
12786 }
12787}
12788
12789impl From<RelocationArg> for RelocationPath {
12791 fn from(subtype: RelocationArg) -> Self {
12792 Self {
12793 from_path: subtype.from_path,
12794 to_path: subtype.to_path,
12795 }
12796 }
12797}
12798#[derive(Debug, Clone, PartialEq, Eq)]
12799#[non_exhaustive] pub struct RelocationBatchArg {
12801 pub entries: Vec<RelocationPath>,
12803 pub autorename: bool,
12806 #[deprecated]
12808 pub allow_shared_folder: bool,
12809 pub allow_ownership_transfer: bool,
12812}
12813
12814impl RelocationBatchArg {
12815 pub fn new(entries: Vec<RelocationPath>) -> Self {
12816 RelocationBatchArg {
12817 entries,
12818 autorename: false,
12819 #[allow(deprecated)] allow_shared_folder: false,
12820 allow_ownership_transfer: false,
12821 }
12822 }
12823
12824 pub fn with_autorename(mut self, value: bool) -> Self {
12825 self.autorename = value;
12826 self
12827 }
12828
12829 #[deprecated]
12830 #[allow(deprecated)]
12831 pub fn with_allow_shared_folder(mut self, value: bool) -> Self {
12832 self.allow_shared_folder = value;
12833 self
12834 }
12835
12836 pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
12837 self.allow_ownership_transfer = value;
12838 self
12839 }
12840}
12841
12842const RELOCATION_BATCH_ARG_FIELDS: &[&str] = &["entries",
12843 "autorename",
12844 "allow_shared_folder",
12845 "allow_ownership_transfer"];
12846impl RelocationBatchArg {
12847 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12848 map: V,
12849 ) -> Result<RelocationBatchArg, V::Error> {
12850 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12851 }
12852
12853 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12854 mut map: V,
12855 optional: bool,
12856 ) -> Result<Option<RelocationBatchArg>, V::Error> {
12857 let mut field_entries = None;
12858 let mut field_autorename = None;
12859 let mut field_allow_shared_folder = None;
12860 let mut field_allow_ownership_transfer = None;
12861 let mut nothing = true;
12862 while let Some(key) = map.next_key::<&str>()? {
12863 nothing = false;
12864 match key {
12865 "entries" => {
12866 if field_entries.is_some() {
12867 return Err(::serde::de::Error::duplicate_field("entries"));
12868 }
12869 field_entries = Some(map.next_value()?);
12870 }
12871 "autorename" => {
12872 if field_autorename.is_some() {
12873 return Err(::serde::de::Error::duplicate_field("autorename"));
12874 }
12875 field_autorename = Some(map.next_value()?);
12876 }
12877 "allow_shared_folder" => {
12878 if field_allow_shared_folder.is_some() {
12879 return Err(::serde::de::Error::duplicate_field("allow_shared_folder"));
12880 }
12881 field_allow_shared_folder = Some(map.next_value()?);
12882 }
12883 "allow_ownership_transfer" => {
12884 if field_allow_ownership_transfer.is_some() {
12885 return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
12886 }
12887 field_allow_ownership_transfer = Some(map.next_value()?);
12888 }
12889 _ => {
12890 map.next_value::<::serde_json::Value>()?;
12892 }
12893 }
12894 }
12895 if optional && nothing {
12896 return Ok(None);
12897 }
12898 let result = RelocationBatchArg {
12899 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
12900 autorename: field_autorename.unwrap_or(false),
12901 #[allow(deprecated)] allow_shared_folder: field_allow_shared_folder.unwrap_or(false),
12902 allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
12903 };
12904 Ok(Some(result))
12905 }
12906
12907 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12908 &self,
12909 s: &mut S::SerializeStruct,
12910 ) -> Result<(), S::Error> {
12911 use serde::ser::SerializeStruct;
12912 s.serialize_field("entries", &self.entries)?;
12913 if self.autorename {
12914 s.serialize_field("autorename", &self.autorename)?;
12915 }
12916 #[allow(deprecated)]
12917 if self.allow_shared_folder {
12918 s.serialize_field("allow_shared_folder", &self.allow_shared_folder)?;
12919 }
12920 if self.allow_ownership_transfer {
12921 s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
12922 }
12923 Ok(())
12924 }
12925}
12926
12927impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchArg {
12928 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12929 use serde::de::{MapAccess, Visitor};
12931 struct StructVisitor;
12932 impl<'de> Visitor<'de> for StructVisitor {
12933 type Value = RelocationBatchArg;
12934 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12935 f.write_str("a RelocationBatchArg struct")
12936 }
12937 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12938 RelocationBatchArg::internal_deserialize(map)
12939 }
12940 }
12941 deserializer.deserialize_struct("RelocationBatchArg", RELOCATION_BATCH_ARG_FIELDS, StructVisitor)
12942 }
12943}
12944
12945impl ::serde::ser::Serialize for RelocationBatchArg {
12946 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12947 use serde::ser::SerializeStruct;
12949 let mut s = serializer.serialize_struct("RelocationBatchArg", 4)?;
12950 self.internal_serialize::<S>(&mut s)?;
12951 s.end()
12952 }
12953}
12954
12955impl From<RelocationBatchArg> for RelocationBatchArgBase {
12957 fn from(subtype: RelocationBatchArg) -> Self {
12958 Self {
12959 entries: subtype.entries,
12960 autorename: subtype.autorename,
12961 }
12962 }
12963}
12964#[derive(Debug, Clone, PartialEq, Eq)]
12965#[non_exhaustive] pub struct RelocationBatchArgBase {
12967 pub entries: Vec<RelocationPath>,
12969 pub autorename: bool,
12972}
12973
12974impl RelocationBatchArgBase {
12975 pub fn new(entries: Vec<RelocationPath>) -> Self {
12976 RelocationBatchArgBase {
12977 entries,
12978 autorename: false,
12979 }
12980 }
12981
12982 pub fn with_autorename(mut self, value: bool) -> Self {
12983 self.autorename = value;
12984 self
12985 }
12986}
12987
12988const RELOCATION_BATCH_ARG_BASE_FIELDS: &[&str] = &["entries",
12989 "autorename"];
12990impl RelocationBatchArgBase {
12991 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12992 map: V,
12993 ) -> Result<RelocationBatchArgBase, V::Error> {
12994 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12995 }
12996
12997 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12998 mut map: V,
12999 optional: bool,
13000 ) -> Result<Option<RelocationBatchArgBase>, V::Error> {
13001 let mut field_entries = None;
13002 let mut field_autorename = None;
13003 let mut nothing = true;
13004 while let Some(key) = map.next_key::<&str>()? {
13005 nothing = false;
13006 match key {
13007 "entries" => {
13008 if field_entries.is_some() {
13009 return Err(::serde::de::Error::duplicate_field("entries"));
13010 }
13011 field_entries = Some(map.next_value()?);
13012 }
13013 "autorename" => {
13014 if field_autorename.is_some() {
13015 return Err(::serde::de::Error::duplicate_field("autorename"));
13016 }
13017 field_autorename = Some(map.next_value()?);
13018 }
13019 _ => {
13020 map.next_value::<::serde_json::Value>()?;
13022 }
13023 }
13024 }
13025 if optional && nothing {
13026 return Ok(None);
13027 }
13028 let result = RelocationBatchArgBase {
13029 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
13030 autorename: field_autorename.unwrap_or(false),
13031 };
13032 Ok(Some(result))
13033 }
13034
13035 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
13036 &self,
13037 s: &mut S::SerializeStruct,
13038 ) -> Result<(), S::Error> {
13039 use serde::ser::SerializeStruct;
13040 s.serialize_field("entries", &self.entries)?;
13041 if self.autorename {
13042 s.serialize_field("autorename", &self.autorename)?;
13043 }
13044 Ok(())
13045 }
13046}
13047
13048impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchArgBase {
13049 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13050 use serde::de::{MapAccess, Visitor};
13052 struct StructVisitor;
13053 impl<'de> Visitor<'de> for StructVisitor {
13054 type Value = RelocationBatchArgBase;
13055 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13056 f.write_str("a RelocationBatchArgBase struct")
13057 }
13058 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
13059 RelocationBatchArgBase::internal_deserialize(map)
13060 }
13061 }
13062 deserializer.deserialize_struct("RelocationBatchArgBase", RELOCATION_BATCH_ARG_BASE_FIELDS, StructVisitor)
13063 }
13064}
13065
13066impl ::serde::ser::Serialize for RelocationBatchArgBase {
13067 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13068 use serde::ser::SerializeStruct;
13070 let mut s = serializer.serialize_struct("RelocationBatchArgBase", 2)?;
13071 self.internal_serialize::<S>(&mut s)?;
13072 s.end()
13073 }
13074}
13075
13076#[derive(Debug, Clone, PartialEq, Eq)]
13077#[non_exhaustive] pub enum RelocationBatchError {
13079 FromLookup(LookupError),
13080 FromWrite(WriteError),
13081 To(WriteError),
13082 CantCopySharedFolder,
13084 CantNestSharedFolder,
13086 CantMoveFolderIntoItself,
13088 TooManyFiles,
13090 DuplicatedOrNestedPaths,
13093 CantTransferOwnership,
13096 InsufficientQuota,
13098 InternalError,
13101 CantMoveSharedFolder,
13103 CantMoveIntoVault(MoveIntoVaultError),
13105 CantMoveIntoFamily(MoveIntoFamilyError),
13108 TooManyWriteOperations,
13110 Other,
13113}
13114
13115impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchError {
13116 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13117 use serde::de::{self, MapAccess, Visitor};
13119 struct EnumVisitor;
13120 impl<'de> Visitor<'de> for EnumVisitor {
13121 type Value = RelocationBatchError;
13122 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13123 f.write_str("a RelocationBatchError structure")
13124 }
13125 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13126 let tag: &str = match map.next_key()? {
13127 Some(".tag") => map.next_value()?,
13128 _ => return Err(de::Error::missing_field(".tag"))
13129 };
13130 let value = match tag {
13131 "from_lookup" => {
13132 match map.next_key()? {
13133 Some("from_lookup") => RelocationBatchError::FromLookup(map.next_value()?),
13134 None => return Err(de::Error::missing_field("from_lookup")),
13135 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13136 }
13137 }
13138 "from_write" => {
13139 match map.next_key()? {
13140 Some("from_write") => RelocationBatchError::FromWrite(map.next_value()?),
13141 None => return Err(de::Error::missing_field("from_write")),
13142 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13143 }
13144 }
13145 "to" => {
13146 match map.next_key()? {
13147 Some("to") => RelocationBatchError::To(map.next_value()?),
13148 None => return Err(de::Error::missing_field("to")),
13149 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13150 }
13151 }
13152 "cant_copy_shared_folder" => RelocationBatchError::CantCopySharedFolder,
13153 "cant_nest_shared_folder" => RelocationBatchError::CantNestSharedFolder,
13154 "cant_move_folder_into_itself" => RelocationBatchError::CantMoveFolderIntoItself,
13155 "too_many_files" => RelocationBatchError::TooManyFiles,
13156 "duplicated_or_nested_paths" => RelocationBatchError::DuplicatedOrNestedPaths,
13157 "cant_transfer_ownership" => RelocationBatchError::CantTransferOwnership,
13158 "insufficient_quota" => RelocationBatchError::InsufficientQuota,
13159 "internal_error" => RelocationBatchError::InternalError,
13160 "cant_move_shared_folder" => RelocationBatchError::CantMoveSharedFolder,
13161 "cant_move_into_vault" => {
13162 match map.next_key()? {
13163 Some("cant_move_into_vault") => RelocationBatchError::CantMoveIntoVault(map.next_value()?),
13164 None => return Err(de::Error::missing_field("cant_move_into_vault")),
13165 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13166 }
13167 }
13168 "cant_move_into_family" => {
13169 match map.next_key()? {
13170 Some("cant_move_into_family") => RelocationBatchError::CantMoveIntoFamily(map.next_value()?),
13171 None => return Err(de::Error::missing_field("cant_move_into_family")),
13172 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13173 }
13174 }
13175 "too_many_write_operations" => RelocationBatchError::TooManyWriteOperations,
13176 _ => RelocationBatchError::Other,
13177 };
13178 crate::eat_json_fields(&mut map)?;
13179 Ok(value)
13180 }
13181 }
13182 const VARIANTS: &[&str] = &["from_lookup",
13183 "from_write",
13184 "to",
13185 "cant_copy_shared_folder",
13186 "cant_nest_shared_folder",
13187 "cant_move_folder_into_itself",
13188 "too_many_files",
13189 "duplicated_or_nested_paths",
13190 "cant_transfer_ownership",
13191 "insufficient_quota",
13192 "internal_error",
13193 "cant_move_shared_folder",
13194 "cant_move_into_vault",
13195 "cant_move_into_family",
13196 "other",
13197 "too_many_write_operations"];
13198 deserializer.deserialize_struct("RelocationBatchError", VARIANTS, EnumVisitor)
13199 }
13200}
13201
13202impl ::serde::ser::Serialize for RelocationBatchError {
13203 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13204 use serde::ser::SerializeStruct;
13206 match self {
13207 RelocationBatchError::FromLookup(x) => {
13208 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13210 s.serialize_field(".tag", "from_lookup")?;
13211 s.serialize_field("from_lookup", x)?;
13212 s.end()
13213 }
13214 RelocationBatchError::FromWrite(x) => {
13215 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13217 s.serialize_field(".tag", "from_write")?;
13218 s.serialize_field("from_write", x)?;
13219 s.end()
13220 }
13221 RelocationBatchError::To(x) => {
13222 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13224 s.serialize_field(".tag", "to")?;
13225 s.serialize_field("to", x)?;
13226 s.end()
13227 }
13228 RelocationBatchError::CantCopySharedFolder => {
13229 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13231 s.serialize_field(".tag", "cant_copy_shared_folder")?;
13232 s.end()
13233 }
13234 RelocationBatchError::CantNestSharedFolder => {
13235 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13237 s.serialize_field(".tag", "cant_nest_shared_folder")?;
13238 s.end()
13239 }
13240 RelocationBatchError::CantMoveFolderIntoItself => {
13241 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13243 s.serialize_field(".tag", "cant_move_folder_into_itself")?;
13244 s.end()
13245 }
13246 RelocationBatchError::TooManyFiles => {
13247 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13249 s.serialize_field(".tag", "too_many_files")?;
13250 s.end()
13251 }
13252 RelocationBatchError::DuplicatedOrNestedPaths => {
13253 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13255 s.serialize_field(".tag", "duplicated_or_nested_paths")?;
13256 s.end()
13257 }
13258 RelocationBatchError::CantTransferOwnership => {
13259 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13261 s.serialize_field(".tag", "cant_transfer_ownership")?;
13262 s.end()
13263 }
13264 RelocationBatchError::InsufficientQuota => {
13265 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13267 s.serialize_field(".tag", "insufficient_quota")?;
13268 s.end()
13269 }
13270 RelocationBatchError::InternalError => {
13271 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13273 s.serialize_field(".tag", "internal_error")?;
13274 s.end()
13275 }
13276 RelocationBatchError::CantMoveSharedFolder => {
13277 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13279 s.serialize_field(".tag", "cant_move_shared_folder")?;
13280 s.end()
13281 }
13282 RelocationBatchError::CantMoveIntoVault(x) => {
13283 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13285 s.serialize_field(".tag", "cant_move_into_vault")?;
13286 s.serialize_field("cant_move_into_vault", x)?;
13287 s.end()
13288 }
13289 RelocationBatchError::CantMoveIntoFamily(x) => {
13290 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13292 s.serialize_field(".tag", "cant_move_into_family")?;
13293 s.serialize_field("cant_move_into_family", x)?;
13294 s.end()
13295 }
13296 RelocationBatchError::TooManyWriteOperations => {
13297 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13299 s.serialize_field(".tag", "too_many_write_operations")?;
13300 s.end()
13301 }
13302 RelocationBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13303 }
13304 }
13305}
13306
13307impl ::std::error::Error for RelocationBatchError {
13308 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
13309 match self {
13310 RelocationBatchError::FromLookup(inner) => Some(inner),
13311 RelocationBatchError::FromWrite(inner) => Some(inner),
13312 RelocationBatchError::To(inner) => Some(inner),
13313 RelocationBatchError::CantMoveIntoVault(inner) => Some(inner),
13314 RelocationBatchError::CantMoveIntoFamily(inner) => Some(inner),
13315 _ => None,
13316 }
13317 }
13318}
13319
13320impl ::std::fmt::Display for RelocationBatchError {
13321 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13322 match self {
13323 RelocationBatchError::FromLookup(inner) => write!(f, "RelocationBatchError: {}", inner),
13324 RelocationBatchError::FromWrite(inner) => write!(f, "RelocationBatchError: {}", inner),
13325 RelocationBatchError::To(inner) => write!(f, "RelocationBatchError: {}", inner),
13326 RelocationBatchError::CantCopySharedFolder => f.write_str("Shared folders can't be copied."),
13327 RelocationBatchError::CantNestSharedFolder => f.write_str("Your move operation would result in nested shared folders. This is not allowed."),
13328 RelocationBatchError::CantMoveFolderIntoItself => f.write_str("You cannot move a folder into itself."),
13329 RelocationBatchError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
13330 RelocationBatchError::InsufficientQuota => f.write_str("The current user does not have enough space to move or copy the files."),
13331 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."),
13332 RelocationBatchError::CantMoveSharedFolder => f.write_str("Can't move the shared folder to the given destination."),
13333 RelocationBatchError::CantMoveIntoVault(inner) => write!(f, "Some content cannot be moved into Vault under certain circumstances, see detailed error: {}", inner),
13334 RelocationBatchError::CantMoveIntoFamily(inner) => write!(f, "Some content cannot be moved into the Family Room folder under certain circumstances, see detailed error: {}", inner),
13335 RelocationBatchError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
13336 _ => write!(f, "{:?}", *self),
13337 }
13338 }
13339}
13340
13341impl From<RelocationError> for RelocationBatchError {
13343 fn from(parent: RelocationError) -> Self {
13344 match parent {
13345 RelocationError::FromLookup(x) => RelocationBatchError::FromLookup(x),
13346 RelocationError::FromWrite(x) => RelocationBatchError::FromWrite(x),
13347 RelocationError::To(x) => RelocationBatchError::To(x),
13348 RelocationError::CantCopySharedFolder => RelocationBatchError::CantCopySharedFolder,
13349 RelocationError::CantNestSharedFolder => RelocationBatchError::CantNestSharedFolder,
13350 RelocationError::CantMoveFolderIntoItself => RelocationBatchError::CantMoveFolderIntoItself,
13351 RelocationError::TooManyFiles => RelocationBatchError::TooManyFiles,
13352 RelocationError::DuplicatedOrNestedPaths => RelocationBatchError::DuplicatedOrNestedPaths,
13353 RelocationError::CantTransferOwnership => RelocationBatchError::CantTransferOwnership,
13354 RelocationError::InsufficientQuota => RelocationBatchError::InsufficientQuota,
13355 RelocationError::InternalError => RelocationBatchError::InternalError,
13356 RelocationError::CantMoveSharedFolder => RelocationBatchError::CantMoveSharedFolder,
13357 RelocationError::CantMoveIntoVault(x) => RelocationBatchError::CantMoveIntoVault(x),
13358 RelocationError::CantMoveIntoFamily(x) => RelocationBatchError::CantMoveIntoFamily(x),
13359 RelocationError::Other => RelocationBatchError::Other,
13360 }
13361 }
13362}
13363#[derive(Debug, Clone, PartialEq, Eq)]
13364#[non_exhaustive] pub enum RelocationBatchErrorEntry {
13366 RelocationError(RelocationError),
13368 InternalError,
13371 TooManyWriteOperations,
13373 Other,
13376}
13377
13378impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchErrorEntry {
13379 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13380 use serde::de::{self, MapAccess, Visitor};
13382 struct EnumVisitor;
13383 impl<'de> Visitor<'de> for EnumVisitor {
13384 type Value = RelocationBatchErrorEntry;
13385 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13386 f.write_str("a RelocationBatchErrorEntry structure")
13387 }
13388 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13389 let tag: &str = match map.next_key()? {
13390 Some(".tag") => map.next_value()?,
13391 _ => return Err(de::Error::missing_field(".tag"))
13392 };
13393 let value = match tag {
13394 "relocation_error" => {
13395 match map.next_key()? {
13396 Some("relocation_error") => RelocationBatchErrorEntry::RelocationError(map.next_value()?),
13397 None => return Err(de::Error::missing_field("relocation_error")),
13398 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13399 }
13400 }
13401 "internal_error" => RelocationBatchErrorEntry::InternalError,
13402 "too_many_write_operations" => RelocationBatchErrorEntry::TooManyWriteOperations,
13403 _ => RelocationBatchErrorEntry::Other,
13404 };
13405 crate::eat_json_fields(&mut map)?;
13406 Ok(value)
13407 }
13408 }
13409 const VARIANTS: &[&str] = &["relocation_error",
13410 "internal_error",
13411 "too_many_write_operations",
13412 "other"];
13413 deserializer.deserialize_struct("RelocationBatchErrorEntry", VARIANTS, EnumVisitor)
13414 }
13415}
13416
13417impl ::serde::ser::Serialize for RelocationBatchErrorEntry {
13418 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13419 use serde::ser::SerializeStruct;
13421 match self {
13422 RelocationBatchErrorEntry::RelocationError(x) => {
13423 let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 2)?;
13425 s.serialize_field(".tag", "relocation_error")?;
13426 s.serialize_field("relocation_error", x)?;
13427 s.end()
13428 }
13429 RelocationBatchErrorEntry::InternalError => {
13430 let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 1)?;
13432 s.serialize_field(".tag", "internal_error")?;
13433 s.end()
13434 }
13435 RelocationBatchErrorEntry::TooManyWriteOperations => {
13436 let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 1)?;
13438 s.serialize_field(".tag", "too_many_write_operations")?;
13439 s.end()
13440 }
13441 RelocationBatchErrorEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13442 }
13443 }
13444}
13445
13446#[derive(Debug, Clone, PartialEq)]
13447pub enum RelocationBatchJobStatus {
13448 InProgress,
13450 Complete(RelocationBatchResult),
13452 Failed(RelocationBatchError),
13454}
13455
13456impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchJobStatus {
13457 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13458 use serde::de::{self, MapAccess, Visitor};
13460 struct EnumVisitor;
13461 impl<'de> Visitor<'de> for EnumVisitor {
13462 type Value = RelocationBatchJobStatus;
13463 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13464 f.write_str("a RelocationBatchJobStatus structure")
13465 }
13466 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13467 let tag: &str = match map.next_key()? {
13468 Some(".tag") => map.next_value()?,
13469 _ => return Err(de::Error::missing_field(".tag"))
13470 };
13471 let value = match tag {
13472 "in_progress" => RelocationBatchJobStatus::InProgress,
13473 "complete" => RelocationBatchJobStatus::Complete(RelocationBatchResult::internal_deserialize(&mut map)?),
13474 "failed" => {
13475 match map.next_key()? {
13476 Some("failed") => RelocationBatchJobStatus::Failed(map.next_value()?),
13477 None => return Err(de::Error::missing_field("failed")),
13478 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13479 }
13480 }
13481 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
13482 };
13483 crate::eat_json_fields(&mut map)?;
13484 Ok(value)
13485 }
13486 }
13487 const VARIANTS: &[&str] = &["in_progress",
13488 "complete",
13489 "failed"];
13490 deserializer.deserialize_struct("RelocationBatchJobStatus", VARIANTS, EnumVisitor)
13491 }
13492}
13493
13494impl ::serde::ser::Serialize for RelocationBatchJobStatus {
13495 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13496 use serde::ser::SerializeStruct;
13498 match self {
13499 RelocationBatchJobStatus::InProgress => {
13500 let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 1)?;
13502 s.serialize_field(".tag", "in_progress")?;
13503 s.end()
13504 }
13505 RelocationBatchJobStatus::Complete(x) => {
13506 let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 2)?;
13508 s.serialize_field(".tag", "complete")?;
13509 x.internal_serialize::<S>(&mut s)?;
13510 s.end()
13511 }
13512 RelocationBatchJobStatus::Failed(x) => {
13513 let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 2)?;
13515 s.serialize_field(".tag", "failed")?;
13516 s.serialize_field("failed", x)?;
13517 s.end()
13518 }
13519 }
13520 }
13521}
13522
13523impl From<crate::types::dbx_async::PollResultBase> for RelocationBatchJobStatus {
13525 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
13526 match parent {
13527 crate::types::dbx_async::PollResultBase::InProgress => RelocationBatchJobStatus::InProgress,
13528 }
13529 }
13530}
13531#[derive(Debug, Clone, PartialEq)]
13535#[non_exhaustive] pub enum RelocationBatchLaunch {
13537 AsyncJobId(crate::types::dbx_async::AsyncJobId),
13540 Complete(RelocationBatchResult),
13541 Other,
13544}
13545
13546impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchLaunch {
13547 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13548 use serde::de::{self, MapAccess, Visitor};
13550 struct EnumVisitor;
13551 impl<'de> Visitor<'de> for EnumVisitor {
13552 type Value = RelocationBatchLaunch;
13553 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13554 f.write_str("a RelocationBatchLaunch structure")
13555 }
13556 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13557 let tag: &str = match map.next_key()? {
13558 Some(".tag") => map.next_value()?,
13559 _ => return Err(de::Error::missing_field(".tag"))
13560 };
13561 let value = match tag {
13562 "async_job_id" => {
13563 match map.next_key()? {
13564 Some("async_job_id") => RelocationBatchLaunch::AsyncJobId(map.next_value()?),
13565 None => return Err(de::Error::missing_field("async_job_id")),
13566 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13567 }
13568 }
13569 "complete" => RelocationBatchLaunch::Complete(RelocationBatchResult::internal_deserialize(&mut map)?),
13570 _ => RelocationBatchLaunch::Other,
13571 };
13572 crate::eat_json_fields(&mut map)?;
13573 Ok(value)
13574 }
13575 }
13576 const VARIANTS: &[&str] = &["async_job_id",
13577 "complete",
13578 "other"];
13579 deserializer.deserialize_struct("RelocationBatchLaunch", VARIANTS, EnumVisitor)
13580 }
13581}
13582
13583impl ::serde::ser::Serialize for RelocationBatchLaunch {
13584 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13585 use serde::ser::SerializeStruct;
13587 match self {
13588 RelocationBatchLaunch::AsyncJobId(x) => {
13589 let mut s = serializer.serialize_struct("RelocationBatchLaunch", 2)?;
13591 s.serialize_field(".tag", "async_job_id")?;
13592 s.serialize_field("async_job_id", x)?;
13593 s.end()
13594 }
13595 RelocationBatchLaunch::Complete(x) => {
13596 let mut s = serializer.serialize_struct("RelocationBatchLaunch", 2)?;
13598 s.serialize_field(".tag", "complete")?;
13599 x.internal_serialize::<S>(&mut s)?;
13600 s.end()
13601 }
13602 RelocationBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13603 }
13604 }
13605}
13606
13607impl From<crate::types::dbx_async::LaunchResultBase> for RelocationBatchLaunch {
13609 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
13610 match parent {
13611 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => RelocationBatchLaunch::AsyncJobId(x),
13612 }
13613 }
13614}
13615#[derive(Debug, Clone, PartialEq)]
13616#[non_exhaustive] pub struct RelocationBatchResult {
13618 pub entries: Vec<RelocationBatchResultData>,
13619}
13620
13621impl RelocationBatchResult {
13622 pub fn new(entries: Vec<RelocationBatchResultData>) -> Self {
13623 RelocationBatchResult {
13624 entries,
13625 }
13626 }
13627}
13628
13629const RELOCATION_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
13630impl RelocationBatchResult {
13631 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
13632 map: V,
13633 ) -> Result<RelocationBatchResult, V::Error> {
13634 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
13635 }
13636
13637 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
13638 mut map: V,
13639 optional: bool,
13640 ) -> Result<Option<RelocationBatchResult>, V::Error> {
13641 let mut field_entries = None;
13642 let mut nothing = true;
13643 while let Some(key) = map.next_key::<&str>()? {
13644 nothing = false;
13645 match key {
13646 "entries" => {
13647 if field_entries.is_some() {
13648 return Err(::serde::de::Error::duplicate_field("entries"));
13649 }
13650 field_entries = Some(map.next_value()?);
13651 }
13652 _ => {
13653 map.next_value::<::serde_json::Value>()?;
13655 }
13656 }
13657 }
13658 if optional && nothing {
13659 return Ok(None);
13660 }
13661 let result = RelocationBatchResult {
13662 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
13663 };
13664 Ok(Some(result))
13665 }
13666
13667 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
13668 &self,
13669 s: &mut S::SerializeStruct,
13670 ) -> Result<(), S::Error> {
13671 use serde::ser::SerializeStruct;
13672 s.serialize_field("entries", &self.entries)?;
13673 Ok(())
13674 }
13675}
13676
13677impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResult {
13678 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13679 use serde::de::{MapAccess, Visitor};
13681 struct StructVisitor;
13682 impl<'de> Visitor<'de> for StructVisitor {
13683 type Value = RelocationBatchResult;
13684 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13685 f.write_str("a RelocationBatchResult struct")
13686 }
13687 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
13688 RelocationBatchResult::internal_deserialize(map)
13689 }
13690 }
13691 deserializer.deserialize_struct("RelocationBatchResult", RELOCATION_BATCH_RESULT_FIELDS, StructVisitor)
13692 }
13693}
13694
13695impl ::serde::ser::Serialize for RelocationBatchResult {
13696 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13697 use serde::ser::SerializeStruct;
13699 let mut s = serializer.serialize_struct("RelocationBatchResult", 1)?;
13700 self.internal_serialize::<S>(&mut s)?;
13701 s.end()
13702 }
13703}
13704
13705impl From<RelocationBatchResult> for FileOpsResult {
13707 fn from(_: RelocationBatchResult) -> Self {
13708 Self {}
13709 }
13710}
13711#[derive(Debug, Clone, PartialEq)]
13712#[non_exhaustive] pub struct RelocationBatchResultData {
13714 pub metadata: Metadata,
13716}
13717
13718impl RelocationBatchResultData {
13719 pub fn new(metadata: Metadata) -> Self {
13720 RelocationBatchResultData {
13721 metadata,
13722 }
13723 }
13724}
13725
13726const RELOCATION_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata"];
13727impl RelocationBatchResultData {
13728 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
13729 map: V,
13730 ) -> Result<RelocationBatchResultData, V::Error> {
13731 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
13732 }
13733
13734 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
13735 mut map: V,
13736 optional: bool,
13737 ) -> Result<Option<RelocationBatchResultData>, V::Error> {
13738 let mut field_metadata = None;
13739 let mut nothing = true;
13740 while let Some(key) = map.next_key::<&str>()? {
13741 nothing = false;
13742 match key {
13743 "metadata" => {
13744 if field_metadata.is_some() {
13745 return Err(::serde::de::Error::duplicate_field("metadata"));
13746 }
13747 field_metadata = Some(map.next_value()?);
13748 }
13749 _ => {
13750 map.next_value::<::serde_json::Value>()?;
13752 }
13753 }
13754 }
13755 if optional && nothing {
13756 return Ok(None);
13757 }
13758 let result = RelocationBatchResultData {
13759 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
13760 };
13761 Ok(Some(result))
13762 }
13763
13764 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
13765 &self,
13766 s: &mut S::SerializeStruct,
13767 ) -> Result<(), S::Error> {
13768 use serde::ser::SerializeStruct;
13769 s.serialize_field("metadata", &self.metadata)?;
13770 Ok(())
13771 }
13772}
13773
13774impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResultData {
13775 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13776 use serde::de::{MapAccess, Visitor};
13778 struct StructVisitor;
13779 impl<'de> Visitor<'de> for StructVisitor {
13780 type Value = RelocationBatchResultData;
13781 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13782 f.write_str("a RelocationBatchResultData struct")
13783 }
13784 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
13785 RelocationBatchResultData::internal_deserialize(map)
13786 }
13787 }
13788 deserializer.deserialize_struct("RelocationBatchResultData", RELOCATION_BATCH_RESULT_DATA_FIELDS, StructVisitor)
13789 }
13790}
13791
13792impl ::serde::ser::Serialize for RelocationBatchResultData {
13793 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13794 use serde::ser::SerializeStruct;
13796 let mut s = serializer.serialize_struct("RelocationBatchResultData", 1)?;
13797 self.internal_serialize::<S>(&mut s)?;
13798 s.end()
13799 }
13800}
13801
13802#[derive(Debug, Clone, PartialEq)]
13803#[non_exhaustive] pub enum RelocationBatchResultEntry {
13805 Success(Metadata),
13806 Failure(RelocationBatchErrorEntry),
13807 Other,
13810}
13811
13812impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResultEntry {
13813 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13814 use serde::de::{self, MapAccess, Visitor};
13816 struct EnumVisitor;
13817 impl<'de> Visitor<'de> for EnumVisitor {
13818 type Value = RelocationBatchResultEntry;
13819 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13820 f.write_str("a RelocationBatchResultEntry structure")
13821 }
13822 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13823 let tag: &str = match map.next_key()? {
13824 Some(".tag") => map.next_value()?,
13825 _ => return Err(de::Error::missing_field(".tag"))
13826 };
13827 let value = match tag {
13828 "success" => {
13829 match map.next_key()? {
13830 Some("success") => RelocationBatchResultEntry::Success(map.next_value()?),
13831 None => return Err(de::Error::missing_field("success")),
13832 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13833 }
13834 }
13835 "failure" => {
13836 match map.next_key()? {
13837 Some("failure") => RelocationBatchResultEntry::Failure(map.next_value()?),
13838 None => return Err(de::Error::missing_field("failure")),
13839 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13840 }
13841 }
13842 _ => RelocationBatchResultEntry::Other,
13843 };
13844 crate::eat_json_fields(&mut map)?;
13845 Ok(value)
13846 }
13847 }
13848 const VARIANTS: &[&str] = &["success",
13849 "failure",
13850 "other"];
13851 deserializer.deserialize_struct("RelocationBatchResultEntry", VARIANTS, EnumVisitor)
13852 }
13853}
13854
13855impl ::serde::ser::Serialize for RelocationBatchResultEntry {
13856 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13857 use serde::ser::SerializeStruct;
13859 match self {
13860 RelocationBatchResultEntry::Success(x) => {
13861 let mut s = serializer.serialize_struct("RelocationBatchResultEntry", 2)?;
13863 s.serialize_field(".tag", "success")?;
13864 s.serialize_field("success", x)?;
13865 s.end()
13866 }
13867 RelocationBatchResultEntry::Failure(x) => {
13868 let mut s = serializer.serialize_struct("RelocationBatchResultEntry", 2)?;
13870 s.serialize_field(".tag", "failure")?;
13871 s.serialize_field("failure", x)?;
13872 s.end()
13873 }
13874 RelocationBatchResultEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13875 }
13876 }
13877}
13878
13879#[derive(Debug, Clone, PartialEq)]
13883pub enum RelocationBatchV2JobStatus {
13884 InProgress,
13886 Complete(RelocationBatchV2Result),
13888}
13889
13890impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2JobStatus {
13891 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13892 use serde::de::{self, MapAccess, Visitor};
13894 struct EnumVisitor;
13895 impl<'de> Visitor<'de> for EnumVisitor {
13896 type Value = RelocationBatchV2JobStatus;
13897 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13898 f.write_str("a RelocationBatchV2JobStatus structure")
13899 }
13900 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13901 let tag: &str = match map.next_key()? {
13902 Some(".tag") => map.next_value()?,
13903 _ => return Err(de::Error::missing_field(".tag"))
13904 };
13905 let value = match tag {
13906 "in_progress" => RelocationBatchV2JobStatus::InProgress,
13907 "complete" => RelocationBatchV2JobStatus::Complete(RelocationBatchV2Result::internal_deserialize(&mut map)?),
13908 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
13909 };
13910 crate::eat_json_fields(&mut map)?;
13911 Ok(value)
13912 }
13913 }
13914 const VARIANTS: &[&str] = &["in_progress",
13915 "complete"];
13916 deserializer.deserialize_struct("RelocationBatchV2JobStatus", VARIANTS, EnumVisitor)
13917 }
13918}
13919
13920impl ::serde::ser::Serialize for RelocationBatchV2JobStatus {
13921 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13922 use serde::ser::SerializeStruct;
13924 match self {
13925 RelocationBatchV2JobStatus::InProgress => {
13926 let mut s = serializer.serialize_struct("RelocationBatchV2JobStatus", 1)?;
13928 s.serialize_field(".tag", "in_progress")?;
13929 s.end()
13930 }
13931 RelocationBatchV2JobStatus::Complete(x) => {
13932 let mut s = serializer.serialize_struct("RelocationBatchV2JobStatus", 2)?;
13934 s.serialize_field(".tag", "complete")?;
13935 x.internal_serialize::<S>(&mut s)?;
13936 s.end()
13937 }
13938 }
13939 }
13940}
13941
13942impl From<crate::types::dbx_async::PollResultBase> for RelocationBatchV2JobStatus {
13944 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
13945 match parent {
13946 crate::types::dbx_async::PollResultBase::InProgress => RelocationBatchV2JobStatus::InProgress,
13947 }
13948 }
13949}
13950#[derive(Debug, Clone, PartialEq)]
13954pub enum RelocationBatchV2Launch {
13955 AsyncJobId(crate::types::dbx_async::AsyncJobId),
13958 Complete(RelocationBatchV2Result),
13959}
13960
13961impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2Launch {
13962 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13963 use serde::de::{self, MapAccess, Visitor};
13965 struct EnumVisitor;
13966 impl<'de> Visitor<'de> for EnumVisitor {
13967 type Value = RelocationBatchV2Launch;
13968 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13969 f.write_str("a RelocationBatchV2Launch structure")
13970 }
13971 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13972 let tag: &str = match map.next_key()? {
13973 Some(".tag") => map.next_value()?,
13974 _ => return Err(de::Error::missing_field(".tag"))
13975 };
13976 let value = match tag {
13977 "async_job_id" => {
13978 match map.next_key()? {
13979 Some("async_job_id") => RelocationBatchV2Launch::AsyncJobId(map.next_value()?),
13980 None => return Err(de::Error::missing_field("async_job_id")),
13981 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13982 }
13983 }
13984 "complete" => RelocationBatchV2Launch::Complete(RelocationBatchV2Result::internal_deserialize(&mut map)?),
13985 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
13986 };
13987 crate::eat_json_fields(&mut map)?;
13988 Ok(value)
13989 }
13990 }
13991 const VARIANTS: &[&str] = &["async_job_id",
13992 "complete"];
13993 deserializer.deserialize_struct("RelocationBatchV2Launch", VARIANTS, EnumVisitor)
13994 }
13995}
13996
13997impl ::serde::ser::Serialize for RelocationBatchV2Launch {
13998 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13999 use serde::ser::SerializeStruct;
14001 match self {
14002 RelocationBatchV2Launch::AsyncJobId(x) => {
14003 let mut s = serializer.serialize_struct("RelocationBatchV2Launch", 2)?;
14005 s.serialize_field(".tag", "async_job_id")?;
14006 s.serialize_field("async_job_id", x)?;
14007 s.end()
14008 }
14009 RelocationBatchV2Launch::Complete(x) => {
14010 let mut s = serializer.serialize_struct("RelocationBatchV2Launch", 2)?;
14012 s.serialize_field(".tag", "complete")?;
14013 x.internal_serialize::<S>(&mut s)?;
14014 s.end()
14015 }
14016 }
14017 }
14018}
14019
14020impl From<crate::types::dbx_async::LaunchResultBase> for RelocationBatchV2Launch {
14022 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
14023 match parent {
14024 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => RelocationBatchV2Launch::AsyncJobId(x),
14025 }
14026 }
14027}
14028#[derive(Debug, Clone, PartialEq)]
14029#[non_exhaustive] pub struct RelocationBatchV2Result {
14031 pub entries: Vec<RelocationBatchResultEntry>,
14034}
14035
14036impl RelocationBatchV2Result {
14037 pub fn new(entries: Vec<RelocationBatchResultEntry>) -> Self {
14038 RelocationBatchV2Result {
14039 entries,
14040 }
14041 }
14042}
14043
14044const RELOCATION_BATCH_V2_RESULT_FIELDS: &[&str] = &["entries"];
14045impl RelocationBatchV2Result {
14046 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14047 map: V,
14048 ) -> Result<RelocationBatchV2Result, V::Error> {
14049 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14050 }
14051
14052 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14053 mut map: V,
14054 optional: bool,
14055 ) -> Result<Option<RelocationBatchV2Result>, V::Error> {
14056 let mut field_entries = None;
14057 let mut nothing = true;
14058 while let Some(key) = map.next_key::<&str>()? {
14059 nothing = false;
14060 match key {
14061 "entries" => {
14062 if field_entries.is_some() {
14063 return Err(::serde::de::Error::duplicate_field("entries"));
14064 }
14065 field_entries = Some(map.next_value()?);
14066 }
14067 _ => {
14068 map.next_value::<::serde_json::Value>()?;
14070 }
14071 }
14072 }
14073 if optional && nothing {
14074 return Ok(None);
14075 }
14076 let result = RelocationBatchV2Result {
14077 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
14078 };
14079 Ok(Some(result))
14080 }
14081
14082 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14083 &self,
14084 s: &mut S::SerializeStruct,
14085 ) -> Result<(), S::Error> {
14086 use serde::ser::SerializeStruct;
14087 s.serialize_field("entries", &self.entries)?;
14088 Ok(())
14089 }
14090}
14091
14092impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2Result {
14093 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14094 use serde::de::{MapAccess, Visitor};
14096 struct StructVisitor;
14097 impl<'de> Visitor<'de> for StructVisitor {
14098 type Value = RelocationBatchV2Result;
14099 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14100 f.write_str("a RelocationBatchV2Result struct")
14101 }
14102 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14103 RelocationBatchV2Result::internal_deserialize(map)
14104 }
14105 }
14106 deserializer.deserialize_struct("RelocationBatchV2Result", RELOCATION_BATCH_V2_RESULT_FIELDS, StructVisitor)
14107 }
14108}
14109
14110impl ::serde::ser::Serialize for RelocationBatchV2Result {
14111 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14112 use serde::ser::SerializeStruct;
14114 let mut s = serializer.serialize_struct("RelocationBatchV2Result", 1)?;
14115 self.internal_serialize::<S>(&mut s)?;
14116 s.end()
14117 }
14118}
14119
14120impl From<RelocationBatchV2Result> for FileOpsResult {
14122 fn from(_: RelocationBatchV2Result) -> Self {
14123 Self {}
14124 }
14125}
14126#[derive(Debug, Clone, PartialEq, Eq)]
14127#[non_exhaustive] pub enum RelocationError {
14129 FromLookup(LookupError),
14130 FromWrite(WriteError),
14131 To(WriteError),
14132 CantCopySharedFolder,
14134 CantNestSharedFolder,
14136 CantMoveFolderIntoItself,
14138 TooManyFiles,
14140 DuplicatedOrNestedPaths,
14143 CantTransferOwnership,
14146 InsufficientQuota,
14148 InternalError,
14151 CantMoveSharedFolder,
14153 CantMoveIntoVault(MoveIntoVaultError),
14155 CantMoveIntoFamily(MoveIntoFamilyError),
14158 Other,
14161}
14162
14163impl<'de> ::serde::de::Deserialize<'de> for RelocationError {
14164 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14165 use serde::de::{self, MapAccess, Visitor};
14167 struct EnumVisitor;
14168 impl<'de> Visitor<'de> for EnumVisitor {
14169 type Value = RelocationError;
14170 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14171 f.write_str("a RelocationError structure")
14172 }
14173 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
14174 let tag: &str = match map.next_key()? {
14175 Some(".tag") => map.next_value()?,
14176 _ => return Err(de::Error::missing_field(".tag"))
14177 };
14178 let value = match tag {
14179 "from_lookup" => {
14180 match map.next_key()? {
14181 Some("from_lookup") => RelocationError::FromLookup(map.next_value()?),
14182 None => return Err(de::Error::missing_field("from_lookup")),
14183 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14184 }
14185 }
14186 "from_write" => {
14187 match map.next_key()? {
14188 Some("from_write") => RelocationError::FromWrite(map.next_value()?),
14189 None => return Err(de::Error::missing_field("from_write")),
14190 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14191 }
14192 }
14193 "to" => {
14194 match map.next_key()? {
14195 Some("to") => RelocationError::To(map.next_value()?),
14196 None => return Err(de::Error::missing_field("to")),
14197 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14198 }
14199 }
14200 "cant_copy_shared_folder" => RelocationError::CantCopySharedFolder,
14201 "cant_nest_shared_folder" => RelocationError::CantNestSharedFolder,
14202 "cant_move_folder_into_itself" => RelocationError::CantMoveFolderIntoItself,
14203 "too_many_files" => RelocationError::TooManyFiles,
14204 "duplicated_or_nested_paths" => RelocationError::DuplicatedOrNestedPaths,
14205 "cant_transfer_ownership" => RelocationError::CantTransferOwnership,
14206 "insufficient_quota" => RelocationError::InsufficientQuota,
14207 "internal_error" => RelocationError::InternalError,
14208 "cant_move_shared_folder" => RelocationError::CantMoveSharedFolder,
14209 "cant_move_into_vault" => {
14210 match map.next_key()? {
14211 Some("cant_move_into_vault") => RelocationError::CantMoveIntoVault(map.next_value()?),
14212 None => return Err(de::Error::missing_field("cant_move_into_vault")),
14213 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14214 }
14215 }
14216 "cant_move_into_family" => {
14217 match map.next_key()? {
14218 Some("cant_move_into_family") => RelocationError::CantMoveIntoFamily(map.next_value()?),
14219 None => return Err(de::Error::missing_field("cant_move_into_family")),
14220 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14221 }
14222 }
14223 _ => RelocationError::Other,
14224 };
14225 crate::eat_json_fields(&mut map)?;
14226 Ok(value)
14227 }
14228 }
14229 const VARIANTS: &[&str] = &["from_lookup",
14230 "from_write",
14231 "to",
14232 "cant_copy_shared_folder",
14233 "cant_nest_shared_folder",
14234 "cant_move_folder_into_itself",
14235 "too_many_files",
14236 "duplicated_or_nested_paths",
14237 "cant_transfer_ownership",
14238 "insufficient_quota",
14239 "internal_error",
14240 "cant_move_shared_folder",
14241 "cant_move_into_vault",
14242 "cant_move_into_family",
14243 "other"];
14244 deserializer.deserialize_struct("RelocationError", VARIANTS, EnumVisitor)
14245 }
14246}
14247
14248impl ::serde::ser::Serialize for RelocationError {
14249 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14250 use serde::ser::SerializeStruct;
14252 match self {
14253 RelocationError::FromLookup(x) => {
14254 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14256 s.serialize_field(".tag", "from_lookup")?;
14257 s.serialize_field("from_lookup", x)?;
14258 s.end()
14259 }
14260 RelocationError::FromWrite(x) => {
14261 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14263 s.serialize_field(".tag", "from_write")?;
14264 s.serialize_field("from_write", x)?;
14265 s.end()
14266 }
14267 RelocationError::To(x) => {
14268 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14270 s.serialize_field(".tag", "to")?;
14271 s.serialize_field("to", x)?;
14272 s.end()
14273 }
14274 RelocationError::CantCopySharedFolder => {
14275 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14277 s.serialize_field(".tag", "cant_copy_shared_folder")?;
14278 s.end()
14279 }
14280 RelocationError::CantNestSharedFolder => {
14281 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14283 s.serialize_field(".tag", "cant_nest_shared_folder")?;
14284 s.end()
14285 }
14286 RelocationError::CantMoveFolderIntoItself => {
14287 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14289 s.serialize_field(".tag", "cant_move_folder_into_itself")?;
14290 s.end()
14291 }
14292 RelocationError::TooManyFiles => {
14293 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14295 s.serialize_field(".tag", "too_many_files")?;
14296 s.end()
14297 }
14298 RelocationError::DuplicatedOrNestedPaths => {
14299 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14301 s.serialize_field(".tag", "duplicated_or_nested_paths")?;
14302 s.end()
14303 }
14304 RelocationError::CantTransferOwnership => {
14305 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14307 s.serialize_field(".tag", "cant_transfer_ownership")?;
14308 s.end()
14309 }
14310 RelocationError::InsufficientQuota => {
14311 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14313 s.serialize_field(".tag", "insufficient_quota")?;
14314 s.end()
14315 }
14316 RelocationError::InternalError => {
14317 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14319 s.serialize_field(".tag", "internal_error")?;
14320 s.end()
14321 }
14322 RelocationError::CantMoveSharedFolder => {
14323 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14325 s.serialize_field(".tag", "cant_move_shared_folder")?;
14326 s.end()
14327 }
14328 RelocationError::CantMoveIntoVault(x) => {
14329 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14331 s.serialize_field(".tag", "cant_move_into_vault")?;
14332 s.serialize_field("cant_move_into_vault", x)?;
14333 s.end()
14334 }
14335 RelocationError::CantMoveIntoFamily(x) => {
14336 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14338 s.serialize_field(".tag", "cant_move_into_family")?;
14339 s.serialize_field("cant_move_into_family", x)?;
14340 s.end()
14341 }
14342 RelocationError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
14343 }
14344 }
14345}
14346
14347impl ::std::error::Error for RelocationError {
14348 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
14349 match self {
14350 RelocationError::FromLookup(inner) => Some(inner),
14351 RelocationError::FromWrite(inner) => Some(inner),
14352 RelocationError::To(inner) => Some(inner),
14353 RelocationError::CantMoveIntoVault(inner) => Some(inner),
14354 RelocationError::CantMoveIntoFamily(inner) => Some(inner),
14355 _ => None,
14356 }
14357 }
14358}
14359
14360impl ::std::fmt::Display for RelocationError {
14361 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14362 match self {
14363 RelocationError::FromLookup(inner) => write!(f, "RelocationError: {}", inner),
14364 RelocationError::FromWrite(inner) => write!(f, "RelocationError: {}", inner),
14365 RelocationError::To(inner) => write!(f, "RelocationError: {}", inner),
14366 RelocationError::CantCopySharedFolder => f.write_str("Shared folders can't be copied."),
14367 RelocationError::CantNestSharedFolder => f.write_str("Your move operation would result in nested shared folders. This is not allowed."),
14368 RelocationError::CantMoveFolderIntoItself => f.write_str("You cannot move a folder into itself."),
14369 RelocationError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
14370 RelocationError::InsufficientQuota => f.write_str("The current user does not have enough space to move or copy the files."),
14371 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."),
14372 RelocationError::CantMoveSharedFolder => f.write_str("Can't move the shared folder to the given destination."),
14373 RelocationError::CantMoveIntoVault(inner) => write!(f, "Some content cannot be moved into Vault under certain circumstances, see detailed error: {}", inner),
14374 RelocationError::CantMoveIntoFamily(inner) => write!(f, "Some content cannot be moved into the Family Room folder under certain circumstances, see detailed error: {}", inner),
14375 _ => write!(f, "{:?}", *self),
14376 }
14377 }
14378}
14379
14380#[derive(Debug, Clone, PartialEq, Eq)]
14381#[non_exhaustive] pub struct RelocationPath {
14383 pub from_path: WritePathOrId,
14385 pub to_path: WritePathOrId,
14387}
14388
14389impl RelocationPath {
14390 pub fn new(from_path: WritePathOrId, to_path: WritePathOrId) -> Self {
14391 RelocationPath {
14392 from_path,
14393 to_path,
14394 }
14395 }
14396}
14397
14398const RELOCATION_PATH_FIELDS: &[&str] = &["from_path",
14399 "to_path"];
14400impl RelocationPath {
14401 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14402 map: V,
14403 ) -> Result<RelocationPath, V::Error> {
14404 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14405 }
14406
14407 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14408 mut map: V,
14409 optional: bool,
14410 ) -> Result<Option<RelocationPath>, V::Error> {
14411 let mut field_from_path = None;
14412 let mut field_to_path = None;
14413 let mut nothing = true;
14414 while let Some(key) = map.next_key::<&str>()? {
14415 nothing = false;
14416 match key {
14417 "from_path" => {
14418 if field_from_path.is_some() {
14419 return Err(::serde::de::Error::duplicate_field("from_path"));
14420 }
14421 field_from_path = Some(map.next_value()?);
14422 }
14423 "to_path" => {
14424 if field_to_path.is_some() {
14425 return Err(::serde::de::Error::duplicate_field("to_path"));
14426 }
14427 field_to_path = Some(map.next_value()?);
14428 }
14429 _ => {
14430 map.next_value::<::serde_json::Value>()?;
14432 }
14433 }
14434 }
14435 if optional && nothing {
14436 return Ok(None);
14437 }
14438 let result = RelocationPath {
14439 from_path: field_from_path.ok_or_else(|| ::serde::de::Error::missing_field("from_path"))?,
14440 to_path: field_to_path.ok_or_else(|| ::serde::de::Error::missing_field("to_path"))?,
14441 };
14442 Ok(Some(result))
14443 }
14444
14445 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14446 &self,
14447 s: &mut S::SerializeStruct,
14448 ) -> Result<(), S::Error> {
14449 use serde::ser::SerializeStruct;
14450 s.serialize_field("from_path", &self.from_path)?;
14451 s.serialize_field("to_path", &self.to_path)?;
14452 Ok(())
14453 }
14454}
14455
14456impl<'de> ::serde::de::Deserialize<'de> for RelocationPath {
14457 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14458 use serde::de::{MapAccess, Visitor};
14460 struct StructVisitor;
14461 impl<'de> Visitor<'de> for StructVisitor {
14462 type Value = RelocationPath;
14463 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14464 f.write_str("a RelocationPath struct")
14465 }
14466 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14467 RelocationPath::internal_deserialize(map)
14468 }
14469 }
14470 deserializer.deserialize_struct("RelocationPath", RELOCATION_PATH_FIELDS, StructVisitor)
14471 }
14472}
14473
14474impl ::serde::ser::Serialize for RelocationPath {
14475 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14476 use serde::ser::SerializeStruct;
14478 let mut s = serializer.serialize_struct("RelocationPath", 2)?;
14479 self.internal_serialize::<S>(&mut s)?;
14480 s.end()
14481 }
14482}
14483
14484#[derive(Debug, Clone, PartialEq)]
14485#[non_exhaustive] pub struct RelocationResult {
14487 pub metadata: Metadata,
14489}
14490
14491impl RelocationResult {
14492 pub fn new(metadata: Metadata) -> Self {
14493 RelocationResult {
14494 metadata,
14495 }
14496 }
14497}
14498
14499const RELOCATION_RESULT_FIELDS: &[&str] = &["metadata"];
14500impl RelocationResult {
14501 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14502 map: V,
14503 ) -> Result<RelocationResult, V::Error> {
14504 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14505 }
14506
14507 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14508 mut map: V,
14509 optional: bool,
14510 ) -> Result<Option<RelocationResult>, V::Error> {
14511 let mut field_metadata = None;
14512 let mut nothing = true;
14513 while let Some(key) = map.next_key::<&str>()? {
14514 nothing = false;
14515 match key {
14516 "metadata" => {
14517 if field_metadata.is_some() {
14518 return Err(::serde::de::Error::duplicate_field("metadata"));
14519 }
14520 field_metadata = Some(map.next_value()?);
14521 }
14522 _ => {
14523 map.next_value::<::serde_json::Value>()?;
14525 }
14526 }
14527 }
14528 if optional && nothing {
14529 return Ok(None);
14530 }
14531 let result = RelocationResult {
14532 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
14533 };
14534 Ok(Some(result))
14535 }
14536
14537 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14538 &self,
14539 s: &mut S::SerializeStruct,
14540 ) -> Result<(), S::Error> {
14541 use serde::ser::SerializeStruct;
14542 s.serialize_field("metadata", &self.metadata)?;
14543 Ok(())
14544 }
14545}
14546
14547impl<'de> ::serde::de::Deserialize<'de> for RelocationResult {
14548 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14549 use serde::de::{MapAccess, Visitor};
14551 struct StructVisitor;
14552 impl<'de> Visitor<'de> for StructVisitor {
14553 type Value = RelocationResult;
14554 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14555 f.write_str("a RelocationResult struct")
14556 }
14557 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14558 RelocationResult::internal_deserialize(map)
14559 }
14560 }
14561 deserializer.deserialize_struct("RelocationResult", RELOCATION_RESULT_FIELDS, StructVisitor)
14562 }
14563}
14564
14565impl ::serde::ser::Serialize for RelocationResult {
14566 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14567 use serde::ser::SerializeStruct;
14569 let mut s = serializer.serialize_struct("RelocationResult", 1)?;
14570 self.internal_serialize::<S>(&mut s)?;
14571 s.end()
14572 }
14573}
14574
14575impl From<RelocationResult> for FileOpsResult {
14577 fn from(_: RelocationResult) -> Self {
14578 Self {}
14579 }
14580}
14581#[derive(Debug, Clone, PartialEq, Eq)]
14582#[non_exhaustive] pub struct RemoveTagArg {
14584 pub path: Path,
14586 pub tag_text: TagText,
14588}
14589
14590impl RemoveTagArg {
14591 pub fn new(path: Path, tag_text: TagText) -> Self {
14592 RemoveTagArg {
14593 path,
14594 tag_text,
14595 }
14596 }
14597}
14598
14599const REMOVE_TAG_ARG_FIELDS: &[&str] = &["path",
14600 "tag_text"];
14601impl RemoveTagArg {
14602 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14603 map: V,
14604 ) -> Result<RemoveTagArg, V::Error> {
14605 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14606 }
14607
14608 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14609 mut map: V,
14610 optional: bool,
14611 ) -> Result<Option<RemoveTagArg>, V::Error> {
14612 let mut field_path = None;
14613 let mut field_tag_text = None;
14614 let mut nothing = true;
14615 while let Some(key) = map.next_key::<&str>()? {
14616 nothing = false;
14617 match key {
14618 "path" => {
14619 if field_path.is_some() {
14620 return Err(::serde::de::Error::duplicate_field("path"));
14621 }
14622 field_path = Some(map.next_value()?);
14623 }
14624 "tag_text" => {
14625 if field_tag_text.is_some() {
14626 return Err(::serde::de::Error::duplicate_field("tag_text"));
14627 }
14628 field_tag_text = Some(map.next_value()?);
14629 }
14630 _ => {
14631 map.next_value::<::serde_json::Value>()?;
14633 }
14634 }
14635 }
14636 if optional && nothing {
14637 return Ok(None);
14638 }
14639 let result = RemoveTagArg {
14640 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
14641 tag_text: field_tag_text.ok_or_else(|| ::serde::de::Error::missing_field("tag_text"))?,
14642 };
14643 Ok(Some(result))
14644 }
14645
14646 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14647 &self,
14648 s: &mut S::SerializeStruct,
14649 ) -> Result<(), S::Error> {
14650 use serde::ser::SerializeStruct;
14651 s.serialize_field("path", &self.path)?;
14652 s.serialize_field("tag_text", &self.tag_text)?;
14653 Ok(())
14654 }
14655}
14656
14657impl<'de> ::serde::de::Deserialize<'de> for RemoveTagArg {
14658 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14659 use serde::de::{MapAccess, Visitor};
14661 struct StructVisitor;
14662 impl<'de> Visitor<'de> for StructVisitor {
14663 type Value = RemoveTagArg;
14664 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14665 f.write_str("a RemoveTagArg struct")
14666 }
14667 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14668 RemoveTagArg::internal_deserialize(map)
14669 }
14670 }
14671 deserializer.deserialize_struct("RemoveTagArg", REMOVE_TAG_ARG_FIELDS, StructVisitor)
14672 }
14673}
14674
14675impl ::serde::ser::Serialize for RemoveTagArg {
14676 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14677 use serde::ser::SerializeStruct;
14679 let mut s = serializer.serialize_struct("RemoveTagArg", 2)?;
14680 self.internal_serialize::<S>(&mut s)?;
14681 s.end()
14682 }
14683}
14684
14685#[derive(Debug, Clone, PartialEq, Eq)]
14686#[non_exhaustive] pub enum RemoveTagError {
14688 Path(LookupError),
14689 TagNotPresent,
14691 Other,
14694}
14695
14696impl<'de> ::serde::de::Deserialize<'de> for RemoveTagError {
14697 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14698 use serde::de::{self, MapAccess, Visitor};
14700 struct EnumVisitor;
14701 impl<'de> Visitor<'de> for EnumVisitor {
14702 type Value = RemoveTagError;
14703 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14704 f.write_str("a RemoveTagError structure")
14705 }
14706 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
14707 let tag: &str = match map.next_key()? {
14708 Some(".tag") => map.next_value()?,
14709 _ => return Err(de::Error::missing_field(".tag"))
14710 };
14711 let value = match tag {
14712 "path" => {
14713 match map.next_key()? {
14714 Some("path") => RemoveTagError::Path(map.next_value()?),
14715 None => return Err(de::Error::missing_field("path")),
14716 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14717 }
14718 }
14719 "tag_not_present" => RemoveTagError::TagNotPresent,
14720 _ => RemoveTagError::Other,
14721 };
14722 crate::eat_json_fields(&mut map)?;
14723 Ok(value)
14724 }
14725 }
14726 const VARIANTS: &[&str] = &["path",
14727 "other",
14728 "tag_not_present"];
14729 deserializer.deserialize_struct("RemoveTagError", VARIANTS, EnumVisitor)
14730 }
14731}
14732
14733impl ::serde::ser::Serialize for RemoveTagError {
14734 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14735 use serde::ser::SerializeStruct;
14737 match self {
14738 RemoveTagError::Path(x) => {
14739 let mut s = serializer.serialize_struct("RemoveTagError", 2)?;
14741 s.serialize_field(".tag", "path")?;
14742 s.serialize_field("path", x)?;
14743 s.end()
14744 }
14745 RemoveTagError::TagNotPresent => {
14746 let mut s = serializer.serialize_struct("RemoveTagError", 1)?;
14748 s.serialize_field(".tag", "tag_not_present")?;
14749 s.end()
14750 }
14751 RemoveTagError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
14752 }
14753 }
14754}
14755
14756impl ::std::error::Error for RemoveTagError {
14757 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
14758 match self {
14759 RemoveTagError::Path(inner) => Some(inner),
14760 _ => None,
14761 }
14762 }
14763}
14764
14765impl ::std::fmt::Display for RemoveTagError {
14766 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14767 match self {
14768 RemoveTagError::Path(inner) => write!(f, "RemoveTagError: {}", inner),
14769 RemoveTagError::TagNotPresent => f.write_str("That tag doesn't exist at this path."),
14770 _ => write!(f, "{:?}", *self),
14771 }
14772 }
14773}
14774
14775impl From<BaseTagError> for RemoveTagError {
14777 fn from(parent: BaseTagError) -> Self {
14778 match parent {
14779 BaseTagError::Path(x) => RemoveTagError::Path(x),
14780 BaseTagError::Other => RemoveTagError::Other,
14781 }
14782 }
14783}
14784#[derive(Debug, Clone, PartialEq, Eq)]
14785#[non_exhaustive] pub struct RestoreArg {
14787 pub path: WritePath,
14789 pub rev: Rev,
14791}
14792
14793impl RestoreArg {
14794 pub fn new(path: WritePath, rev: Rev) -> Self {
14795 RestoreArg {
14796 path,
14797 rev,
14798 }
14799 }
14800}
14801
14802const RESTORE_ARG_FIELDS: &[&str] = &["path",
14803 "rev"];
14804impl RestoreArg {
14805 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14806 map: V,
14807 ) -> Result<RestoreArg, V::Error> {
14808 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14809 }
14810
14811 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14812 mut map: V,
14813 optional: bool,
14814 ) -> Result<Option<RestoreArg>, V::Error> {
14815 let mut field_path = None;
14816 let mut field_rev = None;
14817 let mut nothing = true;
14818 while let Some(key) = map.next_key::<&str>()? {
14819 nothing = false;
14820 match key {
14821 "path" => {
14822 if field_path.is_some() {
14823 return Err(::serde::de::Error::duplicate_field("path"));
14824 }
14825 field_path = Some(map.next_value()?);
14826 }
14827 "rev" => {
14828 if field_rev.is_some() {
14829 return Err(::serde::de::Error::duplicate_field("rev"));
14830 }
14831 field_rev = Some(map.next_value()?);
14832 }
14833 _ => {
14834 map.next_value::<::serde_json::Value>()?;
14836 }
14837 }
14838 }
14839 if optional && nothing {
14840 return Ok(None);
14841 }
14842 let result = RestoreArg {
14843 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
14844 rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
14845 };
14846 Ok(Some(result))
14847 }
14848
14849 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14850 &self,
14851 s: &mut S::SerializeStruct,
14852 ) -> Result<(), S::Error> {
14853 use serde::ser::SerializeStruct;
14854 s.serialize_field("path", &self.path)?;
14855 s.serialize_field("rev", &self.rev)?;
14856 Ok(())
14857 }
14858}
14859
14860impl<'de> ::serde::de::Deserialize<'de> for RestoreArg {
14861 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14862 use serde::de::{MapAccess, Visitor};
14864 struct StructVisitor;
14865 impl<'de> Visitor<'de> for StructVisitor {
14866 type Value = RestoreArg;
14867 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14868 f.write_str("a RestoreArg struct")
14869 }
14870 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14871 RestoreArg::internal_deserialize(map)
14872 }
14873 }
14874 deserializer.deserialize_struct("RestoreArg", RESTORE_ARG_FIELDS, StructVisitor)
14875 }
14876}
14877
14878impl ::serde::ser::Serialize for RestoreArg {
14879 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14880 use serde::ser::SerializeStruct;
14882 let mut s = serializer.serialize_struct("RestoreArg", 2)?;
14883 self.internal_serialize::<S>(&mut s)?;
14884 s.end()
14885 }
14886}
14887
14888#[derive(Debug, Clone, PartialEq, Eq)]
14889#[non_exhaustive] pub enum RestoreError {
14891 PathLookup(LookupError),
14893 PathWrite(WriteError),
14895 InvalidRevision,
14897 InProgress,
14899 Other,
14902}
14903
14904impl<'de> ::serde::de::Deserialize<'de> for RestoreError {
14905 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14906 use serde::de::{self, MapAccess, Visitor};
14908 struct EnumVisitor;
14909 impl<'de> Visitor<'de> for EnumVisitor {
14910 type Value = RestoreError;
14911 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14912 f.write_str("a RestoreError structure")
14913 }
14914 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
14915 let tag: &str = match map.next_key()? {
14916 Some(".tag") => map.next_value()?,
14917 _ => return Err(de::Error::missing_field(".tag"))
14918 };
14919 let value = match tag {
14920 "path_lookup" => {
14921 match map.next_key()? {
14922 Some("path_lookup") => RestoreError::PathLookup(map.next_value()?),
14923 None => return Err(de::Error::missing_field("path_lookup")),
14924 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14925 }
14926 }
14927 "path_write" => {
14928 match map.next_key()? {
14929 Some("path_write") => RestoreError::PathWrite(map.next_value()?),
14930 None => return Err(de::Error::missing_field("path_write")),
14931 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14932 }
14933 }
14934 "invalid_revision" => RestoreError::InvalidRevision,
14935 "in_progress" => RestoreError::InProgress,
14936 _ => RestoreError::Other,
14937 };
14938 crate::eat_json_fields(&mut map)?;
14939 Ok(value)
14940 }
14941 }
14942 const VARIANTS: &[&str] = &["path_lookup",
14943 "path_write",
14944 "invalid_revision",
14945 "in_progress",
14946 "other"];
14947 deserializer.deserialize_struct("RestoreError", VARIANTS, EnumVisitor)
14948 }
14949}
14950
14951impl ::serde::ser::Serialize for RestoreError {
14952 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14953 use serde::ser::SerializeStruct;
14955 match self {
14956 RestoreError::PathLookup(x) => {
14957 let mut s = serializer.serialize_struct("RestoreError", 2)?;
14959 s.serialize_field(".tag", "path_lookup")?;
14960 s.serialize_field("path_lookup", x)?;
14961 s.end()
14962 }
14963 RestoreError::PathWrite(x) => {
14964 let mut s = serializer.serialize_struct("RestoreError", 2)?;
14966 s.serialize_field(".tag", "path_write")?;
14967 s.serialize_field("path_write", x)?;
14968 s.end()
14969 }
14970 RestoreError::InvalidRevision => {
14971 let mut s = serializer.serialize_struct("RestoreError", 1)?;
14973 s.serialize_field(".tag", "invalid_revision")?;
14974 s.end()
14975 }
14976 RestoreError::InProgress => {
14977 let mut s = serializer.serialize_struct("RestoreError", 1)?;
14979 s.serialize_field(".tag", "in_progress")?;
14980 s.end()
14981 }
14982 RestoreError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
14983 }
14984 }
14985}
14986
14987impl ::std::error::Error for RestoreError {
14988 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
14989 match self {
14990 RestoreError::PathLookup(inner) => Some(inner),
14991 RestoreError::PathWrite(inner) => Some(inner),
14992 _ => None,
14993 }
14994 }
14995}
14996
14997impl ::std::fmt::Display for RestoreError {
14998 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14999 match self {
15000 RestoreError::PathLookup(inner) => write!(f, "An error occurs when downloading metadata for the file: {}", inner),
15001 RestoreError::PathWrite(inner) => write!(f, "An error occurs when trying to restore the file to that path: {}", inner),
15002 RestoreError::InvalidRevision => f.write_str("The revision is invalid. It may not exist or may point to a deleted file."),
15003 RestoreError::InProgress => f.write_str("The restore is currently executing, but has not yet completed."),
15004 _ => write!(f, "{:?}", *self),
15005 }
15006 }
15007}
15008
15009#[derive(Debug, Clone, PartialEq, Eq)]
15010#[non_exhaustive] pub struct SaveCopyReferenceArg {
15012 pub copy_reference: String,
15014 pub path: Path,
15016}
15017
15018impl SaveCopyReferenceArg {
15019 pub fn new(copy_reference: String, path: Path) -> Self {
15020 SaveCopyReferenceArg {
15021 copy_reference,
15022 path,
15023 }
15024 }
15025}
15026
15027const SAVE_COPY_REFERENCE_ARG_FIELDS: &[&str] = &["copy_reference",
15028 "path"];
15029impl SaveCopyReferenceArg {
15030 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15031 map: V,
15032 ) -> Result<SaveCopyReferenceArg, V::Error> {
15033 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15034 }
15035
15036 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15037 mut map: V,
15038 optional: bool,
15039 ) -> Result<Option<SaveCopyReferenceArg>, V::Error> {
15040 let mut field_copy_reference = None;
15041 let mut field_path = None;
15042 let mut nothing = true;
15043 while let Some(key) = map.next_key::<&str>()? {
15044 nothing = false;
15045 match key {
15046 "copy_reference" => {
15047 if field_copy_reference.is_some() {
15048 return Err(::serde::de::Error::duplicate_field("copy_reference"));
15049 }
15050 field_copy_reference = Some(map.next_value()?);
15051 }
15052 "path" => {
15053 if field_path.is_some() {
15054 return Err(::serde::de::Error::duplicate_field("path"));
15055 }
15056 field_path = Some(map.next_value()?);
15057 }
15058 _ => {
15059 map.next_value::<::serde_json::Value>()?;
15061 }
15062 }
15063 }
15064 if optional && nothing {
15065 return Ok(None);
15066 }
15067 let result = SaveCopyReferenceArg {
15068 copy_reference: field_copy_reference.ok_or_else(|| ::serde::de::Error::missing_field("copy_reference"))?,
15069 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
15070 };
15071 Ok(Some(result))
15072 }
15073
15074 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15075 &self,
15076 s: &mut S::SerializeStruct,
15077 ) -> Result<(), S::Error> {
15078 use serde::ser::SerializeStruct;
15079 s.serialize_field("copy_reference", &self.copy_reference)?;
15080 s.serialize_field("path", &self.path)?;
15081 Ok(())
15082 }
15083}
15084
15085impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceArg {
15086 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15087 use serde::de::{MapAccess, Visitor};
15089 struct StructVisitor;
15090 impl<'de> Visitor<'de> for StructVisitor {
15091 type Value = SaveCopyReferenceArg;
15092 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15093 f.write_str("a SaveCopyReferenceArg struct")
15094 }
15095 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15096 SaveCopyReferenceArg::internal_deserialize(map)
15097 }
15098 }
15099 deserializer.deserialize_struct("SaveCopyReferenceArg", SAVE_COPY_REFERENCE_ARG_FIELDS, StructVisitor)
15100 }
15101}
15102
15103impl ::serde::ser::Serialize for SaveCopyReferenceArg {
15104 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15105 use serde::ser::SerializeStruct;
15107 let mut s = serializer.serialize_struct("SaveCopyReferenceArg", 2)?;
15108 self.internal_serialize::<S>(&mut s)?;
15109 s.end()
15110 }
15111}
15112
15113#[derive(Debug, Clone, PartialEq, Eq)]
15114#[non_exhaustive] pub enum SaveCopyReferenceError {
15116 Path(WriteError),
15117 InvalidCopyReference,
15119 NoPermission,
15122 NotFound,
15124 TooManyFiles,
15126 Other,
15129}
15130
15131impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceError {
15132 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15133 use serde::de::{self, MapAccess, Visitor};
15135 struct EnumVisitor;
15136 impl<'de> Visitor<'de> for EnumVisitor {
15137 type Value = SaveCopyReferenceError;
15138 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15139 f.write_str("a SaveCopyReferenceError structure")
15140 }
15141 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15142 let tag: &str = match map.next_key()? {
15143 Some(".tag") => map.next_value()?,
15144 _ => return Err(de::Error::missing_field(".tag"))
15145 };
15146 let value = match tag {
15147 "path" => {
15148 match map.next_key()? {
15149 Some("path") => SaveCopyReferenceError::Path(map.next_value()?),
15150 None => return Err(de::Error::missing_field("path")),
15151 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15152 }
15153 }
15154 "invalid_copy_reference" => SaveCopyReferenceError::InvalidCopyReference,
15155 "no_permission" => SaveCopyReferenceError::NoPermission,
15156 "not_found" => SaveCopyReferenceError::NotFound,
15157 "too_many_files" => SaveCopyReferenceError::TooManyFiles,
15158 _ => SaveCopyReferenceError::Other,
15159 };
15160 crate::eat_json_fields(&mut map)?;
15161 Ok(value)
15162 }
15163 }
15164 const VARIANTS: &[&str] = &["path",
15165 "invalid_copy_reference",
15166 "no_permission",
15167 "not_found",
15168 "too_many_files",
15169 "other"];
15170 deserializer.deserialize_struct("SaveCopyReferenceError", VARIANTS, EnumVisitor)
15171 }
15172}
15173
15174impl ::serde::ser::Serialize for SaveCopyReferenceError {
15175 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15176 use serde::ser::SerializeStruct;
15178 match self {
15179 SaveCopyReferenceError::Path(x) => {
15180 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 2)?;
15182 s.serialize_field(".tag", "path")?;
15183 s.serialize_field("path", x)?;
15184 s.end()
15185 }
15186 SaveCopyReferenceError::InvalidCopyReference => {
15187 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15189 s.serialize_field(".tag", "invalid_copy_reference")?;
15190 s.end()
15191 }
15192 SaveCopyReferenceError::NoPermission => {
15193 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15195 s.serialize_field(".tag", "no_permission")?;
15196 s.end()
15197 }
15198 SaveCopyReferenceError::NotFound => {
15199 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15201 s.serialize_field(".tag", "not_found")?;
15202 s.end()
15203 }
15204 SaveCopyReferenceError::TooManyFiles => {
15205 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15207 s.serialize_field(".tag", "too_many_files")?;
15208 s.end()
15209 }
15210 SaveCopyReferenceError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
15211 }
15212 }
15213}
15214
15215impl ::std::error::Error for SaveCopyReferenceError {
15216 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
15217 match self {
15218 SaveCopyReferenceError::Path(inner) => Some(inner),
15219 _ => None,
15220 }
15221 }
15222}
15223
15224impl ::std::fmt::Display for SaveCopyReferenceError {
15225 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15226 match self {
15227 SaveCopyReferenceError::Path(inner) => write!(f, "SaveCopyReferenceError: {}", inner),
15228 SaveCopyReferenceError::InvalidCopyReference => f.write_str("The copy reference is invalid."),
15229 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."),
15230 SaveCopyReferenceError::NotFound => f.write_str("The file referenced by the copy reference cannot be found."),
15231 SaveCopyReferenceError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
15232 _ => write!(f, "{:?}", *self),
15233 }
15234 }
15235}
15236
15237#[derive(Debug, Clone, PartialEq)]
15238#[non_exhaustive] pub struct SaveCopyReferenceResult {
15240 pub metadata: Metadata,
15242}
15243
15244impl SaveCopyReferenceResult {
15245 pub fn new(metadata: Metadata) -> Self {
15246 SaveCopyReferenceResult {
15247 metadata,
15248 }
15249 }
15250}
15251
15252const SAVE_COPY_REFERENCE_RESULT_FIELDS: &[&str] = &["metadata"];
15253impl SaveCopyReferenceResult {
15254 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15255 map: V,
15256 ) -> Result<SaveCopyReferenceResult, V::Error> {
15257 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15258 }
15259
15260 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15261 mut map: V,
15262 optional: bool,
15263 ) -> Result<Option<SaveCopyReferenceResult>, V::Error> {
15264 let mut field_metadata = None;
15265 let mut nothing = true;
15266 while let Some(key) = map.next_key::<&str>()? {
15267 nothing = false;
15268 match key {
15269 "metadata" => {
15270 if field_metadata.is_some() {
15271 return Err(::serde::de::Error::duplicate_field("metadata"));
15272 }
15273 field_metadata = Some(map.next_value()?);
15274 }
15275 _ => {
15276 map.next_value::<::serde_json::Value>()?;
15278 }
15279 }
15280 }
15281 if optional && nothing {
15282 return Ok(None);
15283 }
15284 let result = SaveCopyReferenceResult {
15285 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
15286 };
15287 Ok(Some(result))
15288 }
15289
15290 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15291 &self,
15292 s: &mut S::SerializeStruct,
15293 ) -> Result<(), S::Error> {
15294 use serde::ser::SerializeStruct;
15295 s.serialize_field("metadata", &self.metadata)?;
15296 Ok(())
15297 }
15298}
15299
15300impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceResult {
15301 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15302 use serde::de::{MapAccess, Visitor};
15304 struct StructVisitor;
15305 impl<'de> Visitor<'de> for StructVisitor {
15306 type Value = SaveCopyReferenceResult;
15307 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15308 f.write_str("a SaveCopyReferenceResult struct")
15309 }
15310 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15311 SaveCopyReferenceResult::internal_deserialize(map)
15312 }
15313 }
15314 deserializer.deserialize_struct("SaveCopyReferenceResult", SAVE_COPY_REFERENCE_RESULT_FIELDS, StructVisitor)
15315 }
15316}
15317
15318impl ::serde::ser::Serialize for SaveCopyReferenceResult {
15319 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15320 use serde::ser::SerializeStruct;
15322 let mut s = serializer.serialize_struct("SaveCopyReferenceResult", 1)?;
15323 self.internal_serialize::<S>(&mut s)?;
15324 s.end()
15325 }
15326}
15327
15328#[derive(Debug, Clone, PartialEq, Eq)]
15329#[non_exhaustive] pub struct SaveUrlArg {
15331 pub path: Path,
15333 pub url: String,
15335}
15336
15337impl SaveUrlArg {
15338 pub fn new(path: Path, url: String) -> Self {
15339 SaveUrlArg {
15340 path,
15341 url,
15342 }
15343 }
15344}
15345
15346const SAVE_URL_ARG_FIELDS: &[&str] = &["path",
15347 "url"];
15348impl SaveUrlArg {
15349 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15350 map: V,
15351 ) -> Result<SaveUrlArg, V::Error> {
15352 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15353 }
15354
15355 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15356 mut map: V,
15357 optional: bool,
15358 ) -> Result<Option<SaveUrlArg>, V::Error> {
15359 let mut field_path = None;
15360 let mut field_url = None;
15361 let mut nothing = true;
15362 while let Some(key) = map.next_key::<&str>()? {
15363 nothing = false;
15364 match key {
15365 "path" => {
15366 if field_path.is_some() {
15367 return Err(::serde::de::Error::duplicate_field("path"));
15368 }
15369 field_path = Some(map.next_value()?);
15370 }
15371 "url" => {
15372 if field_url.is_some() {
15373 return Err(::serde::de::Error::duplicate_field("url"));
15374 }
15375 field_url = Some(map.next_value()?);
15376 }
15377 _ => {
15378 map.next_value::<::serde_json::Value>()?;
15380 }
15381 }
15382 }
15383 if optional && nothing {
15384 return Ok(None);
15385 }
15386 let result = SaveUrlArg {
15387 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
15388 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
15389 };
15390 Ok(Some(result))
15391 }
15392
15393 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15394 &self,
15395 s: &mut S::SerializeStruct,
15396 ) -> Result<(), S::Error> {
15397 use serde::ser::SerializeStruct;
15398 s.serialize_field("path", &self.path)?;
15399 s.serialize_field("url", &self.url)?;
15400 Ok(())
15401 }
15402}
15403
15404impl<'de> ::serde::de::Deserialize<'de> for SaveUrlArg {
15405 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15406 use serde::de::{MapAccess, Visitor};
15408 struct StructVisitor;
15409 impl<'de> Visitor<'de> for StructVisitor {
15410 type Value = SaveUrlArg;
15411 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15412 f.write_str("a SaveUrlArg struct")
15413 }
15414 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15415 SaveUrlArg::internal_deserialize(map)
15416 }
15417 }
15418 deserializer.deserialize_struct("SaveUrlArg", SAVE_URL_ARG_FIELDS, StructVisitor)
15419 }
15420}
15421
15422impl ::serde::ser::Serialize for SaveUrlArg {
15423 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15424 use serde::ser::SerializeStruct;
15426 let mut s = serializer.serialize_struct("SaveUrlArg", 2)?;
15427 self.internal_serialize::<S>(&mut s)?;
15428 s.end()
15429 }
15430}
15431
15432#[derive(Debug, Clone, PartialEq, Eq)]
15433#[non_exhaustive] pub enum SaveUrlError {
15435 Path(WriteError),
15436 DownloadFailed,
15439 InvalidUrl,
15441 NotFound,
15443 Other,
15446}
15447
15448impl<'de> ::serde::de::Deserialize<'de> for SaveUrlError {
15449 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15450 use serde::de::{self, MapAccess, Visitor};
15452 struct EnumVisitor;
15453 impl<'de> Visitor<'de> for EnumVisitor {
15454 type Value = SaveUrlError;
15455 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15456 f.write_str("a SaveUrlError structure")
15457 }
15458 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15459 let tag: &str = match map.next_key()? {
15460 Some(".tag") => map.next_value()?,
15461 _ => return Err(de::Error::missing_field(".tag"))
15462 };
15463 let value = match tag {
15464 "path" => {
15465 match map.next_key()? {
15466 Some("path") => SaveUrlError::Path(map.next_value()?),
15467 None => return Err(de::Error::missing_field("path")),
15468 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15469 }
15470 }
15471 "download_failed" => SaveUrlError::DownloadFailed,
15472 "invalid_url" => SaveUrlError::InvalidUrl,
15473 "not_found" => SaveUrlError::NotFound,
15474 _ => SaveUrlError::Other,
15475 };
15476 crate::eat_json_fields(&mut map)?;
15477 Ok(value)
15478 }
15479 }
15480 const VARIANTS: &[&str] = &["path",
15481 "download_failed",
15482 "invalid_url",
15483 "not_found",
15484 "other"];
15485 deserializer.deserialize_struct("SaveUrlError", VARIANTS, EnumVisitor)
15486 }
15487}
15488
15489impl ::serde::ser::Serialize for SaveUrlError {
15490 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15491 use serde::ser::SerializeStruct;
15493 match self {
15494 SaveUrlError::Path(x) => {
15495 let mut s = serializer.serialize_struct("SaveUrlError", 2)?;
15497 s.serialize_field(".tag", "path")?;
15498 s.serialize_field("path", x)?;
15499 s.end()
15500 }
15501 SaveUrlError::DownloadFailed => {
15502 let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
15504 s.serialize_field(".tag", "download_failed")?;
15505 s.end()
15506 }
15507 SaveUrlError::InvalidUrl => {
15508 let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
15510 s.serialize_field(".tag", "invalid_url")?;
15511 s.end()
15512 }
15513 SaveUrlError::NotFound => {
15514 let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
15516 s.serialize_field(".tag", "not_found")?;
15517 s.end()
15518 }
15519 SaveUrlError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
15520 }
15521 }
15522}
15523
15524impl ::std::error::Error for SaveUrlError {
15525 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
15526 match self {
15527 SaveUrlError::Path(inner) => Some(inner),
15528 _ => None,
15529 }
15530 }
15531}
15532
15533impl ::std::fmt::Display for SaveUrlError {
15534 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15535 match self {
15536 SaveUrlError::Path(inner) => write!(f, "SaveUrlError: {}", inner),
15537 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."),
15538 SaveUrlError::InvalidUrl => f.write_str("The given URL is invalid."),
15539 SaveUrlError::NotFound => f.write_str("The file where the URL is saved to no longer exists."),
15540 _ => write!(f, "{:?}", *self),
15541 }
15542 }
15543}
15544
15545#[derive(Debug, Clone, PartialEq)]
15546pub enum SaveUrlJobStatus {
15547 InProgress,
15549 Complete(FileMetadata),
15551 Failed(SaveUrlError),
15552}
15553
15554impl<'de> ::serde::de::Deserialize<'de> for SaveUrlJobStatus {
15555 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15556 use serde::de::{self, MapAccess, Visitor};
15558 struct EnumVisitor;
15559 impl<'de> Visitor<'de> for EnumVisitor {
15560 type Value = SaveUrlJobStatus;
15561 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15562 f.write_str("a SaveUrlJobStatus structure")
15563 }
15564 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15565 let tag: &str = match map.next_key()? {
15566 Some(".tag") => map.next_value()?,
15567 _ => return Err(de::Error::missing_field(".tag"))
15568 };
15569 let value = match tag {
15570 "in_progress" => SaveUrlJobStatus::InProgress,
15571 "complete" => SaveUrlJobStatus::Complete(FileMetadata::internal_deserialize(&mut map)?),
15572 "failed" => {
15573 match map.next_key()? {
15574 Some("failed") => SaveUrlJobStatus::Failed(map.next_value()?),
15575 None => return Err(de::Error::missing_field("failed")),
15576 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15577 }
15578 }
15579 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
15580 };
15581 crate::eat_json_fields(&mut map)?;
15582 Ok(value)
15583 }
15584 }
15585 const VARIANTS: &[&str] = &["in_progress",
15586 "complete",
15587 "failed"];
15588 deserializer.deserialize_struct("SaveUrlJobStatus", VARIANTS, EnumVisitor)
15589 }
15590}
15591
15592impl ::serde::ser::Serialize for SaveUrlJobStatus {
15593 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15594 use serde::ser::SerializeStruct;
15596 match self {
15597 SaveUrlJobStatus::InProgress => {
15598 let mut s = serializer.serialize_struct("SaveUrlJobStatus", 1)?;
15600 s.serialize_field(".tag", "in_progress")?;
15601 s.end()
15602 }
15603 SaveUrlJobStatus::Complete(x) => {
15604 let mut s = serializer.serialize_struct("SaveUrlJobStatus", 21)?;
15606 s.serialize_field(".tag", "complete")?;
15607 x.internal_serialize::<S>(&mut s)?;
15608 s.end()
15609 }
15610 SaveUrlJobStatus::Failed(x) => {
15611 let mut s = serializer.serialize_struct("SaveUrlJobStatus", 2)?;
15613 s.serialize_field(".tag", "failed")?;
15614 s.serialize_field("failed", x)?;
15615 s.end()
15616 }
15617 }
15618 }
15619}
15620
15621impl From<crate::types::dbx_async::PollResultBase> for SaveUrlJobStatus {
15623 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
15624 match parent {
15625 crate::types::dbx_async::PollResultBase::InProgress => SaveUrlJobStatus::InProgress,
15626 }
15627 }
15628}
15629#[derive(Debug, Clone, PartialEq)]
15630pub enum SaveUrlResult {
15631 AsyncJobId(crate::types::dbx_async::AsyncJobId),
15634 Complete(FileMetadata),
15636}
15637
15638impl<'de> ::serde::de::Deserialize<'de> for SaveUrlResult {
15639 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15640 use serde::de::{self, MapAccess, Visitor};
15642 struct EnumVisitor;
15643 impl<'de> Visitor<'de> for EnumVisitor {
15644 type Value = SaveUrlResult;
15645 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15646 f.write_str("a SaveUrlResult structure")
15647 }
15648 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15649 let tag: &str = match map.next_key()? {
15650 Some(".tag") => map.next_value()?,
15651 _ => return Err(de::Error::missing_field(".tag"))
15652 };
15653 let value = match tag {
15654 "async_job_id" => {
15655 match map.next_key()? {
15656 Some("async_job_id") => SaveUrlResult::AsyncJobId(map.next_value()?),
15657 None => return Err(de::Error::missing_field("async_job_id")),
15658 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15659 }
15660 }
15661 "complete" => SaveUrlResult::Complete(FileMetadata::internal_deserialize(&mut map)?),
15662 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
15663 };
15664 crate::eat_json_fields(&mut map)?;
15665 Ok(value)
15666 }
15667 }
15668 const VARIANTS: &[&str] = &["async_job_id",
15669 "complete"];
15670 deserializer.deserialize_struct("SaveUrlResult", VARIANTS, EnumVisitor)
15671 }
15672}
15673
15674impl ::serde::ser::Serialize for SaveUrlResult {
15675 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15676 use serde::ser::SerializeStruct;
15678 match self {
15679 SaveUrlResult::AsyncJobId(x) => {
15680 let mut s = serializer.serialize_struct("SaveUrlResult", 2)?;
15682 s.serialize_field(".tag", "async_job_id")?;
15683 s.serialize_field("async_job_id", x)?;
15684 s.end()
15685 }
15686 SaveUrlResult::Complete(x) => {
15687 let mut s = serializer.serialize_struct("SaveUrlResult", 21)?;
15689 s.serialize_field(".tag", "complete")?;
15690 x.internal_serialize::<S>(&mut s)?;
15691 s.end()
15692 }
15693 }
15694 }
15695}
15696
15697impl From<crate::types::dbx_async::LaunchResultBase> for SaveUrlResult {
15699 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
15700 match parent {
15701 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => SaveUrlResult::AsyncJobId(x),
15702 }
15703 }
15704}
15705#[derive(Debug, Clone, PartialEq, Eq)]
15706#[non_exhaustive] pub struct SearchArg {
15708 pub path: PathROrId,
15710 pub query: String,
15714 pub start: u64,
15716 pub max_results: u64,
15718 pub mode: SearchMode,
15721}
15722
15723impl SearchArg {
15724 pub fn new(path: PathROrId, query: String) -> Self {
15725 SearchArg {
15726 path,
15727 query,
15728 start: 0,
15729 max_results: 100,
15730 mode: SearchMode::Filename,
15731 }
15732 }
15733
15734 pub fn with_start(mut self, value: u64) -> Self {
15735 self.start = value;
15736 self
15737 }
15738
15739 pub fn with_max_results(mut self, value: u64) -> Self {
15740 self.max_results = value;
15741 self
15742 }
15743
15744 pub fn with_mode(mut self, value: SearchMode) -> Self {
15745 self.mode = value;
15746 self
15747 }
15748}
15749
15750const SEARCH_ARG_FIELDS: &[&str] = &["path",
15751 "query",
15752 "start",
15753 "max_results",
15754 "mode"];
15755impl SearchArg {
15756 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15757 map: V,
15758 ) -> Result<SearchArg, V::Error> {
15759 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15760 }
15761
15762 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15763 mut map: V,
15764 optional: bool,
15765 ) -> Result<Option<SearchArg>, V::Error> {
15766 let mut field_path = None;
15767 let mut field_query = None;
15768 let mut field_start = None;
15769 let mut field_max_results = None;
15770 let mut field_mode = None;
15771 let mut nothing = true;
15772 while let Some(key) = map.next_key::<&str>()? {
15773 nothing = false;
15774 match key {
15775 "path" => {
15776 if field_path.is_some() {
15777 return Err(::serde::de::Error::duplicate_field("path"));
15778 }
15779 field_path = Some(map.next_value()?);
15780 }
15781 "query" => {
15782 if field_query.is_some() {
15783 return Err(::serde::de::Error::duplicate_field("query"));
15784 }
15785 field_query = Some(map.next_value()?);
15786 }
15787 "start" => {
15788 if field_start.is_some() {
15789 return Err(::serde::de::Error::duplicate_field("start"));
15790 }
15791 field_start = Some(map.next_value()?);
15792 }
15793 "max_results" => {
15794 if field_max_results.is_some() {
15795 return Err(::serde::de::Error::duplicate_field("max_results"));
15796 }
15797 field_max_results = Some(map.next_value()?);
15798 }
15799 "mode" => {
15800 if field_mode.is_some() {
15801 return Err(::serde::de::Error::duplicate_field("mode"));
15802 }
15803 field_mode = Some(map.next_value()?);
15804 }
15805 _ => {
15806 map.next_value::<::serde_json::Value>()?;
15808 }
15809 }
15810 }
15811 if optional && nothing {
15812 return Ok(None);
15813 }
15814 let result = SearchArg {
15815 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
15816 query: field_query.ok_or_else(|| ::serde::de::Error::missing_field("query"))?,
15817 start: field_start.unwrap_or(0),
15818 max_results: field_max_results.unwrap_or(100),
15819 mode: field_mode.unwrap_or(SearchMode::Filename),
15820 };
15821 Ok(Some(result))
15822 }
15823
15824 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15825 &self,
15826 s: &mut S::SerializeStruct,
15827 ) -> Result<(), S::Error> {
15828 use serde::ser::SerializeStruct;
15829 s.serialize_field("path", &self.path)?;
15830 s.serialize_field("query", &self.query)?;
15831 if self.start != 0 {
15832 s.serialize_field("start", &self.start)?;
15833 }
15834 if self.max_results != 100 {
15835 s.serialize_field("max_results", &self.max_results)?;
15836 }
15837 if self.mode != SearchMode::Filename {
15838 s.serialize_field("mode", &self.mode)?;
15839 }
15840 Ok(())
15841 }
15842}
15843
15844impl<'de> ::serde::de::Deserialize<'de> for SearchArg {
15845 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15846 use serde::de::{MapAccess, Visitor};
15848 struct StructVisitor;
15849 impl<'de> Visitor<'de> for StructVisitor {
15850 type Value = SearchArg;
15851 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15852 f.write_str("a SearchArg struct")
15853 }
15854 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15855 SearchArg::internal_deserialize(map)
15856 }
15857 }
15858 deserializer.deserialize_struct("SearchArg", SEARCH_ARG_FIELDS, StructVisitor)
15859 }
15860}
15861
15862impl ::serde::ser::Serialize for SearchArg {
15863 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15864 use serde::ser::SerializeStruct;
15866 let mut s = serializer.serialize_struct("SearchArg", 5)?;
15867 self.internal_serialize::<S>(&mut s)?;
15868 s.end()
15869 }
15870}
15871
15872#[derive(Debug, Clone, PartialEq, Eq)]
15873#[non_exhaustive] pub enum SearchError {
15875 Path(LookupError),
15876 InvalidArgument(Option<String>),
15877 InternalError,
15879 Other,
15882}
15883
15884impl<'de> ::serde::de::Deserialize<'de> for SearchError {
15885 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15886 use serde::de::{self, MapAccess, Visitor};
15888 struct EnumVisitor;
15889 impl<'de> Visitor<'de> for EnumVisitor {
15890 type Value = SearchError;
15891 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15892 f.write_str("a SearchError structure")
15893 }
15894 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15895 let tag: &str = match map.next_key()? {
15896 Some(".tag") => map.next_value()?,
15897 _ => return Err(de::Error::missing_field(".tag"))
15898 };
15899 let value = match tag {
15900 "path" => {
15901 match map.next_key()? {
15902 Some("path") => SearchError::Path(map.next_value()?),
15903 None => return Err(de::Error::missing_field("path")),
15904 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15905 }
15906 }
15907 "invalid_argument" => {
15908 match map.next_key()? {
15909 Some("invalid_argument") => SearchError::InvalidArgument(map.next_value()?),
15910 None => SearchError::InvalidArgument(None),
15911 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15912 }
15913 }
15914 "internal_error" => SearchError::InternalError,
15915 _ => SearchError::Other,
15916 };
15917 crate::eat_json_fields(&mut map)?;
15918 Ok(value)
15919 }
15920 }
15921 const VARIANTS: &[&str] = &["path",
15922 "invalid_argument",
15923 "internal_error",
15924 "other"];
15925 deserializer.deserialize_struct("SearchError", VARIANTS, EnumVisitor)
15926 }
15927}
15928
15929impl ::serde::ser::Serialize for SearchError {
15930 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15931 use serde::ser::SerializeStruct;
15933 match self {
15934 SearchError::Path(x) => {
15935 let mut s = serializer.serialize_struct("SearchError", 2)?;
15937 s.serialize_field(".tag", "path")?;
15938 s.serialize_field("path", x)?;
15939 s.end()
15940 }
15941 SearchError::InvalidArgument(x) => {
15942 let n = if x.is_some() { 2 } else { 1 };
15944 let mut s = serializer.serialize_struct("SearchError", n)?;
15945 s.serialize_field(".tag", "invalid_argument")?;
15946 if let Some(x) = x {
15947 s.serialize_field("invalid_argument", &x)?;
15948 }
15949 s.end()
15950 }
15951 SearchError::InternalError => {
15952 let mut s = serializer.serialize_struct("SearchError", 1)?;
15954 s.serialize_field(".tag", "internal_error")?;
15955 s.end()
15956 }
15957 SearchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
15958 }
15959 }
15960}
15961
15962impl ::std::error::Error for SearchError {
15963 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
15964 match self {
15965 SearchError::Path(inner) => Some(inner),
15966 _ => None,
15967 }
15968 }
15969}
15970
15971impl ::std::fmt::Display for SearchError {
15972 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15973 match self {
15974 SearchError::Path(inner) => write!(f, "SearchError: {}", inner),
15975 SearchError::InvalidArgument(None) => f.write_str("invalid_argument"),
15976 SearchError::InvalidArgument(Some(inner)) => write!(f, "invalid_argument: {:?}", inner),
15977 SearchError::InternalError => f.write_str("Something went wrong, please try again."),
15978 _ => write!(f, "{:?}", *self),
15979 }
15980 }
15981}
15982
15983#[derive(Debug, Clone, PartialEq)]
15984#[non_exhaustive] pub struct SearchMatch {
15986 pub match_type: SearchMatchType,
15988 pub metadata: Metadata,
15990}
15991
15992impl SearchMatch {
15993 pub fn new(match_type: SearchMatchType, metadata: Metadata) -> Self {
15994 SearchMatch {
15995 match_type,
15996 metadata,
15997 }
15998 }
15999}
16000
16001const SEARCH_MATCH_FIELDS: &[&str] = &["match_type",
16002 "metadata"];
16003impl SearchMatch {
16004 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16005 map: V,
16006 ) -> Result<SearchMatch, V::Error> {
16007 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16008 }
16009
16010 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16011 mut map: V,
16012 optional: bool,
16013 ) -> Result<Option<SearchMatch>, V::Error> {
16014 let mut field_match_type = None;
16015 let mut field_metadata = None;
16016 let mut nothing = true;
16017 while let Some(key) = map.next_key::<&str>()? {
16018 nothing = false;
16019 match key {
16020 "match_type" => {
16021 if field_match_type.is_some() {
16022 return Err(::serde::de::Error::duplicate_field("match_type"));
16023 }
16024 field_match_type = Some(map.next_value()?);
16025 }
16026 "metadata" => {
16027 if field_metadata.is_some() {
16028 return Err(::serde::de::Error::duplicate_field("metadata"));
16029 }
16030 field_metadata = Some(map.next_value()?);
16031 }
16032 _ => {
16033 map.next_value::<::serde_json::Value>()?;
16035 }
16036 }
16037 }
16038 if optional && nothing {
16039 return Ok(None);
16040 }
16041 let result = SearchMatch {
16042 match_type: field_match_type.ok_or_else(|| ::serde::de::Error::missing_field("match_type"))?,
16043 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
16044 };
16045 Ok(Some(result))
16046 }
16047
16048 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16049 &self,
16050 s: &mut S::SerializeStruct,
16051 ) -> Result<(), S::Error> {
16052 use serde::ser::SerializeStruct;
16053 s.serialize_field("match_type", &self.match_type)?;
16054 s.serialize_field("metadata", &self.metadata)?;
16055 Ok(())
16056 }
16057}
16058
16059impl<'de> ::serde::de::Deserialize<'de> for SearchMatch {
16060 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16061 use serde::de::{MapAccess, Visitor};
16063 struct StructVisitor;
16064 impl<'de> Visitor<'de> for StructVisitor {
16065 type Value = SearchMatch;
16066 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16067 f.write_str("a SearchMatch struct")
16068 }
16069 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16070 SearchMatch::internal_deserialize(map)
16071 }
16072 }
16073 deserializer.deserialize_struct("SearchMatch", SEARCH_MATCH_FIELDS, StructVisitor)
16074 }
16075}
16076
16077impl ::serde::ser::Serialize for SearchMatch {
16078 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16079 use serde::ser::SerializeStruct;
16081 let mut s = serializer.serialize_struct("SearchMatch", 2)?;
16082 self.internal_serialize::<S>(&mut s)?;
16083 s.end()
16084 }
16085}
16086
16087#[derive(Debug, Clone, PartialEq, Eq, Default)]
16088#[non_exhaustive] pub struct SearchMatchFieldOptions {
16090 pub include_highlights: bool,
16092}
16093
16094impl SearchMatchFieldOptions {
16095 pub fn with_include_highlights(mut self, value: bool) -> Self {
16096 self.include_highlights = value;
16097 self
16098 }
16099}
16100
16101const SEARCH_MATCH_FIELD_OPTIONS_FIELDS: &[&str] = &["include_highlights"];
16102impl SearchMatchFieldOptions {
16103 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16105 mut map: V,
16106 ) -> Result<SearchMatchFieldOptions, V::Error> {
16107 let mut field_include_highlights = None;
16108 while let Some(key) = map.next_key::<&str>()? {
16109 match key {
16110 "include_highlights" => {
16111 if field_include_highlights.is_some() {
16112 return Err(::serde::de::Error::duplicate_field("include_highlights"));
16113 }
16114 field_include_highlights = Some(map.next_value()?);
16115 }
16116 _ => {
16117 map.next_value::<::serde_json::Value>()?;
16119 }
16120 }
16121 }
16122 let result = SearchMatchFieldOptions {
16123 include_highlights: field_include_highlights.unwrap_or(false),
16124 };
16125 Ok(result)
16126 }
16127
16128 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16129 &self,
16130 s: &mut S::SerializeStruct,
16131 ) -> Result<(), S::Error> {
16132 use serde::ser::SerializeStruct;
16133 if self.include_highlights {
16134 s.serialize_field("include_highlights", &self.include_highlights)?;
16135 }
16136 Ok(())
16137 }
16138}
16139
16140impl<'de> ::serde::de::Deserialize<'de> for SearchMatchFieldOptions {
16141 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16142 use serde::de::{MapAccess, Visitor};
16144 struct StructVisitor;
16145 impl<'de> Visitor<'de> for StructVisitor {
16146 type Value = SearchMatchFieldOptions;
16147 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16148 f.write_str("a SearchMatchFieldOptions struct")
16149 }
16150 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16151 SearchMatchFieldOptions::internal_deserialize(map)
16152 }
16153 }
16154 deserializer.deserialize_struct("SearchMatchFieldOptions", SEARCH_MATCH_FIELD_OPTIONS_FIELDS, StructVisitor)
16155 }
16156}
16157
16158impl ::serde::ser::Serialize for SearchMatchFieldOptions {
16159 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16160 use serde::ser::SerializeStruct;
16162 let mut s = serializer.serialize_struct("SearchMatchFieldOptions", 1)?;
16163 self.internal_serialize::<S>(&mut s)?;
16164 s.end()
16165 }
16166}
16167
16168#[derive(Debug, Clone, PartialEq, Eq)]
16170pub enum SearchMatchType {
16171 Filename,
16173 Content,
16175 Both,
16177}
16178
16179impl<'de> ::serde::de::Deserialize<'de> for SearchMatchType {
16180 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16181 use serde::de::{self, MapAccess, Visitor};
16183 struct EnumVisitor;
16184 impl<'de> Visitor<'de> for EnumVisitor {
16185 type Value = SearchMatchType;
16186 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16187 f.write_str("a SearchMatchType structure")
16188 }
16189 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16190 let tag: &str = match map.next_key()? {
16191 Some(".tag") => map.next_value()?,
16192 _ => return Err(de::Error::missing_field(".tag"))
16193 };
16194 let value = match tag {
16195 "filename" => SearchMatchType::Filename,
16196 "content" => SearchMatchType::Content,
16197 "both" => SearchMatchType::Both,
16198 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
16199 };
16200 crate::eat_json_fields(&mut map)?;
16201 Ok(value)
16202 }
16203 }
16204 const VARIANTS: &[&str] = &["filename",
16205 "content",
16206 "both"];
16207 deserializer.deserialize_struct("SearchMatchType", VARIANTS, EnumVisitor)
16208 }
16209}
16210
16211impl ::serde::ser::Serialize for SearchMatchType {
16212 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16213 use serde::ser::SerializeStruct;
16215 match self {
16216 SearchMatchType::Filename => {
16217 let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
16219 s.serialize_field(".tag", "filename")?;
16220 s.end()
16221 }
16222 SearchMatchType::Content => {
16223 let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
16225 s.serialize_field(".tag", "content")?;
16226 s.end()
16227 }
16228 SearchMatchType::Both => {
16229 let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
16231 s.serialize_field(".tag", "both")?;
16232 s.end()
16233 }
16234 }
16235 }
16236}
16237
16238#[derive(Debug, Clone, PartialEq, Eq)]
16240#[non_exhaustive] pub enum SearchMatchTypeV2 {
16242 Filename,
16244 FileContent,
16246 FilenameAndContent,
16248 ImageContent,
16250 Metadata,
16252 Other,
16255}
16256
16257impl<'de> ::serde::de::Deserialize<'de> for SearchMatchTypeV2 {
16258 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16259 use serde::de::{self, MapAccess, Visitor};
16261 struct EnumVisitor;
16262 impl<'de> Visitor<'de> for EnumVisitor {
16263 type Value = SearchMatchTypeV2;
16264 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16265 f.write_str("a SearchMatchTypeV2 structure")
16266 }
16267 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16268 let tag: &str = match map.next_key()? {
16269 Some(".tag") => map.next_value()?,
16270 _ => return Err(de::Error::missing_field(".tag"))
16271 };
16272 let value = match tag {
16273 "filename" => SearchMatchTypeV2::Filename,
16274 "file_content" => SearchMatchTypeV2::FileContent,
16275 "filename_and_content" => SearchMatchTypeV2::FilenameAndContent,
16276 "image_content" => SearchMatchTypeV2::ImageContent,
16277 "metadata" => SearchMatchTypeV2::Metadata,
16278 _ => SearchMatchTypeV2::Other,
16279 };
16280 crate::eat_json_fields(&mut map)?;
16281 Ok(value)
16282 }
16283 }
16284 const VARIANTS: &[&str] = &["filename",
16285 "file_content",
16286 "filename_and_content",
16287 "image_content",
16288 "metadata",
16289 "other"];
16290 deserializer.deserialize_struct("SearchMatchTypeV2", VARIANTS, EnumVisitor)
16291 }
16292}
16293
16294impl ::serde::ser::Serialize for SearchMatchTypeV2 {
16295 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16296 use serde::ser::SerializeStruct;
16298 match self {
16299 SearchMatchTypeV2::Filename => {
16300 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16302 s.serialize_field(".tag", "filename")?;
16303 s.end()
16304 }
16305 SearchMatchTypeV2::FileContent => {
16306 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16308 s.serialize_field(".tag", "file_content")?;
16309 s.end()
16310 }
16311 SearchMatchTypeV2::FilenameAndContent => {
16312 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16314 s.serialize_field(".tag", "filename_and_content")?;
16315 s.end()
16316 }
16317 SearchMatchTypeV2::ImageContent => {
16318 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16320 s.serialize_field(".tag", "image_content")?;
16321 s.end()
16322 }
16323 SearchMatchTypeV2::Metadata => {
16324 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16326 s.serialize_field(".tag", "metadata")?;
16327 s.end()
16328 }
16329 SearchMatchTypeV2::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
16330 }
16331 }
16332}
16333
16334#[derive(Debug, Clone, PartialEq)]
16335#[non_exhaustive] pub struct SearchMatchV2 {
16337 pub metadata: MetadataV2,
16339 pub match_type: Option<SearchMatchTypeV2>,
16341 pub highlight_spans: Option<Vec<HighlightSpan>>,
16343}
16344
16345impl SearchMatchV2 {
16346 pub fn new(metadata: MetadataV2) -> Self {
16347 SearchMatchV2 {
16348 metadata,
16349 match_type: None,
16350 highlight_spans: None,
16351 }
16352 }
16353
16354 pub fn with_match_type(mut self, value: SearchMatchTypeV2) -> Self {
16355 self.match_type = Some(value);
16356 self
16357 }
16358
16359 pub fn with_highlight_spans(mut self, value: Vec<HighlightSpan>) -> Self {
16360 self.highlight_spans = Some(value);
16361 self
16362 }
16363}
16364
16365const SEARCH_MATCH_V2_FIELDS: &[&str] = &["metadata",
16366 "match_type",
16367 "highlight_spans"];
16368impl SearchMatchV2 {
16369 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16370 map: V,
16371 ) -> Result<SearchMatchV2, V::Error> {
16372 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16373 }
16374
16375 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16376 mut map: V,
16377 optional: bool,
16378 ) -> Result<Option<SearchMatchV2>, V::Error> {
16379 let mut field_metadata = None;
16380 let mut field_match_type = None;
16381 let mut field_highlight_spans = None;
16382 let mut nothing = true;
16383 while let Some(key) = map.next_key::<&str>()? {
16384 nothing = false;
16385 match key {
16386 "metadata" => {
16387 if field_metadata.is_some() {
16388 return Err(::serde::de::Error::duplicate_field("metadata"));
16389 }
16390 field_metadata = Some(map.next_value()?);
16391 }
16392 "match_type" => {
16393 if field_match_type.is_some() {
16394 return Err(::serde::de::Error::duplicate_field("match_type"));
16395 }
16396 field_match_type = Some(map.next_value()?);
16397 }
16398 "highlight_spans" => {
16399 if field_highlight_spans.is_some() {
16400 return Err(::serde::de::Error::duplicate_field("highlight_spans"));
16401 }
16402 field_highlight_spans = Some(map.next_value()?);
16403 }
16404 _ => {
16405 map.next_value::<::serde_json::Value>()?;
16407 }
16408 }
16409 }
16410 if optional && nothing {
16411 return Ok(None);
16412 }
16413 let result = SearchMatchV2 {
16414 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
16415 match_type: field_match_type.and_then(Option::flatten),
16416 highlight_spans: field_highlight_spans.and_then(Option::flatten),
16417 };
16418 Ok(Some(result))
16419 }
16420
16421 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16422 &self,
16423 s: &mut S::SerializeStruct,
16424 ) -> Result<(), S::Error> {
16425 use serde::ser::SerializeStruct;
16426 s.serialize_field("metadata", &self.metadata)?;
16427 if let Some(val) = &self.match_type {
16428 s.serialize_field("match_type", val)?;
16429 }
16430 if let Some(val) = &self.highlight_spans {
16431 s.serialize_field("highlight_spans", val)?;
16432 }
16433 Ok(())
16434 }
16435}
16436
16437impl<'de> ::serde::de::Deserialize<'de> for SearchMatchV2 {
16438 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16439 use serde::de::{MapAccess, Visitor};
16441 struct StructVisitor;
16442 impl<'de> Visitor<'de> for StructVisitor {
16443 type Value = SearchMatchV2;
16444 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16445 f.write_str("a SearchMatchV2 struct")
16446 }
16447 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16448 SearchMatchV2::internal_deserialize(map)
16449 }
16450 }
16451 deserializer.deserialize_struct("SearchMatchV2", SEARCH_MATCH_V2_FIELDS, StructVisitor)
16452 }
16453}
16454
16455impl ::serde::ser::Serialize for SearchMatchV2 {
16456 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16457 use serde::ser::SerializeStruct;
16459 let mut s = serializer.serialize_struct("SearchMatchV2", 3)?;
16460 self.internal_serialize::<S>(&mut s)?;
16461 s.end()
16462 }
16463}
16464
16465#[derive(Debug, Clone, PartialEq, Eq)]
16466pub enum SearchMode {
16467 Filename,
16469 FilenameAndContent,
16471 DeletedFilename,
16473}
16474
16475impl<'de> ::serde::de::Deserialize<'de> for SearchMode {
16476 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16477 use serde::de::{self, MapAccess, Visitor};
16479 struct EnumVisitor;
16480 impl<'de> Visitor<'de> for EnumVisitor {
16481 type Value = SearchMode;
16482 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16483 f.write_str("a SearchMode structure")
16484 }
16485 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16486 let tag: &str = match map.next_key()? {
16487 Some(".tag") => map.next_value()?,
16488 _ => return Err(de::Error::missing_field(".tag"))
16489 };
16490 let value = match tag {
16491 "filename" => SearchMode::Filename,
16492 "filename_and_content" => SearchMode::FilenameAndContent,
16493 "deleted_filename" => SearchMode::DeletedFilename,
16494 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
16495 };
16496 crate::eat_json_fields(&mut map)?;
16497 Ok(value)
16498 }
16499 }
16500 const VARIANTS: &[&str] = &["filename",
16501 "filename_and_content",
16502 "deleted_filename"];
16503 deserializer.deserialize_struct("SearchMode", VARIANTS, EnumVisitor)
16504 }
16505}
16506
16507impl ::serde::ser::Serialize for SearchMode {
16508 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16509 use serde::ser::SerializeStruct;
16511 match self {
16512 SearchMode::Filename => {
16513 let mut s = serializer.serialize_struct("SearchMode", 1)?;
16515 s.serialize_field(".tag", "filename")?;
16516 s.end()
16517 }
16518 SearchMode::FilenameAndContent => {
16519 let mut s = serializer.serialize_struct("SearchMode", 1)?;
16521 s.serialize_field(".tag", "filename_and_content")?;
16522 s.end()
16523 }
16524 SearchMode::DeletedFilename => {
16525 let mut s = serializer.serialize_struct("SearchMode", 1)?;
16527 s.serialize_field(".tag", "deleted_filename")?;
16528 s.end()
16529 }
16530 }
16531 }
16532}
16533
16534#[derive(Debug, Clone, PartialEq, Eq)]
16535#[non_exhaustive] pub struct SearchOptions {
16537 pub path: Option<PathROrId>,
16540 pub max_results: u64,
16542 pub order_by: Option<SearchOrderBy>,
16545 pub file_status: FileStatus,
16547 pub filename_only: bool,
16549 pub file_extensions: Option<Vec<String>>,
16551 pub file_categories: Option<Vec<FileCategory>>,
16554 pub account_id: Option<crate::types::users_common::AccountId>,
16556}
16557
16558impl Default for SearchOptions {
16559 fn default() -> Self {
16560 SearchOptions {
16561 path: None,
16562 max_results: 100,
16563 order_by: None,
16564 file_status: FileStatus::Active,
16565 filename_only: false,
16566 file_extensions: None,
16567 file_categories: None,
16568 account_id: None,
16569 }
16570 }
16571}
16572
16573impl SearchOptions {
16574 pub fn with_path(mut self, value: PathROrId) -> Self {
16575 self.path = Some(value);
16576 self
16577 }
16578
16579 pub fn with_max_results(mut self, value: u64) -> Self {
16580 self.max_results = value;
16581 self
16582 }
16583
16584 pub fn with_order_by(mut self, value: SearchOrderBy) -> Self {
16585 self.order_by = Some(value);
16586 self
16587 }
16588
16589 pub fn with_file_status(mut self, value: FileStatus) -> Self {
16590 self.file_status = value;
16591 self
16592 }
16593
16594 pub fn with_filename_only(mut self, value: bool) -> Self {
16595 self.filename_only = value;
16596 self
16597 }
16598
16599 pub fn with_file_extensions(mut self, value: Vec<String>) -> Self {
16600 self.file_extensions = Some(value);
16601 self
16602 }
16603
16604 pub fn with_file_categories(mut self, value: Vec<FileCategory>) -> Self {
16605 self.file_categories = Some(value);
16606 self
16607 }
16608
16609 pub fn with_account_id(mut self, value: crate::types::users_common::AccountId) -> Self {
16610 self.account_id = Some(value);
16611 self
16612 }
16613}
16614
16615const SEARCH_OPTIONS_FIELDS: &[&str] = &["path",
16616 "max_results",
16617 "order_by",
16618 "file_status",
16619 "filename_only",
16620 "file_extensions",
16621 "file_categories",
16622 "account_id"];
16623impl SearchOptions {
16624 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16626 mut map: V,
16627 ) -> Result<SearchOptions, V::Error> {
16628 let mut field_path = None;
16629 let mut field_max_results = None;
16630 let mut field_order_by = None;
16631 let mut field_file_status = None;
16632 let mut field_filename_only = None;
16633 let mut field_file_extensions = None;
16634 let mut field_file_categories = None;
16635 let mut field_account_id = None;
16636 while let Some(key) = map.next_key::<&str>()? {
16637 match key {
16638 "path" => {
16639 if field_path.is_some() {
16640 return Err(::serde::de::Error::duplicate_field("path"));
16641 }
16642 field_path = Some(map.next_value()?);
16643 }
16644 "max_results" => {
16645 if field_max_results.is_some() {
16646 return Err(::serde::de::Error::duplicate_field("max_results"));
16647 }
16648 field_max_results = Some(map.next_value()?);
16649 }
16650 "order_by" => {
16651 if field_order_by.is_some() {
16652 return Err(::serde::de::Error::duplicate_field("order_by"));
16653 }
16654 field_order_by = Some(map.next_value()?);
16655 }
16656 "file_status" => {
16657 if field_file_status.is_some() {
16658 return Err(::serde::de::Error::duplicate_field("file_status"));
16659 }
16660 field_file_status = Some(map.next_value()?);
16661 }
16662 "filename_only" => {
16663 if field_filename_only.is_some() {
16664 return Err(::serde::de::Error::duplicate_field("filename_only"));
16665 }
16666 field_filename_only = Some(map.next_value()?);
16667 }
16668 "file_extensions" => {
16669 if field_file_extensions.is_some() {
16670 return Err(::serde::de::Error::duplicate_field("file_extensions"));
16671 }
16672 field_file_extensions = Some(map.next_value()?);
16673 }
16674 "file_categories" => {
16675 if field_file_categories.is_some() {
16676 return Err(::serde::de::Error::duplicate_field("file_categories"));
16677 }
16678 field_file_categories = Some(map.next_value()?);
16679 }
16680 "account_id" => {
16681 if field_account_id.is_some() {
16682 return Err(::serde::de::Error::duplicate_field("account_id"));
16683 }
16684 field_account_id = Some(map.next_value()?);
16685 }
16686 _ => {
16687 map.next_value::<::serde_json::Value>()?;
16689 }
16690 }
16691 }
16692 let result = SearchOptions {
16693 path: field_path.and_then(Option::flatten),
16694 max_results: field_max_results.unwrap_or(100),
16695 order_by: field_order_by.and_then(Option::flatten),
16696 file_status: field_file_status.unwrap_or(FileStatus::Active),
16697 filename_only: field_filename_only.unwrap_or(false),
16698 file_extensions: field_file_extensions.and_then(Option::flatten),
16699 file_categories: field_file_categories.and_then(Option::flatten),
16700 account_id: field_account_id.and_then(Option::flatten),
16701 };
16702 Ok(result)
16703 }
16704
16705 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16706 &self,
16707 s: &mut S::SerializeStruct,
16708 ) -> Result<(), S::Error> {
16709 use serde::ser::SerializeStruct;
16710 if let Some(val) = &self.path {
16711 s.serialize_field("path", val)?;
16712 }
16713 if self.max_results != 100 {
16714 s.serialize_field("max_results", &self.max_results)?;
16715 }
16716 if let Some(val) = &self.order_by {
16717 s.serialize_field("order_by", val)?;
16718 }
16719 if self.file_status != FileStatus::Active {
16720 s.serialize_field("file_status", &self.file_status)?;
16721 }
16722 if self.filename_only {
16723 s.serialize_field("filename_only", &self.filename_only)?;
16724 }
16725 if let Some(val) = &self.file_extensions {
16726 s.serialize_field("file_extensions", val)?;
16727 }
16728 if let Some(val) = &self.file_categories {
16729 s.serialize_field("file_categories", val)?;
16730 }
16731 if let Some(val) = &self.account_id {
16732 s.serialize_field("account_id", val)?;
16733 }
16734 Ok(())
16735 }
16736}
16737
16738impl<'de> ::serde::de::Deserialize<'de> for SearchOptions {
16739 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16740 use serde::de::{MapAccess, Visitor};
16742 struct StructVisitor;
16743 impl<'de> Visitor<'de> for StructVisitor {
16744 type Value = SearchOptions;
16745 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16746 f.write_str("a SearchOptions struct")
16747 }
16748 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16749 SearchOptions::internal_deserialize(map)
16750 }
16751 }
16752 deserializer.deserialize_struct("SearchOptions", SEARCH_OPTIONS_FIELDS, StructVisitor)
16753 }
16754}
16755
16756impl ::serde::ser::Serialize for SearchOptions {
16757 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16758 use serde::ser::SerializeStruct;
16760 let mut s = serializer.serialize_struct("SearchOptions", 8)?;
16761 self.internal_serialize::<S>(&mut s)?;
16762 s.end()
16763 }
16764}
16765
16766#[derive(Debug, Clone, PartialEq, Eq)]
16767#[non_exhaustive] pub enum SearchOrderBy {
16769 Relevance,
16770 LastModifiedTime,
16771 Other,
16774}
16775
16776impl<'de> ::serde::de::Deserialize<'de> for SearchOrderBy {
16777 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16778 use serde::de::{self, MapAccess, Visitor};
16780 struct EnumVisitor;
16781 impl<'de> Visitor<'de> for EnumVisitor {
16782 type Value = SearchOrderBy;
16783 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16784 f.write_str("a SearchOrderBy structure")
16785 }
16786 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16787 let tag: &str = match map.next_key()? {
16788 Some(".tag") => map.next_value()?,
16789 _ => return Err(de::Error::missing_field(".tag"))
16790 };
16791 let value = match tag {
16792 "relevance" => SearchOrderBy::Relevance,
16793 "last_modified_time" => SearchOrderBy::LastModifiedTime,
16794 _ => SearchOrderBy::Other,
16795 };
16796 crate::eat_json_fields(&mut map)?;
16797 Ok(value)
16798 }
16799 }
16800 const VARIANTS: &[&str] = &["relevance",
16801 "last_modified_time",
16802 "other"];
16803 deserializer.deserialize_struct("SearchOrderBy", VARIANTS, EnumVisitor)
16804 }
16805}
16806
16807impl ::serde::ser::Serialize for SearchOrderBy {
16808 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16809 use serde::ser::SerializeStruct;
16811 match self {
16812 SearchOrderBy::Relevance => {
16813 let mut s = serializer.serialize_struct("SearchOrderBy", 1)?;
16815 s.serialize_field(".tag", "relevance")?;
16816 s.end()
16817 }
16818 SearchOrderBy::LastModifiedTime => {
16819 let mut s = serializer.serialize_struct("SearchOrderBy", 1)?;
16821 s.serialize_field(".tag", "last_modified_time")?;
16822 s.end()
16823 }
16824 SearchOrderBy::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
16825 }
16826 }
16827}
16828
16829#[derive(Debug, Clone, PartialEq)]
16830#[non_exhaustive] pub struct SearchResult {
16832 pub matches: Vec<SearchMatch>,
16834 pub more: bool,
16837 pub start: u64,
16840}
16841
16842impl SearchResult {
16843 pub fn new(matches: Vec<SearchMatch>, more: bool, start: u64) -> Self {
16844 SearchResult {
16845 matches,
16846 more,
16847 start,
16848 }
16849 }
16850}
16851
16852const SEARCH_RESULT_FIELDS: &[&str] = &["matches",
16853 "more",
16854 "start"];
16855impl SearchResult {
16856 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16857 map: V,
16858 ) -> Result<SearchResult, V::Error> {
16859 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16860 }
16861
16862 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16863 mut map: V,
16864 optional: bool,
16865 ) -> Result<Option<SearchResult>, V::Error> {
16866 let mut field_matches = None;
16867 let mut field_more = None;
16868 let mut field_start = None;
16869 let mut nothing = true;
16870 while let Some(key) = map.next_key::<&str>()? {
16871 nothing = false;
16872 match key {
16873 "matches" => {
16874 if field_matches.is_some() {
16875 return Err(::serde::de::Error::duplicate_field("matches"));
16876 }
16877 field_matches = Some(map.next_value()?);
16878 }
16879 "more" => {
16880 if field_more.is_some() {
16881 return Err(::serde::de::Error::duplicate_field("more"));
16882 }
16883 field_more = Some(map.next_value()?);
16884 }
16885 "start" => {
16886 if field_start.is_some() {
16887 return Err(::serde::de::Error::duplicate_field("start"));
16888 }
16889 field_start = Some(map.next_value()?);
16890 }
16891 _ => {
16892 map.next_value::<::serde_json::Value>()?;
16894 }
16895 }
16896 }
16897 if optional && nothing {
16898 return Ok(None);
16899 }
16900 let result = SearchResult {
16901 matches: field_matches.ok_or_else(|| ::serde::de::Error::missing_field("matches"))?,
16902 more: field_more.ok_or_else(|| ::serde::de::Error::missing_field("more"))?,
16903 start: field_start.ok_or_else(|| ::serde::de::Error::missing_field("start"))?,
16904 };
16905 Ok(Some(result))
16906 }
16907
16908 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16909 &self,
16910 s: &mut S::SerializeStruct,
16911 ) -> Result<(), S::Error> {
16912 use serde::ser::SerializeStruct;
16913 s.serialize_field("matches", &self.matches)?;
16914 s.serialize_field("more", &self.more)?;
16915 s.serialize_field("start", &self.start)?;
16916 Ok(())
16917 }
16918}
16919
16920impl<'de> ::serde::de::Deserialize<'de> for SearchResult {
16921 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16922 use serde::de::{MapAccess, Visitor};
16924 struct StructVisitor;
16925 impl<'de> Visitor<'de> for StructVisitor {
16926 type Value = SearchResult;
16927 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16928 f.write_str("a SearchResult struct")
16929 }
16930 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16931 SearchResult::internal_deserialize(map)
16932 }
16933 }
16934 deserializer.deserialize_struct("SearchResult", SEARCH_RESULT_FIELDS, StructVisitor)
16935 }
16936}
16937
16938impl ::serde::ser::Serialize for SearchResult {
16939 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16940 use serde::ser::SerializeStruct;
16942 let mut s = serializer.serialize_struct("SearchResult", 3)?;
16943 self.internal_serialize::<S>(&mut s)?;
16944 s.end()
16945 }
16946}
16947
16948#[derive(Debug, Clone, PartialEq, Eq)]
16949#[non_exhaustive] pub struct SearchV2Arg {
16951 pub query: String,
16953 pub options: Option<SearchOptions>,
16955 pub match_field_options: Option<SearchMatchFieldOptions>,
16957 #[deprecated]
16959 pub include_highlights: Option<bool>,
16960}
16961
16962impl SearchV2Arg {
16963 pub fn new(query: String) -> Self {
16964 SearchV2Arg {
16965 query,
16966 options: None,
16967 match_field_options: None,
16968 #[allow(deprecated)] include_highlights: None,
16969 }
16970 }
16971
16972 pub fn with_options(mut self, value: SearchOptions) -> Self {
16973 self.options = Some(value);
16974 self
16975 }
16976
16977 pub fn with_match_field_options(mut self, value: SearchMatchFieldOptions) -> Self {
16978 self.match_field_options = Some(value);
16979 self
16980 }
16981
16982 #[deprecated]
16983 #[allow(deprecated)]
16984 pub fn with_include_highlights(mut self, value: bool) -> Self {
16985 self.include_highlights = Some(value);
16986 self
16987 }
16988}
16989
16990const SEARCH_V2_ARG_FIELDS: &[&str] = &["query",
16991 "options",
16992 "match_field_options",
16993 "include_highlights"];
16994impl SearchV2Arg {
16995 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16996 map: V,
16997 ) -> Result<SearchV2Arg, V::Error> {
16998 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16999 }
17000
17001 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17002 mut map: V,
17003 optional: bool,
17004 ) -> Result<Option<SearchV2Arg>, V::Error> {
17005 let mut field_query = None;
17006 let mut field_options = None;
17007 let mut field_match_field_options = None;
17008 let mut field_include_highlights = None;
17009 let mut nothing = true;
17010 while let Some(key) = map.next_key::<&str>()? {
17011 nothing = false;
17012 match key {
17013 "query" => {
17014 if field_query.is_some() {
17015 return Err(::serde::de::Error::duplicate_field("query"));
17016 }
17017 field_query = Some(map.next_value()?);
17018 }
17019 "options" => {
17020 if field_options.is_some() {
17021 return Err(::serde::de::Error::duplicate_field("options"));
17022 }
17023 field_options = Some(map.next_value()?);
17024 }
17025 "match_field_options" => {
17026 if field_match_field_options.is_some() {
17027 return Err(::serde::de::Error::duplicate_field("match_field_options"));
17028 }
17029 field_match_field_options = Some(map.next_value()?);
17030 }
17031 "include_highlights" => {
17032 if field_include_highlights.is_some() {
17033 return Err(::serde::de::Error::duplicate_field("include_highlights"));
17034 }
17035 field_include_highlights = Some(map.next_value()?);
17036 }
17037 _ => {
17038 map.next_value::<::serde_json::Value>()?;
17040 }
17041 }
17042 }
17043 if optional && nothing {
17044 return Ok(None);
17045 }
17046 let result = SearchV2Arg {
17047 query: field_query.ok_or_else(|| ::serde::de::Error::missing_field("query"))?,
17048 options: field_options.and_then(Option::flatten),
17049 match_field_options: field_match_field_options.and_then(Option::flatten),
17050 #[allow(deprecated)] include_highlights: field_include_highlights.and_then(Option::flatten),
17051 };
17052 Ok(Some(result))
17053 }
17054
17055 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17056 &self,
17057 s: &mut S::SerializeStruct,
17058 ) -> Result<(), S::Error> {
17059 use serde::ser::SerializeStruct;
17060 s.serialize_field("query", &self.query)?;
17061 if let Some(val) = &self.options {
17062 s.serialize_field("options", val)?;
17063 }
17064 if let Some(val) = &self.match_field_options {
17065 s.serialize_field("match_field_options", val)?;
17066 }
17067 #[allow(deprecated)]
17068 if let Some(val) = &self.include_highlights {
17069 s.serialize_field("include_highlights", val)?;
17070 }
17071 Ok(())
17072 }
17073}
17074
17075impl<'de> ::serde::de::Deserialize<'de> for SearchV2Arg {
17076 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17077 use serde::de::{MapAccess, Visitor};
17079 struct StructVisitor;
17080 impl<'de> Visitor<'de> for StructVisitor {
17081 type Value = SearchV2Arg;
17082 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17083 f.write_str("a SearchV2Arg struct")
17084 }
17085 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17086 SearchV2Arg::internal_deserialize(map)
17087 }
17088 }
17089 deserializer.deserialize_struct("SearchV2Arg", SEARCH_V2_ARG_FIELDS, StructVisitor)
17090 }
17091}
17092
17093impl ::serde::ser::Serialize for SearchV2Arg {
17094 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17095 use serde::ser::SerializeStruct;
17097 let mut s = serializer.serialize_struct("SearchV2Arg", 4)?;
17098 self.internal_serialize::<S>(&mut s)?;
17099 s.end()
17100 }
17101}
17102
17103#[derive(Debug, Clone, PartialEq, Eq)]
17104#[non_exhaustive] pub struct SearchV2ContinueArg {
17106 pub cursor: SearchV2Cursor,
17109}
17110
17111impl SearchV2ContinueArg {
17112 pub fn new(cursor: SearchV2Cursor) -> Self {
17113 SearchV2ContinueArg {
17114 cursor,
17115 }
17116 }
17117}
17118
17119const SEARCH_V2_CONTINUE_ARG_FIELDS: &[&str] = &["cursor"];
17120impl SearchV2ContinueArg {
17121 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17122 map: V,
17123 ) -> Result<SearchV2ContinueArg, V::Error> {
17124 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17125 }
17126
17127 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17128 mut map: V,
17129 optional: bool,
17130 ) -> Result<Option<SearchV2ContinueArg>, V::Error> {
17131 let mut field_cursor = None;
17132 let mut nothing = true;
17133 while let Some(key) = map.next_key::<&str>()? {
17134 nothing = false;
17135 match key {
17136 "cursor" => {
17137 if field_cursor.is_some() {
17138 return Err(::serde::de::Error::duplicate_field("cursor"));
17139 }
17140 field_cursor = Some(map.next_value()?);
17141 }
17142 _ => {
17143 map.next_value::<::serde_json::Value>()?;
17145 }
17146 }
17147 }
17148 if optional && nothing {
17149 return Ok(None);
17150 }
17151 let result = SearchV2ContinueArg {
17152 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
17153 };
17154 Ok(Some(result))
17155 }
17156
17157 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17158 &self,
17159 s: &mut S::SerializeStruct,
17160 ) -> Result<(), S::Error> {
17161 use serde::ser::SerializeStruct;
17162 s.serialize_field("cursor", &self.cursor)?;
17163 Ok(())
17164 }
17165}
17166
17167impl<'de> ::serde::de::Deserialize<'de> for SearchV2ContinueArg {
17168 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17169 use serde::de::{MapAccess, Visitor};
17171 struct StructVisitor;
17172 impl<'de> Visitor<'de> for StructVisitor {
17173 type Value = SearchV2ContinueArg;
17174 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17175 f.write_str("a SearchV2ContinueArg struct")
17176 }
17177 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17178 SearchV2ContinueArg::internal_deserialize(map)
17179 }
17180 }
17181 deserializer.deserialize_struct("SearchV2ContinueArg", SEARCH_V2_CONTINUE_ARG_FIELDS, StructVisitor)
17182 }
17183}
17184
17185impl ::serde::ser::Serialize for SearchV2ContinueArg {
17186 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17187 use serde::ser::SerializeStruct;
17189 let mut s = serializer.serialize_struct("SearchV2ContinueArg", 1)?;
17190 self.internal_serialize::<S>(&mut s)?;
17191 s.end()
17192 }
17193}
17194
17195#[derive(Debug, Clone, PartialEq)]
17196#[non_exhaustive] pub struct SearchV2Result {
17198 pub matches: Vec<SearchMatchV2>,
17200 pub has_more: bool,
17204 pub cursor: Option<SearchV2Cursor>,
17207}
17208
17209impl SearchV2Result {
17210 pub fn new(matches: Vec<SearchMatchV2>, has_more: bool) -> Self {
17211 SearchV2Result {
17212 matches,
17213 has_more,
17214 cursor: None,
17215 }
17216 }
17217
17218 pub fn with_cursor(mut self, value: SearchV2Cursor) -> Self {
17219 self.cursor = Some(value);
17220 self
17221 }
17222}
17223
17224const SEARCH_V2_RESULT_FIELDS: &[&str] = &["matches",
17225 "has_more",
17226 "cursor"];
17227impl SearchV2Result {
17228 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17229 map: V,
17230 ) -> Result<SearchV2Result, V::Error> {
17231 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17232 }
17233
17234 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17235 mut map: V,
17236 optional: bool,
17237 ) -> Result<Option<SearchV2Result>, V::Error> {
17238 let mut field_matches = None;
17239 let mut field_has_more = None;
17240 let mut field_cursor = None;
17241 let mut nothing = true;
17242 while let Some(key) = map.next_key::<&str>()? {
17243 nothing = false;
17244 match key {
17245 "matches" => {
17246 if field_matches.is_some() {
17247 return Err(::serde::de::Error::duplicate_field("matches"));
17248 }
17249 field_matches = Some(map.next_value()?);
17250 }
17251 "has_more" => {
17252 if field_has_more.is_some() {
17253 return Err(::serde::de::Error::duplicate_field("has_more"));
17254 }
17255 field_has_more = Some(map.next_value()?);
17256 }
17257 "cursor" => {
17258 if field_cursor.is_some() {
17259 return Err(::serde::de::Error::duplicate_field("cursor"));
17260 }
17261 field_cursor = Some(map.next_value()?);
17262 }
17263 _ => {
17264 map.next_value::<::serde_json::Value>()?;
17266 }
17267 }
17268 }
17269 if optional && nothing {
17270 return Ok(None);
17271 }
17272 let result = SearchV2Result {
17273 matches: field_matches.ok_or_else(|| ::serde::de::Error::missing_field("matches"))?,
17274 has_more: field_has_more.ok_or_else(|| ::serde::de::Error::missing_field("has_more"))?,
17275 cursor: field_cursor.and_then(Option::flatten),
17276 };
17277 Ok(Some(result))
17278 }
17279
17280 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17281 &self,
17282 s: &mut S::SerializeStruct,
17283 ) -> Result<(), S::Error> {
17284 use serde::ser::SerializeStruct;
17285 s.serialize_field("matches", &self.matches)?;
17286 s.serialize_field("has_more", &self.has_more)?;
17287 if let Some(val) = &self.cursor {
17288 s.serialize_field("cursor", val)?;
17289 }
17290 Ok(())
17291 }
17292}
17293
17294impl<'de> ::serde::de::Deserialize<'de> for SearchV2Result {
17295 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17296 use serde::de::{MapAccess, Visitor};
17298 struct StructVisitor;
17299 impl<'de> Visitor<'de> for StructVisitor {
17300 type Value = SearchV2Result;
17301 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17302 f.write_str("a SearchV2Result struct")
17303 }
17304 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17305 SearchV2Result::internal_deserialize(map)
17306 }
17307 }
17308 deserializer.deserialize_struct("SearchV2Result", SEARCH_V2_RESULT_FIELDS, StructVisitor)
17309 }
17310}
17311
17312impl ::serde::ser::Serialize for SearchV2Result {
17313 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17314 use serde::ser::SerializeStruct;
17316 let mut s = serializer.serialize_struct("SearchV2Result", 3)?;
17317 self.internal_serialize::<S>(&mut s)?;
17318 s.end()
17319 }
17320}
17321
17322#[derive(Debug, Clone, PartialEq, Eq)]
17323#[non_exhaustive] pub struct SharedLink {
17325 pub url: SharedLinkUrl,
17327 pub password: Option<String>,
17329}
17330
17331impl SharedLink {
17332 pub fn new(url: SharedLinkUrl) -> Self {
17333 SharedLink {
17334 url,
17335 password: None,
17336 }
17337 }
17338
17339 pub fn with_password(mut self, value: String) -> Self {
17340 self.password = Some(value);
17341 self
17342 }
17343}
17344
17345const SHARED_LINK_FIELDS: &[&str] = &["url",
17346 "password"];
17347impl SharedLink {
17348 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17349 map: V,
17350 ) -> Result<SharedLink, V::Error> {
17351 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17352 }
17353
17354 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17355 mut map: V,
17356 optional: bool,
17357 ) -> Result<Option<SharedLink>, V::Error> {
17358 let mut field_url = None;
17359 let mut field_password = None;
17360 let mut nothing = true;
17361 while let Some(key) = map.next_key::<&str>()? {
17362 nothing = false;
17363 match key {
17364 "url" => {
17365 if field_url.is_some() {
17366 return Err(::serde::de::Error::duplicate_field("url"));
17367 }
17368 field_url = Some(map.next_value()?);
17369 }
17370 "password" => {
17371 if field_password.is_some() {
17372 return Err(::serde::de::Error::duplicate_field("password"));
17373 }
17374 field_password = Some(map.next_value()?);
17375 }
17376 _ => {
17377 map.next_value::<::serde_json::Value>()?;
17379 }
17380 }
17381 }
17382 if optional && nothing {
17383 return Ok(None);
17384 }
17385 let result = SharedLink {
17386 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
17387 password: field_password.and_then(Option::flatten),
17388 };
17389 Ok(Some(result))
17390 }
17391
17392 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17393 &self,
17394 s: &mut S::SerializeStruct,
17395 ) -> Result<(), S::Error> {
17396 use serde::ser::SerializeStruct;
17397 s.serialize_field("url", &self.url)?;
17398 if let Some(val) = &self.password {
17399 s.serialize_field("password", val)?;
17400 }
17401 Ok(())
17402 }
17403}
17404
17405impl<'de> ::serde::de::Deserialize<'de> for SharedLink {
17406 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17407 use serde::de::{MapAccess, Visitor};
17409 struct StructVisitor;
17410 impl<'de> Visitor<'de> for StructVisitor {
17411 type Value = SharedLink;
17412 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17413 f.write_str("a SharedLink struct")
17414 }
17415 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17416 SharedLink::internal_deserialize(map)
17417 }
17418 }
17419 deserializer.deserialize_struct("SharedLink", SHARED_LINK_FIELDS, StructVisitor)
17420 }
17421}
17422
17423impl ::serde::ser::Serialize for SharedLink {
17424 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17425 use serde::ser::SerializeStruct;
17427 let mut s = serializer.serialize_struct("SharedLink", 2)?;
17428 self.internal_serialize::<S>(&mut s)?;
17429 s.end()
17430 }
17431}
17432
17433#[derive(Debug, Clone, PartialEq, Eq)]
17434#[non_exhaustive] pub struct SharedLinkFileInfo {
17436 pub url: String,
17440 pub path: Option<String>,
17443 pub password: Option<String>,
17446}
17447
17448impl SharedLinkFileInfo {
17449 pub fn new(url: String) -> Self {
17450 SharedLinkFileInfo {
17451 url,
17452 path: None,
17453 password: None,
17454 }
17455 }
17456
17457 pub fn with_path(mut self, value: String) -> Self {
17458 self.path = Some(value);
17459 self
17460 }
17461
17462 pub fn with_password(mut self, value: String) -> Self {
17463 self.password = Some(value);
17464 self
17465 }
17466}
17467
17468const SHARED_LINK_FILE_INFO_FIELDS: &[&str] = &["url",
17469 "path",
17470 "password"];
17471impl SharedLinkFileInfo {
17472 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17473 map: V,
17474 ) -> Result<SharedLinkFileInfo, V::Error> {
17475 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17476 }
17477
17478 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17479 mut map: V,
17480 optional: bool,
17481 ) -> Result<Option<SharedLinkFileInfo>, V::Error> {
17482 let mut field_url = None;
17483 let mut field_path = None;
17484 let mut field_password = None;
17485 let mut nothing = true;
17486 while let Some(key) = map.next_key::<&str>()? {
17487 nothing = false;
17488 match key {
17489 "url" => {
17490 if field_url.is_some() {
17491 return Err(::serde::de::Error::duplicate_field("url"));
17492 }
17493 field_url = Some(map.next_value()?);
17494 }
17495 "path" => {
17496 if field_path.is_some() {
17497 return Err(::serde::de::Error::duplicate_field("path"));
17498 }
17499 field_path = Some(map.next_value()?);
17500 }
17501 "password" => {
17502 if field_password.is_some() {
17503 return Err(::serde::de::Error::duplicate_field("password"));
17504 }
17505 field_password = Some(map.next_value()?);
17506 }
17507 _ => {
17508 map.next_value::<::serde_json::Value>()?;
17510 }
17511 }
17512 }
17513 if optional && nothing {
17514 return Ok(None);
17515 }
17516 let result = SharedLinkFileInfo {
17517 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
17518 path: field_path.and_then(Option::flatten),
17519 password: field_password.and_then(Option::flatten),
17520 };
17521 Ok(Some(result))
17522 }
17523
17524 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17525 &self,
17526 s: &mut S::SerializeStruct,
17527 ) -> Result<(), S::Error> {
17528 use serde::ser::SerializeStruct;
17529 s.serialize_field("url", &self.url)?;
17530 if let Some(val) = &self.path {
17531 s.serialize_field("path", val)?;
17532 }
17533 if let Some(val) = &self.password {
17534 s.serialize_field("password", val)?;
17535 }
17536 Ok(())
17537 }
17538}
17539
17540impl<'de> ::serde::de::Deserialize<'de> for SharedLinkFileInfo {
17541 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17542 use serde::de::{MapAccess, Visitor};
17544 struct StructVisitor;
17545 impl<'de> Visitor<'de> for StructVisitor {
17546 type Value = SharedLinkFileInfo;
17547 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17548 f.write_str("a SharedLinkFileInfo struct")
17549 }
17550 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17551 SharedLinkFileInfo::internal_deserialize(map)
17552 }
17553 }
17554 deserializer.deserialize_struct("SharedLinkFileInfo", SHARED_LINK_FILE_INFO_FIELDS, StructVisitor)
17555 }
17556}
17557
17558impl ::serde::ser::Serialize for SharedLinkFileInfo {
17559 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17560 use serde::ser::SerializeStruct;
17562 let mut s = serializer.serialize_struct("SharedLinkFileInfo", 3)?;
17563 self.internal_serialize::<S>(&mut s)?;
17564 s.end()
17565 }
17566}
17567
17568#[derive(Debug, Clone, PartialEq, Eq)]
17570#[non_exhaustive] pub struct SharingInfo {
17572 pub read_only: bool,
17574}
17575
17576impl SharingInfo {
17577 pub fn new(read_only: bool) -> Self {
17578 SharingInfo {
17579 read_only,
17580 }
17581 }
17582}
17583
17584const SHARING_INFO_FIELDS: &[&str] = &["read_only"];
17585impl SharingInfo {
17586 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17587 map: V,
17588 ) -> Result<SharingInfo, V::Error> {
17589 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17590 }
17591
17592 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17593 mut map: V,
17594 optional: bool,
17595 ) -> Result<Option<SharingInfo>, V::Error> {
17596 let mut field_read_only = None;
17597 let mut nothing = true;
17598 while let Some(key) = map.next_key::<&str>()? {
17599 nothing = false;
17600 match key {
17601 "read_only" => {
17602 if field_read_only.is_some() {
17603 return Err(::serde::de::Error::duplicate_field("read_only"));
17604 }
17605 field_read_only = Some(map.next_value()?);
17606 }
17607 _ => {
17608 map.next_value::<::serde_json::Value>()?;
17610 }
17611 }
17612 }
17613 if optional && nothing {
17614 return Ok(None);
17615 }
17616 let result = SharingInfo {
17617 read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
17618 };
17619 Ok(Some(result))
17620 }
17621
17622 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17623 &self,
17624 s: &mut S::SerializeStruct,
17625 ) -> Result<(), S::Error> {
17626 use serde::ser::SerializeStruct;
17627 s.serialize_field("read_only", &self.read_only)?;
17628 Ok(())
17629 }
17630}
17631
17632impl<'de> ::serde::de::Deserialize<'de> for SharingInfo {
17633 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17634 use serde::de::{MapAccess, Visitor};
17636 struct StructVisitor;
17637 impl<'de> Visitor<'de> for StructVisitor {
17638 type Value = SharingInfo;
17639 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17640 f.write_str("a SharingInfo struct")
17641 }
17642 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17643 SharingInfo::internal_deserialize(map)
17644 }
17645 }
17646 deserializer.deserialize_struct("SharingInfo", SHARING_INFO_FIELDS, StructVisitor)
17647 }
17648}
17649
17650impl ::serde::ser::Serialize for SharingInfo {
17651 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17652 use serde::ser::SerializeStruct;
17654 let mut s = serializer.serialize_struct("SharingInfo", 1)?;
17655 self.internal_serialize::<S>(&mut s)?;
17656 s.end()
17657 }
17658}
17659
17660#[derive(Debug, Clone, PartialEq, Eq)]
17661#[non_exhaustive] pub struct SingleUserLock {
17663 pub created: crate::types::common::DropboxTimestamp,
17665 pub lock_holder_account_id: crate::types::users_common::AccountId,
17667 pub lock_holder_team_id: Option<String>,
17669}
17670
17671impl SingleUserLock {
17672 pub fn new(
17673 created: crate::types::common::DropboxTimestamp,
17674 lock_holder_account_id: crate::types::users_common::AccountId,
17675 ) -> Self {
17676 SingleUserLock {
17677 created,
17678 lock_holder_account_id,
17679 lock_holder_team_id: None,
17680 }
17681 }
17682
17683 pub fn with_lock_holder_team_id(mut self, value: String) -> Self {
17684 self.lock_holder_team_id = Some(value);
17685 self
17686 }
17687}
17688
17689const SINGLE_USER_LOCK_FIELDS: &[&str] = &["created",
17690 "lock_holder_account_id",
17691 "lock_holder_team_id"];
17692impl SingleUserLock {
17693 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17694 map: V,
17695 ) -> Result<SingleUserLock, V::Error> {
17696 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17697 }
17698
17699 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17700 mut map: V,
17701 optional: bool,
17702 ) -> Result<Option<SingleUserLock>, V::Error> {
17703 let mut field_created = None;
17704 let mut field_lock_holder_account_id = None;
17705 let mut field_lock_holder_team_id = None;
17706 let mut nothing = true;
17707 while let Some(key) = map.next_key::<&str>()? {
17708 nothing = false;
17709 match key {
17710 "created" => {
17711 if field_created.is_some() {
17712 return Err(::serde::de::Error::duplicate_field("created"));
17713 }
17714 field_created = Some(map.next_value()?);
17715 }
17716 "lock_holder_account_id" => {
17717 if field_lock_holder_account_id.is_some() {
17718 return Err(::serde::de::Error::duplicate_field("lock_holder_account_id"));
17719 }
17720 field_lock_holder_account_id = Some(map.next_value()?);
17721 }
17722 "lock_holder_team_id" => {
17723 if field_lock_holder_team_id.is_some() {
17724 return Err(::serde::de::Error::duplicate_field("lock_holder_team_id"));
17725 }
17726 field_lock_holder_team_id = Some(map.next_value()?);
17727 }
17728 _ => {
17729 map.next_value::<::serde_json::Value>()?;
17731 }
17732 }
17733 }
17734 if optional && nothing {
17735 return Ok(None);
17736 }
17737 let result = SingleUserLock {
17738 created: field_created.ok_or_else(|| ::serde::de::Error::missing_field("created"))?,
17739 lock_holder_account_id: field_lock_holder_account_id.ok_or_else(|| ::serde::de::Error::missing_field("lock_holder_account_id"))?,
17740 lock_holder_team_id: field_lock_holder_team_id.and_then(Option::flatten),
17741 };
17742 Ok(Some(result))
17743 }
17744
17745 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17746 &self,
17747 s: &mut S::SerializeStruct,
17748 ) -> Result<(), S::Error> {
17749 use serde::ser::SerializeStruct;
17750 s.serialize_field("created", &self.created)?;
17751 s.serialize_field("lock_holder_account_id", &self.lock_holder_account_id)?;
17752 if let Some(val) = &self.lock_holder_team_id {
17753 s.serialize_field("lock_holder_team_id", val)?;
17754 }
17755 Ok(())
17756 }
17757}
17758
17759impl<'de> ::serde::de::Deserialize<'de> for SingleUserLock {
17760 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17761 use serde::de::{MapAccess, Visitor};
17763 struct StructVisitor;
17764 impl<'de> Visitor<'de> for StructVisitor {
17765 type Value = SingleUserLock;
17766 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17767 f.write_str("a SingleUserLock struct")
17768 }
17769 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17770 SingleUserLock::internal_deserialize(map)
17771 }
17772 }
17773 deserializer.deserialize_struct("SingleUserLock", SINGLE_USER_LOCK_FIELDS, StructVisitor)
17774 }
17775}
17776
17777impl ::serde::ser::Serialize for SingleUserLock {
17778 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17779 use serde::ser::SerializeStruct;
17781 let mut s = serializer.serialize_struct("SingleUserLock", 3)?;
17782 self.internal_serialize::<S>(&mut s)?;
17783 s.end()
17784 }
17785}
17786
17787#[derive(Debug, Clone, PartialEq, Eq)]
17788#[non_exhaustive] pub struct SymlinkInfo {
17790 pub target: String,
17792}
17793
17794impl SymlinkInfo {
17795 pub fn new(target: String) -> Self {
17796 SymlinkInfo {
17797 target,
17798 }
17799 }
17800}
17801
17802const SYMLINK_INFO_FIELDS: &[&str] = &["target"];
17803impl SymlinkInfo {
17804 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17805 map: V,
17806 ) -> Result<SymlinkInfo, V::Error> {
17807 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17808 }
17809
17810 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17811 mut map: V,
17812 optional: bool,
17813 ) -> Result<Option<SymlinkInfo>, V::Error> {
17814 let mut field_target = None;
17815 let mut nothing = true;
17816 while let Some(key) = map.next_key::<&str>()? {
17817 nothing = false;
17818 match key {
17819 "target" => {
17820 if field_target.is_some() {
17821 return Err(::serde::de::Error::duplicate_field("target"));
17822 }
17823 field_target = Some(map.next_value()?);
17824 }
17825 _ => {
17826 map.next_value::<::serde_json::Value>()?;
17828 }
17829 }
17830 }
17831 if optional && nothing {
17832 return Ok(None);
17833 }
17834 let result = SymlinkInfo {
17835 target: field_target.ok_or_else(|| ::serde::de::Error::missing_field("target"))?,
17836 };
17837 Ok(Some(result))
17838 }
17839
17840 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17841 &self,
17842 s: &mut S::SerializeStruct,
17843 ) -> Result<(), S::Error> {
17844 use serde::ser::SerializeStruct;
17845 s.serialize_field("target", &self.target)?;
17846 Ok(())
17847 }
17848}
17849
17850impl<'de> ::serde::de::Deserialize<'de> for SymlinkInfo {
17851 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17852 use serde::de::{MapAccess, Visitor};
17854 struct StructVisitor;
17855 impl<'de> Visitor<'de> for StructVisitor {
17856 type Value = SymlinkInfo;
17857 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17858 f.write_str("a SymlinkInfo struct")
17859 }
17860 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17861 SymlinkInfo::internal_deserialize(map)
17862 }
17863 }
17864 deserializer.deserialize_struct("SymlinkInfo", SYMLINK_INFO_FIELDS, StructVisitor)
17865 }
17866}
17867
17868impl ::serde::ser::Serialize for SymlinkInfo {
17869 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17870 use serde::ser::SerializeStruct;
17872 let mut s = serializer.serialize_struct("SymlinkInfo", 1)?;
17873 self.internal_serialize::<S>(&mut s)?;
17874 s.end()
17875 }
17876}
17877
17878#[derive(Debug, Clone, PartialEq, Eq)]
17879#[non_exhaustive] pub enum SyncSetting {
17881 Default,
17884 NotSynced,
17887 NotSyncedInactive,
17890 Other,
17893}
17894
17895impl<'de> ::serde::de::Deserialize<'de> for SyncSetting {
17896 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17897 use serde::de::{self, MapAccess, Visitor};
17899 struct EnumVisitor;
17900 impl<'de> Visitor<'de> for EnumVisitor {
17901 type Value = SyncSetting;
17902 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17903 f.write_str("a SyncSetting structure")
17904 }
17905 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
17906 let tag: &str = match map.next_key()? {
17907 Some(".tag") => map.next_value()?,
17908 _ => return Err(de::Error::missing_field(".tag"))
17909 };
17910 let value = match tag {
17911 "default" => SyncSetting::Default,
17912 "not_synced" => SyncSetting::NotSynced,
17913 "not_synced_inactive" => SyncSetting::NotSyncedInactive,
17914 _ => SyncSetting::Other,
17915 };
17916 crate::eat_json_fields(&mut map)?;
17917 Ok(value)
17918 }
17919 }
17920 const VARIANTS: &[&str] = &["default",
17921 "not_synced",
17922 "not_synced_inactive",
17923 "other"];
17924 deserializer.deserialize_struct("SyncSetting", VARIANTS, EnumVisitor)
17925 }
17926}
17927
17928impl ::serde::ser::Serialize for SyncSetting {
17929 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17930 use serde::ser::SerializeStruct;
17932 match self {
17933 SyncSetting::Default => {
17934 let mut s = serializer.serialize_struct("SyncSetting", 1)?;
17936 s.serialize_field(".tag", "default")?;
17937 s.end()
17938 }
17939 SyncSetting::NotSynced => {
17940 let mut s = serializer.serialize_struct("SyncSetting", 1)?;
17942 s.serialize_field(".tag", "not_synced")?;
17943 s.end()
17944 }
17945 SyncSetting::NotSyncedInactive => {
17946 let mut s = serializer.serialize_struct("SyncSetting", 1)?;
17948 s.serialize_field(".tag", "not_synced_inactive")?;
17949 s.end()
17950 }
17951 SyncSetting::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
17952 }
17953 }
17954}
17955
17956#[derive(Debug, Clone, PartialEq, Eq)]
17957#[non_exhaustive] pub enum SyncSettingArg {
17959 Default,
17962 NotSynced,
17965 Other,
17968}
17969
17970impl<'de> ::serde::de::Deserialize<'de> for SyncSettingArg {
17971 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17972 use serde::de::{self, MapAccess, Visitor};
17974 struct EnumVisitor;
17975 impl<'de> Visitor<'de> for EnumVisitor {
17976 type Value = SyncSettingArg;
17977 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17978 f.write_str("a SyncSettingArg structure")
17979 }
17980 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
17981 let tag: &str = match map.next_key()? {
17982 Some(".tag") => map.next_value()?,
17983 _ => return Err(de::Error::missing_field(".tag"))
17984 };
17985 let value = match tag {
17986 "default" => SyncSettingArg::Default,
17987 "not_synced" => SyncSettingArg::NotSynced,
17988 _ => SyncSettingArg::Other,
17989 };
17990 crate::eat_json_fields(&mut map)?;
17991 Ok(value)
17992 }
17993 }
17994 const VARIANTS: &[&str] = &["default",
17995 "not_synced",
17996 "other"];
17997 deserializer.deserialize_struct("SyncSettingArg", VARIANTS, EnumVisitor)
17998 }
17999}
18000
18001impl ::serde::ser::Serialize for SyncSettingArg {
18002 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18003 use serde::ser::SerializeStruct;
18005 match self {
18006 SyncSettingArg::Default => {
18007 let mut s = serializer.serialize_struct("SyncSettingArg", 1)?;
18009 s.serialize_field(".tag", "default")?;
18010 s.end()
18011 }
18012 SyncSettingArg::NotSynced => {
18013 let mut s = serializer.serialize_struct("SyncSettingArg", 1)?;
18015 s.serialize_field(".tag", "not_synced")?;
18016 s.end()
18017 }
18018 SyncSettingArg::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
18019 }
18020 }
18021}
18022
18023#[derive(Debug, Clone, PartialEq, Eq)]
18024#[non_exhaustive] pub enum SyncSettingsError {
18026 Path(LookupError),
18027 UnsupportedCombination,
18029 UnsupportedConfiguration,
18031 Other,
18034}
18035
18036impl<'de> ::serde::de::Deserialize<'de> for SyncSettingsError {
18037 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18038 use serde::de::{self, MapAccess, Visitor};
18040 struct EnumVisitor;
18041 impl<'de> Visitor<'de> for EnumVisitor {
18042 type Value = SyncSettingsError;
18043 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18044 f.write_str("a SyncSettingsError structure")
18045 }
18046 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18047 let tag: &str = match map.next_key()? {
18048 Some(".tag") => map.next_value()?,
18049 _ => return Err(de::Error::missing_field(".tag"))
18050 };
18051 let value = match tag {
18052 "path" => {
18053 match map.next_key()? {
18054 Some("path") => SyncSettingsError::Path(map.next_value()?),
18055 None => return Err(de::Error::missing_field("path")),
18056 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
18057 }
18058 }
18059 "unsupported_combination" => SyncSettingsError::UnsupportedCombination,
18060 "unsupported_configuration" => SyncSettingsError::UnsupportedConfiguration,
18061 _ => SyncSettingsError::Other,
18062 };
18063 crate::eat_json_fields(&mut map)?;
18064 Ok(value)
18065 }
18066 }
18067 const VARIANTS: &[&str] = &["path",
18068 "unsupported_combination",
18069 "unsupported_configuration",
18070 "other"];
18071 deserializer.deserialize_struct("SyncSettingsError", VARIANTS, EnumVisitor)
18072 }
18073}
18074
18075impl ::serde::ser::Serialize for SyncSettingsError {
18076 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18077 use serde::ser::SerializeStruct;
18079 match self {
18080 SyncSettingsError::Path(x) => {
18081 let mut s = serializer.serialize_struct("SyncSettingsError", 2)?;
18083 s.serialize_field(".tag", "path")?;
18084 s.serialize_field("path", x)?;
18085 s.end()
18086 }
18087 SyncSettingsError::UnsupportedCombination => {
18088 let mut s = serializer.serialize_struct("SyncSettingsError", 1)?;
18090 s.serialize_field(".tag", "unsupported_combination")?;
18091 s.end()
18092 }
18093 SyncSettingsError::UnsupportedConfiguration => {
18094 let mut s = serializer.serialize_struct("SyncSettingsError", 1)?;
18096 s.serialize_field(".tag", "unsupported_configuration")?;
18097 s.end()
18098 }
18099 SyncSettingsError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
18100 }
18101 }
18102}
18103
18104impl ::std::error::Error for SyncSettingsError {
18105 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
18106 match self {
18107 SyncSettingsError::Path(inner) => Some(inner),
18108 _ => None,
18109 }
18110 }
18111}
18112
18113impl ::std::fmt::Display for SyncSettingsError {
18114 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18115 match self {
18116 SyncSettingsError::Path(inner) => write!(f, "SyncSettingsError: {}", inner),
18117 SyncSettingsError::UnsupportedCombination => f.write_str("Setting this combination of sync settings simultaneously is not supported."),
18118 SyncSettingsError::UnsupportedConfiguration => f.write_str("The specified configuration is not supported."),
18119 _ => write!(f, "{:?}", *self),
18120 }
18121 }
18122}
18123
18124#[derive(Debug, Clone, PartialEq, Eq)]
18126#[non_exhaustive] pub enum Tag {
18128 UserGeneratedTag(UserGeneratedTag),
18130 Other,
18133}
18134
18135impl<'de> ::serde::de::Deserialize<'de> for Tag {
18136 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18137 use serde::de::{self, MapAccess, Visitor};
18139 struct EnumVisitor;
18140 impl<'de> Visitor<'de> for EnumVisitor {
18141 type Value = Tag;
18142 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18143 f.write_str("a Tag structure")
18144 }
18145 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18146 let tag: &str = match map.next_key()? {
18147 Some(".tag") => map.next_value()?,
18148 _ => return Err(de::Error::missing_field(".tag"))
18149 };
18150 let value = match tag {
18151 "user_generated_tag" => Tag::UserGeneratedTag(UserGeneratedTag::internal_deserialize(&mut map)?),
18152 _ => Tag::Other,
18153 };
18154 crate::eat_json_fields(&mut map)?;
18155 Ok(value)
18156 }
18157 }
18158 const VARIANTS: &[&str] = &["user_generated_tag",
18159 "other"];
18160 deserializer.deserialize_struct("Tag", VARIANTS, EnumVisitor)
18161 }
18162}
18163
18164impl ::serde::ser::Serialize for Tag {
18165 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18166 use serde::ser::SerializeStruct;
18168 match self {
18169 Tag::UserGeneratedTag(x) => {
18170 let mut s = serializer.serialize_struct("Tag", 2)?;
18172 s.serialize_field(".tag", "user_generated_tag")?;
18173 x.internal_serialize::<S>(&mut s)?;
18174 s.end()
18175 }
18176 Tag::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
18177 }
18178 }
18179}
18180
18181#[derive(Debug, Clone, PartialEq, Eq)]
18182#[non_exhaustive] pub struct ThumbnailArg {
18184 pub path: ReadPath,
18186 pub format: ThumbnailFormat,
18190 pub size: ThumbnailSize,
18192 pub mode: ThumbnailMode,
18194 pub quality: ThumbnailQuality,
18196 pub exclude_media_info: Option<bool>,
18200}
18201
18202impl ThumbnailArg {
18203 pub fn new(path: ReadPath) -> Self {
18204 ThumbnailArg {
18205 path,
18206 format: ThumbnailFormat::Jpeg,
18207 size: ThumbnailSize::W64h64,
18208 mode: ThumbnailMode::Strict,
18209 quality: ThumbnailQuality::Quality80,
18210 exclude_media_info: None,
18211 }
18212 }
18213
18214 pub fn with_format(mut self, value: ThumbnailFormat) -> Self {
18215 self.format = value;
18216 self
18217 }
18218
18219 pub fn with_size(mut self, value: ThumbnailSize) -> Self {
18220 self.size = value;
18221 self
18222 }
18223
18224 pub fn with_mode(mut self, value: ThumbnailMode) -> Self {
18225 self.mode = value;
18226 self
18227 }
18228
18229 pub fn with_quality(mut self, value: ThumbnailQuality) -> Self {
18230 self.quality = value;
18231 self
18232 }
18233
18234 pub fn with_exclude_media_info(mut self, value: bool) -> Self {
18235 self.exclude_media_info = Some(value);
18236 self
18237 }
18238}
18239
18240const THUMBNAIL_ARG_FIELDS: &[&str] = &["path",
18241 "format",
18242 "size",
18243 "mode",
18244 "quality",
18245 "exclude_media_info"];
18246impl ThumbnailArg {
18247 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
18248 map: V,
18249 ) -> Result<ThumbnailArg, V::Error> {
18250 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
18251 }
18252
18253 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
18254 mut map: V,
18255 optional: bool,
18256 ) -> Result<Option<ThumbnailArg>, V::Error> {
18257 let mut field_path = None;
18258 let mut field_format = None;
18259 let mut field_size = None;
18260 let mut field_mode = None;
18261 let mut field_quality = None;
18262 let mut field_exclude_media_info = None;
18263 let mut nothing = true;
18264 while let Some(key) = map.next_key::<&str>()? {
18265 nothing = false;
18266 match key {
18267 "path" => {
18268 if field_path.is_some() {
18269 return Err(::serde::de::Error::duplicate_field("path"));
18270 }
18271 field_path = Some(map.next_value()?);
18272 }
18273 "format" => {
18274 if field_format.is_some() {
18275 return Err(::serde::de::Error::duplicate_field("format"));
18276 }
18277 field_format = Some(map.next_value()?);
18278 }
18279 "size" => {
18280 if field_size.is_some() {
18281 return Err(::serde::de::Error::duplicate_field("size"));
18282 }
18283 field_size = Some(map.next_value()?);
18284 }
18285 "mode" => {
18286 if field_mode.is_some() {
18287 return Err(::serde::de::Error::duplicate_field("mode"));
18288 }
18289 field_mode = Some(map.next_value()?);
18290 }
18291 "quality" => {
18292 if field_quality.is_some() {
18293 return Err(::serde::de::Error::duplicate_field("quality"));
18294 }
18295 field_quality = Some(map.next_value()?);
18296 }
18297 "exclude_media_info" => {
18298 if field_exclude_media_info.is_some() {
18299 return Err(::serde::de::Error::duplicate_field("exclude_media_info"));
18300 }
18301 field_exclude_media_info = Some(map.next_value()?);
18302 }
18303 _ => {
18304 map.next_value::<::serde_json::Value>()?;
18306 }
18307 }
18308 }
18309 if optional && nothing {
18310 return Ok(None);
18311 }
18312 let result = ThumbnailArg {
18313 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
18314 format: field_format.unwrap_or(ThumbnailFormat::Jpeg),
18315 size: field_size.unwrap_or(ThumbnailSize::W64h64),
18316 mode: field_mode.unwrap_or(ThumbnailMode::Strict),
18317 quality: field_quality.unwrap_or(ThumbnailQuality::Quality80),
18318 exclude_media_info: field_exclude_media_info.and_then(Option::flatten),
18319 };
18320 Ok(Some(result))
18321 }
18322
18323 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
18324 &self,
18325 s: &mut S::SerializeStruct,
18326 ) -> Result<(), S::Error> {
18327 use serde::ser::SerializeStruct;
18328 s.serialize_field("path", &self.path)?;
18329 if self.format != ThumbnailFormat::Jpeg {
18330 s.serialize_field("format", &self.format)?;
18331 }
18332 if self.size != ThumbnailSize::W64h64 {
18333 s.serialize_field("size", &self.size)?;
18334 }
18335 if self.mode != ThumbnailMode::Strict {
18336 s.serialize_field("mode", &self.mode)?;
18337 }
18338 if self.quality != ThumbnailQuality::Quality80 {
18339 s.serialize_field("quality", &self.quality)?;
18340 }
18341 if let Some(val) = &self.exclude_media_info {
18342 s.serialize_field("exclude_media_info", val)?;
18343 }
18344 Ok(())
18345 }
18346}
18347
18348impl<'de> ::serde::de::Deserialize<'de> for ThumbnailArg {
18349 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18350 use serde::de::{MapAccess, Visitor};
18352 struct StructVisitor;
18353 impl<'de> Visitor<'de> for StructVisitor {
18354 type Value = ThumbnailArg;
18355 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18356 f.write_str("a ThumbnailArg struct")
18357 }
18358 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
18359 ThumbnailArg::internal_deserialize(map)
18360 }
18361 }
18362 deserializer.deserialize_struct("ThumbnailArg", THUMBNAIL_ARG_FIELDS, StructVisitor)
18363 }
18364}
18365
18366impl ::serde::ser::Serialize for ThumbnailArg {
18367 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18368 use serde::ser::SerializeStruct;
18370 let mut s = serializer.serialize_struct("ThumbnailArg", 6)?;
18371 self.internal_serialize::<S>(&mut s)?;
18372 s.end()
18373 }
18374}
18375
18376#[derive(Debug, Clone, PartialEq, Eq)]
18377pub enum ThumbnailError {
18378 Path(LookupError),
18380 UnsupportedExtension,
18382 UnsupportedImage,
18384 EncryptedContent,
18386 ConversionError,
18388}
18389
18390impl<'de> ::serde::de::Deserialize<'de> for ThumbnailError {
18391 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18392 use serde::de::{self, MapAccess, Visitor};
18394 struct EnumVisitor;
18395 impl<'de> Visitor<'de> for EnumVisitor {
18396 type Value = ThumbnailError;
18397 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18398 f.write_str("a ThumbnailError structure")
18399 }
18400 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18401 let tag: &str = match map.next_key()? {
18402 Some(".tag") => map.next_value()?,
18403 _ => return Err(de::Error::missing_field(".tag"))
18404 };
18405 let value = match tag {
18406 "path" => {
18407 match map.next_key()? {
18408 Some("path") => ThumbnailError::Path(map.next_value()?),
18409 None => return Err(de::Error::missing_field("path")),
18410 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
18411 }
18412 }
18413 "unsupported_extension" => ThumbnailError::UnsupportedExtension,
18414 "unsupported_image" => ThumbnailError::UnsupportedImage,
18415 "encrypted_content" => ThumbnailError::EncryptedContent,
18416 "conversion_error" => ThumbnailError::ConversionError,
18417 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18418 };
18419 crate::eat_json_fields(&mut map)?;
18420 Ok(value)
18421 }
18422 }
18423 const VARIANTS: &[&str] = &["path",
18424 "unsupported_extension",
18425 "unsupported_image",
18426 "encrypted_content",
18427 "conversion_error"];
18428 deserializer.deserialize_struct("ThumbnailError", VARIANTS, EnumVisitor)
18429 }
18430}
18431
18432impl ::serde::ser::Serialize for ThumbnailError {
18433 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18434 use serde::ser::SerializeStruct;
18436 match self {
18437 ThumbnailError::Path(x) => {
18438 let mut s = serializer.serialize_struct("ThumbnailError", 2)?;
18440 s.serialize_field(".tag", "path")?;
18441 s.serialize_field("path", x)?;
18442 s.end()
18443 }
18444 ThumbnailError::UnsupportedExtension => {
18445 let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18447 s.serialize_field(".tag", "unsupported_extension")?;
18448 s.end()
18449 }
18450 ThumbnailError::UnsupportedImage => {
18451 let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18453 s.serialize_field(".tag", "unsupported_image")?;
18454 s.end()
18455 }
18456 ThumbnailError::EncryptedContent => {
18457 let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18459 s.serialize_field(".tag", "encrypted_content")?;
18460 s.end()
18461 }
18462 ThumbnailError::ConversionError => {
18463 let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18465 s.serialize_field(".tag", "conversion_error")?;
18466 s.end()
18467 }
18468 }
18469 }
18470}
18471
18472impl ::std::error::Error for ThumbnailError {
18473 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
18474 match self {
18475 ThumbnailError::Path(inner) => Some(inner),
18476 _ => None,
18477 }
18478 }
18479}
18480
18481impl ::std::fmt::Display for ThumbnailError {
18482 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18483 match self {
18484 ThumbnailError::Path(inner) => write!(f, "An error occurs when downloading metadata for the image: {}", inner),
18485 ThumbnailError::UnsupportedExtension => f.write_str("The file extension doesn't allow conversion to a thumbnail."),
18486 ThumbnailError::UnsupportedImage => f.write_str("The image cannot be converted to a thumbnail."),
18487 ThumbnailError::EncryptedContent => f.write_str("Encrypted content cannot be converted to a thumbnail."),
18488 ThumbnailError::ConversionError => f.write_str("An error occurs during thumbnail conversion."),
18489 }
18490 }
18491}
18492
18493#[derive(Debug, Clone, PartialEq, Eq)]
18494pub enum ThumbnailFormat {
18495 Jpeg,
18496 Png,
18497 Webp,
18498}
18499
18500impl<'de> ::serde::de::Deserialize<'de> for ThumbnailFormat {
18501 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18502 use serde::de::{self, MapAccess, Visitor};
18504 struct EnumVisitor;
18505 impl<'de> Visitor<'de> for EnumVisitor {
18506 type Value = ThumbnailFormat;
18507 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18508 f.write_str("a ThumbnailFormat structure")
18509 }
18510 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18511 let tag: &str = match map.next_key()? {
18512 Some(".tag") => map.next_value()?,
18513 _ => return Err(de::Error::missing_field(".tag"))
18514 };
18515 let value = match tag {
18516 "jpeg" => ThumbnailFormat::Jpeg,
18517 "png" => ThumbnailFormat::Png,
18518 "webp" => ThumbnailFormat::Webp,
18519 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18520 };
18521 crate::eat_json_fields(&mut map)?;
18522 Ok(value)
18523 }
18524 }
18525 const VARIANTS: &[&str] = &["jpeg",
18526 "png",
18527 "webp"];
18528 deserializer.deserialize_struct("ThumbnailFormat", VARIANTS, EnumVisitor)
18529 }
18530}
18531
18532impl ::serde::ser::Serialize for ThumbnailFormat {
18533 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18534 use serde::ser::SerializeStruct;
18536 match self {
18537 ThumbnailFormat::Jpeg => {
18538 let mut s = serializer.serialize_struct("ThumbnailFormat", 1)?;
18540 s.serialize_field(".tag", "jpeg")?;
18541 s.end()
18542 }
18543 ThumbnailFormat::Png => {
18544 let mut s = serializer.serialize_struct("ThumbnailFormat", 1)?;
18546 s.serialize_field(".tag", "png")?;
18547 s.end()
18548 }
18549 ThumbnailFormat::Webp => {
18550 let mut s = serializer.serialize_struct("ThumbnailFormat", 1)?;
18552 s.serialize_field(".tag", "webp")?;
18553 s.end()
18554 }
18555 }
18556 }
18557}
18558
18559#[derive(Debug, Clone, PartialEq, Eq)]
18560pub enum ThumbnailMode {
18561 Strict,
18563 Bestfit,
18565 FitoneBestfit,
18567 Original,
18569}
18570
18571impl<'de> ::serde::de::Deserialize<'de> for ThumbnailMode {
18572 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18573 use serde::de::{self, MapAccess, Visitor};
18575 struct EnumVisitor;
18576 impl<'de> Visitor<'de> for EnumVisitor {
18577 type Value = ThumbnailMode;
18578 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18579 f.write_str("a ThumbnailMode structure")
18580 }
18581 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18582 let tag: &str = match map.next_key()? {
18583 Some(".tag") => map.next_value()?,
18584 _ => return Err(de::Error::missing_field(".tag"))
18585 };
18586 let value = match tag {
18587 "strict" => ThumbnailMode::Strict,
18588 "bestfit" => ThumbnailMode::Bestfit,
18589 "fitone_bestfit" => ThumbnailMode::FitoneBestfit,
18590 "original" => ThumbnailMode::Original,
18591 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18592 };
18593 crate::eat_json_fields(&mut map)?;
18594 Ok(value)
18595 }
18596 }
18597 const VARIANTS: &[&str] = &["strict",
18598 "bestfit",
18599 "fitone_bestfit",
18600 "original"];
18601 deserializer.deserialize_struct("ThumbnailMode", VARIANTS, EnumVisitor)
18602 }
18603}
18604
18605impl ::serde::ser::Serialize for ThumbnailMode {
18606 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18607 use serde::ser::SerializeStruct;
18609 match self {
18610 ThumbnailMode::Strict => {
18611 let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18613 s.serialize_field(".tag", "strict")?;
18614 s.end()
18615 }
18616 ThumbnailMode::Bestfit => {
18617 let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18619 s.serialize_field(".tag", "bestfit")?;
18620 s.end()
18621 }
18622 ThumbnailMode::FitoneBestfit => {
18623 let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18625 s.serialize_field(".tag", "fitone_bestfit")?;
18626 s.end()
18627 }
18628 ThumbnailMode::Original => {
18629 let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18631 s.serialize_field(".tag", "original")?;
18632 s.end()
18633 }
18634 }
18635 }
18636}
18637
18638#[derive(Debug, Clone, PartialEq, Eq)]
18639pub enum ThumbnailQuality {
18640 Quality80,
18642 Quality90,
18644}
18645
18646impl<'de> ::serde::de::Deserialize<'de> for ThumbnailQuality {
18647 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18648 use serde::de::{self, MapAccess, Visitor};
18650 struct EnumVisitor;
18651 impl<'de> Visitor<'de> for EnumVisitor {
18652 type Value = ThumbnailQuality;
18653 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18654 f.write_str("a ThumbnailQuality structure")
18655 }
18656 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18657 let tag: &str = match map.next_key()? {
18658 Some(".tag") => map.next_value()?,
18659 _ => return Err(de::Error::missing_field(".tag"))
18660 };
18661 let value = match tag {
18662 "quality_80" => ThumbnailQuality::Quality80,
18663 "quality_90" => ThumbnailQuality::Quality90,
18664 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18665 };
18666 crate::eat_json_fields(&mut map)?;
18667 Ok(value)
18668 }
18669 }
18670 const VARIANTS: &[&str] = &["quality_80",
18671 "quality_90"];
18672 deserializer.deserialize_struct("ThumbnailQuality", VARIANTS, EnumVisitor)
18673 }
18674}
18675
18676impl ::serde::ser::Serialize for ThumbnailQuality {
18677 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18678 use serde::ser::SerializeStruct;
18680 match self {
18681 ThumbnailQuality::Quality80 => {
18682 let mut s = serializer.serialize_struct("ThumbnailQuality", 1)?;
18684 s.serialize_field(".tag", "quality_80")?;
18685 s.end()
18686 }
18687 ThumbnailQuality::Quality90 => {
18688 let mut s = serializer.serialize_struct("ThumbnailQuality", 1)?;
18690 s.serialize_field(".tag", "quality_90")?;
18691 s.end()
18692 }
18693 }
18694 }
18695}
18696
18697#[derive(Debug, Clone, PartialEq, Eq)]
18698pub enum ThumbnailSize {
18699 W32h32,
18701 W64h64,
18703 W128h128,
18705 W256h256,
18707 W480h320,
18709 W640h480,
18711 W960h640,
18713 W1024h768,
18715 W2048h1536,
18717 W3200h2400,
18719}
18720
18721impl<'de> ::serde::de::Deserialize<'de> for ThumbnailSize {
18722 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18723 use serde::de::{self, MapAccess, Visitor};
18725 struct EnumVisitor;
18726 impl<'de> Visitor<'de> for EnumVisitor {
18727 type Value = ThumbnailSize;
18728 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18729 f.write_str("a ThumbnailSize structure")
18730 }
18731 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18732 let tag: &str = match map.next_key()? {
18733 Some(".tag") => map.next_value()?,
18734 _ => return Err(de::Error::missing_field(".tag"))
18735 };
18736 let value = match tag {
18737 "w32h32" => ThumbnailSize::W32h32,
18738 "w64h64" => ThumbnailSize::W64h64,
18739 "w128h128" => ThumbnailSize::W128h128,
18740 "w256h256" => ThumbnailSize::W256h256,
18741 "w480h320" => ThumbnailSize::W480h320,
18742 "w640h480" => ThumbnailSize::W640h480,
18743 "w960h640" => ThumbnailSize::W960h640,
18744 "w1024h768" => ThumbnailSize::W1024h768,
18745 "w2048h1536" => ThumbnailSize::W2048h1536,
18746 "w3200h2400" => ThumbnailSize::W3200h2400,
18747 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18748 };
18749 crate::eat_json_fields(&mut map)?;
18750 Ok(value)
18751 }
18752 }
18753 const VARIANTS: &[&str] = &["w32h32",
18754 "w64h64",
18755 "w128h128",
18756 "w256h256",
18757 "w480h320",
18758 "w640h480",
18759 "w960h640",
18760 "w1024h768",
18761 "w2048h1536",
18762 "w3200h2400"];
18763 deserializer.deserialize_struct("ThumbnailSize", VARIANTS, EnumVisitor)
18764 }
18765}
18766
18767impl ::serde::ser::Serialize for ThumbnailSize {
18768 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18769 use serde::ser::SerializeStruct;
18771 match self {
18772 ThumbnailSize::W32h32 => {
18773 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18775 s.serialize_field(".tag", "w32h32")?;
18776 s.end()
18777 }
18778 ThumbnailSize::W64h64 => {
18779 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18781 s.serialize_field(".tag", "w64h64")?;
18782 s.end()
18783 }
18784 ThumbnailSize::W128h128 => {
18785 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18787 s.serialize_field(".tag", "w128h128")?;
18788 s.end()
18789 }
18790 ThumbnailSize::W256h256 => {
18791 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18793 s.serialize_field(".tag", "w256h256")?;
18794 s.end()
18795 }
18796 ThumbnailSize::W480h320 => {
18797 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18799 s.serialize_field(".tag", "w480h320")?;
18800 s.end()
18801 }
18802 ThumbnailSize::W640h480 => {
18803 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18805 s.serialize_field(".tag", "w640h480")?;
18806 s.end()
18807 }
18808 ThumbnailSize::W960h640 => {
18809 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18811 s.serialize_field(".tag", "w960h640")?;
18812 s.end()
18813 }
18814 ThumbnailSize::W1024h768 => {
18815 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18817 s.serialize_field(".tag", "w1024h768")?;
18818 s.end()
18819 }
18820 ThumbnailSize::W2048h1536 => {
18821 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18823 s.serialize_field(".tag", "w2048h1536")?;
18824 s.end()
18825 }
18826 ThumbnailSize::W3200h2400 => {
18827 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18829 s.serialize_field(".tag", "w3200h2400")?;
18830 s.end()
18831 }
18832 }
18833 }
18834}
18835
18836#[derive(Debug, Clone, PartialEq, Eq)]
18837#[non_exhaustive] pub struct ThumbnailV2Arg {
18839 pub resource: PathOrLink,
18842 pub format: ThumbnailFormat,
18846 pub size: ThumbnailSize,
18848 pub mode: ThumbnailMode,
18850 pub quality: ThumbnailQuality,
18852 pub exclude_media_info: Option<bool>,
18856}
18857
18858impl ThumbnailV2Arg {
18859 pub fn new(resource: PathOrLink) -> Self {
18860 ThumbnailV2Arg {
18861 resource,
18862 format: ThumbnailFormat::Jpeg,
18863 size: ThumbnailSize::W64h64,
18864 mode: ThumbnailMode::Strict,
18865 quality: ThumbnailQuality::Quality80,
18866 exclude_media_info: None,
18867 }
18868 }
18869
18870 pub fn with_format(mut self, value: ThumbnailFormat) -> Self {
18871 self.format = value;
18872 self
18873 }
18874
18875 pub fn with_size(mut self, value: ThumbnailSize) -> Self {
18876 self.size = value;
18877 self
18878 }
18879
18880 pub fn with_mode(mut self, value: ThumbnailMode) -> Self {
18881 self.mode = value;
18882 self
18883 }
18884
18885 pub fn with_quality(mut self, value: ThumbnailQuality) -> Self {
18886 self.quality = value;
18887 self
18888 }
18889
18890 pub fn with_exclude_media_info(mut self, value: bool) -> Self {
18891 self.exclude_media_info = Some(value);
18892 self
18893 }
18894}
18895
18896const THUMBNAIL_V2_ARG_FIELDS: &[&str] = &["resource",
18897 "format",
18898 "size",
18899 "mode",
18900 "quality",
18901 "exclude_media_info"];
18902impl ThumbnailV2Arg {
18903 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
18904 map: V,
18905 ) -> Result<ThumbnailV2Arg, V::Error> {
18906 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
18907 }
18908
18909 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
18910 mut map: V,
18911 optional: bool,
18912 ) -> Result<Option<ThumbnailV2Arg>, V::Error> {
18913 let mut field_resource = None;
18914 let mut field_format = None;
18915 let mut field_size = None;
18916 let mut field_mode = None;
18917 let mut field_quality = None;
18918 let mut field_exclude_media_info = None;
18919 let mut nothing = true;
18920 while let Some(key) = map.next_key::<&str>()? {
18921 nothing = false;
18922 match key {
18923 "resource" => {
18924 if field_resource.is_some() {
18925 return Err(::serde::de::Error::duplicate_field("resource"));
18926 }
18927 field_resource = Some(map.next_value()?);
18928 }
18929 "format" => {
18930 if field_format.is_some() {
18931 return Err(::serde::de::Error::duplicate_field("format"));
18932 }
18933 field_format = Some(map.next_value()?);
18934 }
18935 "size" => {
18936 if field_size.is_some() {
18937 return Err(::serde::de::Error::duplicate_field("size"));
18938 }
18939 field_size = Some(map.next_value()?);
18940 }
18941 "mode" => {
18942 if field_mode.is_some() {
18943 return Err(::serde::de::Error::duplicate_field("mode"));
18944 }
18945 field_mode = Some(map.next_value()?);
18946 }
18947 "quality" => {
18948 if field_quality.is_some() {
18949 return Err(::serde::de::Error::duplicate_field("quality"));
18950 }
18951 field_quality = Some(map.next_value()?);
18952 }
18953 "exclude_media_info" => {
18954 if field_exclude_media_info.is_some() {
18955 return Err(::serde::de::Error::duplicate_field("exclude_media_info"));
18956 }
18957 field_exclude_media_info = Some(map.next_value()?);
18958 }
18959 _ => {
18960 map.next_value::<::serde_json::Value>()?;
18962 }
18963 }
18964 }
18965 if optional && nothing {
18966 return Ok(None);
18967 }
18968 let result = ThumbnailV2Arg {
18969 resource: field_resource.ok_or_else(|| ::serde::de::Error::missing_field("resource"))?,
18970 format: field_format.unwrap_or(ThumbnailFormat::Jpeg),
18971 size: field_size.unwrap_or(ThumbnailSize::W64h64),
18972 mode: field_mode.unwrap_or(ThumbnailMode::Strict),
18973 quality: field_quality.unwrap_or(ThumbnailQuality::Quality80),
18974 exclude_media_info: field_exclude_media_info.and_then(Option::flatten),
18975 };
18976 Ok(Some(result))
18977 }
18978
18979 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
18980 &self,
18981 s: &mut S::SerializeStruct,
18982 ) -> Result<(), S::Error> {
18983 use serde::ser::SerializeStruct;
18984 s.serialize_field("resource", &self.resource)?;
18985 if self.format != ThumbnailFormat::Jpeg {
18986 s.serialize_field("format", &self.format)?;
18987 }
18988 if self.size != ThumbnailSize::W64h64 {
18989 s.serialize_field("size", &self.size)?;
18990 }
18991 if self.mode != ThumbnailMode::Strict {
18992 s.serialize_field("mode", &self.mode)?;
18993 }
18994 if self.quality != ThumbnailQuality::Quality80 {
18995 s.serialize_field("quality", &self.quality)?;
18996 }
18997 if let Some(val) = &self.exclude_media_info {
18998 s.serialize_field("exclude_media_info", val)?;
18999 }
19000 Ok(())
19001 }
19002}
19003
19004impl<'de> ::serde::de::Deserialize<'de> for ThumbnailV2Arg {
19005 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19006 use serde::de::{MapAccess, Visitor};
19008 struct StructVisitor;
19009 impl<'de> Visitor<'de> for StructVisitor {
19010 type Value = ThumbnailV2Arg;
19011 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19012 f.write_str("a ThumbnailV2Arg struct")
19013 }
19014 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19015 ThumbnailV2Arg::internal_deserialize(map)
19016 }
19017 }
19018 deserializer.deserialize_struct("ThumbnailV2Arg", THUMBNAIL_V2_ARG_FIELDS, StructVisitor)
19019 }
19020}
19021
19022impl ::serde::ser::Serialize for ThumbnailV2Arg {
19023 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19024 use serde::ser::SerializeStruct;
19026 let mut s = serializer.serialize_struct("ThumbnailV2Arg", 6)?;
19027 self.internal_serialize::<S>(&mut s)?;
19028 s.end()
19029 }
19030}
19031
19032#[derive(Debug, Clone, PartialEq, Eq)]
19033#[non_exhaustive] pub enum ThumbnailV2Error {
19035 Path(LookupError),
19037 UnsupportedExtension,
19039 UnsupportedImage,
19041 EncryptedContent,
19043 ConversionError,
19045 AccessDenied,
19047 NotFound,
19049 Other,
19052}
19053
19054impl<'de> ::serde::de::Deserialize<'de> for ThumbnailV2Error {
19055 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19056 use serde::de::{self, MapAccess, Visitor};
19058 struct EnumVisitor;
19059 impl<'de> Visitor<'de> for EnumVisitor {
19060 type Value = ThumbnailV2Error;
19061 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19062 f.write_str("a ThumbnailV2Error structure")
19063 }
19064 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
19065 let tag: &str = match map.next_key()? {
19066 Some(".tag") => map.next_value()?,
19067 _ => return Err(de::Error::missing_field(".tag"))
19068 };
19069 let value = match tag {
19070 "path" => {
19071 match map.next_key()? {
19072 Some("path") => ThumbnailV2Error::Path(map.next_value()?),
19073 None => return Err(de::Error::missing_field("path")),
19074 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
19075 }
19076 }
19077 "unsupported_extension" => ThumbnailV2Error::UnsupportedExtension,
19078 "unsupported_image" => ThumbnailV2Error::UnsupportedImage,
19079 "encrypted_content" => ThumbnailV2Error::EncryptedContent,
19080 "conversion_error" => ThumbnailV2Error::ConversionError,
19081 "access_denied" => ThumbnailV2Error::AccessDenied,
19082 "not_found" => ThumbnailV2Error::NotFound,
19083 _ => ThumbnailV2Error::Other,
19084 };
19085 crate::eat_json_fields(&mut map)?;
19086 Ok(value)
19087 }
19088 }
19089 const VARIANTS: &[&str] = &["path",
19090 "unsupported_extension",
19091 "unsupported_image",
19092 "encrypted_content",
19093 "conversion_error",
19094 "access_denied",
19095 "not_found",
19096 "other"];
19097 deserializer.deserialize_struct("ThumbnailV2Error", VARIANTS, EnumVisitor)
19098 }
19099}
19100
19101impl ::serde::ser::Serialize for ThumbnailV2Error {
19102 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19103 use serde::ser::SerializeStruct;
19105 match self {
19106 ThumbnailV2Error::Path(x) => {
19107 let mut s = serializer.serialize_struct("ThumbnailV2Error", 2)?;
19109 s.serialize_field(".tag", "path")?;
19110 s.serialize_field("path", x)?;
19111 s.end()
19112 }
19113 ThumbnailV2Error::UnsupportedExtension => {
19114 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19116 s.serialize_field(".tag", "unsupported_extension")?;
19117 s.end()
19118 }
19119 ThumbnailV2Error::UnsupportedImage => {
19120 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19122 s.serialize_field(".tag", "unsupported_image")?;
19123 s.end()
19124 }
19125 ThumbnailV2Error::EncryptedContent => {
19126 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19128 s.serialize_field(".tag", "encrypted_content")?;
19129 s.end()
19130 }
19131 ThumbnailV2Error::ConversionError => {
19132 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19134 s.serialize_field(".tag", "conversion_error")?;
19135 s.end()
19136 }
19137 ThumbnailV2Error::AccessDenied => {
19138 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19140 s.serialize_field(".tag", "access_denied")?;
19141 s.end()
19142 }
19143 ThumbnailV2Error::NotFound => {
19144 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19146 s.serialize_field(".tag", "not_found")?;
19147 s.end()
19148 }
19149 ThumbnailV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
19150 }
19151 }
19152}
19153
19154impl ::std::error::Error for ThumbnailV2Error {
19155 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
19156 match self {
19157 ThumbnailV2Error::Path(inner) => Some(inner),
19158 _ => None,
19159 }
19160 }
19161}
19162
19163impl ::std::fmt::Display for ThumbnailV2Error {
19164 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19165 match self {
19166 ThumbnailV2Error::Path(inner) => write!(f, "An error occurred when downloading metadata for the image: {}", inner),
19167 ThumbnailV2Error::UnsupportedExtension => f.write_str("The file extension doesn't allow conversion to a thumbnail."),
19168 ThumbnailV2Error::UnsupportedImage => f.write_str("The image cannot be converted to a thumbnail."),
19169 ThumbnailV2Error::EncryptedContent => f.write_str("Encrypted content cannot be converted to a thumbnail."),
19170 ThumbnailV2Error::ConversionError => f.write_str("An error occurred during thumbnail conversion."),
19171 ThumbnailV2Error::AccessDenied => f.write_str("Access to this shared link is forbidden."),
19172 ThumbnailV2Error::NotFound => f.write_str("The shared link does not exist."),
19173 _ => write!(f, "{:?}", *self),
19174 }
19175 }
19176}
19177
19178#[derive(Debug, Clone, PartialEq, Eq)]
19179#[non_exhaustive] pub struct UnlockFileArg {
19181 pub path: WritePathOrId,
19183}
19184
19185impl UnlockFileArg {
19186 pub fn new(path: WritePathOrId) -> Self {
19187 UnlockFileArg {
19188 path,
19189 }
19190 }
19191}
19192
19193const UNLOCK_FILE_ARG_FIELDS: &[&str] = &["path"];
19194impl UnlockFileArg {
19195 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19196 map: V,
19197 ) -> Result<UnlockFileArg, V::Error> {
19198 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19199 }
19200
19201 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19202 mut map: V,
19203 optional: bool,
19204 ) -> Result<Option<UnlockFileArg>, V::Error> {
19205 let mut field_path = None;
19206 let mut nothing = true;
19207 while let Some(key) = map.next_key::<&str>()? {
19208 nothing = false;
19209 match key {
19210 "path" => {
19211 if field_path.is_some() {
19212 return Err(::serde::de::Error::duplicate_field("path"));
19213 }
19214 field_path = Some(map.next_value()?);
19215 }
19216 _ => {
19217 map.next_value::<::serde_json::Value>()?;
19219 }
19220 }
19221 }
19222 if optional && nothing {
19223 return Ok(None);
19224 }
19225 let result = UnlockFileArg {
19226 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
19227 };
19228 Ok(Some(result))
19229 }
19230
19231 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19232 &self,
19233 s: &mut S::SerializeStruct,
19234 ) -> Result<(), S::Error> {
19235 use serde::ser::SerializeStruct;
19236 s.serialize_field("path", &self.path)?;
19237 Ok(())
19238 }
19239}
19240
19241impl<'de> ::serde::de::Deserialize<'de> for UnlockFileArg {
19242 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19243 use serde::de::{MapAccess, Visitor};
19245 struct StructVisitor;
19246 impl<'de> Visitor<'de> for StructVisitor {
19247 type Value = UnlockFileArg;
19248 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19249 f.write_str("a UnlockFileArg struct")
19250 }
19251 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19252 UnlockFileArg::internal_deserialize(map)
19253 }
19254 }
19255 deserializer.deserialize_struct("UnlockFileArg", UNLOCK_FILE_ARG_FIELDS, StructVisitor)
19256 }
19257}
19258
19259impl ::serde::ser::Serialize for UnlockFileArg {
19260 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19261 use serde::ser::SerializeStruct;
19263 let mut s = serializer.serialize_struct("UnlockFileArg", 1)?;
19264 self.internal_serialize::<S>(&mut s)?;
19265 s.end()
19266 }
19267}
19268
19269#[derive(Debug, Clone, PartialEq, Eq)]
19270#[non_exhaustive] pub struct UnlockFileBatchArg {
19272 pub entries: Vec<UnlockFileArg>,
19275}
19276
19277impl UnlockFileBatchArg {
19278 pub fn new(entries: Vec<UnlockFileArg>) -> Self {
19279 UnlockFileBatchArg {
19280 entries,
19281 }
19282 }
19283}
19284
19285const UNLOCK_FILE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
19286impl UnlockFileBatchArg {
19287 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19288 map: V,
19289 ) -> Result<UnlockFileBatchArg, V::Error> {
19290 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19291 }
19292
19293 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19294 mut map: V,
19295 optional: bool,
19296 ) -> Result<Option<UnlockFileBatchArg>, V::Error> {
19297 let mut field_entries = None;
19298 let mut nothing = true;
19299 while let Some(key) = map.next_key::<&str>()? {
19300 nothing = false;
19301 match key {
19302 "entries" => {
19303 if field_entries.is_some() {
19304 return Err(::serde::de::Error::duplicate_field("entries"));
19305 }
19306 field_entries = Some(map.next_value()?);
19307 }
19308 _ => {
19309 map.next_value::<::serde_json::Value>()?;
19311 }
19312 }
19313 }
19314 if optional && nothing {
19315 return Ok(None);
19316 }
19317 let result = UnlockFileBatchArg {
19318 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
19319 };
19320 Ok(Some(result))
19321 }
19322
19323 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19324 &self,
19325 s: &mut S::SerializeStruct,
19326 ) -> Result<(), S::Error> {
19327 use serde::ser::SerializeStruct;
19328 s.serialize_field("entries", &self.entries)?;
19329 Ok(())
19330 }
19331}
19332
19333impl<'de> ::serde::de::Deserialize<'de> for UnlockFileBatchArg {
19334 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19335 use serde::de::{MapAccess, Visitor};
19337 struct StructVisitor;
19338 impl<'de> Visitor<'de> for StructVisitor {
19339 type Value = UnlockFileBatchArg;
19340 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19341 f.write_str("a UnlockFileBatchArg struct")
19342 }
19343 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19344 UnlockFileBatchArg::internal_deserialize(map)
19345 }
19346 }
19347 deserializer.deserialize_struct("UnlockFileBatchArg", UNLOCK_FILE_BATCH_ARG_FIELDS, StructVisitor)
19348 }
19349}
19350
19351impl ::serde::ser::Serialize for UnlockFileBatchArg {
19352 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19353 use serde::ser::SerializeStruct;
19355 let mut s = serializer.serialize_struct("UnlockFileBatchArg", 1)?;
19356 self.internal_serialize::<S>(&mut s)?;
19357 s.end()
19358 }
19359}
19360
19361#[derive(Debug, Clone, PartialEq, Eq)]
19362#[non_exhaustive] pub struct UploadArg {
19364 pub path: WritePathOrId,
19366 pub mode: WriteMode,
19368 pub autorename: bool,
19371 pub client_modified: Option<crate::types::common::DropboxTimestamp>,
19376 pub mute: bool,
19380 pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
19382 pub strict_conflict: bool,
19387 pub content_hash: Option<Sha256HexHash>,
19391}
19392
19393impl UploadArg {
19394 pub fn new(path: WritePathOrId) -> Self {
19395 UploadArg {
19396 path,
19397 mode: WriteMode::Add,
19398 autorename: false,
19399 client_modified: None,
19400 mute: false,
19401 property_groups: None,
19402 strict_conflict: false,
19403 content_hash: None,
19404 }
19405 }
19406
19407 pub fn with_mode(mut self, value: WriteMode) -> Self {
19408 self.mode = value;
19409 self
19410 }
19411
19412 pub fn with_autorename(mut self, value: bool) -> Self {
19413 self.autorename = value;
19414 self
19415 }
19416
19417 pub fn with_client_modified(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
19418 self.client_modified = Some(value);
19419 self
19420 }
19421
19422 pub fn with_mute(mut self, value: bool) -> Self {
19423 self.mute = value;
19424 self
19425 }
19426
19427 pub fn with_property_groups(
19428 mut self,
19429 value: Vec<crate::types::file_properties::PropertyGroup>,
19430 ) -> Self {
19431 self.property_groups = Some(value);
19432 self
19433 }
19434
19435 pub fn with_strict_conflict(mut self, value: bool) -> Self {
19436 self.strict_conflict = value;
19437 self
19438 }
19439
19440 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
19441 self.content_hash = Some(value);
19442 self
19443 }
19444}
19445
19446const UPLOAD_ARG_FIELDS: &[&str] = &["path",
19447 "mode",
19448 "autorename",
19449 "client_modified",
19450 "mute",
19451 "property_groups",
19452 "strict_conflict",
19453 "content_hash"];
19454impl UploadArg {
19455 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19456 map: V,
19457 ) -> Result<UploadArg, V::Error> {
19458 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19459 }
19460
19461 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19462 mut map: V,
19463 optional: bool,
19464 ) -> Result<Option<UploadArg>, V::Error> {
19465 let mut field_path = None;
19466 let mut field_mode = None;
19467 let mut field_autorename = None;
19468 let mut field_client_modified = None;
19469 let mut field_mute = None;
19470 let mut field_property_groups = None;
19471 let mut field_strict_conflict = None;
19472 let mut field_content_hash = None;
19473 let mut nothing = true;
19474 while let Some(key) = map.next_key::<&str>()? {
19475 nothing = false;
19476 match key {
19477 "path" => {
19478 if field_path.is_some() {
19479 return Err(::serde::de::Error::duplicate_field("path"));
19480 }
19481 field_path = Some(map.next_value()?);
19482 }
19483 "mode" => {
19484 if field_mode.is_some() {
19485 return Err(::serde::de::Error::duplicate_field("mode"));
19486 }
19487 field_mode = Some(map.next_value()?);
19488 }
19489 "autorename" => {
19490 if field_autorename.is_some() {
19491 return Err(::serde::de::Error::duplicate_field("autorename"));
19492 }
19493 field_autorename = Some(map.next_value()?);
19494 }
19495 "client_modified" => {
19496 if field_client_modified.is_some() {
19497 return Err(::serde::de::Error::duplicate_field("client_modified"));
19498 }
19499 field_client_modified = Some(map.next_value()?);
19500 }
19501 "mute" => {
19502 if field_mute.is_some() {
19503 return Err(::serde::de::Error::duplicate_field("mute"));
19504 }
19505 field_mute = Some(map.next_value()?);
19506 }
19507 "property_groups" => {
19508 if field_property_groups.is_some() {
19509 return Err(::serde::de::Error::duplicate_field("property_groups"));
19510 }
19511 field_property_groups = Some(map.next_value()?);
19512 }
19513 "strict_conflict" => {
19514 if field_strict_conflict.is_some() {
19515 return Err(::serde::de::Error::duplicate_field("strict_conflict"));
19516 }
19517 field_strict_conflict = Some(map.next_value()?);
19518 }
19519 "content_hash" => {
19520 if field_content_hash.is_some() {
19521 return Err(::serde::de::Error::duplicate_field("content_hash"));
19522 }
19523 field_content_hash = Some(map.next_value()?);
19524 }
19525 _ => {
19526 map.next_value::<::serde_json::Value>()?;
19528 }
19529 }
19530 }
19531 if optional && nothing {
19532 return Ok(None);
19533 }
19534 let result = UploadArg {
19535 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
19536 mode: field_mode.unwrap_or(WriteMode::Add),
19537 autorename: field_autorename.unwrap_or(false),
19538 client_modified: field_client_modified.and_then(Option::flatten),
19539 mute: field_mute.unwrap_or(false),
19540 property_groups: field_property_groups.and_then(Option::flatten),
19541 strict_conflict: field_strict_conflict.unwrap_or(false),
19542 content_hash: field_content_hash.and_then(Option::flatten),
19543 };
19544 Ok(Some(result))
19545 }
19546
19547 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19548 &self,
19549 s: &mut S::SerializeStruct,
19550 ) -> Result<(), S::Error> {
19551 use serde::ser::SerializeStruct;
19552 s.serialize_field("path", &self.path)?;
19553 if self.mode != WriteMode::Add {
19554 s.serialize_field("mode", &self.mode)?;
19555 }
19556 if self.autorename {
19557 s.serialize_field("autorename", &self.autorename)?;
19558 }
19559 if let Some(val) = &self.client_modified {
19560 s.serialize_field("client_modified", val)?;
19561 }
19562 if self.mute {
19563 s.serialize_field("mute", &self.mute)?;
19564 }
19565 if let Some(val) = &self.property_groups {
19566 s.serialize_field("property_groups", val)?;
19567 }
19568 if self.strict_conflict {
19569 s.serialize_field("strict_conflict", &self.strict_conflict)?;
19570 }
19571 if let Some(val) = &self.content_hash {
19572 s.serialize_field("content_hash", val)?;
19573 }
19574 Ok(())
19575 }
19576}
19577
19578impl<'de> ::serde::de::Deserialize<'de> for UploadArg {
19579 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19580 use serde::de::{MapAccess, Visitor};
19582 struct StructVisitor;
19583 impl<'de> Visitor<'de> for StructVisitor {
19584 type Value = UploadArg;
19585 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19586 f.write_str("a UploadArg struct")
19587 }
19588 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19589 UploadArg::internal_deserialize(map)
19590 }
19591 }
19592 deserializer.deserialize_struct("UploadArg", UPLOAD_ARG_FIELDS, StructVisitor)
19593 }
19594}
19595
19596impl ::serde::ser::Serialize for UploadArg {
19597 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19598 use serde::ser::SerializeStruct;
19600 let mut s = serializer.serialize_struct("UploadArg", 8)?;
19601 self.internal_serialize::<S>(&mut s)?;
19602 s.end()
19603 }
19604}
19605
19606impl From<UploadArg> for CommitInfo {
19608 fn from(subtype: UploadArg) -> Self {
19609 Self {
19610 path: subtype.path,
19611 mode: subtype.mode,
19612 autorename: subtype.autorename,
19613 client_modified: subtype.client_modified,
19614 mute: subtype.mute,
19615 property_groups: subtype.property_groups,
19616 strict_conflict: subtype.strict_conflict,
19617 }
19618 }
19619}
19620#[derive(Debug, Clone, PartialEq, Eq)]
19621#[non_exhaustive] pub enum UploadError {
19623 Path(UploadWriteFailed),
19625 PropertiesError(crate::types::file_properties::InvalidPropertyGroupError),
19627 PayloadTooLarge,
19629 ContentHashMismatch,
19632 EncryptionNotSupported,
19634 Other,
19637}
19638
19639impl<'de> ::serde::de::Deserialize<'de> for UploadError {
19640 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19641 use serde::de::{self, MapAccess, Visitor};
19643 struct EnumVisitor;
19644 impl<'de> Visitor<'de> for EnumVisitor {
19645 type Value = UploadError;
19646 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19647 f.write_str("a UploadError structure")
19648 }
19649 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
19650 let tag: &str = match map.next_key()? {
19651 Some(".tag") => map.next_value()?,
19652 _ => return Err(de::Error::missing_field(".tag"))
19653 };
19654 let value = match tag {
19655 "path" => UploadError::Path(UploadWriteFailed::internal_deserialize(&mut map)?),
19656 "properties_error" => {
19657 match map.next_key()? {
19658 Some("properties_error") => UploadError::PropertiesError(map.next_value()?),
19659 None => return Err(de::Error::missing_field("properties_error")),
19660 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
19661 }
19662 }
19663 "payload_too_large" => UploadError::PayloadTooLarge,
19664 "content_hash_mismatch" => UploadError::ContentHashMismatch,
19665 "encryption_not_supported" => UploadError::EncryptionNotSupported,
19666 _ => UploadError::Other,
19667 };
19668 crate::eat_json_fields(&mut map)?;
19669 Ok(value)
19670 }
19671 }
19672 const VARIANTS: &[&str] = &["path",
19673 "properties_error",
19674 "payload_too_large",
19675 "content_hash_mismatch",
19676 "encryption_not_supported",
19677 "other"];
19678 deserializer.deserialize_struct("UploadError", VARIANTS, EnumVisitor)
19679 }
19680}
19681
19682impl ::serde::ser::Serialize for UploadError {
19683 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19684 use serde::ser::SerializeStruct;
19686 match self {
19687 UploadError::Path(x) => {
19688 let mut s = serializer.serialize_struct("UploadError", 3)?;
19690 s.serialize_field(".tag", "path")?;
19691 x.internal_serialize::<S>(&mut s)?;
19692 s.end()
19693 }
19694 UploadError::PropertiesError(x) => {
19695 let mut s = serializer.serialize_struct("UploadError", 2)?;
19697 s.serialize_field(".tag", "properties_error")?;
19698 s.serialize_field("properties_error", x)?;
19699 s.end()
19700 }
19701 UploadError::PayloadTooLarge => {
19702 let mut s = serializer.serialize_struct("UploadError", 1)?;
19704 s.serialize_field(".tag", "payload_too_large")?;
19705 s.end()
19706 }
19707 UploadError::ContentHashMismatch => {
19708 let mut s = serializer.serialize_struct("UploadError", 1)?;
19710 s.serialize_field(".tag", "content_hash_mismatch")?;
19711 s.end()
19712 }
19713 UploadError::EncryptionNotSupported => {
19714 let mut s = serializer.serialize_struct("UploadError", 1)?;
19716 s.serialize_field(".tag", "encryption_not_supported")?;
19717 s.end()
19718 }
19719 UploadError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
19720 }
19721 }
19722}
19723
19724impl ::std::error::Error for UploadError {
19725 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
19726 match self {
19727 UploadError::PropertiesError(inner) => Some(inner),
19728 _ => None,
19729 }
19730 }
19731}
19732
19733impl ::std::fmt::Display for UploadError {
19734 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19735 match self {
19736 UploadError::Path(inner) => write!(f, "Unable to save the uploaded contents to a file: {:?}", inner),
19737 UploadError::PropertiesError(inner) => write!(f, "The supplied property group is invalid. The file has uploaded without property groups: {}", inner),
19738 UploadError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
19739 UploadError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
19740 UploadError::EncryptionNotSupported => f.write_str("The file is required to be encrypted, which is not supported in our public API."),
19741 _ => write!(f, "{:?}", *self),
19742 }
19743 }
19744}
19745
19746#[derive(Debug, Clone, PartialEq, Eq)]
19747#[non_exhaustive] pub struct UploadSessionAppendArg {
19749 pub cursor: UploadSessionCursor,
19751 pub close: bool,
19755 pub content_hash: Option<Sha256HexHash>,
19759}
19760
19761impl UploadSessionAppendArg {
19762 pub fn new(cursor: UploadSessionCursor) -> Self {
19763 UploadSessionAppendArg {
19764 cursor,
19765 close: false,
19766 content_hash: None,
19767 }
19768 }
19769
19770 pub fn with_close(mut self, value: bool) -> Self {
19771 self.close = value;
19772 self
19773 }
19774
19775 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
19776 self.content_hash = Some(value);
19777 self
19778 }
19779}
19780
19781const UPLOAD_SESSION_APPEND_ARG_FIELDS: &[&str] = &["cursor",
19782 "close",
19783 "content_hash"];
19784impl UploadSessionAppendArg {
19785 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19786 map: V,
19787 ) -> Result<UploadSessionAppendArg, V::Error> {
19788 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19789 }
19790
19791 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19792 mut map: V,
19793 optional: bool,
19794 ) -> Result<Option<UploadSessionAppendArg>, V::Error> {
19795 let mut field_cursor = None;
19796 let mut field_close = None;
19797 let mut field_content_hash = None;
19798 let mut nothing = true;
19799 while let Some(key) = map.next_key::<&str>()? {
19800 nothing = false;
19801 match key {
19802 "cursor" => {
19803 if field_cursor.is_some() {
19804 return Err(::serde::de::Error::duplicate_field("cursor"));
19805 }
19806 field_cursor = Some(map.next_value()?);
19807 }
19808 "close" => {
19809 if field_close.is_some() {
19810 return Err(::serde::de::Error::duplicate_field("close"));
19811 }
19812 field_close = Some(map.next_value()?);
19813 }
19814 "content_hash" => {
19815 if field_content_hash.is_some() {
19816 return Err(::serde::de::Error::duplicate_field("content_hash"));
19817 }
19818 field_content_hash = Some(map.next_value()?);
19819 }
19820 _ => {
19821 map.next_value::<::serde_json::Value>()?;
19823 }
19824 }
19825 }
19826 if optional && nothing {
19827 return Ok(None);
19828 }
19829 let result = UploadSessionAppendArg {
19830 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
19831 close: field_close.unwrap_or(false),
19832 content_hash: field_content_hash.and_then(Option::flatten),
19833 };
19834 Ok(Some(result))
19835 }
19836
19837 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19838 &self,
19839 s: &mut S::SerializeStruct,
19840 ) -> Result<(), S::Error> {
19841 use serde::ser::SerializeStruct;
19842 s.serialize_field("cursor", &self.cursor)?;
19843 if self.close {
19844 s.serialize_field("close", &self.close)?;
19845 }
19846 if let Some(val) = &self.content_hash {
19847 s.serialize_field("content_hash", val)?;
19848 }
19849 Ok(())
19850 }
19851}
19852
19853impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendArg {
19854 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19855 use serde::de::{MapAccess, Visitor};
19857 struct StructVisitor;
19858 impl<'de> Visitor<'de> for StructVisitor {
19859 type Value = UploadSessionAppendArg;
19860 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19861 f.write_str("a UploadSessionAppendArg struct")
19862 }
19863 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19864 UploadSessionAppendArg::internal_deserialize(map)
19865 }
19866 }
19867 deserializer.deserialize_struct("UploadSessionAppendArg", UPLOAD_SESSION_APPEND_ARG_FIELDS, StructVisitor)
19868 }
19869}
19870
19871impl ::serde::ser::Serialize for UploadSessionAppendArg {
19872 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19873 use serde::ser::SerializeStruct;
19875 let mut s = serializer.serialize_struct("UploadSessionAppendArg", 3)?;
19876 self.internal_serialize::<S>(&mut s)?;
19877 s.end()
19878 }
19879}
19880
19881#[derive(Debug, Clone, PartialEq, Eq)]
19882#[non_exhaustive] pub struct UploadSessionAppendBatchArg {
19884 pub entries: Vec<UploadSessionAppendBatchArgEntry>,
19886 pub content_hash: Option<Sha256HexHash>,
19891}
19892
19893impl UploadSessionAppendBatchArg {
19894 pub fn new(entries: Vec<UploadSessionAppendBatchArgEntry>) -> Self {
19895 UploadSessionAppendBatchArg {
19896 entries,
19897 content_hash: None,
19898 }
19899 }
19900
19901 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
19902 self.content_hash = Some(value);
19903 self
19904 }
19905}
19906
19907const UPLOAD_SESSION_APPEND_BATCH_ARG_FIELDS: &[&str] = &["entries",
19908 "content_hash"];
19909impl UploadSessionAppendBatchArg {
19910 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19911 map: V,
19912 ) -> Result<UploadSessionAppendBatchArg, V::Error> {
19913 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19914 }
19915
19916 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19917 mut map: V,
19918 optional: bool,
19919 ) -> Result<Option<UploadSessionAppendBatchArg>, V::Error> {
19920 let mut field_entries = None;
19921 let mut field_content_hash = None;
19922 let mut nothing = true;
19923 while let Some(key) = map.next_key::<&str>()? {
19924 nothing = false;
19925 match key {
19926 "entries" => {
19927 if field_entries.is_some() {
19928 return Err(::serde::de::Error::duplicate_field("entries"));
19929 }
19930 field_entries = Some(map.next_value()?);
19931 }
19932 "content_hash" => {
19933 if field_content_hash.is_some() {
19934 return Err(::serde::de::Error::duplicate_field("content_hash"));
19935 }
19936 field_content_hash = Some(map.next_value()?);
19937 }
19938 _ => {
19939 map.next_value::<::serde_json::Value>()?;
19941 }
19942 }
19943 }
19944 if optional && nothing {
19945 return Ok(None);
19946 }
19947 let result = UploadSessionAppendBatchArg {
19948 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
19949 content_hash: field_content_hash.and_then(Option::flatten),
19950 };
19951 Ok(Some(result))
19952 }
19953
19954 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19955 &self,
19956 s: &mut S::SerializeStruct,
19957 ) -> Result<(), S::Error> {
19958 use serde::ser::SerializeStruct;
19959 s.serialize_field("entries", &self.entries)?;
19960 if let Some(val) = &self.content_hash {
19961 s.serialize_field("content_hash", val)?;
19962 }
19963 Ok(())
19964 }
19965}
19966
19967impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchArg {
19968 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19969 use serde::de::{MapAccess, Visitor};
19971 struct StructVisitor;
19972 impl<'de> Visitor<'de> for StructVisitor {
19973 type Value = UploadSessionAppendBatchArg;
19974 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19975 f.write_str("a UploadSessionAppendBatchArg struct")
19976 }
19977 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19978 UploadSessionAppendBatchArg::internal_deserialize(map)
19979 }
19980 }
19981 deserializer.deserialize_struct("UploadSessionAppendBatchArg", UPLOAD_SESSION_APPEND_BATCH_ARG_FIELDS, StructVisitor)
19982 }
19983}
19984
19985impl ::serde::ser::Serialize for UploadSessionAppendBatchArg {
19986 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19987 use serde::ser::SerializeStruct;
19989 let mut s = serializer.serialize_struct("UploadSessionAppendBatchArg", 2)?;
19990 self.internal_serialize::<S>(&mut s)?;
19991 s.end()
19992 }
19993}
19994
19995#[derive(Debug, Clone, PartialEq, Eq)]
19996#[non_exhaustive] pub struct UploadSessionAppendBatchArgEntry {
19998 pub cursor: UploadSessionCursor,
20000 pub length: u64,
20003 pub close: bool,
20007}
20008
20009impl UploadSessionAppendBatchArgEntry {
20010 pub fn new(cursor: UploadSessionCursor, length: u64) -> Self {
20011 UploadSessionAppendBatchArgEntry {
20012 cursor,
20013 length,
20014 close: false,
20015 }
20016 }
20017
20018 pub fn with_close(mut self, value: bool) -> Self {
20019 self.close = value;
20020 self
20021 }
20022}
20023
20024const UPLOAD_SESSION_APPEND_BATCH_ARG_ENTRY_FIELDS: &[&str] = &["cursor",
20025 "length",
20026 "close"];
20027impl UploadSessionAppendBatchArgEntry {
20028 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20029 map: V,
20030 ) -> Result<UploadSessionAppendBatchArgEntry, V::Error> {
20031 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20032 }
20033
20034 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20035 mut map: V,
20036 optional: bool,
20037 ) -> Result<Option<UploadSessionAppendBatchArgEntry>, V::Error> {
20038 let mut field_cursor = None;
20039 let mut field_length = None;
20040 let mut field_close = None;
20041 let mut nothing = true;
20042 while let Some(key) = map.next_key::<&str>()? {
20043 nothing = false;
20044 match key {
20045 "cursor" => {
20046 if field_cursor.is_some() {
20047 return Err(::serde::de::Error::duplicate_field("cursor"));
20048 }
20049 field_cursor = Some(map.next_value()?);
20050 }
20051 "length" => {
20052 if field_length.is_some() {
20053 return Err(::serde::de::Error::duplicate_field("length"));
20054 }
20055 field_length = Some(map.next_value()?);
20056 }
20057 "close" => {
20058 if field_close.is_some() {
20059 return Err(::serde::de::Error::duplicate_field("close"));
20060 }
20061 field_close = Some(map.next_value()?);
20062 }
20063 _ => {
20064 map.next_value::<::serde_json::Value>()?;
20066 }
20067 }
20068 }
20069 if optional && nothing {
20070 return Ok(None);
20071 }
20072 let result = UploadSessionAppendBatchArgEntry {
20073 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
20074 length: field_length.ok_or_else(|| ::serde::de::Error::missing_field("length"))?,
20075 close: field_close.unwrap_or(false),
20076 };
20077 Ok(Some(result))
20078 }
20079
20080 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20081 &self,
20082 s: &mut S::SerializeStruct,
20083 ) -> Result<(), S::Error> {
20084 use serde::ser::SerializeStruct;
20085 s.serialize_field("cursor", &self.cursor)?;
20086 s.serialize_field("length", &self.length)?;
20087 if self.close {
20088 s.serialize_field("close", &self.close)?;
20089 }
20090 Ok(())
20091 }
20092}
20093
20094impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchArgEntry {
20095 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20096 use serde::de::{MapAccess, Visitor};
20098 struct StructVisitor;
20099 impl<'de> Visitor<'de> for StructVisitor {
20100 type Value = UploadSessionAppendBatchArgEntry;
20101 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20102 f.write_str("a UploadSessionAppendBatchArgEntry struct")
20103 }
20104 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20105 UploadSessionAppendBatchArgEntry::internal_deserialize(map)
20106 }
20107 }
20108 deserializer.deserialize_struct("UploadSessionAppendBatchArgEntry", UPLOAD_SESSION_APPEND_BATCH_ARG_ENTRY_FIELDS, StructVisitor)
20109 }
20110}
20111
20112impl ::serde::ser::Serialize for UploadSessionAppendBatchArgEntry {
20113 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20114 use serde::ser::SerializeStruct;
20116 let mut s = serializer.serialize_struct("UploadSessionAppendBatchArgEntry", 3)?;
20117 self.internal_serialize::<S>(&mut s)?;
20118 s.end()
20119 }
20120}
20121
20122#[derive(Debug, Clone, PartialEq, Eq)]
20123#[non_exhaustive] pub enum UploadSessionAppendBatchEntryError {
20125 NotFound,
20127 IncorrectOffset(UploadSessionOffsetError),
20131 Closed,
20134 TooLarge,
20137 ConcurrentSessionInvalidOffset,
20139 ConcurrentSessionInvalidDataSize,
20142 Other,
20145}
20146
20147impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchEntryError {
20148 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20149 use serde::de::{self, MapAccess, Visitor};
20151 struct EnumVisitor;
20152 impl<'de> Visitor<'de> for EnumVisitor {
20153 type Value = UploadSessionAppendBatchEntryError;
20154 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20155 f.write_str("a UploadSessionAppendBatchEntryError structure")
20156 }
20157 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20158 let tag: &str = match map.next_key()? {
20159 Some(".tag") => map.next_value()?,
20160 _ => return Err(de::Error::missing_field(".tag"))
20161 };
20162 let value = match tag {
20163 "not_found" => UploadSessionAppendBatchEntryError::NotFound,
20164 "incorrect_offset" => UploadSessionAppendBatchEntryError::IncorrectOffset(UploadSessionOffsetError::internal_deserialize(&mut map)?),
20165 "closed" => UploadSessionAppendBatchEntryError::Closed,
20166 "too_large" => UploadSessionAppendBatchEntryError::TooLarge,
20167 "concurrent_session_invalid_offset" => UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidOffset,
20168 "concurrent_session_invalid_data_size" => UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidDataSize,
20169 _ => UploadSessionAppendBatchEntryError::Other,
20170 };
20171 crate::eat_json_fields(&mut map)?;
20172 Ok(value)
20173 }
20174 }
20175 const VARIANTS: &[&str] = &["not_found",
20176 "incorrect_offset",
20177 "closed",
20178 "too_large",
20179 "concurrent_session_invalid_offset",
20180 "concurrent_session_invalid_data_size",
20181 "other"];
20182 deserializer.deserialize_struct("UploadSessionAppendBatchEntryError", VARIANTS, EnumVisitor)
20183 }
20184}
20185
20186impl ::serde::ser::Serialize for UploadSessionAppendBatchEntryError {
20187 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20188 use serde::ser::SerializeStruct;
20190 match self {
20191 UploadSessionAppendBatchEntryError::NotFound => {
20192 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20194 s.serialize_field(".tag", "not_found")?;
20195 s.end()
20196 }
20197 UploadSessionAppendBatchEntryError::IncorrectOffset(x) => {
20198 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 2)?;
20200 s.serialize_field(".tag", "incorrect_offset")?;
20201 x.internal_serialize::<S>(&mut s)?;
20202 s.end()
20203 }
20204 UploadSessionAppendBatchEntryError::Closed => {
20205 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20207 s.serialize_field(".tag", "closed")?;
20208 s.end()
20209 }
20210 UploadSessionAppendBatchEntryError::TooLarge => {
20211 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20213 s.serialize_field(".tag", "too_large")?;
20214 s.end()
20215 }
20216 UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidOffset => {
20217 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20219 s.serialize_field(".tag", "concurrent_session_invalid_offset")?;
20220 s.end()
20221 }
20222 UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidDataSize => {
20223 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20225 s.serialize_field(".tag", "concurrent_session_invalid_data_size")?;
20226 s.end()
20227 }
20228 UploadSessionAppendBatchEntryError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
20229 }
20230 }
20231}
20232
20233impl ::std::error::Error for UploadSessionAppendBatchEntryError {
20234}
20235
20236impl ::std::fmt::Display for UploadSessionAppendBatchEntryError {
20237 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20238 match self {
20239 UploadSessionAppendBatchEntryError::NotFound => f.write_str("The upload session ID was not found or has expired. Upload sessions are valid for 7 days."),
20240 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),
20241 UploadSessionAppendBatchEntryError::Closed => f.write_str("You are attempting to append data to an upload session that has already been closed (i.e. committed)."),
20242 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)."),
20243 UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidOffset => f.write_str("For concurrent upload sessions, offset needs to be multiple of 2^22 (4,194,304) bytes."),
20244 UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidDataSize => f.write_str("For concurrent upload sessions, only chunks with size multiple of 2^22 (4,194,304) bytes can be uploaded."),
20245 _ => write!(f, "{:?}", *self),
20246 }
20247 }
20248}
20249
20250#[derive(Debug, Clone, PartialEq, Eq)]
20251#[non_exhaustive] pub enum UploadSessionAppendBatchError {
20253 PayloadTooLarge,
20255 ContentHashMismatch,
20258 LengthMismatch,
20261 Other,
20264}
20265
20266impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchError {
20267 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20268 use serde::de::{self, MapAccess, Visitor};
20270 struct EnumVisitor;
20271 impl<'de> Visitor<'de> for EnumVisitor {
20272 type Value = UploadSessionAppendBatchError;
20273 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20274 f.write_str("a UploadSessionAppendBatchError structure")
20275 }
20276 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20277 let tag: &str = match map.next_key()? {
20278 Some(".tag") => map.next_value()?,
20279 _ => return Err(de::Error::missing_field(".tag"))
20280 };
20281 let value = match tag {
20282 "payload_too_large" => UploadSessionAppendBatchError::PayloadTooLarge,
20283 "content_hash_mismatch" => UploadSessionAppendBatchError::ContentHashMismatch,
20284 "length_mismatch" => UploadSessionAppendBatchError::LengthMismatch,
20285 _ => UploadSessionAppendBatchError::Other,
20286 };
20287 crate::eat_json_fields(&mut map)?;
20288 Ok(value)
20289 }
20290 }
20291 const VARIANTS: &[&str] = &["payload_too_large",
20292 "content_hash_mismatch",
20293 "length_mismatch",
20294 "other"];
20295 deserializer.deserialize_struct("UploadSessionAppendBatchError", VARIANTS, EnumVisitor)
20296 }
20297}
20298
20299impl ::serde::ser::Serialize for UploadSessionAppendBatchError {
20300 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20301 use serde::ser::SerializeStruct;
20303 match self {
20304 UploadSessionAppendBatchError::PayloadTooLarge => {
20305 let mut s = serializer.serialize_struct("UploadSessionAppendBatchError", 1)?;
20307 s.serialize_field(".tag", "payload_too_large")?;
20308 s.end()
20309 }
20310 UploadSessionAppendBatchError::ContentHashMismatch => {
20311 let mut s = serializer.serialize_struct("UploadSessionAppendBatchError", 1)?;
20313 s.serialize_field(".tag", "content_hash_mismatch")?;
20314 s.end()
20315 }
20316 UploadSessionAppendBatchError::LengthMismatch => {
20317 let mut s = serializer.serialize_struct("UploadSessionAppendBatchError", 1)?;
20319 s.serialize_field(".tag", "length_mismatch")?;
20320 s.end()
20321 }
20322 UploadSessionAppendBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
20323 }
20324 }
20325}
20326
20327impl ::std::error::Error for UploadSessionAppendBatchError {
20328}
20329
20330impl ::std::fmt::Display for UploadSessionAppendBatchError {
20331 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20332 match self {
20333 UploadSessionAppendBatchError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
20334 UploadSessionAppendBatchError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
20335 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."),
20336 _ => write!(f, "{:?}", *self),
20337 }
20338 }
20339}
20340
20341#[derive(Debug, Clone, PartialEq, Eq)]
20342#[non_exhaustive] pub struct UploadSessionAppendBatchResult {
20344 pub entries: Vec<UploadSessionAppendBatchResultEntry>,
20348}
20349
20350impl UploadSessionAppendBatchResult {
20351 pub fn new(entries: Vec<UploadSessionAppendBatchResultEntry>) -> Self {
20352 UploadSessionAppendBatchResult {
20353 entries,
20354 }
20355 }
20356}
20357
20358const UPLOAD_SESSION_APPEND_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
20359impl UploadSessionAppendBatchResult {
20360 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20361 map: V,
20362 ) -> Result<UploadSessionAppendBatchResult, V::Error> {
20363 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20364 }
20365
20366 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20367 mut map: V,
20368 optional: bool,
20369 ) -> Result<Option<UploadSessionAppendBatchResult>, V::Error> {
20370 let mut field_entries = None;
20371 let mut nothing = true;
20372 while let Some(key) = map.next_key::<&str>()? {
20373 nothing = false;
20374 match key {
20375 "entries" => {
20376 if field_entries.is_some() {
20377 return Err(::serde::de::Error::duplicate_field("entries"));
20378 }
20379 field_entries = Some(map.next_value()?);
20380 }
20381 _ => {
20382 map.next_value::<::serde_json::Value>()?;
20384 }
20385 }
20386 }
20387 if optional && nothing {
20388 return Ok(None);
20389 }
20390 let result = UploadSessionAppendBatchResult {
20391 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
20392 };
20393 Ok(Some(result))
20394 }
20395
20396 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20397 &self,
20398 s: &mut S::SerializeStruct,
20399 ) -> Result<(), S::Error> {
20400 use serde::ser::SerializeStruct;
20401 s.serialize_field("entries", &self.entries)?;
20402 Ok(())
20403 }
20404}
20405
20406impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchResult {
20407 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20408 use serde::de::{MapAccess, Visitor};
20410 struct StructVisitor;
20411 impl<'de> Visitor<'de> for StructVisitor {
20412 type Value = UploadSessionAppendBatchResult;
20413 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20414 f.write_str("a UploadSessionAppendBatchResult struct")
20415 }
20416 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20417 UploadSessionAppendBatchResult::internal_deserialize(map)
20418 }
20419 }
20420 deserializer.deserialize_struct("UploadSessionAppendBatchResult", UPLOAD_SESSION_APPEND_BATCH_RESULT_FIELDS, StructVisitor)
20421 }
20422}
20423
20424impl ::serde::ser::Serialize for UploadSessionAppendBatchResult {
20425 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20426 use serde::ser::SerializeStruct;
20428 let mut s = serializer.serialize_struct("UploadSessionAppendBatchResult", 1)?;
20429 self.internal_serialize::<S>(&mut s)?;
20430 s.end()
20431 }
20432}
20433
20434#[derive(Debug, Clone, PartialEq, Eq)]
20435pub enum UploadSessionAppendBatchResultEntry {
20436 Success,
20437 Failure(UploadSessionAppendBatchEntryError),
20438}
20439
20440impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchResultEntry {
20441 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20442 use serde::de::{self, MapAccess, Visitor};
20444 struct EnumVisitor;
20445 impl<'de> Visitor<'de> for EnumVisitor {
20446 type Value = UploadSessionAppendBatchResultEntry;
20447 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20448 f.write_str("a UploadSessionAppendBatchResultEntry structure")
20449 }
20450 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20451 let tag: &str = match map.next_key()? {
20452 Some(".tag") => map.next_value()?,
20453 _ => return Err(de::Error::missing_field(".tag"))
20454 };
20455 let value = match tag {
20456 "success" => UploadSessionAppendBatchResultEntry::Success,
20457 "failure" => {
20458 match map.next_key()? {
20459 Some("failure") => UploadSessionAppendBatchResultEntry::Failure(map.next_value()?),
20460 None => return Err(de::Error::missing_field("failure")),
20461 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
20462 }
20463 }
20464 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
20465 };
20466 crate::eat_json_fields(&mut map)?;
20467 Ok(value)
20468 }
20469 }
20470 const VARIANTS: &[&str] = &["success",
20471 "failure"];
20472 deserializer.deserialize_struct("UploadSessionAppendBatchResultEntry", VARIANTS, EnumVisitor)
20473 }
20474}
20475
20476impl ::serde::ser::Serialize for UploadSessionAppendBatchResultEntry {
20477 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20478 use serde::ser::SerializeStruct;
20480 match self {
20481 UploadSessionAppendBatchResultEntry::Success => {
20482 let mut s = serializer.serialize_struct("UploadSessionAppendBatchResultEntry", 1)?;
20484 s.serialize_field(".tag", "success")?;
20485 s.end()
20486 }
20487 UploadSessionAppendBatchResultEntry::Failure(x) => {
20488 let mut s = serializer.serialize_struct("UploadSessionAppendBatchResultEntry", 2)?;
20490 s.serialize_field(".tag", "failure")?;
20491 s.serialize_field("failure", x)?;
20492 s.end()
20493 }
20494 }
20495 }
20496}
20497
20498#[derive(Debug, Clone, PartialEq, Eq)]
20499#[non_exhaustive] pub enum UploadSessionAppendError {
20501 NotFound,
20503 IncorrectOffset(UploadSessionOffsetError),
20507 Closed,
20510 TooLarge,
20513 ConcurrentSessionInvalidOffset,
20515 ConcurrentSessionInvalidDataSize,
20518 PayloadTooLarge,
20520 ContentHashMismatch,
20523 Other,
20526}
20527
20528impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendError {
20529 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20530 use serde::de::{self, MapAccess, Visitor};
20532 struct EnumVisitor;
20533 impl<'de> Visitor<'de> for EnumVisitor {
20534 type Value = UploadSessionAppendError;
20535 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20536 f.write_str("a UploadSessionAppendError structure")
20537 }
20538 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20539 let tag: &str = match map.next_key()? {
20540 Some(".tag") => map.next_value()?,
20541 _ => return Err(de::Error::missing_field(".tag"))
20542 };
20543 let value = match tag {
20544 "not_found" => UploadSessionAppendError::NotFound,
20545 "incorrect_offset" => UploadSessionAppendError::IncorrectOffset(UploadSessionOffsetError::internal_deserialize(&mut map)?),
20546 "closed" => UploadSessionAppendError::Closed,
20547 "too_large" => UploadSessionAppendError::TooLarge,
20548 "concurrent_session_invalid_offset" => UploadSessionAppendError::ConcurrentSessionInvalidOffset,
20549 "concurrent_session_invalid_data_size" => UploadSessionAppendError::ConcurrentSessionInvalidDataSize,
20550 "payload_too_large" => UploadSessionAppendError::PayloadTooLarge,
20551 "content_hash_mismatch" => UploadSessionAppendError::ContentHashMismatch,
20552 _ => UploadSessionAppendError::Other,
20553 };
20554 crate::eat_json_fields(&mut map)?;
20555 Ok(value)
20556 }
20557 }
20558 const VARIANTS: &[&str] = &["not_found",
20559 "incorrect_offset",
20560 "closed",
20561 "too_large",
20562 "concurrent_session_invalid_offset",
20563 "concurrent_session_invalid_data_size",
20564 "payload_too_large",
20565 "content_hash_mismatch",
20566 "other"];
20567 deserializer.deserialize_struct("UploadSessionAppendError", VARIANTS, EnumVisitor)
20568 }
20569}
20570
20571impl ::serde::ser::Serialize for UploadSessionAppendError {
20572 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20573 use serde::ser::SerializeStruct;
20575 match self {
20576 UploadSessionAppendError::NotFound => {
20577 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20579 s.serialize_field(".tag", "not_found")?;
20580 s.end()
20581 }
20582 UploadSessionAppendError::IncorrectOffset(x) => {
20583 let mut s = serializer.serialize_struct("UploadSessionAppendError", 2)?;
20585 s.serialize_field(".tag", "incorrect_offset")?;
20586 x.internal_serialize::<S>(&mut s)?;
20587 s.end()
20588 }
20589 UploadSessionAppendError::Closed => {
20590 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20592 s.serialize_field(".tag", "closed")?;
20593 s.end()
20594 }
20595 UploadSessionAppendError::TooLarge => {
20596 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20598 s.serialize_field(".tag", "too_large")?;
20599 s.end()
20600 }
20601 UploadSessionAppendError::ConcurrentSessionInvalidOffset => {
20602 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20604 s.serialize_field(".tag", "concurrent_session_invalid_offset")?;
20605 s.end()
20606 }
20607 UploadSessionAppendError::ConcurrentSessionInvalidDataSize => {
20608 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20610 s.serialize_field(".tag", "concurrent_session_invalid_data_size")?;
20611 s.end()
20612 }
20613 UploadSessionAppendError::PayloadTooLarge => {
20614 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20616 s.serialize_field(".tag", "payload_too_large")?;
20617 s.end()
20618 }
20619 UploadSessionAppendError::ContentHashMismatch => {
20620 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20622 s.serialize_field(".tag", "content_hash_mismatch")?;
20623 s.end()
20624 }
20625 UploadSessionAppendError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
20626 }
20627 }
20628}
20629
20630impl ::std::error::Error for UploadSessionAppendError {
20631}
20632
20633impl ::std::fmt::Display for UploadSessionAppendError {
20634 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20635 match self {
20636 UploadSessionAppendError::NotFound => f.write_str("The upload session ID was not found or has expired. Upload sessions are valid for 7 days."),
20637 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),
20638 UploadSessionAppendError::Closed => f.write_str("You are attempting to append data to an upload session that has already been closed (i.e. committed)."),
20639 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)."),
20640 UploadSessionAppendError::ConcurrentSessionInvalidOffset => f.write_str("For concurrent upload sessions, offset needs to be multiple of 2^22 (4,194,304) bytes."),
20641 UploadSessionAppendError::ConcurrentSessionInvalidDataSize => f.write_str("For concurrent upload sessions, only chunks with size multiple of 2^22 (4,194,304) bytes can be uploaded."),
20642 UploadSessionAppendError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
20643 UploadSessionAppendError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
20644 _ => write!(f, "{:?}", *self),
20645 }
20646 }
20647}
20648
20649#[derive(Debug, Clone, PartialEq, Eq)]
20650#[non_exhaustive] pub struct UploadSessionCursor {
20652 pub session_id: String,
20655 pub offset: u64,
20658}
20659
20660impl UploadSessionCursor {
20661 pub fn new(session_id: String, offset: u64) -> Self {
20662 UploadSessionCursor {
20663 session_id,
20664 offset,
20665 }
20666 }
20667}
20668
20669const UPLOAD_SESSION_CURSOR_FIELDS: &[&str] = &["session_id",
20670 "offset"];
20671impl UploadSessionCursor {
20672 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20673 map: V,
20674 ) -> Result<UploadSessionCursor, V::Error> {
20675 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20676 }
20677
20678 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20679 mut map: V,
20680 optional: bool,
20681 ) -> Result<Option<UploadSessionCursor>, V::Error> {
20682 let mut field_session_id = None;
20683 let mut field_offset = None;
20684 let mut nothing = true;
20685 while let Some(key) = map.next_key::<&str>()? {
20686 nothing = false;
20687 match key {
20688 "session_id" => {
20689 if field_session_id.is_some() {
20690 return Err(::serde::de::Error::duplicate_field("session_id"));
20691 }
20692 field_session_id = Some(map.next_value()?);
20693 }
20694 "offset" => {
20695 if field_offset.is_some() {
20696 return Err(::serde::de::Error::duplicate_field("offset"));
20697 }
20698 field_offset = Some(map.next_value()?);
20699 }
20700 _ => {
20701 map.next_value::<::serde_json::Value>()?;
20703 }
20704 }
20705 }
20706 if optional && nothing {
20707 return Ok(None);
20708 }
20709 let result = UploadSessionCursor {
20710 session_id: field_session_id.ok_or_else(|| ::serde::de::Error::missing_field("session_id"))?,
20711 offset: field_offset.ok_or_else(|| ::serde::de::Error::missing_field("offset"))?,
20712 };
20713 Ok(Some(result))
20714 }
20715
20716 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20717 &self,
20718 s: &mut S::SerializeStruct,
20719 ) -> Result<(), S::Error> {
20720 use serde::ser::SerializeStruct;
20721 s.serialize_field("session_id", &self.session_id)?;
20722 s.serialize_field("offset", &self.offset)?;
20723 Ok(())
20724 }
20725}
20726
20727impl<'de> ::serde::de::Deserialize<'de> for UploadSessionCursor {
20728 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20729 use serde::de::{MapAccess, Visitor};
20731 struct StructVisitor;
20732 impl<'de> Visitor<'de> for StructVisitor {
20733 type Value = UploadSessionCursor;
20734 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20735 f.write_str("a UploadSessionCursor struct")
20736 }
20737 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20738 UploadSessionCursor::internal_deserialize(map)
20739 }
20740 }
20741 deserializer.deserialize_struct("UploadSessionCursor", UPLOAD_SESSION_CURSOR_FIELDS, StructVisitor)
20742 }
20743}
20744
20745impl ::serde::ser::Serialize for UploadSessionCursor {
20746 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20747 use serde::ser::SerializeStruct;
20749 let mut s = serializer.serialize_struct("UploadSessionCursor", 2)?;
20750 self.internal_serialize::<S>(&mut s)?;
20751 s.end()
20752 }
20753}
20754
20755#[derive(Debug, Clone, PartialEq, Eq)]
20756#[non_exhaustive] pub struct UploadSessionFinishArg {
20758 pub cursor: UploadSessionCursor,
20760 pub commit: CommitInfo,
20762 pub content_hash: Option<Sha256HexHash>,
20766}
20767
20768impl UploadSessionFinishArg {
20769 pub fn new(cursor: UploadSessionCursor, commit: CommitInfo) -> Self {
20770 UploadSessionFinishArg {
20771 cursor,
20772 commit,
20773 content_hash: None,
20774 }
20775 }
20776
20777 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
20778 self.content_hash = Some(value);
20779 self
20780 }
20781}
20782
20783const UPLOAD_SESSION_FINISH_ARG_FIELDS: &[&str] = &["cursor",
20784 "commit",
20785 "content_hash"];
20786impl UploadSessionFinishArg {
20787 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20788 map: V,
20789 ) -> Result<UploadSessionFinishArg, V::Error> {
20790 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20791 }
20792
20793 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20794 mut map: V,
20795 optional: bool,
20796 ) -> Result<Option<UploadSessionFinishArg>, V::Error> {
20797 let mut field_cursor = None;
20798 let mut field_commit = None;
20799 let mut field_content_hash = None;
20800 let mut nothing = true;
20801 while let Some(key) = map.next_key::<&str>()? {
20802 nothing = false;
20803 match key {
20804 "cursor" => {
20805 if field_cursor.is_some() {
20806 return Err(::serde::de::Error::duplicate_field("cursor"));
20807 }
20808 field_cursor = Some(map.next_value()?);
20809 }
20810 "commit" => {
20811 if field_commit.is_some() {
20812 return Err(::serde::de::Error::duplicate_field("commit"));
20813 }
20814 field_commit = Some(map.next_value()?);
20815 }
20816 "content_hash" => {
20817 if field_content_hash.is_some() {
20818 return Err(::serde::de::Error::duplicate_field("content_hash"));
20819 }
20820 field_content_hash = Some(map.next_value()?);
20821 }
20822 _ => {
20823 map.next_value::<::serde_json::Value>()?;
20825 }
20826 }
20827 }
20828 if optional && nothing {
20829 return Ok(None);
20830 }
20831 let result = UploadSessionFinishArg {
20832 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
20833 commit: field_commit.ok_or_else(|| ::serde::de::Error::missing_field("commit"))?,
20834 content_hash: field_content_hash.and_then(Option::flatten),
20835 };
20836 Ok(Some(result))
20837 }
20838
20839 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20840 &self,
20841 s: &mut S::SerializeStruct,
20842 ) -> Result<(), S::Error> {
20843 use serde::ser::SerializeStruct;
20844 s.serialize_field("cursor", &self.cursor)?;
20845 s.serialize_field("commit", &self.commit)?;
20846 if let Some(val) = &self.content_hash {
20847 s.serialize_field("content_hash", val)?;
20848 }
20849 Ok(())
20850 }
20851}
20852
20853impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishArg {
20854 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20855 use serde::de::{MapAccess, Visitor};
20857 struct StructVisitor;
20858 impl<'de> Visitor<'de> for StructVisitor {
20859 type Value = UploadSessionFinishArg;
20860 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20861 f.write_str("a UploadSessionFinishArg struct")
20862 }
20863 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20864 UploadSessionFinishArg::internal_deserialize(map)
20865 }
20866 }
20867 deserializer.deserialize_struct("UploadSessionFinishArg", UPLOAD_SESSION_FINISH_ARG_FIELDS, StructVisitor)
20868 }
20869}
20870
20871impl ::serde::ser::Serialize for UploadSessionFinishArg {
20872 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20873 use serde::ser::SerializeStruct;
20875 let mut s = serializer.serialize_struct("UploadSessionFinishArg", 3)?;
20876 self.internal_serialize::<S>(&mut s)?;
20877 s.end()
20878 }
20879}
20880
20881#[derive(Debug, Clone, PartialEq, Eq)]
20882#[non_exhaustive] pub struct UploadSessionFinishBatchArg {
20884 pub entries: Vec<UploadSessionFinishArg>,
20886}
20887
20888impl UploadSessionFinishBatchArg {
20889 pub fn new(entries: Vec<UploadSessionFinishArg>) -> Self {
20890 UploadSessionFinishBatchArg {
20891 entries,
20892 }
20893 }
20894}
20895
20896const UPLOAD_SESSION_FINISH_BATCH_ARG_FIELDS: &[&str] = &["entries"];
20897impl UploadSessionFinishBatchArg {
20898 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20899 map: V,
20900 ) -> Result<UploadSessionFinishBatchArg, V::Error> {
20901 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20902 }
20903
20904 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20905 mut map: V,
20906 optional: bool,
20907 ) -> Result<Option<UploadSessionFinishBatchArg>, V::Error> {
20908 let mut field_entries = None;
20909 let mut nothing = true;
20910 while let Some(key) = map.next_key::<&str>()? {
20911 nothing = false;
20912 match key {
20913 "entries" => {
20914 if field_entries.is_some() {
20915 return Err(::serde::de::Error::duplicate_field("entries"));
20916 }
20917 field_entries = Some(map.next_value()?);
20918 }
20919 _ => {
20920 map.next_value::<::serde_json::Value>()?;
20922 }
20923 }
20924 }
20925 if optional && nothing {
20926 return Ok(None);
20927 }
20928 let result = UploadSessionFinishBatchArg {
20929 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
20930 };
20931 Ok(Some(result))
20932 }
20933
20934 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20935 &self,
20936 s: &mut S::SerializeStruct,
20937 ) -> Result<(), S::Error> {
20938 use serde::ser::SerializeStruct;
20939 s.serialize_field("entries", &self.entries)?;
20940 Ok(())
20941 }
20942}
20943
20944impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchArg {
20945 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20946 use serde::de::{MapAccess, Visitor};
20948 struct StructVisitor;
20949 impl<'de> Visitor<'de> for StructVisitor {
20950 type Value = UploadSessionFinishBatchArg;
20951 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20952 f.write_str("a UploadSessionFinishBatchArg struct")
20953 }
20954 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20955 UploadSessionFinishBatchArg::internal_deserialize(map)
20956 }
20957 }
20958 deserializer.deserialize_struct("UploadSessionFinishBatchArg", UPLOAD_SESSION_FINISH_BATCH_ARG_FIELDS, StructVisitor)
20959 }
20960}
20961
20962impl ::serde::ser::Serialize for UploadSessionFinishBatchArg {
20963 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20964 use serde::ser::SerializeStruct;
20966 let mut s = serializer.serialize_struct("UploadSessionFinishBatchArg", 1)?;
20967 self.internal_serialize::<S>(&mut s)?;
20968 s.end()
20969 }
20970}
20971
20972#[derive(Debug, Clone, PartialEq)]
20973pub enum UploadSessionFinishBatchJobStatus {
20974 InProgress,
20976 Complete(UploadSessionFinishBatchResult),
20979}
20980
20981impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchJobStatus {
20982 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20983 use serde::de::{self, MapAccess, Visitor};
20985 struct EnumVisitor;
20986 impl<'de> Visitor<'de> for EnumVisitor {
20987 type Value = UploadSessionFinishBatchJobStatus;
20988 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20989 f.write_str("a UploadSessionFinishBatchJobStatus structure")
20990 }
20991 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20992 let tag: &str = match map.next_key()? {
20993 Some(".tag") => map.next_value()?,
20994 _ => return Err(de::Error::missing_field(".tag"))
20995 };
20996 let value = match tag {
20997 "in_progress" => UploadSessionFinishBatchJobStatus::InProgress,
20998 "complete" => UploadSessionFinishBatchJobStatus::Complete(UploadSessionFinishBatchResult::internal_deserialize(&mut map)?),
20999 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
21000 };
21001 crate::eat_json_fields(&mut map)?;
21002 Ok(value)
21003 }
21004 }
21005 const VARIANTS: &[&str] = &["in_progress",
21006 "complete"];
21007 deserializer.deserialize_struct("UploadSessionFinishBatchJobStatus", VARIANTS, EnumVisitor)
21008 }
21009}
21010
21011impl ::serde::ser::Serialize for UploadSessionFinishBatchJobStatus {
21012 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21013 use serde::ser::SerializeStruct;
21015 match self {
21016 UploadSessionFinishBatchJobStatus::InProgress => {
21017 let mut s = serializer.serialize_struct("UploadSessionFinishBatchJobStatus", 1)?;
21019 s.serialize_field(".tag", "in_progress")?;
21020 s.end()
21021 }
21022 UploadSessionFinishBatchJobStatus::Complete(x) => {
21023 let mut s = serializer.serialize_struct("UploadSessionFinishBatchJobStatus", 2)?;
21025 s.serialize_field(".tag", "complete")?;
21026 x.internal_serialize::<S>(&mut s)?;
21027 s.end()
21028 }
21029 }
21030 }
21031}
21032
21033impl From<crate::types::dbx_async::PollResultBase> for UploadSessionFinishBatchJobStatus {
21035 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
21036 match parent {
21037 crate::types::dbx_async::PollResultBase::InProgress => UploadSessionFinishBatchJobStatus::InProgress,
21038 }
21039 }
21040}
21041#[derive(Debug, Clone, PartialEq)]
21044#[non_exhaustive] pub enum UploadSessionFinishBatchLaunch {
21046 AsyncJobId(crate::types::dbx_async::AsyncJobId),
21049 Complete(UploadSessionFinishBatchResult),
21050 Other,
21053}
21054
21055impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchLaunch {
21056 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21057 use serde::de::{self, MapAccess, Visitor};
21059 struct EnumVisitor;
21060 impl<'de> Visitor<'de> for EnumVisitor {
21061 type Value = UploadSessionFinishBatchLaunch;
21062 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21063 f.write_str("a UploadSessionFinishBatchLaunch structure")
21064 }
21065 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21066 let tag: &str = match map.next_key()? {
21067 Some(".tag") => map.next_value()?,
21068 _ => return Err(de::Error::missing_field(".tag"))
21069 };
21070 let value = match tag {
21071 "async_job_id" => {
21072 match map.next_key()? {
21073 Some("async_job_id") => UploadSessionFinishBatchLaunch::AsyncJobId(map.next_value()?),
21074 None => return Err(de::Error::missing_field("async_job_id")),
21075 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21076 }
21077 }
21078 "complete" => UploadSessionFinishBatchLaunch::Complete(UploadSessionFinishBatchResult::internal_deserialize(&mut map)?),
21079 _ => UploadSessionFinishBatchLaunch::Other,
21080 };
21081 crate::eat_json_fields(&mut map)?;
21082 Ok(value)
21083 }
21084 }
21085 const VARIANTS: &[&str] = &["async_job_id",
21086 "complete",
21087 "other"];
21088 deserializer.deserialize_struct("UploadSessionFinishBatchLaunch", VARIANTS, EnumVisitor)
21089 }
21090}
21091
21092impl ::serde::ser::Serialize for UploadSessionFinishBatchLaunch {
21093 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21094 use serde::ser::SerializeStruct;
21096 match self {
21097 UploadSessionFinishBatchLaunch::AsyncJobId(x) => {
21098 let mut s = serializer.serialize_struct("UploadSessionFinishBatchLaunch", 2)?;
21100 s.serialize_field(".tag", "async_job_id")?;
21101 s.serialize_field("async_job_id", x)?;
21102 s.end()
21103 }
21104 UploadSessionFinishBatchLaunch::Complete(x) => {
21105 let mut s = serializer.serialize_struct("UploadSessionFinishBatchLaunch", 2)?;
21107 s.serialize_field(".tag", "complete")?;
21108 x.internal_serialize::<S>(&mut s)?;
21109 s.end()
21110 }
21111 UploadSessionFinishBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
21112 }
21113 }
21114}
21115
21116impl From<crate::types::dbx_async::LaunchResultBase> for UploadSessionFinishBatchLaunch {
21118 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
21119 match parent {
21120 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => UploadSessionFinishBatchLaunch::AsyncJobId(x),
21121 }
21122 }
21123}
21124#[derive(Debug, Clone, PartialEq)]
21125#[non_exhaustive] pub struct UploadSessionFinishBatchResult {
21127 pub entries: Vec<UploadSessionFinishBatchResultEntry>,
21131}
21132
21133impl UploadSessionFinishBatchResult {
21134 pub fn new(entries: Vec<UploadSessionFinishBatchResultEntry>) -> Self {
21135 UploadSessionFinishBatchResult {
21136 entries,
21137 }
21138 }
21139}
21140
21141const UPLOAD_SESSION_FINISH_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
21142impl UploadSessionFinishBatchResult {
21143 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21144 map: V,
21145 ) -> Result<UploadSessionFinishBatchResult, V::Error> {
21146 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21147 }
21148
21149 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21150 mut map: V,
21151 optional: bool,
21152 ) -> Result<Option<UploadSessionFinishBatchResult>, V::Error> {
21153 let mut field_entries = None;
21154 let mut nothing = true;
21155 while let Some(key) = map.next_key::<&str>()? {
21156 nothing = false;
21157 match key {
21158 "entries" => {
21159 if field_entries.is_some() {
21160 return Err(::serde::de::Error::duplicate_field("entries"));
21161 }
21162 field_entries = Some(map.next_value()?);
21163 }
21164 _ => {
21165 map.next_value::<::serde_json::Value>()?;
21167 }
21168 }
21169 }
21170 if optional && nothing {
21171 return Ok(None);
21172 }
21173 let result = UploadSessionFinishBatchResult {
21174 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
21175 };
21176 Ok(Some(result))
21177 }
21178
21179 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21180 &self,
21181 s: &mut S::SerializeStruct,
21182 ) -> Result<(), S::Error> {
21183 use serde::ser::SerializeStruct;
21184 s.serialize_field("entries", &self.entries)?;
21185 Ok(())
21186 }
21187}
21188
21189impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchResult {
21190 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21191 use serde::de::{MapAccess, Visitor};
21193 struct StructVisitor;
21194 impl<'de> Visitor<'de> for StructVisitor {
21195 type Value = UploadSessionFinishBatchResult;
21196 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21197 f.write_str("a UploadSessionFinishBatchResult struct")
21198 }
21199 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21200 UploadSessionFinishBatchResult::internal_deserialize(map)
21201 }
21202 }
21203 deserializer.deserialize_struct("UploadSessionFinishBatchResult", UPLOAD_SESSION_FINISH_BATCH_RESULT_FIELDS, StructVisitor)
21204 }
21205}
21206
21207impl ::serde::ser::Serialize for UploadSessionFinishBatchResult {
21208 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21209 use serde::ser::SerializeStruct;
21211 let mut s = serializer.serialize_struct("UploadSessionFinishBatchResult", 1)?;
21212 self.internal_serialize::<S>(&mut s)?;
21213 s.end()
21214 }
21215}
21216
21217#[derive(Debug, Clone, PartialEq)]
21218pub enum UploadSessionFinishBatchResultEntry {
21219 Success(FileMetadata),
21220 Failure(UploadSessionFinishError),
21221}
21222
21223impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchResultEntry {
21224 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21225 use serde::de::{self, MapAccess, Visitor};
21227 struct EnumVisitor;
21228 impl<'de> Visitor<'de> for EnumVisitor {
21229 type Value = UploadSessionFinishBatchResultEntry;
21230 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21231 f.write_str("a UploadSessionFinishBatchResultEntry structure")
21232 }
21233 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21234 let tag: &str = match map.next_key()? {
21235 Some(".tag") => map.next_value()?,
21236 _ => return Err(de::Error::missing_field(".tag"))
21237 };
21238 let value = match tag {
21239 "success" => UploadSessionFinishBatchResultEntry::Success(FileMetadata::internal_deserialize(&mut map)?),
21240 "failure" => {
21241 match map.next_key()? {
21242 Some("failure") => UploadSessionFinishBatchResultEntry::Failure(map.next_value()?),
21243 None => return Err(de::Error::missing_field("failure")),
21244 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21245 }
21246 }
21247 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
21248 };
21249 crate::eat_json_fields(&mut map)?;
21250 Ok(value)
21251 }
21252 }
21253 const VARIANTS: &[&str] = &["success",
21254 "failure"];
21255 deserializer.deserialize_struct("UploadSessionFinishBatchResultEntry", VARIANTS, EnumVisitor)
21256 }
21257}
21258
21259impl ::serde::ser::Serialize for UploadSessionFinishBatchResultEntry {
21260 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21261 use serde::ser::SerializeStruct;
21263 match self {
21264 UploadSessionFinishBatchResultEntry::Success(x) => {
21265 let mut s = serializer.serialize_struct("UploadSessionFinishBatchResultEntry", 21)?;
21267 s.serialize_field(".tag", "success")?;
21268 x.internal_serialize::<S>(&mut s)?;
21269 s.end()
21270 }
21271 UploadSessionFinishBatchResultEntry::Failure(x) => {
21272 let mut s = serializer.serialize_struct("UploadSessionFinishBatchResultEntry", 2)?;
21274 s.serialize_field(".tag", "failure")?;
21275 s.serialize_field("failure", x)?;
21276 s.end()
21277 }
21278 }
21279 }
21280}
21281
21282#[derive(Debug, Clone, PartialEq, Eq)]
21283#[non_exhaustive] pub enum UploadSessionFinishError {
21285 LookupFailed(UploadSessionLookupError),
21287 Path(WriteError),
21290 PropertiesError(crate::types::file_properties::InvalidPropertyGroupError),
21292 #[deprecated]
21295 TooManySharedFolderTargets,
21296 TooManyWriteOperations,
21299 ConcurrentSessionDataNotAllowed,
21301 ConcurrentSessionNotClosed,
21303 ConcurrentSessionMissingData,
21305 PayloadTooLarge,
21307 ContentHashMismatch,
21310 EncryptionNotSupported,
21312 Other,
21315}
21316
21317impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishError {
21318 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21319 use serde::de::{self, MapAccess, Visitor};
21321 struct EnumVisitor;
21322 impl<'de> Visitor<'de> for EnumVisitor {
21323 type Value = UploadSessionFinishError;
21324 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21325 f.write_str("a UploadSessionFinishError structure")
21326 }
21327 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21328 let tag: &str = match map.next_key()? {
21329 Some(".tag") => map.next_value()?,
21330 _ => return Err(de::Error::missing_field(".tag"))
21331 };
21332 let value = match tag {
21333 "lookup_failed" => {
21334 match map.next_key()? {
21335 Some("lookup_failed") => UploadSessionFinishError::LookupFailed(map.next_value()?),
21336 None => return Err(de::Error::missing_field("lookup_failed")),
21337 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21338 }
21339 }
21340 "path" => {
21341 match map.next_key()? {
21342 Some("path") => UploadSessionFinishError::Path(map.next_value()?),
21343 None => return Err(de::Error::missing_field("path")),
21344 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21345 }
21346 }
21347 "properties_error" => {
21348 match map.next_key()? {
21349 Some("properties_error") => UploadSessionFinishError::PropertiesError(map.next_value()?),
21350 None => return Err(de::Error::missing_field("properties_error")),
21351 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21352 }
21353 }
21354 #[allow(deprecated)]
21355 "too_many_shared_folder_targets" => UploadSessionFinishError::TooManySharedFolderTargets,
21356 "too_many_write_operations" => UploadSessionFinishError::TooManyWriteOperations,
21357 "concurrent_session_data_not_allowed" => UploadSessionFinishError::ConcurrentSessionDataNotAllowed,
21358 "concurrent_session_not_closed" => UploadSessionFinishError::ConcurrentSessionNotClosed,
21359 "concurrent_session_missing_data" => UploadSessionFinishError::ConcurrentSessionMissingData,
21360 "payload_too_large" => UploadSessionFinishError::PayloadTooLarge,
21361 "content_hash_mismatch" => UploadSessionFinishError::ContentHashMismatch,
21362 "encryption_not_supported" => UploadSessionFinishError::EncryptionNotSupported,
21363 _ => UploadSessionFinishError::Other,
21364 };
21365 crate::eat_json_fields(&mut map)?;
21366 Ok(value)
21367 }
21368 }
21369 const VARIANTS: &[&str] = &["lookup_failed",
21370 "path",
21371 "properties_error",
21372 "too_many_shared_folder_targets",
21373 "too_many_write_operations",
21374 "concurrent_session_data_not_allowed",
21375 "concurrent_session_not_closed",
21376 "concurrent_session_missing_data",
21377 "payload_too_large",
21378 "content_hash_mismatch",
21379 "encryption_not_supported",
21380 "other"];
21381 deserializer.deserialize_struct("UploadSessionFinishError", VARIANTS, EnumVisitor)
21382 }
21383}
21384
21385impl ::serde::ser::Serialize for UploadSessionFinishError {
21386 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21387 use serde::ser::SerializeStruct;
21389 match self {
21390 UploadSessionFinishError::LookupFailed(x) => {
21391 let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
21393 s.serialize_field(".tag", "lookup_failed")?;
21394 s.serialize_field("lookup_failed", x)?;
21395 s.end()
21396 }
21397 UploadSessionFinishError::Path(x) => {
21398 let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
21400 s.serialize_field(".tag", "path")?;
21401 s.serialize_field("path", x)?;
21402 s.end()
21403 }
21404 UploadSessionFinishError::PropertiesError(x) => {
21405 let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
21407 s.serialize_field(".tag", "properties_error")?;
21408 s.serialize_field("properties_error", x)?;
21409 s.end()
21410 }
21411 #[allow(deprecated)]
21412 UploadSessionFinishError::TooManySharedFolderTargets => {
21413 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21415 s.serialize_field(".tag", "too_many_shared_folder_targets")?;
21416 s.end()
21417 }
21418 UploadSessionFinishError::TooManyWriteOperations => {
21419 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21421 s.serialize_field(".tag", "too_many_write_operations")?;
21422 s.end()
21423 }
21424 UploadSessionFinishError::ConcurrentSessionDataNotAllowed => {
21425 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21427 s.serialize_field(".tag", "concurrent_session_data_not_allowed")?;
21428 s.end()
21429 }
21430 UploadSessionFinishError::ConcurrentSessionNotClosed => {
21431 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21433 s.serialize_field(".tag", "concurrent_session_not_closed")?;
21434 s.end()
21435 }
21436 UploadSessionFinishError::ConcurrentSessionMissingData => {
21437 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21439 s.serialize_field(".tag", "concurrent_session_missing_data")?;
21440 s.end()
21441 }
21442 UploadSessionFinishError::PayloadTooLarge => {
21443 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21445 s.serialize_field(".tag", "payload_too_large")?;
21446 s.end()
21447 }
21448 UploadSessionFinishError::ContentHashMismatch => {
21449 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21451 s.serialize_field(".tag", "content_hash_mismatch")?;
21452 s.end()
21453 }
21454 UploadSessionFinishError::EncryptionNotSupported => {
21455 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21457 s.serialize_field(".tag", "encryption_not_supported")?;
21458 s.end()
21459 }
21460 UploadSessionFinishError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
21461 }
21462 }
21463}
21464
21465impl ::std::error::Error for UploadSessionFinishError {
21466 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
21467 match self {
21468 UploadSessionFinishError::LookupFailed(inner) => Some(inner),
21469 UploadSessionFinishError::Path(inner) => Some(inner),
21470 UploadSessionFinishError::PropertiesError(inner) => Some(inner),
21471 _ => None,
21472 }
21473 }
21474}
21475
21476impl ::std::fmt::Display for UploadSessionFinishError {
21477 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21478 match self {
21479 UploadSessionFinishError::LookupFailed(inner) => write!(f, "The session arguments are incorrect; the value explains the reason: {}", inner),
21480 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),
21481 UploadSessionFinishError::PropertiesError(inner) => write!(f, "The supplied property group is invalid. The file has uploaded without property groups: {}", inner),
21482 #[allow(deprecated)] UploadSessionFinishError::TooManySharedFolderTargets => f.write_str("Field is deprecated. The batch request commits files into too many different shared folders. Please limit your batch request to files contained in a single shared folder."),
21483 UploadSessionFinishError::TooManyWriteOperations => f.write_str("There are too many write operations happening in the user's Dropbox. You should retry uploading this file."),
21484 UploadSessionFinishError::ConcurrentSessionDataNotAllowed => f.write_str("Uploading data not allowed when finishing concurrent upload session."),
21485 UploadSessionFinishError::ConcurrentSessionNotClosed => f.write_str("Concurrent upload sessions need to be closed before finishing."),
21486 UploadSessionFinishError::ConcurrentSessionMissingData => f.write_str("Not all pieces of data were uploaded before trying to finish the session."),
21487 UploadSessionFinishError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
21488 UploadSessionFinishError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
21489 UploadSessionFinishError::EncryptionNotSupported => f.write_str("The file is required to be encrypted, which is not supported in our public API."),
21490 _ => write!(f, "{:?}", *self),
21491 }
21492 }
21493}
21494
21495#[derive(Debug, Clone, PartialEq, Eq)]
21496#[non_exhaustive] pub enum UploadSessionLookupError {
21498 NotFound,
21500 IncorrectOffset(UploadSessionOffsetError),
21504 Closed,
21507 NotClosed,
21509 TooLarge,
21512 ConcurrentSessionInvalidOffset,
21514 ConcurrentSessionInvalidDataSize,
21517 PayloadTooLarge,
21519 Other,
21522}
21523
21524impl<'de> ::serde::de::Deserialize<'de> for UploadSessionLookupError {
21525 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21526 use serde::de::{self, MapAccess, Visitor};
21528 struct EnumVisitor;
21529 impl<'de> Visitor<'de> for EnumVisitor {
21530 type Value = UploadSessionLookupError;
21531 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21532 f.write_str("a UploadSessionLookupError structure")
21533 }
21534 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21535 let tag: &str = match map.next_key()? {
21536 Some(".tag") => map.next_value()?,
21537 _ => return Err(de::Error::missing_field(".tag"))
21538 };
21539 let value = match tag {
21540 "not_found" => UploadSessionLookupError::NotFound,
21541 "incorrect_offset" => UploadSessionLookupError::IncorrectOffset(UploadSessionOffsetError::internal_deserialize(&mut map)?),
21542 "closed" => UploadSessionLookupError::Closed,
21543 "not_closed" => UploadSessionLookupError::NotClosed,
21544 "too_large" => UploadSessionLookupError::TooLarge,
21545 "concurrent_session_invalid_offset" => UploadSessionLookupError::ConcurrentSessionInvalidOffset,
21546 "concurrent_session_invalid_data_size" => UploadSessionLookupError::ConcurrentSessionInvalidDataSize,
21547 "payload_too_large" => UploadSessionLookupError::PayloadTooLarge,
21548 _ => UploadSessionLookupError::Other,
21549 };
21550 crate::eat_json_fields(&mut map)?;
21551 Ok(value)
21552 }
21553 }
21554 const VARIANTS: &[&str] = &["not_found",
21555 "incorrect_offset",
21556 "closed",
21557 "not_closed",
21558 "too_large",
21559 "concurrent_session_invalid_offset",
21560 "concurrent_session_invalid_data_size",
21561 "payload_too_large",
21562 "other"];
21563 deserializer.deserialize_struct("UploadSessionLookupError", VARIANTS, EnumVisitor)
21564 }
21565}
21566
21567impl ::serde::ser::Serialize for UploadSessionLookupError {
21568 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21569 use serde::ser::SerializeStruct;
21571 match self {
21572 UploadSessionLookupError::NotFound => {
21573 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21575 s.serialize_field(".tag", "not_found")?;
21576 s.end()
21577 }
21578 UploadSessionLookupError::IncorrectOffset(x) => {
21579 let mut s = serializer.serialize_struct("UploadSessionLookupError", 2)?;
21581 s.serialize_field(".tag", "incorrect_offset")?;
21582 x.internal_serialize::<S>(&mut s)?;
21583 s.end()
21584 }
21585 UploadSessionLookupError::Closed => {
21586 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21588 s.serialize_field(".tag", "closed")?;
21589 s.end()
21590 }
21591 UploadSessionLookupError::NotClosed => {
21592 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21594 s.serialize_field(".tag", "not_closed")?;
21595 s.end()
21596 }
21597 UploadSessionLookupError::TooLarge => {
21598 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21600 s.serialize_field(".tag", "too_large")?;
21601 s.end()
21602 }
21603 UploadSessionLookupError::ConcurrentSessionInvalidOffset => {
21604 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21606 s.serialize_field(".tag", "concurrent_session_invalid_offset")?;
21607 s.end()
21608 }
21609 UploadSessionLookupError::ConcurrentSessionInvalidDataSize => {
21610 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21612 s.serialize_field(".tag", "concurrent_session_invalid_data_size")?;
21613 s.end()
21614 }
21615 UploadSessionLookupError::PayloadTooLarge => {
21616 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21618 s.serialize_field(".tag", "payload_too_large")?;
21619 s.end()
21620 }
21621 UploadSessionLookupError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
21622 }
21623 }
21624}
21625
21626impl ::std::error::Error for UploadSessionLookupError {
21627}
21628
21629impl ::std::fmt::Display for UploadSessionLookupError {
21630 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21631 match self {
21632 UploadSessionLookupError::NotFound => f.write_str("The upload session ID was not found or has expired. Upload sessions are valid for 7 days."),
21633 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),
21634 UploadSessionLookupError::Closed => f.write_str("You are attempting to append data to an upload session that has already been closed (i.e. committed)."),
21635 UploadSessionLookupError::NotClosed => f.write_str("The session must be closed before calling upload_session/finish_batch."),
21636 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)."),
21637 UploadSessionLookupError::ConcurrentSessionInvalidOffset => f.write_str("For concurrent upload sessions, offset needs to be multiple of 2^22 (4,194,304) bytes."),
21638 UploadSessionLookupError::ConcurrentSessionInvalidDataSize => f.write_str("For concurrent upload sessions, only chunks with size multiple of 2^22 (4,194,304) bytes can be uploaded."),
21639 UploadSessionLookupError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
21640 _ => write!(f, "{:?}", *self),
21641 }
21642 }
21643}
21644
21645#[derive(Debug, Clone, PartialEq, Eq)]
21646#[non_exhaustive] pub struct UploadSessionOffsetError {
21648 pub correct_offset: u64,
21650}
21651
21652impl UploadSessionOffsetError {
21653 pub fn new(correct_offset: u64) -> Self {
21654 UploadSessionOffsetError {
21655 correct_offset,
21656 }
21657 }
21658}
21659
21660const UPLOAD_SESSION_OFFSET_ERROR_FIELDS: &[&str] = &["correct_offset"];
21661impl UploadSessionOffsetError {
21662 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21663 map: V,
21664 ) -> Result<UploadSessionOffsetError, V::Error> {
21665 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21666 }
21667
21668 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21669 mut map: V,
21670 optional: bool,
21671 ) -> Result<Option<UploadSessionOffsetError>, V::Error> {
21672 let mut field_correct_offset = None;
21673 let mut nothing = true;
21674 while let Some(key) = map.next_key::<&str>()? {
21675 nothing = false;
21676 match key {
21677 "correct_offset" => {
21678 if field_correct_offset.is_some() {
21679 return Err(::serde::de::Error::duplicate_field("correct_offset"));
21680 }
21681 field_correct_offset = Some(map.next_value()?);
21682 }
21683 _ => {
21684 map.next_value::<::serde_json::Value>()?;
21686 }
21687 }
21688 }
21689 if optional && nothing {
21690 return Ok(None);
21691 }
21692 let result = UploadSessionOffsetError {
21693 correct_offset: field_correct_offset.ok_or_else(|| ::serde::de::Error::missing_field("correct_offset"))?,
21694 };
21695 Ok(Some(result))
21696 }
21697
21698 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21699 &self,
21700 s: &mut S::SerializeStruct,
21701 ) -> Result<(), S::Error> {
21702 use serde::ser::SerializeStruct;
21703 s.serialize_field("correct_offset", &self.correct_offset)?;
21704 Ok(())
21705 }
21706}
21707
21708impl<'de> ::serde::de::Deserialize<'de> for UploadSessionOffsetError {
21709 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21710 use serde::de::{MapAccess, Visitor};
21712 struct StructVisitor;
21713 impl<'de> Visitor<'de> for StructVisitor {
21714 type Value = UploadSessionOffsetError;
21715 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21716 f.write_str("a UploadSessionOffsetError struct")
21717 }
21718 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21719 UploadSessionOffsetError::internal_deserialize(map)
21720 }
21721 }
21722 deserializer.deserialize_struct("UploadSessionOffsetError", UPLOAD_SESSION_OFFSET_ERROR_FIELDS, StructVisitor)
21723 }
21724}
21725
21726impl ::serde::ser::Serialize for UploadSessionOffsetError {
21727 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21728 use serde::ser::SerializeStruct;
21730 let mut s = serializer.serialize_struct("UploadSessionOffsetError", 1)?;
21731 self.internal_serialize::<S>(&mut s)?;
21732 s.end()
21733 }
21734}
21735
21736#[derive(Debug, Clone, PartialEq, Eq, Default)]
21737#[non_exhaustive] pub struct UploadSessionStartArg {
21739 pub close: bool,
21743 pub session_type: Option<UploadSessionType>,
21746 pub content_hash: Option<Sha256HexHash>,
21750}
21751
21752impl UploadSessionStartArg {
21753 pub fn with_close(mut self, value: bool) -> Self {
21754 self.close = value;
21755 self
21756 }
21757
21758 pub fn with_session_type(mut self, value: UploadSessionType) -> Self {
21759 self.session_type = Some(value);
21760 self
21761 }
21762
21763 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
21764 self.content_hash = Some(value);
21765 self
21766 }
21767}
21768
21769const UPLOAD_SESSION_START_ARG_FIELDS: &[&str] = &["close",
21770 "session_type",
21771 "content_hash"];
21772impl UploadSessionStartArg {
21773 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21775 mut map: V,
21776 ) -> Result<UploadSessionStartArg, V::Error> {
21777 let mut field_close = None;
21778 let mut field_session_type = None;
21779 let mut field_content_hash = None;
21780 while let Some(key) = map.next_key::<&str>()? {
21781 match key {
21782 "close" => {
21783 if field_close.is_some() {
21784 return Err(::serde::de::Error::duplicate_field("close"));
21785 }
21786 field_close = Some(map.next_value()?);
21787 }
21788 "session_type" => {
21789 if field_session_type.is_some() {
21790 return Err(::serde::de::Error::duplicate_field("session_type"));
21791 }
21792 field_session_type = Some(map.next_value()?);
21793 }
21794 "content_hash" => {
21795 if field_content_hash.is_some() {
21796 return Err(::serde::de::Error::duplicate_field("content_hash"));
21797 }
21798 field_content_hash = Some(map.next_value()?);
21799 }
21800 _ => {
21801 map.next_value::<::serde_json::Value>()?;
21803 }
21804 }
21805 }
21806 let result = UploadSessionStartArg {
21807 close: field_close.unwrap_or(false),
21808 session_type: field_session_type.and_then(Option::flatten),
21809 content_hash: field_content_hash.and_then(Option::flatten),
21810 };
21811 Ok(result)
21812 }
21813
21814 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21815 &self,
21816 s: &mut S::SerializeStruct,
21817 ) -> Result<(), S::Error> {
21818 use serde::ser::SerializeStruct;
21819 if self.close {
21820 s.serialize_field("close", &self.close)?;
21821 }
21822 if let Some(val) = &self.session_type {
21823 s.serialize_field("session_type", val)?;
21824 }
21825 if let Some(val) = &self.content_hash {
21826 s.serialize_field("content_hash", val)?;
21827 }
21828 Ok(())
21829 }
21830}
21831
21832impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartArg {
21833 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21834 use serde::de::{MapAccess, Visitor};
21836 struct StructVisitor;
21837 impl<'de> Visitor<'de> for StructVisitor {
21838 type Value = UploadSessionStartArg;
21839 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21840 f.write_str("a UploadSessionStartArg struct")
21841 }
21842 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21843 UploadSessionStartArg::internal_deserialize(map)
21844 }
21845 }
21846 deserializer.deserialize_struct("UploadSessionStartArg", UPLOAD_SESSION_START_ARG_FIELDS, StructVisitor)
21847 }
21848}
21849
21850impl ::serde::ser::Serialize for UploadSessionStartArg {
21851 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21852 use serde::ser::SerializeStruct;
21854 let mut s = serializer.serialize_struct("UploadSessionStartArg", 3)?;
21855 self.internal_serialize::<S>(&mut s)?;
21856 s.end()
21857 }
21858}
21859
21860#[derive(Debug, Clone, PartialEq, Eq)]
21861#[non_exhaustive] pub struct UploadSessionStartBatchArg {
21863 pub num_sessions: u64,
21865 pub session_type: Option<UploadSessionType>,
21868}
21869
21870impl UploadSessionStartBatchArg {
21871 pub fn new(num_sessions: u64) -> Self {
21872 UploadSessionStartBatchArg {
21873 num_sessions,
21874 session_type: None,
21875 }
21876 }
21877
21878 pub fn with_session_type(mut self, value: UploadSessionType) -> Self {
21879 self.session_type = Some(value);
21880 self
21881 }
21882}
21883
21884const UPLOAD_SESSION_START_BATCH_ARG_FIELDS: &[&str] = &["num_sessions",
21885 "session_type"];
21886impl UploadSessionStartBatchArg {
21887 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21888 map: V,
21889 ) -> Result<UploadSessionStartBatchArg, V::Error> {
21890 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21891 }
21892
21893 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21894 mut map: V,
21895 optional: bool,
21896 ) -> Result<Option<UploadSessionStartBatchArg>, V::Error> {
21897 let mut field_num_sessions = None;
21898 let mut field_session_type = None;
21899 let mut nothing = true;
21900 while let Some(key) = map.next_key::<&str>()? {
21901 nothing = false;
21902 match key {
21903 "num_sessions" => {
21904 if field_num_sessions.is_some() {
21905 return Err(::serde::de::Error::duplicate_field("num_sessions"));
21906 }
21907 field_num_sessions = Some(map.next_value()?);
21908 }
21909 "session_type" => {
21910 if field_session_type.is_some() {
21911 return Err(::serde::de::Error::duplicate_field("session_type"));
21912 }
21913 field_session_type = Some(map.next_value()?);
21914 }
21915 _ => {
21916 map.next_value::<::serde_json::Value>()?;
21918 }
21919 }
21920 }
21921 if optional && nothing {
21922 return Ok(None);
21923 }
21924 let result = UploadSessionStartBatchArg {
21925 num_sessions: field_num_sessions.ok_or_else(|| ::serde::de::Error::missing_field("num_sessions"))?,
21926 session_type: field_session_type.and_then(Option::flatten),
21927 };
21928 Ok(Some(result))
21929 }
21930
21931 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21932 &self,
21933 s: &mut S::SerializeStruct,
21934 ) -> Result<(), S::Error> {
21935 use serde::ser::SerializeStruct;
21936 s.serialize_field("num_sessions", &self.num_sessions)?;
21937 if let Some(val) = &self.session_type {
21938 s.serialize_field("session_type", val)?;
21939 }
21940 Ok(())
21941 }
21942}
21943
21944impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartBatchArg {
21945 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21946 use serde::de::{MapAccess, Visitor};
21948 struct StructVisitor;
21949 impl<'de> Visitor<'de> for StructVisitor {
21950 type Value = UploadSessionStartBatchArg;
21951 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21952 f.write_str("a UploadSessionStartBatchArg struct")
21953 }
21954 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21955 UploadSessionStartBatchArg::internal_deserialize(map)
21956 }
21957 }
21958 deserializer.deserialize_struct("UploadSessionStartBatchArg", UPLOAD_SESSION_START_BATCH_ARG_FIELDS, StructVisitor)
21959 }
21960}
21961
21962impl ::serde::ser::Serialize for UploadSessionStartBatchArg {
21963 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21964 use serde::ser::SerializeStruct;
21966 let mut s = serializer.serialize_struct("UploadSessionStartBatchArg", 2)?;
21967 self.internal_serialize::<S>(&mut s)?;
21968 s.end()
21969 }
21970}
21971
21972#[derive(Debug, Clone, PartialEq, Eq)]
21973#[non_exhaustive] pub struct UploadSessionStartBatchResult {
21975 pub session_ids: Vec<String>,
21979}
21980
21981impl UploadSessionStartBatchResult {
21982 pub fn new(session_ids: Vec<String>) -> Self {
21983 UploadSessionStartBatchResult {
21984 session_ids,
21985 }
21986 }
21987}
21988
21989const UPLOAD_SESSION_START_BATCH_RESULT_FIELDS: &[&str] = &["session_ids"];
21990impl UploadSessionStartBatchResult {
21991 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21992 map: V,
21993 ) -> Result<UploadSessionStartBatchResult, V::Error> {
21994 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21995 }
21996
21997 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21998 mut map: V,
21999 optional: bool,
22000 ) -> Result<Option<UploadSessionStartBatchResult>, V::Error> {
22001 let mut field_session_ids = None;
22002 let mut nothing = true;
22003 while let Some(key) = map.next_key::<&str>()? {
22004 nothing = false;
22005 match key {
22006 "session_ids" => {
22007 if field_session_ids.is_some() {
22008 return Err(::serde::de::Error::duplicate_field("session_ids"));
22009 }
22010 field_session_ids = Some(map.next_value()?);
22011 }
22012 _ => {
22013 map.next_value::<::serde_json::Value>()?;
22015 }
22016 }
22017 }
22018 if optional && nothing {
22019 return Ok(None);
22020 }
22021 let result = UploadSessionStartBatchResult {
22022 session_ids: field_session_ids.ok_or_else(|| ::serde::de::Error::missing_field("session_ids"))?,
22023 };
22024 Ok(Some(result))
22025 }
22026
22027 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
22028 &self,
22029 s: &mut S::SerializeStruct,
22030 ) -> Result<(), S::Error> {
22031 use serde::ser::SerializeStruct;
22032 s.serialize_field("session_ids", &self.session_ids)?;
22033 Ok(())
22034 }
22035}
22036
22037impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartBatchResult {
22038 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22039 use serde::de::{MapAccess, Visitor};
22041 struct StructVisitor;
22042 impl<'de> Visitor<'de> for StructVisitor {
22043 type Value = UploadSessionStartBatchResult;
22044 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22045 f.write_str("a UploadSessionStartBatchResult struct")
22046 }
22047 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
22048 UploadSessionStartBatchResult::internal_deserialize(map)
22049 }
22050 }
22051 deserializer.deserialize_struct("UploadSessionStartBatchResult", UPLOAD_SESSION_START_BATCH_RESULT_FIELDS, StructVisitor)
22052 }
22053}
22054
22055impl ::serde::ser::Serialize for UploadSessionStartBatchResult {
22056 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22057 use serde::ser::SerializeStruct;
22059 let mut s = serializer.serialize_struct("UploadSessionStartBatchResult", 1)?;
22060 self.internal_serialize::<S>(&mut s)?;
22061 s.end()
22062 }
22063}
22064
22065#[derive(Debug, Clone, PartialEq, Eq)]
22066#[non_exhaustive] pub enum UploadSessionStartError {
22068 ConcurrentSessionDataNotAllowed,
22070 ConcurrentSessionCloseNotAllowed,
22072 PayloadTooLarge,
22074 ContentHashMismatch,
22077 Other,
22080}
22081
22082impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartError {
22083 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22084 use serde::de::{self, MapAccess, Visitor};
22086 struct EnumVisitor;
22087 impl<'de> Visitor<'de> for EnumVisitor {
22088 type Value = UploadSessionStartError;
22089 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22090 f.write_str("a UploadSessionStartError structure")
22091 }
22092 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22093 let tag: &str = match map.next_key()? {
22094 Some(".tag") => map.next_value()?,
22095 _ => return Err(de::Error::missing_field(".tag"))
22096 };
22097 let value = match tag {
22098 "concurrent_session_data_not_allowed" => UploadSessionStartError::ConcurrentSessionDataNotAllowed,
22099 "concurrent_session_close_not_allowed" => UploadSessionStartError::ConcurrentSessionCloseNotAllowed,
22100 "payload_too_large" => UploadSessionStartError::PayloadTooLarge,
22101 "content_hash_mismatch" => UploadSessionStartError::ContentHashMismatch,
22102 _ => UploadSessionStartError::Other,
22103 };
22104 crate::eat_json_fields(&mut map)?;
22105 Ok(value)
22106 }
22107 }
22108 const VARIANTS: &[&str] = &["concurrent_session_data_not_allowed",
22109 "concurrent_session_close_not_allowed",
22110 "payload_too_large",
22111 "content_hash_mismatch",
22112 "other"];
22113 deserializer.deserialize_struct("UploadSessionStartError", VARIANTS, EnumVisitor)
22114 }
22115}
22116
22117impl ::serde::ser::Serialize for UploadSessionStartError {
22118 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22119 use serde::ser::SerializeStruct;
22121 match self {
22122 UploadSessionStartError::ConcurrentSessionDataNotAllowed => {
22123 let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
22125 s.serialize_field(".tag", "concurrent_session_data_not_allowed")?;
22126 s.end()
22127 }
22128 UploadSessionStartError::ConcurrentSessionCloseNotAllowed => {
22129 let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
22131 s.serialize_field(".tag", "concurrent_session_close_not_allowed")?;
22132 s.end()
22133 }
22134 UploadSessionStartError::PayloadTooLarge => {
22135 let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
22137 s.serialize_field(".tag", "payload_too_large")?;
22138 s.end()
22139 }
22140 UploadSessionStartError::ContentHashMismatch => {
22141 let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
22143 s.serialize_field(".tag", "content_hash_mismatch")?;
22144 s.end()
22145 }
22146 UploadSessionStartError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
22147 }
22148 }
22149}
22150
22151impl ::std::error::Error for UploadSessionStartError {
22152}
22153
22154impl ::std::fmt::Display for UploadSessionStartError {
22155 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22156 match self {
22157 UploadSessionStartError::ConcurrentSessionDataNotAllowed => f.write_str("Uploading data not allowed when starting concurrent upload session."),
22158 UploadSessionStartError::ConcurrentSessionCloseNotAllowed => f.write_str("Can not start a closed concurrent upload session."),
22159 UploadSessionStartError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
22160 UploadSessionStartError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
22161 _ => write!(f, "{:?}", *self),
22162 }
22163 }
22164}
22165
22166#[derive(Debug, Clone, PartialEq, Eq)]
22167#[non_exhaustive] pub struct UploadSessionStartResult {
22169 pub session_id: String,
22173}
22174
22175impl UploadSessionStartResult {
22176 pub fn new(session_id: String) -> Self {
22177 UploadSessionStartResult {
22178 session_id,
22179 }
22180 }
22181}
22182
22183const UPLOAD_SESSION_START_RESULT_FIELDS: &[&str] = &["session_id"];
22184impl UploadSessionStartResult {
22185 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
22186 map: V,
22187 ) -> Result<UploadSessionStartResult, V::Error> {
22188 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
22189 }
22190
22191 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
22192 mut map: V,
22193 optional: bool,
22194 ) -> Result<Option<UploadSessionStartResult>, V::Error> {
22195 let mut field_session_id = None;
22196 let mut nothing = true;
22197 while let Some(key) = map.next_key::<&str>()? {
22198 nothing = false;
22199 match key {
22200 "session_id" => {
22201 if field_session_id.is_some() {
22202 return Err(::serde::de::Error::duplicate_field("session_id"));
22203 }
22204 field_session_id = Some(map.next_value()?);
22205 }
22206 _ => {
22207 map.next_value::<::serde_json::Value>()?;
22209 }
22210 }
22211 }
22212 if optional && nothing {
22213 return Ok(None);
22214 }
22215 let result = UploadSessionStartResult {
22216 session_id: field_session_id.ok_or_else(|| ::serde::de::Error::missing_field("session_id"))?,
22217 };
22218 Ok(Some(result))
22219 }
22220
22221 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
22222 &self,
22223 s: &mut S::SerializeStruct,
22224 ) -> Result<(), S::Error> {
22225 use serde::ser::SerializeStruct;
22226 s.serialize_field("session_id", &self.session_id)?;
22227 Ok(())
22228 }
22229}
22230
22231impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartResult {
22232 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22233 use serde::de::{MapAccess, Visitor};
22235 struct StructVisitor;
22236 impl<'de> Visitor<'de> for StructVisitor {
22237 type Value = UploadSessionStartResult;
22238 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22239 f.write_str("a UploadSessionStartResult struct")
22240 }
22241 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
22242 UploadSessionStartResult::internal_deserialize(map)
22243 }
22244 }
22245 deserializer.deserialize_struct("UploadSessionStartResult", UPLOAD_SESSION_START_RESULT_FIELDS, StructVisitor)
22246 }
22247}
22248
22249impl ::serde::ser::Serialize for UploadSessionStartResult {
22250 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22251 use serde::ser::SerializeStruct;
22253 let mut s = serializer.serialize_struct("UploadSessionStartResult", 1)?;
22254 self.internal_serialize::<S>(&mut s)?;
22255 s.end()
22256 }
22257}
22258
22259#[derive(Debug, Clone, PartialEq, Eq)]
22260#[non_exhaustive] pub enum UploadSessionType {
22262 Sequential,
22264 Concurrent,
22266 Other,
22269}
22270
22271impl<'de> ::serde::de::Deserialize<'de> for UploadSessionType {
22272 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22273 use serde::de::{self, MapAccess, Visitor};
22275 struct EnumVisitor;
22276 impl<'de> Visitor<'de> for EnumVisitor {
22277 type Value = UploadSessionType;
22278 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22279 f.write_str("a UploadSessionType structure")
22280 }
22281 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22282 let tag: &str = match map.next_key()? {
22283 Some(".tag") => map.next_value()?,
22284 _ => return Err(de::Error::missing_field(".tag"))
22285 };
22286 let value = match tag {
22287 "sequential" => UploadSessionType::Sequential,
22288 "concurrent" => UploadSessionType::Concurrent,
22289 _ => UploadSessionType::Other,
22290 };
22291 crate::eat_json_fields(&mut map)?;
22292 Ok(value)
22293 }
22294 }
22295 const VARIANTS: &[&str] = &["sequential",
22296 "concurrent",
22297 "other"];
22298 deserializer.deserialize_struct("UploadSessionType", VARIANTS, EnumVisitor)
22299 }
22300}
22301
22302impl ::serde::ser::Serialize for UploadSessionType {
22303 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22304 use serde::ser::SerializeStruct;
22306 match self {
22307 UploadSessionType::Sequential => {
22308 let mut s = serializer.serialize_struct("UploadSessionType", 1)?;
22310 s.serialize_field(".tag", "sequential")?;
22311 s.end()
22312 }
22313 UploadSessionType::Concurrent => {
22314 let mut s = serializer.serialize_struct("UploadSessionType", 1)?;
22316 s.serialize_field(".tag", "concurrent")?;
22317 s.end()
22318 }
22319 UploadSessionType::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
22320 }
22321 }
22322}
22323
22324#[derive(Debug, Clone, PartialEq, Eq)]
22325#[non_exhaustive] pub struct UploadWriteFailed {
22327 pub reason: WriteError,
22329 pub upload_session_id: String,
22333}
22334
22335impl UploadWriteFailed {
22336 pub fn new(reason: WriteError, upload_session_id: String) -> Self {
22337 UploadWriteFailed {
22338 reason,
22339 upload_session_id,
22340 }
22341 }
22342}
22343
22344const UPLOAD_WRITE_FAILED_FIELDS: &[&str] = &["reason",
22345 "upload_session_id"];
22346impl UploadWriteFailed {
22347 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
22348 map: V,
22349 ) -> Result<UploadWriteFailed, V::Error> {
22350 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
22351 }
22352
22353 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
22354 mut map: V,
22355 optional: bool,
22356 ) -> Result<Option<UploadWriteFailed>, V::Error> {
22357 let mut field_reason = None;
22358 let mut field_upload_session_id = None;
22359 let mut nothing = true;
22360 while let Some(key) = map.next_key::<&str>()? {
22361 nothing = false;
22362 match key {
22363 "reason" => {
22364 if field_reason.is_some() {
22365 return Err(::serde::de::Error::duplicate_field("reason"));
22366 }
22367 field_reason = Some(map.next_value()?);
22368 }
22369 "upload_session_id" => {
22370 if field_upload_session_id.is_some() {
22371 return Err(::serde::de::Error::duplicate_field("upload_session_id"));
22372 }
22373 field_upload_session_id = Some(map.next_value()?);
22374 }
22375 _ => {
22376 map.next_value::<::serde_json::Value>()?;
22378 }
22379 }
22380 }
22381 if optional && nothing {
22382 return Ok(None);
22383 }
22384 let result = UploadWriteFailed {
22385 reason: field_reason.ok_or_else(|| ::serde::de::Error::missing_field("reason"))?,
22386 upload_session_id: field_upload_session_id.ok_or_else(|| ::serde::de::Error::missing_field("upload_session_id"))?,
22387 };
22388 Ok(Some(result))
22389 }
22390
22391 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
22392 &self,
22393 s: &mut S::SerializeStruct,
22394 ) -> Result<(), S::Error> {
22395 use serde::ser::SerializeStruct;
22396 s.serialize_field("reason", &self.reason)?;
22397 s.serialize_field("upload_session_id", &self.upload_session_id)?;
22398 Ok(())
22399 }
22400}
22401
22402impl<'de> ::serde::de::Deserialize<'de> for UploadWriteFailed {
22403 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22404 use serde::de::{MapAccess, Visitor};
22406 struct StructVisitor;
22407 impl<'de> Visitor<'de> for StructVisitor {
22408 type Value = UploadWriteFailed;
22409 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22410 f.write_str("a UploadWriteFailed struct")
22411 }
22412 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
22413 UploadWriteFailed::internal_deserialize(map)
22414 }
22415 }
22416 deserializer.deserialize_struct("UploadWriteFailed", UPLOAD_WRITE_FAILED_FIELDS, StructVisitor)
22417 }
22418}
22419
22420impl ::serde::ser::Serialize for UploadWriteFailed {
22421 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22422 use serde::ser::SerializeStruct;
22424 let mut s = serializer.serialize_struct("UploadWriteFailed", 2)?;
22425 self.internal_serialize::<S>(&mut s)?;
22426 s.end()
22427 }
22428}
22429
22430#[derive(Debug, Clone, PartialEq, Eq)]
22431#[non_exhaustive] pub struct UserGeneratedTag {
22433 pub tag_text: TagText,
22434}
22435
22436impl UserGeneratedTag {
22437 pub fn new(tag_text: TagText) -> Self {
22438 UserGeneratedTag {
22439 tag_text,
22440 }
22441 }
22442}
22443
22444const USER_GENERATED_TAG_FIELDS: &[&str] = &["tag_text"];
22445impl UserGeneratedTag {
22446 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
22447 map: V,
22448 ) -> Result<UserGeneratedTag, V::Error> {
22449 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
22450 }
22451
22452 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
22453 mut map: V,
22454 optional: bool,
22455 ) -> Result<Option<UserGeneratedTag>, V::Error> {
22456 let mut field_tag_text = None;
22457 let mut nothing = true;
22458 while let Some(key) = map.next_key::<&str>()? {
22459 nothing = false;
22460 match key {
22461 "tag_text" => {
22462 if field_tag_text.is_some() {
22463 return Err(::serde::de::Error::duplicate_field("tag_text"));
22464 }
22465 field_tag_text = Some(map.next_value()?);
22466 }
22467 _ => {
22468 map.next_value::<::serde_json::Value>()?;
22470 }
22471 }
22472 }
22473 if optional && nothing {
22474 return Ok(None);
22475 }
22476 let result = UserGeneratedTag {
22477 tag_text: field_tag_text.ok_or_else(|| ::serde::de::Error::missing_field("tag_text"))?,
22478 };
22479 Ok(Some(result))
22480 }
22481
22482 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
22483 &self,
22484 s: &mut S::SerializeStruct,
22485 ) -> Result<(), S::Error> {
22486 use serde::ser::SerializeStruct;
22487 s.serialize_field("tag_text", &self.tag_text)?;
22488 Ok(())
22489 }
22490}
22491
22492impl<'de> ::serde::de::Deserialize<'de> for UserGeneratedTag {
22493 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22494 use serde::de::{MapAccess, Visitor};
22496 struct StructVisitor;
22497 impl<'de> Visitor<'de> for StructVisitor {
22498 type Value = UserGeneratedTag;
22499 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22500 f.write_str("a UserGeneratedTag struct")
22501 }
22502 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
22503 UserGeneratedTag::internal_deserialize(map)
22504 }
22505 }
22506 deserializer.deserialize_struct("UserGeneratedTag", USER_GENERATED_TAG_FIELDS, StructVisitor)
22507 }
22508}
22509
22510impl ::serde::ser::Serialize for UserGeneratedTag {
22511 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22512 use serde::ser::SerializeStruct;
22514 let mut s = serializer.serialize_struct("UserGeneratedTag", 1)?;
22515 self.internal_serialize::<S>(&mut s)?;
22516 s.end()
22517 }
22518}
22519
22520#[derive(Debug, Clone, PartialEq, Default)]
22522#[non_exhaustive] pub struct VideoMetadata {
22524 pub dimensions: Option<Dimensions>,
22526 pub location: Option<GpsCoordinates>,
22528 pub time_taken: Option<crate::types::common::DropboxTimestamp>,
22530 pub duration: Option<u64>,
22532}
22533
22534impl VideoMetadata {
22535 pub fn with_dimensions(mut self, value: Dimensions) -> Self {
22536 self.dimensions = Some(value);
22537 self
22538 }
22539
22540 pub fn with_location(mut self, value: GpsCoordinates) -> Self {
22541 self.location = Some(value);
22542 self
22543 }
22544
22545 pub fn with_time_taken(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
22546 self.time_taken = Some(value);
22547 self
22548 }
22549
22550 pub fn with_duration(mut self, value: u64) -> Self {
22551 self.duration = Some(value);
22552 self
22553 }
22554}
22555
22556const VIDEO_METADATA_FIELDS: &[&str] = &["dimensions",
22557 "location",
22558 "time_taken",
22559 "duration"];
22560impl VideoMetadata {
22561 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
22563 mut map: V,
22564 ) -> Result<VideoMetadata, V::Error> {
22565 let mut field_dimensions = None;
22566 let mut field_location = None;
22567 let mut field_time_taken = None;
22568 let mut field_duration = None;
22569 while let Some(key) = map.next_key::<&str>()? {
22570 match key {
22571 "dimensions" => {
22572 if field_dimensions.is_some() {
22573 return Err(::serde::de::Error::duplicate_field("dimensions"));
22574 }
22575 field_dimensions = Some(map.next_value()?);
22576 }
22577 "location" => {
22578 if field_location.is_some() {
22579 return Err(::serde::de::Error::duplicate_field("location"));
22580 }
22581 field_location = Some(map.next_value()?);
22582 }
22583 "time_taken" => {
22584 if field_time_taken.is_some() {
22585 return Err(::serde::de::Error::duplicate_field("time_taken"));
22586 }
22587 field_time_taken = Some(map.next_value()?);
22588 }
22589 "duration" => {
22590 if field_duration.is_some() {
22591 return Err(::serde::de::Error::duplicate_field("duration"));
22592 }
22593 field_duration = Some(map.next_value()?);
22594 }
22595 _ => {
22596 map.next_value::<::serde_json::Value>()?;
22598 }
22599 }
22600 }
22601 let result = VideoMetadata {
22602 dimensions: field_dimensions.and_then(Option::flatten),
22603 location: field_location.and_then(Option::flatten),
22604 time_taken: field_time_taken.and_then(Option::flatten),
22605 duration: field_duration.and_then(Option::flatten),
22606 };
22607 Ok(result)
22608 }
22609
22610 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
22611 &self,
22612 s: &mut S::SerializeStruct,
22613 ) -> Result<(), S::Error> {
22614 use serde::ser::SerializeStruct;
22615 if let Some(val) = &self.dimensions {
22616 s.serialize_field("dimensions", val)?;
22617 }
22618 if let Some(val) = &self.location {
22619 s.serialize_field("location", val)?;
22620 }
22621 if let Some(val) = &self.time_taken {
22622 s.serialize_field("time_taken", val)?;
22623 }
22624 if let Some(val) = &self.duration {
22625 s.serialize_field("duration", val)?;
22626 }
22627 Ok(())
22628 }
22629}
22630
22631impl<'de> ::serde::de::Deserialize<'de> for VideoMetadata {
22632 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22633 use serde::de::{MapAccess, Visitor};
22635 struct StructVisitor;
22636 impl<'de> Visitor<'de> for StructVisitor {
22637 type Value = VideoMetadata;
22638 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22639 f.write_str("a VideoMetadata struct")
22640 }
22641 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
22642 VideoMetadata::internal_deserialize(map)
22643 }
22644 }
22645 deserializer.deserialize_struct("VideoMetadata", VIDEO_METADATA_FIELDS, StructVisitor)
22646 }
22647}
22648
22649impl ::serde::ser::Serialize for VideoMetadata {
22650 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22651 use serde::ser::SerializeStruct;
22653 let mut s = serializer.serialize_struct("VideoMetadata", 4)?;
22654 self.internal_serialize::<S>(&mut s)?;
22655 s.end()
22656 }
22657}
22658
22659impl From<VideoMetadata> for MediaMetadata {
22661 fn from(subtype: VideoMetadata) -> Self {
22662 MediaMetadata::Video(subtype)
22663 }
22664}
22665#[derive(Debug, Clone, PartialEq, Eq)]
22666#[non_exhaustive] pub enum WriteConflictError {
22668 File,
22670 Folder,
22672 FileAncestor,
22674 Other,
22677}
22678
22679impl<'de> ::serde::de::Deserialize<'de> for WriteConflictError {
22680 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22681 use serde::de::{self, MapAccess, Visitor};
22683 struct EnumVisitor;
22684 impl<'de> Visitor<'de> for EnumVisitor {
22685 type Value = WriteConflictError;
22686 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22687 f.write_str("a WriteConflictError structure")
22688 }
22689 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22690 let tag: &str = match map.next_key()? {
22691 Some(".tag") => map.next_value()?,
22692 _ => return Err(de::Error::missing_field(".tag"))
22693 };
22694 let value = match tag {
22695 "file" => WriteConflictError::File,
22696 "folder" => WriteConflictError::Folder,
22697 "file_ancestor" => WriteConflictError::FileAncestor,
22698 _ => WriteConflictError::Other,
22699 };
22700 crate::eat_json_fields(&mut map)?;
22701 Ok(value)
22702 }
22703 }
22704 const VARIANTS: &[&str] = &["file",
22705 "folder",
22706 "file_ancestor",
22707 "other"];
22708 deserializer.deserialize_struct("WriteConflictError", VARIANTS, EnumVisitor)
22709 }
22710}
22711
22712impl ::serde::ser::Serialize for WriteConflictError {
22713 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22714 use serde::ser::SerializeStruct;
22716 match self {
22717 WriteConflictError::File => {
22718 let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
22720 s.serialize_field(".tag", "file")?;
22721 s.end()
22722 }
22723 WriteConflictError::Folder => {
22724 let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
22726 s.serialize_field(".tag", "folder")?;
22727 s.end()
22728 }
22729 WriteConflictError::FileAncestor => {
22730 let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
22732 s.serialize_field(".tag", "file_ancestor")?;
22733 s.end()
22734 }
22735 WriteConflictError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
22736 }
22737 }
22738}
22739
22740impl ::std::error::Error for WriteConflictError {
22741}
22742
22743impl ::std::fmt::Display for WriteConflictError {
22744 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22745 match self {
22746 WriteConflictError::File => f.write_str("There's a file in the way."),
22747 WriteConflictError::Folder => f.write_str("There's a folder in the way."),
22748 WriteConflictError::FileAncestor => f.write_str("There's a file at an ancestor path, so we couldn't create the required parent folders."),
22749 _ => write!(f, "{:?}", *self),
22750 }
22751 }
22752}
22753
22754#[derive(Debug, Clone, PartialEq, Eq)]
22755#[non_exhaustive] pub enum WriteError {
22757 MalformedPath(MalformedPathError),
22761 Conflict(WriteConflictError),
22763 NoWritePermission,
22765 InsufficientSpace,
22767 DisallowedName,
22769 TeamFolder,
22771 OperationSuppressed,
22773 TooManyWriteOperations,
22775 AccessRestricted,
22778 Other,
22781}
22782
22783impl<'de> ::serde::de::Deserialize<'de> for WriteError {
22784 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22785 use serde::de::{self, MapAccess, Visitor};
22787 struct EnumVisitor;
22788 impl<'de> Visitor<'de> for EnumVisitor {
22789 type Value = WriteError;
22790 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22791 f.write_str("a WriteError structure")
22792 }
22793 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22794 let tag: &str = match map.next_key()? {
22795 Some(".tag") => map.next_value()?,
22796 _ => return Err(de::Error::missing_field(".tag"))
22797 };
22798 let value = match tag {
22799 "malformed_path" => {
22800 match map.next_key()? {
22801 Some("malformed_path") => WriteError::MalformedPath(map.next_value()?),
22802 None => WriteError::MalformedPath(None),
22803 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
22804 }
22805 }
22806 "conflict" => {
22807 match map.next_key()? {
22808 Some("conflict") => WriteError::Conflict(map.next_value()?),
22809 None => return Err(de::Error::missing_field("conflict")),
22810 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
22811 }
22812 }
22813 "no_write_permission" => WriteError::NoWritePermission,
22814 "insufficient_space" => WriteError::InsufficientSpace,
22815 "disallowed_name" => WriteError::DisallowedName,
22816 "team_folder" => WriteError::TeamFolder,
22817 "operation_suppressed" => WriteError::OperationSuppressed,
22818 "too_many_write_operations" => WriteError::TooManyWriteOperations,
22819 "access_restricted" => WriteError::AccessRestricted,
22820 _ => WriteError::Other,
22821 };
22822 crate::eat_json_fields(&mut map)?;
22823 Ok(value)
22824 }
22825 }
22826 const VARIANTS: &[&str] = &["malformed_path",
22827 "conflict",
22828 "no_write_permission",
22829 "insufficient_space",
22830 "disallowed_name",
22831 "team_folder",
22832 "operation_suppressed",
22833 "too_many_write_operations",
22834 "access_restricted",
22835 "other"];
22836 deserializer.deserialize_struct("WriteError", VARIANTS, EnumVisitor)
22837 }
22838}
22839
22840impl ::serde::ser::Serialize for WriteError {
22841 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22842 use serde::ser::SerializeStruct;
22844 match self {
22845 WriteError::MalformedPath(x) => {
22846 let n = if x.is_some() { 2 } else { 1 };
22848 let mut s = serializer.serialize_struct("WriteError", n)?;
22849 s.serialize_field(".tag", "malformed_path")?;
22850 if let Some(x) = x {
22851 s.serialize_field("malformed_path", &x)?;
22852 }
22853 s.end()
22854 }
22855 WriteError::Conflict(x) => {
22856 let mut s = serializer.serialize_struct("WriteError", 2)?;
22858 s.serialize_field(".tag", "conflict")?;
22859 s.serialize_field("conflict", x)?;
22860 s.end()
22861 }
22862 WriteError::NoWritePermission => {
22863 let mut s = serializer.serialize_struct("WriteError", 1)?;
22865 s.serialize_field(".tag", "no_write_permission")?;
22866 s.end()
22867 }
22868 WriteError::InsufficientSpace => {
22869 let mut s = serializer.serialize_struct("WriteError", 1)?;
22871 s.serialize_field(".tag", "insufficient_space")?;
22872 s.end()
22873 }
22874 WriteError::DisallowedName => {
22875 let mut s = serializer.serialize_struct("WriteError", 1)?;
22877 s.serialize_field(".tag", "disallowed_name")?;
22878 s.end()
22879 }
22880 WriteError::TeamFolder => {
22881 let mut s = serializer.serialize_struct("WriteError", 1)?;
22883 s.serialize_field(".tag", "team_folder")?;
22884 s.end()
22885 }
22886 WriteError::OperationSuppressed => {
22887 let mut s = serializer.serialize_struct("WriteError", 1)?;
22889 s.serialize_field(".tag", "operation_suppressed")?;
22890 s.end()
22891 }
22892 WriteError::TooManyWriteOperations => {
22893 let mut s = serializer.serialize_struct("WriteError", 1)?;
22895 s.serialize_field(".tag", "too_many_write_operations")?;
22896 s.end()
22897 }
22898 WriteError::AccessRestricted => {
22899 let mut s = serializer.serialize_struct("WriteError", 1)?;
22901 s.serialize_field(".tag", "access_restricted")?;
22902 s.end()
22903 }
22904 WriteError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
22905 }
22906 }
22907}
22908
22909impl ::std::error::Error for WriteError {
22910 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
22911 match self {
22912 WriteError::Conflict(inner) => Some(inner),
22913 _ => None,
22914 }
22915 }
22916}
22917
22918impl ::std::fmt::Display for WriteError {
22919 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22920 match self {
22921 WriteError::MalformedPath(inner) => write!(f, "malformed_path: {:?}", inner),
22922 WriteError::Conflict(inner) => write!(f, "Couldn't write to the target path because there was something in the way: {}", inner),
22923 WriteError::NoWritePermission => f.write_str("The user doesn't have permissions to write to the target location."),
22924 WriteError::InsufficientSpace => f.write_str("The user doesn't have enough available space (bytes) to write more data."),
22925 WriteError::DisallowedName => f.write_str("Dropbox will not save the file or folder because of its name."),
22926 WriteError::TeamFolder => f.write_str("This endpoint cannot move or delete team folders."),
22927 WriteError::OperationSuppressed => f.write_str("This file operation is not allowed at this path."),
22928 WriteError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
22929 WriteError::AccessRestricted => f.write_str("The user doesn't have permission to perform the action due to restrictions set by a team administrator"),
22930 _ => write!(f, "{:?}", *self),
22931 }
22932 }
22933}
22934
22935#[derive(Debug, Clone, PartialEq, Eq)]
22943pub enum WriteMode {
22944 Add,
22948 Overwrite,
22951 Update(Rev),
22959}
22960
22961impl<'de> ::serde::de::Deserialize<'de> for WriteMode {
22962 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22963 use serde::de::{self, MapAccess, Visitor};
22965 struct EnumVisitor;
22966 impl<'de> Visitor<'de> for EnumVisitor {
22967 type Value = WriteMode;
22968 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22969 f.write_str("a WriteMode structure")
22970 }
22971 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22972 let tag: &str = match map.next_key()? {
22973 Some(".tag") => map.next_value()?,
22974 _ => return Err(de::Error::missing_field(".tag"))
22975 };
22976 let value = match tag {
22977 "add" => WriteMode::Add,
22978 "overwrite" => WriteMode::Overwrite,
22979 "update" => {
22980 match map.next_key()? {
22981 Some("update") => WriteMode::Update(map.next_value()?),
22982 None => return Err(de::Error::missing_field("update")),
22983 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
22984 }
22985 }
22986 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
22987 };
22988 crate::eat_json_fields(&mut map)?;
22989 Ok(value)
22990 }
22991 }
22992 const VARIANTS: &[&str] = &["add",
22993 "overwrite",
22994 "update"];
22995 deserializer.deserialize_struct("WriteMode", VARIANTS, EnumVisitor)
22996 }
22997}
22998
22999impl ::serde::ser::Serialize for WriteMode {
23000 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
23001 use serde::ser::SerializeStruct;
23003 match self {
23004 WriteMode::Add => {
23005 let mut s = serializer.serialize_struct("WriteMode", 1)?;
23007 s.serialize_field(".tag", "add")?;
23008 s.end()
23009 }
23010 WriteMode::Overwrite => {
23011 let mut s = serializer.serialize_struct("WriteMode", 1)?;
23013 s.serialize_field(".tag", "overwrite")?;
23014 s.end()
23015 }
23016 WriteMode::Update(x) => {
23017 let mut s = serializer.serialize_struct("WriteMode", 2)?;
23019 s.serialize_field(".tag", "update")?;
23020 s.serialize_field("update", x)?;
23021 s.end()
23022 }
23023 }
23024 }
23025}
23026