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}
2985
2986impl DeletedMetadata {
2987 pub fn new(name: String) -> Self {
2988 DeletedMetadata {
2989 name,
2990 path_lower: None,
2991 path_display: None,
2992 #[allow(deprecated)] parent_shared_folder_id: None,
2993 preview_url: None,
2994 }
2995 }
2996
2997 pub fn with_path_lower(mut self, value: String) -> Self {
2998 self.path_lower = Some(value);
2999 self
3000 }
3001
3002 pub fn with_path_display(mut self, value: String) -> Self {
3003 self.path_display = Some(value);
3004 self
3005 }
3006
3007 #[deprecated]
3008 #[allow(deprecated)]
3009 pub fn with_parent_shared_folder_id(
3010 mut self,
3011 value: crate::types::common::SharedFolderId,
3012 ) -> Self {
3013 self.parent_shared_folder_id = Some(value);
3014 self
3015 }
3016
3017 pub fn with_preview_url(mut self, value: String) -> Self {
3018 self.preview_url = Some(value);
3019 self
3020 }
3021}
3022
3023const DELETED_METADATA_FIELDS: &[&str] = &["name",
3024 "path_lower",
3025 "path_display",
3026 "parent_shared_folder_id",
3027 "preview_url"];
3028impl DeletedMetadata {
3029 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3030 map: V,
3031 ) -> Result<DeletedMetadata, V::Error> {
3032 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3033 }
3034
3035 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3036 mut map: V,
3037 optional: bool,
3038 ) -> Result<Option<DeletedMetadata>, V::Error> {
3039 let mut field_name = None;
3040 let mut field_path_lower = None;
3041 let mut field_path_display = None;
3042 let mut field_parent_shared_folder_id = None;
3043 let mut field_preview_url = None;
3044 let mut nothing = true;
3045 while let Some(key) = map.next_key::<&str>()? {
3046 nothing = false;
3047 match key {
3048 "name" => {
3049 if field_name.is_some() {
3050 return Err(::serde::de::Error::duplicate_field("name"));
3051 }
3052 field_name = Some(map.next_value()?);
3053 }
3054 "path_lower" => {
3055 if field_path_lower.is_some() {
3056 return Err(::serde::de::Error::duplicate_field("path_lower"));
3057 }
3058 field_path_lower = Some(map.next_value()?);
3059 }
3060 "path_display" => {
3061 if field_path_display.is_some() {
3062 return Err(::serde::de::Error::duplicate_field("path_display"));
3063 }
3064 field_path_display = Some(map.next_value()?);
3065 }
3066 "parent_shared_folder_id" => {
3067 if field_parent_shared_folder_id.is_some() {
3068 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
3069 }
3070 field_parent_shared_folder_id = Some(map.next_value()?);
3071 }
3072 "preview_url" => {
3073 if field_preview_url.is_some() {
3074 return Err(::serde::de::Error::duplicate_field("preview_url"));
3075 }
3076 field_preview_url = Some(map.next_value()?);
3077 }
3078 _ => {
3079 map.next_value::<::serde_json::Value>()?;
3081 }
3082 }
3083 }
3084 if optional && nothing {
3085 return Ok(None);
3086 }
3087 let result = DeletedMetadata {
3088 name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
3089 path_lower: field_path_lower.and_then(Option::flatten),
3090 path_display: field_path_display.and_then(Option::flatten),
3091 #[allow(deprecated)] parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
3092 preview_url: field_preview_url.and_then(Option::flatten),
3093 };
3094 Ok(Some(result))
3095 }
3096
3097 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3098 &self,
3099 s: &mut S::SerializeStruct,
3100 ) -> Result<(), S::Error> {
3101 use serde::ser::SerializeStruct;
3102 s.serialize_field("name", &self.name)?;
3103 if let Some(val) = &self.path_lower {
3104 s.serialize_field("path_lower", val)?;
3105 }
3106 if let Some(val) = &self.path_display {
3107 s.serialize_field("path_display", val)?;
3108 }
3109 #[allow(deprecated)]
3110 if let Some(val) = &self.parent_shared_folder_id {
3111 s.serialize_field("parent_shared_folder_id", val)?;
3112 }
3113 if let Some(val) = &self.preview_url {
3114 s.serialize_field("preview_url", val)?;
3115 }
3116 Ok(())
3117 }
3118}
3119
3120impl<'de> ::serde::de::Deserialize<'de> for DeletedMetadata {
3121 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3122 use serde::de::{MapAccess, Visitor};
3124 struct StructVisitor;
3125 impl<'de> Visitor<'de> for StructVisitor {
3126 type Value = DeletedMetadata;
3127 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3128 f.write_str("a DeletedMetadata struct")
3129 }
3130 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3131 DeletedMetadata::internal_deserialize(map)
3132 }
3133 }
3134 deserializer.deserialize_struct("DeletedMetadata", DELETED_METADATA_FIELDS, StructVisitor)
3135 }
3136}
3137
3138impl ::serde::ser::Serialize for DeletedMetadata {
3139 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3140 use serde::ser::SerializeStruct;
3142 let mut s = serializer.serialize_struct("DeletedMetadata", 5)?;
3143 self.internal_serialize::<S>(&mut s)?;
3144 s.end()
3145 }
3146}
3147
3148impl From<DeletedMetadata> for Metadata {
3150 fn from(subtype: DeletedMetadata) -> Self {
3151 Metadata::Deleted(subtype)
3152 }
3153}
3154#[derive(Debug, Clone, PartialEq, Eq)]
3156#[non_exhaustive] pub struct Dimensions {
3158 pub height: u64,
3160 pub width: u64,
3162}
3163
3164impl Dimensions {
3165 pub fn new(height: u64, width: u64) -> Self {
3166 Dimensions {
3167 height,
3168 width,
3169 }
3170 }
3171}
3172
3173const DIMENSIONS_FIELDS: &[&str] = &["height",
3174 "width"];
3175impl Dimensions {
3176 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3177 map: V,
3178 ) -> Result<Dimensions, V::Error> {
3179 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3180 }
3181
3182 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3183 mut map: V,
3184 optional: bool,
3185 ) -> Result<Option<Dimensions>, V::Error> {
3186 let mut field_height = None;
3187 let mut field_width = None;
3188 let mut nothing = true;
3189 while let Some(key) = map.next_key::<&str>()? {
3190 nothing = false;
3191 match key {
3192 "height" => {
3193 if field_height.is_some() {
3194 return Err(::serde::de::Error::duplicate_field("height"));
3195 }
3196 field_height = Some(map.next_value()?);
3197 }
3198 "width" => {
3199 if field_width.is_some() {
3200 return Err(::serde::de::Error::duplicate_field("width"));
3201 }
3202 field_width = Some(map.next_value()?);
3203 }
3204 _ => {
3205 map.next_value::<::serde_json::Value>()?;
3207 }
3208 }
3209 }
3210 if optional && nothing {
3211 return Ok(None);
3212 }
3213 let result = Dimensions {
3214 height: field_height.ok_or_else(|| ::serde::de::Error::missing_field("height"))?,
3215 width: field_width.ok_or_else(|| ::serde::de::Error::missing_field("width"))?,
3216 };
3217 Ok(Some(result))
3218 }
3219
3220 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3221 &self,
3222 s: &mut S::SerializeStruct,
3223 ) -> Result<(), S::Error> {
3224 use serde::ser::SerializeStruct;
3225 s.serialize_field("height", &self.height)?;
3226 s.serialize_field("width", &self.width)?;
3227 Ok(())
3228 }
3229}
3230
3231impl<'de> ::serde::de::Deserialize<'de> for Dimensions {
3232 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3233 use serde::de::{MapAccess, Visitor};
3235 struct StructVisitor;
3236 impl<'de> Visitor<'de> for StructVisitor {
3237 type Value = Dimensions;
3238 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3239 f.write_str("a Dimensions struct")
3240 }
3241 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3242 Dimensions::internal_deserialize(map)
3243 }
3244 }
3245 deserializer.deserialize_struct("Dimensions", DIMENSIONS_FIELDS, StructVisitor)
3246 }
3247}
3248
3249impl ::serde::ser::Serialize for Dimensions {
3250 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3251 use serde::ser::SerializeStruct;
3253 let mut s = serializer.serialize_struct("Dimensions", 2)?;
3254 self.internal_serialize::<S>(&mut s)?;
3255 s.end()
3256 }
3257}
3258
3259#[derive(Debug, Clone, PartialEq, Eq)]
3260#[non_exhaustive] pub struct DownloadArg {
3262 pub path: ReadPath,
3264 #[deprecated]
3266 pub rev: Option<Rev>,
3267}
3268
3269impl DownloadArg {
3270 pub fn new(path: ReadPath) -> Self {
3271 DownloadArg {
3272 path,
3273 #[allow(deprecated)] rev: None,
3274 }
3275 }
3276
3277 #[deprecated]
3278 #[allow(deprecated)]
3279 pub fn with_rev(mut self, value: Rev) -> Self {
3280 self.rev = Some(value);
3281 self
3282 }
3283}
3284
3285const DOWNLOAD_ARG_FIELDS: &[&str] = &["path",
3286 "rev"];
3287impl DownloadArg {
3288 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3289 map: V,
3290 ) -> Result<DownloadArg, V::Error> {
3291 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3292 }
3293
3294 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3295 mut map: V,
3296 optional: bool,
3297 ) -> Result<Option<DownloadArg>, V::Error> {
3298 let mut field_path = None;
3299 let mut field_rev = None;
3300 let mut nothing = true;
3301 while let Some(key) = map.next_key::<&str>()? {
3302 nothing = false;
3303 match key {
3304 "path" => {
3305 if field_path.is_some() {
3306 return Err(::serde::de::Error::duplicate_field("path"));
3307 }
3308 field_path = Some(map.next_value()?);
3309 }
3310 "rev" => {
3311 if field_rev.is_some() {
3312 return Err(::serde::de::Error::duplicate_field("rev"));
3313 }
3314 field_rev = Some(map.next_value()?);
3315 }
3316 _ => {
3317 map.next_value::<::serde_json::Value>()?;
3319 }
3320 }
3321 }
3322 if optional && nothing {
3323 return Ok(None);
3324 }
3325 let result = DownloadArg {
3326 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
3327 #[allow(deprecated)] rev: field_rev.and_then(Option::flatten),
3328 };
3329 Ok(Some(result))
3330 }
3331
3332 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3333 &self,
3334 s: &mut S::SerializeStruct,
3335 ) -> Result<(), S::Error> {
3336 use serde::ser::SerializeStruct;
3337 s.serialize_field("path", &self.path)?;
3338 #[allow(deprecated)]
3339 if let Some(val) = &self.rev {
3340 s.serialize_field("rev", val)?;
3341 }
3342 Ok(())
3343 }
3344}
3345
3346impl<'de> ::serde::de::Deserialize<'de> for DownloadArg {
3347 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3348 use serde::de::{MapAccess, Visitor};
3350 struct StructVisitor;
3351 impl<'de> Visitor<'de> for StructVisitor {
3352 type Value = DownloadArg;
3353 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3354 f.write_str("a DownloadArg struct")
3355 }
3356 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3357 DownloadArg::internal_deserialize(map)
3358 }
3359 }
3360 deserializer.deserialize_struct("DownloadArg", DOWNLOAD_ARG_FIELDS, StructVisitor)
3361 }
3362}
3363
3364impl ::serde::ser::Serialize for DownloadArg {
3365 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3366 use serde::ser::SerializeStruct;
3368 let mut s = serializer.serialize_struct("DownloadArg", 2)?;
3369 self.internal_serialize::<S>(&mut s)?;
3370 s.end()
3371 }
3372}
3373
3374#[derive(Debug, Clone, PartialEq, Eq)]
3375#[non_exhaustive] pub enum DownloadError {
3377 Path(LookupError),
3378 UnsupportedFile,
3381 Other,
3384}
3385
3386impl<'de> ::serde::de::Deserialize<'de> for DownloadError {
3387 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3388 use serde::de::{self, MapAccess, Visitor};
3390 struct EnumVisitor;
3391 impl<'de> Visitor<'de> for EnumVisitor {
3392 type Value = DownloadError;
3393 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3394 f.write_str("a DownloadError structure")
3395 }
3396 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3397 let tag: &str = match map.next_key()? {
3398 Some(".tag") => map.next_value()?,
3399 _ => return Err(de::Error::missing_field(".tag"))
3400 };
3401 let value = match tag {
3402 "path" => {
3403 match map.next_key()? {
3404 Some("path") => DownloadError::Path(map.next_value()?),
3405 None => return Err(de::Error::missing_field("path")),
3406 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3407 }
3408 }
3409 "unsupported_file" => DownloadError::UnsupportedFile,
3410 _ => DownloadError::Other,
3411 };
3412 crate::eat_json_fields(&mut map)?;
3413 Ok(value)
3414 }
3415 }
3416 const VARIANTS: &[&str] = &["path",
3417 "unsupported_file",
3418 "other"];
3419 deserializer.deserialize_struct("DownloadError", VARIANTS, EnumVisitor)
3420 }
3421}
3422
3423impl ::serde::ser::Serialize for DownloadError {
3424 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3425 use serde::ser::SerializeStruct;
3427 match self {
3428 DownloadError::Path(x) => {
3429 let mut s = serializer.serialize_struct("DownloadError", 2)?;
3431 s.serialize_field(".tag", "path")?;
3432 s.serialize_field("path", x)?;
3433 s.end()
3434 }
3435 DownloadError::UnsupportedFile => {
3436 let mut s = serializer.serialize_struct("DownloadError", 1)?;
3438 s.serialize_field(".tag", "unsupported_file")?;
3439 s.end()
3440 }
3441 DownloadError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3442 }
3443 }
3444}
3445
3446impl ::std::error::Error for DownloadError {
3447 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
3448 match self {
3449 DownloadError::Path(inner) => Some(inner),
3450 _ => None,
3451 }
3452 }
3453}
3454
3455impl ::std::fmt::Display for DownloadError {
3456 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3457 match self {
3458 DownloadError::Path(inner) => write!(f, "DownloadError: {}", inner),
3459 _ => write!(f, "{:?}", *self),
3460 }
3461 }
3462}
3463
3464#[derive(Debug, Clone, PartialEq, Eq)]
3465#[non_exhaustive] pub struct DownloadZipArg {
3467 pub path: ReadPath,
3469}
3470
3471impl DownloadZipArg {
3472 pub fn new(path: ReadPath) -> Self {
3473 DownloadZipArg {
3474 path,
3475 }
3476 }
3477}
3478
3479const DOWNLOAD_ZIP_ARG_FIELDS: &[&str] = &["path"];
3480impl DownloadZipArg {
3481 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3482 map: V,
3483 ) -> Result<DownloadZipArg, V::Error> {
3484 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3485 }
3486
3487 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3488 mut map: V,
3489 optional: bool,
3490 ) -> Result<Option<DownloadZipArg>, V::Error> {
3491 let mut field_path = None;
3492 let mut nothing = true;
3493 while let Some(key) = map.next_key::<&str>()? {
3494 nothing = false;
3495 match key {
3496 "path" => {
3497 if field_path.is_some() {
3498 return Err(::serde::de::Error::duplicate_field("path"));
3499 }
3500 field_path = Some(map.next_value()?);
3501 }
3502 _ => {
3503 map.next_value::<::serde_json::Value>()?;
3505 }
3506 }
3507 }
3508 if optional && nothing {
3509 return Ok(None);
3510 }
3511 let result = DownloadZipArg {
3512 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
3513 };
3514 Ok(Some(result))
3515 }
3516
3517 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3518 &self,
3519 s: &mut S::SerializeStruct,
3520 ) -> Result<(), S::Error> {
3521 use serde::ser::SerializeStruct;
3522 s.serialize_field("path", &self.path)?;
3523 Ok(())
3524 }
3525}
3526
3527impl<'de> ::serde::de::Deserialize<'de> for DownloadZipArg {
3528 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3529 use serde::de::{MapAccess, Visitor};
3531 struct StructVisitor;
3532 impl<'de> Visitor<'de> for StructVisitor {
3533 type Value = DownloadZipArg;
3534 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3535 f.write_str("a DownloadZipArg struct")
3536 }
3537 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3538 DownloadZipArg::internal_deserialize(map)
3539 }
3540 }
3541 deserializer.deserialize_struct("DownloadZipArg", DOWNLOAD_ZIP_ARG_FIELDS, StructVisitor)
3542 }
3543}
3544
3545impl ::serde::ser::Serialize for DownloadZipArg {
3546 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3547 use serde::ser::SerializeStruct;
3549 let mut s = serializer.serialize_struct("DownloadZipArg", 1)?;
3550 self.internal_serialize::<S>(&mut s)?;
3551 s.end()
3552 }
3553}
3554
3555#[derive(Debug, Clone, PartialEq, Eq)]
3556#[non_exhaustive] pub enum DownloadZipError {
3558 Path(LookupError),
3559 TooLarge,
3561 TooManyFiles,
3563 Other,
3566}
3567
3568impl<'de> ::serde::de::Deserialize<'de> for DownloadZipError {
3569 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3570 use serde::de::{self, MapAccess, Visitor};
3572 struct EnumVisitor;
3573 impl<'de> Visitor<'de> for EnumVisitor {
3574 type Value = DownloadZipError;
3575 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3576 f.write_str("a DownloadZipError structure")
3577 }
3578 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3579 let tag: &str = match map.next_key()? {
3580 Some(".tag") => map.next_value()?,
3581 _ => return Err(de::Error::missing_field(".tag"))
3582 };
3583 let value = match tag {
3584 "path" => {
3585 match map.next_key()? {
3586 Some("path") => DownloadZipError::Path(map.next_value()?),
3587 None => return Err(de::Error::missing_field("path")),
3588 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3589 }
3590 }
3591 "too_large" => DownloadZipError::TooLarge,
3592 "too_many_files" => DownloadZipError::TooManyFiles,
3593 _ => DownloadZipError::Other,
3594 };
3595 crate::eat_json_fields(&mut map)?;
3596 Ok(value)
3597 }
3598 }
3599 const VARIANTS: &[&str] = &["path",
3600 "too_large",
3601 "too_many_files",
3602 "other"];
3603 deserializer.deserialize_struct("DownloadZipError", VARIANTS, EnumVisitor)
3604 }
3605}
3606
3607impl ::serde::ser::Serialize for DownloadZipError {
3608 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3609 use serde::ser::SerializeStruct;
3611 match self {
3612 DownloadZipError::Path(x) => {
3613 let mut s = serializer.serialize_struct("DownloadZipError", 2)?;
3615 s.serialize_field(".tag", "path")?;
3616 s.serialize_field("path", x)?;
3617 s.end()
3618 }
3619 DownloadZipError::TooLarge => {
3620 let mut s = serializer.serialize_struct("DownloadZipError", 1)?;
3622 s.serialize_field(".tag", "too_large")?;
3623 s.end()
3624 }
3625 DownloadZipError::TooManyFiles => {
3626 let mut s = serializer.serialize_struct("DownloadZipError", 1)?;
3628 s.serialize_field(".tag", "too_many_files")?;
3629 s.end()
3630 }
3631 DownloadZipError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3632 }
3633 }
3634}
3635
3636impl ::std::error::Error for DownloadZipError {
3637 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
3638 match self {
3639 DownloadZipError::Path(inner) => Some(inner),
3640 _ => None,
3641 }
3642 }
3643}
3644
3645impl ::std::fmt::Display for DownloadZipError {
3646 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3647 match self {
3648 DownloadZipError::Path(inner) => write!(f, "DownloadZipError: {}", inner),
3649 DownloadZipError::TooLarge => f.write_str("The folder or a file is too large to download."),
3650 DownloadZipError::TooManyFiles => f.write_str("The folder has too many files to download."),
3651 _ => write!(f, "{:?}", *self),
3652 }
3653 }
3654}
3655
3656#[derive(Debug, Clone, PartialEq, Eq)]
3657#[non_exhaustive] pub struct DownloadZipResult {
3659 pub metadata: FolderMetadata,
3660}
3661
3662impl DownloadZipResult {
3663 pub fn new(metadata: FolderMetadata) -> Self {
3664 DownloadZipResult {
3665 metadata,
3666 }
3667 }
3668}
3669
3670const DOWNLOAD_ZIP_RESULT_FIELDS: &[&str] = &["metadata"];
3671impl DownloadZipResult {
3672 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3673 map: V,
3674 ) -> Result<DownloadZipResult, V::Error> {
3675 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3676 }
3677
3678 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3679 mut map: V,
3680 optional: bool,
3681 ) -> Result<Option<DownloadZipResult>, V::Error> {
3682 let mut field_metadata = None;
3683 let mut nothing = true;
3684 while let Some(key) = map.next_key::<&str>()? {
3685 nothing = false;
3686 match key {
3687 "metadata" => {
3688 if field_metadata.is_some() {
3689 return Err(::serde::de::Error::duplicate_field("metadata"));
3690 }
3691 field_metadata = Some(map.next_value()?);
3692 }
3693 _ => {
3694 map.next_value::<::serde_json::Value>()?;
3696 }
3697 }
3698 }
3699 if optional && nothing {
3700 return Ok(None);
3701 }
3702 let result = DownloadZipResult {
3703 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
3704 };
3705 Ok(Some(result))
3706 }
3707
3708 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3709 &self,
3710 s: &mut S::SerializeStruct,
3711 ) -> Result<(), S::Error> {
3712 use serde::ser::SerializeStruct;
3713 s.serialize_field("metadata", &self.metadata)?;
3714 Ok(())
3715 }
3716}
3717
3718impl<'de> ::serde::de::Deserialize<'de> for DownloadZipResult {
3719 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3720 use serde::de::{MapAccess, Visitor};
3722 struct StructVisitor;
3723 impl<'de> Visitor<'de> for StructVisitor {
3724 type Value = DownloadZipResult;
3725 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3726 f.write_str("a DownloadZipResult struct")
3727 }
3728 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3729 DownloadZipResult::internal_deserialize(map)
3730 }
3731 }
3732 deserializer.deserialize_struct("DownloadZipResult", DOWNLOAD_ZIP_RESULT_FIELDS, StructVisitor)
3733 }
3734}
3735
3736impl ::serde::ser::Serialize for DownloadZipResult {
3737 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3738 use serde::ser::SerializeStruct;
3740 let mut s = serializer.serialize_struct("DownloadZipResult", 1)?;
3741 self.internal_serialize::<S>(&mut s)?;
3742 s.end()
3743 }
3744}
3745
3746#[derive(Debug, Clone, PartialEq, Eq)]
3747#[non_exhaustive] pub struct ExportArg {
3749 pub path: ReadPath,
3751 pub export_format: Option<String>,
3756}
3757
3758impl ExportArg {
3759 pub fn new(path: ReadPath) -> Self {
3760 ExportArg {
3761 path,
3762 export_format: None,
3763 }
3764 }
3765
3766 pub fn with_export_format(mut self, value: String) -> Self {
3767 self.export_format = Some(value);
3768 self
3769 }
3770}
3771
3772const EXPORT_ARG_FIELDS: &[&str] = &["path",
3773 "export_format"];
3774impl ExportArg {
3775 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3776 map: V,
3777 ) -> Result<ExportArg, V::Error> {
3778 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
3779 }
3780
3781 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
3782 mut map: V,
3783 optional: bool,
3784 ) -> Result<Option<ExportArg>, V::Error> {
3785 let mut field_path = None;
3786 let mut field_export_format = None;
3787 let mut nothing = true;
3788 while let Some(key) = map.next_key::<&str>()? {
3789 nothing = false;
3790 match key {
3791 "path" => {
3792 if field_path.is_some() {
3793 return Err(::serde::de::Error::duplicate_field("path"));
3794 }
3795 field_path = Some(map.next_value()?);
3796 }
3797 "export_format" => {
3798 if field_export_format.is_some() {
3799 return Err(::serde::de::Error::duplicate_field("export_format"));
3800 }
3801 field_export_format = Some(map.next_value()?);
3802 }
3803 _ => {
3804 map.next_value::<::serde_json::Value>()?;
3806 }
3807 }
3808 }
3809 if optional && nothing {
3810 return Ok(None);
3811 }
3812 let result = ExportArg {
3813 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
3814 export_format: field_export_format.and_then(Option::flatten),
3815 };
3816 Ok(Some(result))
3817 }
3818
3819 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
3820 &self,
3821 s: &mut S::SerializeStruct,
3822 ) -> Result<(), S::Error> {
3823 use serde::ser::SerializeStruct;
3824 s.serialize_field("path", &self.path)?;
3825 if let Some(val) = &self.export_format {
3826 s.serialize_field("export_format", val)?;
3827 }
3828 Ok(())
3829 }
3830}
3831
3832impl<'de> ::serde::de::Deserialize<'de> for ExportArg {
3833 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3834 use serde::de::{MapAccess, Visitor};
3836 struct StructVisitor;
3837 impl<'de> Visitor<'de> for StructVisitor {
3838 type Value = ExportArg;
3839 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3840 f.write_str("a ExportArg struct")
3841 }
3842 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
3843 ExportArg::internal_deserialize(map)
3844 }
3845 }
3846 deserializer.deserialize_struct("ExportArg", EXPORT_ARG_FIELDS, StructVisitor)
3847 }
3848}
3849
3850impl ::serde::ser::Serialize for ExportArg {
3851 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3852 use serde::ser::SerializeStruct;
3854 let mut s = serializer.serialize_struct("ExportArg", 2)?;
3855 self.internal_serialize::<S>(&mut s)?;
3856 s.end()
3857 }
3858}
3859
3860#[derive(Debug, Clone, PartialEq, Eq)]
3861#[non_exhaustive] pub enum ExportError {
3863 Path(LookupError),
3864 NonExportable,
3866 InvalidExportFormat,
3868 RetryError,
3870 Other,
3873}
3874
3875impl<'de> ::serde::de::Deserialize<'de> for ExportError {
3876 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
3877 use serde::de::{self, MapAccess, Visitor};
3879 struct EnumVisitor;
3880 impl<'de> Visitor<'de> for EnumVisitor {
3881 type Value = ExportError;
3882 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3883 f.write_str("a ExportError structure")
3884 }
3885 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
3886 let tag: &str = match map.next_key()? {
3887 Some(".tag") => map.next_value()?,
3888 _ => return Err(de::Error::missing_field(".tag"))
3889 };
3890 let value = match tag {
3891 "path" => {
3892 match map.next_key()? {
3893 Some("path") => ExportError::Path(map.next_value()?),
3894 None => return Err(de::Error::missing_field("path")),
3895 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
3896 }
3897 }
3898 "non_exportable" => ExportError::NonExportable,
3899 "invalid_export_format" => ExportError::InvalidExportFormat,
3900 "retry_error" => ExportError::RetryError,
3901 _ => ExportError::Other,
3902 };
3903 crate::eat_json_fields(&mut map)?;
3904 Ok(value)
3905 }
3906 }
3907 const VARIANTS: &[&str] = &["path",
3908 "non_exportable",
3909 "invalid_export_format",
3910 "retry_error",
3911 "other"];
3912 deserializer.deserialize_struct("ExportError", VARIANTS, EnumVisitor)
3913 }
3914}
3915
3916impl ::serde::ser::Serialize for ExportError {
3917 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
3918 use serde::ser::SerializeStruct;
3920 match self {
3921 ExportError::Path(x) => {
3922 let mut s = serializer.serialize_struct("ExportError", 2)?;
3924 s.serialize_field(".tag", "path")?;
3925 s.serialize_field("path", x)?;
3926 s.end()
3927 }
3928 ExportError::NonExportable => {
3929 let mut s = serializer.serialize_struct("ExportError", 1)?;
3931 s.serialize_field(".tag", "non_exportable")?;
3932 s.end()
3933 }
3934 ExportError::InvalidExportFormat => {
3935 let mut s = serializer.serialize_struct("ExportError", 1)?;
3937 s.serialize_field(".tag", "invalid_export_format")?;
3938 s.end()
3939 }
3940 ExportError::RetryError => {
3941 let mut s = serializer.serialize_struct("ExportError", 1)?;
3943 s.serialize_field(".tag", "retry_error")?;
3944 s.end()
3945 }
3946 ExportError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
3947 }
3948 }
3949}
3950
3951impl ::std::error::Error for ExportError {
3952 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
3953 match self {
3954 ExportError::Path(inner) => Some(inner),
3955 _ => None,
3956 }
3957 }
3958}
3959
3960impl ::std::fmt::Display for ExportError {
3961 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
3962 match self {
3963 ExportError::Path(inner) => write!(f, "ExportError: {}", inner),
3964 ExportError::InvalidExportFormat => f.write_str("The specified export format is not a valid option for this file type."),
3965 ExportError::RetryError => f.write_str("The exportable content is not yet available. Please retry later."),
3966 _ => write!(f, "{:?}", *self),
3967 }
3968 }
3969}
3970
3971#[derive(Debug, Clone, PartialEq, Eq, Default)]
3973#[non_exhaustive] pub struct ExportInfo {
3975 pub export_as: Option<String>,
3977 pub export_options: Option<Vec<String>>,
3980}
3981
3982impl ExportInfo {
3983 pub fn with_export_as(mut self, value: String) -> Self {
3984 self.export_as = Some(value);
3985 self
3986 }
3987
3988 pub fn with_export_options(mut self, value: Vec<String>) -> Self {
3989 self.export_options = Some(value);
3990 self
3991 }
3992}
3993
3994const EXPORT_INFO_FIELDS: &[&str] = &["export_as",
3995 "export_options"];
3996impl ExportInfo {
3997 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
3999 mut map: V,
4000 ) -> Result<ExportInfo, V::Error> {
4001 let mut field_export_as = None;
4002 let mut field_export_options = None;
4003 while let Some(key) = map.next_key::<&str>()? {
4004 match key {
4005 "export_as" => {
4006 if field_export_as.is_some() {
4007 return Err(::serde::de::Error::duplicate_field("export_as"));
4008 }
4009 field_export_as = Some(map.next_value()?);
4010 }
4011 "export_options" => {
4012 if field_export_options.is_some() {
4013 return Err(::serde::de::Error::duplicate_field("export_options"));
4014 }
4015 field_export_options = Some(map.next_value()?);
4016 }
4017 _ => {
4018 map.next_value::<::serde_json::Value>()?;
4020 }
4021 }
4022 }
4023 let result = ExportInfo {
4024 export_as: field_export_as.and_then(Option::flatten),
4025 export_options: field_export_options.and_then(Option::flatten),
4026 };
4027 Ok(result)
4028 }
4029
4030 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4031 &self,
4032 s: &mut S::SerializeStruct,
4033 ) -> Result<(), S::Error> {
4034 use serde::ser::SerializeStruct;
4035 if let Some(val) = &self.export_as {
4036 s.serialize_field("export_as", val)?;
4037 }
4038 if let Some(val) = &self.export_options {
4039 s.serialize_field("export_options", val)?;
4040 }
4041 Ok(())
4042 }
4043}
4044
4045impl<'de> ::serde::de::Deserialize<'de> for ExportInfo {
4046 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4047 use serde::de::{MapAccess, Visitor};
4049 struct StructVisitor;
4050 impl<'de> Visitor<'de> for StructVisitor {
4051 type Value = ExportInfo;
4052 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4053 f.write_str("a ExportInfo struct")
4054 }
4055 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4056 ExportInfo::internal_deserialize(map)
4057 }
4058 }
4059 deserializer.deserialize_struct("ExportInfo", EXPORT_INFO_FIELDS, StructVisitor)
4060 }
4061}
4062
4063impl ::serde::ser::Serialize for ExportInfo {
4064 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4065 use serde::ser::SerializeStruct;
4067 let mut s = serializer.serialize_struct("ExportInfo", 2)?;
4068 self.internal_serialize::<S>(&mut s)?;
4069 s.end()
4070 }
4071}
4072
4073#[derive(Debug, Clone, PartialEq, Eq)]
4074#[non_exhaustive] pub struct ExportMetadata {
4076 pub name: String,
4078 pub size: u64,
4080 pub export_hash: Option<Sha256HexHash>,
4084 pub paper_revision: Option<i64>,
4087}
4088
4089impl ExportMetadata {
4090 pub fn new(name: String, size: u64) -> Self {
4091 ExportMetadata {
4092 name,
4093 size,
4094 export_hash: None,
4095 paper_revision: None,
4096 }
4097 }
4098
4099 pub fn with_export_hash(mut self, value: Sha256HexHash) -> Self {
4100 self.export_hash = Some(value);
4101 self
4102 }
4103
4104 pub fn with_paper_revision(mut self, value: i64) -> Self {
4105 self.paper_revision = Some(value);
4106 self
4107 }
4108}
4109
4110const EXPORT_METADATA_FIELDS: &[&str] = &["name",
4111 "size",
4112 "export_hash",
4113 "paper_revision"];
4114impl ExportMetadata {
4115 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4116 map: V,
4117 ) -> Result<ExportMetadata, V::Error> {
4118 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4119 }
4120
4121 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4122 mut map: V,
4123 optional: bool,
4124 ) -> Result<Option<ExportMetadata>, V::Error> {
4125 let mut field_name = None;
4126 let mut field_size = None;
4127 let mut field_export_hash = None;
4128 let mut field_paper_revision = None;
4129 let mut nothing = true;
4130 while let Some(key) = map.next_key::<&str>()? {
4131 nothing = false;
4132 match key {
4133 "name" => {
4134 if field_name.is_some() {
4135 return Err(::serde::de::Error::duplicate_field("name"));
4136 }
4137 field_name = Some(map.next_value()?);
4138 }
4139 "size" => {
4140 if field_size.is_some() {
4141 return Err(::serde::de::Error::duplicate_field("size"));
4142 }
4143 field_size = Some(map.next_value()?);
4144 }
4145 "export_hash" => {
4146 if field_export_hash.is_some() {
4147 return Err(::serde::de::Error::duplicate_field("export_hash"));
4148 }
4149 field_export_hash = Some(map.next_value()?);
4150 }
4151 "paper_revision" => {
4152 if field_paper_revision.is_some() {
4153 return Err(::serde::de::Error::duplicate_field("paper_revision"));
4154 }
4155 field_paper_revision = Some(map.next_value()?);
4156 }
4157 _ => {
4158 map.next_value::<::serde_json::Value>()?;
4160 }
4161 }
4162 }
4163 if optional && nothing {
4164 return Ok(None);
4165 }
4166 let result = ExportMetadata {
4167 name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
4168 size: field_size.ok_or_else(|| ::serde::de::Error::missing_field("size"))?,
4169 export_hash: field_export_hash.and_then(Option::flatten),
4170 paper_revision: field_paper_revision.and_then(Option::flatten),
4171 };
4172 Ok(Some(result))
4173 }
4174
4175 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4176 &self,
4177 s: &mut S::SerializeStruct,
4178 ) -> Result<(), S::Error> {
4179 use serde::ser::SerializeStruct;
4180 s.serialize_field("name", &self.name)?;
4181 s.serialize_field("size", &self.size)?;
4182 if let Some(val) = &self.export_hash {
4183 s.serialize_field("export_hash", val)?;
4184 }
4185 if let Some(val) = &self.paper_revision {
4186 s.serialize_field("paper_revision", val)?;
4187 }
4188 Ok(())
4189 }
4190}
4191
4192impl<'de> ::serde::de::Deserialize<'de> for ExportMetadata {
4193 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4194 use serde::de::{MapAccess, Visitor};
4196 struct StructVisitor;
4197 impl<'de> Visitor<'de> for StructVisitor {
4198 type Value = ExportMetadata;
4199 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4200 f.write_str("a ExportMetadata struct")
4201 }
4202 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4203 ExportMetadata::internal_deserialize(map)
4204 }
4205 }
4206 deserializer.deserialize_struct("ExportMetadata", EXPORT_METADATA_FIELDS, StructVisitor)
4207 }
4208}
4209
4210impl ::serde::ser::Serialize for ExportMetadata {
4211 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4212 use serde::ser::SerializeStruct;
4214 let mut s = serializer.serialize_struct("ExportMetadata", 4)?;
4215 self.internal_serialize::<S>(&mut s)?;
4216 s.end()
4217 }
4218}
4219
4220#[derive(Debug, Clone, PartialEq)]
4221#[non_exhaustive] pub struct ExportResult {
4223 pub export_metadata: ExportMetadata,
4225 pub file_metadata: FileMetadata,
4227}
4228
4229impl ExportResult {
4230 pub fn new(export_metadata: ExportMetadata, file_metadata: FileMetadata) -> Self {
4231 ExportResult {
4232 export_metadata,
4233 file_metadata,
4234 }
4235 }
4236}
4237
4238const EXPORT_RESULT_FIELDS: &[&str] = &["export_metadata",
4239 "file_metadata"];
4240impl ExportResult {
4241 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4242 map: V,
4243 ) -> Result<ExportResult, V::Error> {
4244 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4245 }
4246
4247 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4248 mut map: V,
4249 optional: bool,
4250 ) -> Result<Option<ExportResult>, V::Error> {
4251 let mut field_export_metadata = None;
4252 let mut field_file_metadata = None;
4253 let mut nothing = true;
4254 while let Some(key) = map.next_key::<&str>()? {
4255 nothing = false;
4256 match key {
4257 "export_metadata" => {
4258 if field_export_metadata.is_some() {
4259 return Err(::serde::de::Error::duplicate_field("export_metadata"));
4260 }
4261 field_export_metadata = Some(map.next_value()?);
4262 }
4263 "file_metadata" => {
4264 if field_file_metadata.is_some() {
4265 return Err(::serde::de::Error::duplicate_field("file_metadata"));
4266 }
4267 field_file_metadata = Some(map.next_value()?);
4268 }
4269 _ => {
4270 map.next_value::<::serde_json::Value>()?;
4272 }
4273 }
4274 }
4275 if optional && nothing {
4276 return Ok(None);
4277 }
4278 let result = ExportResult {
4279 export_metadata: field_export_metadata.ok_or_else(|| ::serde::de::Error::missing_field("export_metadata"))?,
4280 file_metadata: field_file_metadata.ok_or_else(|| ::serde::de::Error::missing_field("file_metadata"))?,
4281 };
4282 Ok(Some(result))
4283 }
4284
4285 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4286 &self,
4287 s: &mut S::SerializeStruct,
4288 ) -> Result<(), S::Error> {
4289 use serde::ser::SerializeStruct;
4290 s.serialize_field("export_metadata", &self.export_metadata)?;
4291 s.serialize_field("file_metadata", &self.file_metadata)?;
4292 Ok(())
4293 }
4294}
4295
4296impl<'de> ::serde::de::Deserialize<'de> for ExportResult {
4297 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4298 use serde::de::{MapAccess, Visitor};
4300 struct StructVisitor;
4301 impl<'de> Visitor<'de> for StructVisitor {
4302 type Value = ExportResult;
4303 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4304 f.write_str("a ExportResult struct")
4305 }
4306 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4307 ExportResult::internal_deserialize(map)
4308 }
4309 }
4310 deserializer.deserialize_struct("ExportResult", EXPORT_RESULT_FIELDS, StructVisitor)
4311 }
4312}
4313
4314impl ::serde::ser::Serialize for ExportResult {
4315 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4316 use serde::ser::SerializeStruct;
4318 let mut s = serializer.serialize_struct("ExportResult", 2)?;
4319 self.internal_serialize::<S>(&mut s)?;
4320 s.end()
4321 }
4322}
4323
4324#[derive(Debug, Clone, PartialEq, Eq)]
4325#[non_exhaustive] pub enum FileCategory {
4327 Image,
4329 Document,
4331 Pdf,
4333 Spreadsheet,
4335 Presentation,
4337 Audio,
4339 Video,
4341 Folder,
4343 Paper,
4345 Others,
4347 Other,
4350}
4351
4352impl<'de> ::serde::de::Deserialize<'de> for FileCategory {
4353 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4354 use serde::de::{self, MapAccess, Visitor};
4356 struct EnumVisitor;
4357 impl<'de> Visitor<'de> for EnumVisitor {
4358 type Value = FileCategory;
4359 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4360 f.write_str("a FileCategory structure")
4361 }
4362 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
4363 let tag: &str = match map.next_key()? {
4364 Some(".tag") => map.next_value()?,
4365 _ => return Err(de::Error::missing_field(".tag"))
4366 };
4367 let value = match tag {
4368 "image" => FileCategory::Image,
4369 "document" => FileCategory::Document,
4370 "pdf" => FileCategory::Pdf,
4371 "spreadsheet" => FileCategory::Spreadsheet,
4372 "presentation" => FileCategory::Presentation,
4373 "audio" => FileCategory::Audio,
4374 "video" => FileCategory::Video,
4375 "folder" => FileCategory::Folder,
4376 "paper" => FileCategory::Paper,
4377 "others" => FileCategory::Others,
4378 _ => FileCategory::Other,
4379 };
4380 crate::eat_json_fields(&mut map)?;
4381 Ok(value)
4382 }
4383 }
4384 const VARIANTS: &[&str] = &["image",
4385 "document",
4386 "pdf",
4387 "spreadsheet",
4388 "presentation",
4389 "audio",
4390 "video",
4391 "folder",
4392 "paper",
4393 "others",
4394 "other"];
4395 deserializer.deserialize_struct("FileCategory", VARIANTS, EnumVisitor)
4396 }
4397}
4398
4399impl ::serde::ser::Serialize for FileCategory {
4400 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4401 use serde::ser::SerializeStruct;
4403 match self {
4404 FileCategory::Image => {
4405 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4407 s.serialize_field(".tag", "image")?;
4408 s.end()
4409 }
4410 FileCategory::Document => {
4411 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4413 s.serialize_field(".tag", "document")?;
4414 s.end()
4415 }
4416 FileCategory::Pdf => {
4417 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4419 s.serialize_field(".tag", "pdf")?;
4420 s.end()
4421 }
4422 FileCategory::Spreadsheet => {
4423 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4425 s.serialize_field(".tag", "spreadsheet")?;
4426 s.end()
4427 }
4428 FileCategory::Presentation => {
4429 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4431 s.serialize_field(".tag", "presentation")?;
4432 s.end()
4433 }
4434 FileCategory::Audio => {
4435 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4437 s.serialize_field(".tag", "audio")?;
4438 s.end()
4439 }
4440 FileCategory::Video => {
4441 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4443 s.serialize_field(".tag", "video")?;
4444 s.end()
4445 }
4446 FileCategory::Folder => {
4447 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4449 s.serialize_field(".tag", "folder")?;
4450 s.end()
4451 }
4452 FileCategory::Paper => {
4453 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4455 s.serialize_field(".tag", "paper")?;
4456 s.end()
4457 }
4458 FileCategory::Others => {
4459 let mut s = serializer.serialize_struct("FileCategory", 1)?;
4461 s.serialize_field(".tag", "others")?;
4462 s.end()
4463 }
4464 FileCategory::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
4465 }
4466 }
4467}
4468
4469#[derive(Debug, Clone, PartialEq, Eq)]
4470#[non_exhaustive] pub struct FileLock {
4472 pub content: FileLockContent,
4474}
4475
4476impl FileLock {
4477 pub fn new(content: FileLockContent) -> Self {
4478 FileLock {
4479 content,
4480 }
4481 }
4482}
4483
4484const FILE_LOCK_FIELDS: &[&str] = &["content"];
4485impl FileLock {
4486 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4487 map: V,
4488 ) -> Result<FileLock, V::Error> {
4489 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4490 }
4491
4492 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4493 mut map: V,
4494 optional: bool,
4495 ) -> Result<Option<FileLock>, V::Error> {
4496 let mut field_content = None;
4497 let mut nothing = true;
4498 while let Some(key) = map.next_key::<&str>()? {
4499 nothing = false;
4500 match key {
4501 "content" => {
4502 if field_content.is_some() {
4503 return Err(::serde::de::Error::duplicate_field("content"));
4504 }
4505 field_content = Some(map.next_value()?);
4506 }
4507 _ => {
4508 map.next_value::<::serde_json::Value>()?;
4510 }
4511 }
4512 }
4513 if optional && nothing {
4514 return Ok(None);
4515 }
4516 let result = FileLock {
4517 content: field_content.ok_or_else(|| ::serde::de::Error::missing_field("content"))?,
4518 };
4519 Ok(Some(result))
4520 }
4521
4522 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4523 &self,
4524 s: &mut S::SerializeStruct,
4525 ) -> Result<(), S::Error> {
4526 use serde::ser::SerializeStruct;
4527 s.serialize_field("content", &self.content)?;
4528 Ok(())
4529 }
4530}
4531
4532impl<'de> ::serde::de::Deserialize<'de> for FileLock {
4533 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4534 use serde::de::{MapAccess, Visitor};
4536 struct StructVisitor;
4537 impl<'de> Visitor<'de> for StructVisitor {
4538 type Value = FileLock;
4539 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4540 f.write_str("a FileLock struct")
4541 }
4542 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4543 FileLock::internal_deserialize(map)
4544 }
4545 }
4546 deserializer.deserialize_struct("FileLock", FILE_LOCK_FIELDS, StructVisitor)
4547 }
4548}
4549
4550impl ::serde::ser::Serialize for FileLock {
4551 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4552 use serde::ser::SerializeStruct;
4554 let mut s = serializer.serialize_struct("FileLock", 1)?;
4555 self.internal_serialize::<S>(&mut s)?;
4556 s.end()
4557 }
4558}
4559
4560#[derive(Debug, Clone, PartialEq, Eq)]
4561#[non_exhaustive] pub enum FileLockContent {
4563 Unlocked,
4565 SingleUser(SingleUserLock),
4567 Other,
4570}
4571
4572impl<'de> ::serde::de::Deserialize<'de> for FileLockContent {
4573 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4574 use serde::de::{self, MapAccess, Visitor};
4576 struct EnumVisitor;
4577 impl<'de> Visitor<'de> for EnumVisitor {
4578 type Value = FileLockContent;
4579 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4580 f.write_str("a FileLockContent structure")
4581 }
4582 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
4583 let tag: &str = match map.next_key()? {
4584 Some(".tag") => map.next_value()?,
4585 _ => return Err(de::Error::missing_field(".tag"))
4586 };
4587 let value = match tag {
4588 "unlocked" => FileLockContent::Unlocked,
4589 "single_user" => FileLockContent::SingleUser(SingleUserLock::internal_deserialize(&mut map)?),
4590 _ => FileLockContent::Other,
4591 };
4592 crate::eat_json_fields(&mut map)?;
4593 Ok(value)
4594 }
4595 }
4596 const VARIANTS: &[&str] = &["unlocked",
4597 "single_user",
4598 "other"];
4599 deserializer.deserialize_struct("FileLockContent", VARIANTS, EnumVisitor)
4600 }
4601}
4602
4603impl ::serde::ser::Serialize for FileLockContent {
4604 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4605 use serde::ser::SerializeStruct;
4607 match self {
4608 FileLockContent::Unlocked => {
4609 let mut s = serializer.serialize_struct("FileLockContent", 1)?;
4611 s.serialize_field(".tag", "unlocked")?;
4612 s.end()
4613 }
4614 FileLockContent::SingleUser(x) => {
4615 let mut s = serializer.serialize_struct("FileLockContent", 4)?;
4617 s.serialize_field(".tag", "single_user")?;
4618 x.internal_serialize::<S>(&mut s)?;
4619 s.end()
4620 }
4621 FileLockContent::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
4622 }
4623 }
4624}
4625
4626#[derive(Debug, Clone, PartialEq, Eq, Default)]
4627#[non_exhaustive] pub struct FileLockMetadata {
4629 pub is_lockholder: Option<bool>,
4631 pub lockholder_name: Option<String>,
4633 pub lockholder_account_id: Option<crate::types::users_common::AccountId>,
4635 pub created: Option<crate::types::common::DropboxTimestamp>,
4637}
4638
4639impl FileLockMetadata {
4640 pub fn with_is_lockholder(mut self, value: bool) -> Self {
4641 self.is_lockholder = Some(value);
4642 self
4643 }
4644
4645 pub fn with_lockholder_name(mut self, value: String) -> Self {
4646 self.lockholder_name = Some(value);
4647 self
4648 }
4649
4650 pub fn with_lockholder_account_id(
4651 mut self,
4652 value: crate::types::users_common::AccountId,
4653 ) -> Self {
4654 self.lockholder_account_id = Some(value);
4655 self
4656 }
4657
4658 pub fn with_created(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
4659 self.created = Some(value);
4660 self
4661 }
4662}
4663
4664const FILE_LOCK_METADATA_FIELDS: &[&str] = &["is_lockholder",
4665 "lockholder_name",
4666 "lockholder_account_id",
4667 "created"];
4668impl FileLockMetadata {
4669 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4671 mut map: V,
4672 ) -> Result<FileLockMetadata, V::Error> {
4673 let mut field_is_lockholder = None;
4674 let mut field_lockholder_name = None;
4675 let mut field_lockholder_account_id = None;
4676 let mut field_created = None;
4677 while let Some(key) = map.next_key::<&str>()? {
4678 match key {
4679 "is_lockholder" => {
4680 if field_is_lockholder.is_some() {
4681 return Err(::serde::de::Error::duplicate_field("is_lockholder"));
4682 }
4683 field_is_lockholder = Some(map.next_value()?);
4684 }
4685 "lockholder_name" => {
4686 if field_lockholder_name.is_some() {
4687 return Err(::serde::de::Error::duplicate_field("lockholder_name"));
4688 }
4689 field_lockholder_name = Some(map.next_value()?);
4690 }
4691 "lockholder_account_id" => {
4692 if field_lockholder_account_id.is_some() {
4693 return Err(::serde::de::Error::duplicate_field("lockholder_account_id"));
4694 }
4695 field_lockholder_account_id = Some(map.next_value()?);
4696 }
4697 "created" => {
4698 if field_created.is_some() {
4699 return Err(::serde::de::Error::duplicate_field("created"));
4700 }
4701 field_created = Some(map.next_value()?);
4702 }
4703 _ => {
4704 map.next_value::<::serde_json::Value>()?;
4706 }
4707 }
4708 }
4709 let result = FileLockMetadata {
4710 is_lockholder: field_is_lockholder.and_then(Option::flatten),
4711 lockholder_name: field_lockholder_name.and_then(Option::flatten),
4712 lockholder_account_id: field_lockholder_account_id.and_then(Option::flatten),
4713 created: field_created.and_then(Option::flatten),
4714 };
4715 Ok(result)
4716 }
4717
4718 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
4719 &self,
4720 s: &mut S::SerializeStruct,
4721 ) -> Result<(), S::Error> {
4722 use serde::ser::SerializeStruct;
4723 if let Some(val) = &self.is_lockholder {
4724 s.serialize_field("is_lockholder", val)?;
4725 }
4726 if let Some(val) = &self.lockholder_name {
4727 s.serialize_field("lockholder_name", val)?;
4728 }
4729 if let Some(val) = &self.lockholder_account_id {
4730 s.serialize_field("lockholder_account_id", val)?;
4731 }
4732 if let Some(val) = &self.created {
4733 s.serialize_field("created", val)?;
4734 }
4735 Ok(())
4736 }
4737}
4738
4739impl<'de> ::serde::de::Deserialize<'de> for FileLockMetadata {
4740 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
4741 use serde::de::{MapAccess, Visitor};
4743 struct StructVisitor;
4744 impl<'de> Visitor<'de> for StructVisitor {
4745 type Value = FileLockMetadata;
4746 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4747 f.write_str("a FileLockMetadata struct")
4748 }
4749 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
4750 FileLockMetadata::internal_deserialize(map)
4751 }
4752 }
4753 deserializer.deserialize_struct("FileLockMetadata", FILE_LOCK_METADATA_FIELDS, StructVisitor)
4754 }
4755}
4756
4757impl ::serde::ser::Serialize for FileLockMetadata {
4758 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
4759 use serde::ser::SerializeStruct;
4761 let mut s = serializer.serialize_struct("FileLockMetadata", 4)?;
4762 self.internal_serialize::<S>(&mut s)?;
4763 s.end()
4764 }
4765}
4766
4767#[derive(Debug, Clone, PartialEq)]
4768#[non_exhaustive] pub struct FileMetadata {
4770 pub name: String,
4772 pub id: Id,
4774 pub client_modified: crate::types::common::DropboxTimestamp,
4779 pub server_modified: crate::types::common::DropboxTimestamp,
4781 pub rev: Rev,
4784 pub size: u64,
4786 pub path_lower: Option<String>,
4789 pub path_display: Option<String>,
4796 #[deprecated]
4800 pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
4801 pub preview_url: Option<String>,
4803 pub media_info: Option<MediaInfo>,
4808 pub symlink_info: Option<SymlinkInfo>,
4810 pub sharing_info: Option<FileSharingInfo>,
4812 pub is_downloadable: bool,
4814 pub export_info: Option<ExportInfo>,
4817 pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
4820 pub has_explicit_shared_members: Option<bool>,
4827 pub content_hash: Option<Sha256HexHash>,
4831 pub file_lock_info: Option<FileLockMetadata>,
4833}
4834
4835impl FileMetadata {
4836 pub fn new(
4837 name: String,
4838 id: Id,
4839 client_modified: crate::types::common::DropboxTimestamp,
4840 server_modified: crate::types::common::DropboxTimestamp,
4841 rev: Rev,
4842 size: u64,
4843 ) -> Self {
4844 FileMetadata {
4845 name,
4846 id,
4847 client_modified,
4848 server_modified,
4849 rev,
4850 size,
4851 path_lower: None,
4852 path_display: None,
4853 #[allow(deprecated)] parent_shared_folder_id: None,
4854 preview_url: None,
4855 media_info: None,
4856 symlink_info: None,
4857 sharing_info: None,
4858 is_downloadable: true,
4859 export_info: None,
4860 property_groups: None,
4861 has_explicit_shared_members: None,
4862 content_hash: None,
4863 file_lock_info: None,
4864 }
4865 }
4866
4867 pub fn with_path_lower(mut self, value: String) -> Self {
4868 self.path_lower = Some(value);
4869 self
4870 }
4871
4872 pub fn with_path_display(mut self, value: String) -> Self {
4873 self.path_display = Some(value);
4874 self
4875 }
4876
4877 #[deprecated]
4878 #[allow(deprecated)]
4879 pub fn with_parent_shared_folder_id(
4880 mut self,
4881 value: crate::types::common::SharedFolderId,
4882 ) -> Self {
4883 self.parent_shared_folder_id = Some(value);
4884 self
4885 }
4886
4887 pub fn with_preview_url(mut self, value: String) -> Self {
4888 self.preview_url = Some(value);
4889 self
4890 }
4891
4892 pub fn with_media_info(mut self, value: MediaInfo) -> Self {
4893 self.media_info = Some(value);
4894 self
4895 }
4896
4897 pub fn with_symlink_info(mut self, value: SymlinkInfo) -> Self {
4898 self.symlink_info = Some(value);
4899 self
4900 }
4901
4902 pub fn with_sharing_info(mut self, value: FileSharingInfo) -> Self {
4903 self.sharing_info = Some(value);
4904 self
4905 }
4906
4907 pub fn with_is_downloadable(mut self, value: bool) -> Self {
4908 self.is_downloadable = value;
4909 self
4910 }
4911
4912 pub fn with_export_info(mut self, value: ExportInfo) -> Self {
4913 self.export_info = Some(value);
4914 self
4915 }
4916
4917 pub fn with_property_groups(
4918 mut self,
4919 value: Vec<crate::types::file_properties::PropertyGroup>,
4920 ) -> Self {
4921 self.property_groups = Some(value);
4922 self
4923 }
4924
4925 pub fn with_has_explicit_shared_members(mut self, value: bool) -> Self {
4926 self.has_explicit_shared_members = Some(value);
4927 self
4928 }
4929
4930 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
4931 self.content_hash = Some(value);
4932 self
4933 }
4934
4935 pub fn with_file_lock_info(mut self, value: FileLockMetadata) -> Self {
4936 self.file_lock_info = Some(value);
4937 self
4938 }
4939}
4940
4941const FILE_METADATA_FIELDS: &[&str] = &["name",
4942 "id",
4943 "client_modified",
4944 "server_modified",
4945 "rev",
4946 "size",
4947 "path_lower",
4948 "path_display",
4949 "parent_shared_folder_id",
4950 "preview_url",
4951 "media_info",
4952 "symlink_info",
4953 "sharing_info",
4954 "is_downloadable",
4955 "export_info",
4956 "property_groups",
4957 "has_explicit_shared_members",
4958 "content_hash",
4959 "file_lock_info"];
4960impl FileMetadata {
4961 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
4962 map: V,
4963 ) -> Result<FileMetadata, V::Error> {
4964 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
4965 }
4966
4967 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
4968 mut map: V,
4969 optional: bool,
4970 ) -> Result<Option<FileMetadata>, V::Error> {
4971 let mut field_name = None;
4972 let mut field_id = None;
4973 let mut field_client_modified = None;
4974 let mut field_server_modified = None;
4975 let mut field_rev = None;
4976 let mut field_size = None;
4977 let mut field_path_lower = None;
4978 let mut field_path_display = None;
4979 let mut field_parent_shared_folder_id = None;
4980 let mut field_preview_url = None;
4981 let mut field_media_info = None;
4982 let mut field_symlink_info = None;
4983 let mut field_sharing_info = None;
4984 let mut field_is_downloadable = None;
4985 let mut field_export_info = None;
4986 let mut field_property_groups = None;
4987 let mut field_has_explicit_shared_members = None;
4988 let mut field_content_hash = None;
4989 let mut field_file_lock_info = None;
4990 let mut nothing = true;
4991 while let Some(key) = map.next_key::<&str>()? {
4992 nothing = false;
4993 match key {
4994 "name" => {
4995 if field_name.is_some() {
4996 return Err(::serde::de::Error::duplicate_field("name"));
4997 }
4998 field_name = Some(map.next_value()?);
4999 }
5000 "id" => {
5001 if field_id.is_some() {
5002 return Err(::serde::de::Error::duplicate_field("id"));
5003 }
5004 field_id = Some(map.next_value()?);
5005 }
5006 "client_modified" => {
5007 if field_client_modified.is_some() {
5008 return Err(::serde::de::Error::duplicate_field("client_modified"));
5009 }
5010 field_client_modified = Some(map.next_value()?);
5011 }
5012 "server_modified" => {
5013 if field_server_modified.is_some() {
5014 return Err(::serde::de::Error::duplicate_field("server_modified"));
5015 }
5016 field_server_modified = Some(map.next_value()?);
5017 }
5018 "rev" => {
5019 if field_rev.is_some() {
5020 return Err(::serde::de::Error::duplicate_field("rev"));
5021 }
5022 field_rev = Some(map.next_value()?);
5023 }
5024 "size" => {
5025 if field_size.is_some() {
5026 return Err(::serde::de::Error::duplicate_field("size"));
5027 }
5028 field_size = Some(map.next_value()?);
5029 }
5030 "path_lower" => {
5031 if field_path_lower.is_some() {
5032 return Err(::serde::de::Error::duplicate_field("path_lower"));
5033 }
5034 field_path_lower = Some(map.next_value()?);
5035 }
5036 "path_display" => {
5037 if field_path_display.is_some() {
5038 return Err(::serde::de::Error::duplicate_field("path_display"));
5039 }
5040 field_path_display = Some(map.next_value()?);
5041 }
5042 "parent_shared_folder_id" => {
5043 if field_parent_shared_folder_id.is_some() {
5044 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5045 }
5046 field_parent_shared_folder_id = Some(map.next_value()?);
5047 }
5048 "preview_url" => {
5049 if field_preview_url.is_some() {
5050 return Err(::serde::de::Error::duplicate_field("preview_url"));
5051 }
5052 field_preview_url = Some(map.next_value()?);
5053 }
5054 "media_info" => {
5055 if field_media_info.is_some() {
5056 return Err(::serde::de::Error::duplicate_field("media_info"));
5057 }
5058 field_media_info = Some(map.next_value()?);
5059 }
5060 "symlink_info" => {
5061 if field_symlink_info.is_some() {
5062 return Err(::serde::de::Error::duplicate_field("symlink_info"));
5063 }
5064 field_symlink_info = Some(map.next_value()?);
5065 }
5066 "sharing_info" => {
5067 if field_sharing_info.is_some() {
5068 return Err(::serde::de::Error::duplicate_field("sharing_info"));
5069 }
5070 field_sharing_info = Some(map.next_value()?);
5071 }
5072 "is_downloadable" => {
5073 if field_is_downloadable.is_some() {
5074 return Err(::serde::de::Error::duplicate_field("is_downloadable"));
5075 }
5076 field_is_downloadable = Some(map.next_value()?);
5077 }
5078 "export_info" => {
5079 if field_export_info.is_some() {
5080 return Err(::serde::de::Error::duplicate_field("export_info"));
5081 }
5082 field_export_info = Some(map.next_value()?);
5083 }
5084 "property_groups" => {
5085 if field_property_groups.is_some() {
5086 return Err(::serde::de::Error::duplicate_field("property_groups"));
5087 }
5088 field_property_groups = Some(map.next_value()?);
5089 }
5090 "has_explicit_shared_members" => {
5091 if field_has_explicit_shared_members.is_some() {
5092 return Err(::serde::de::Error::duplicate_field("has_explicit_shared_members"));
5093 }
5094 field_has_explicit_shared_members = Some(map.next_value()?);
5095 }
5096 "content_hash" => {
5097 if field_content_hash.is_some() {
5098 return Err(::serde::de::Error::duplicate_field("content_hash"));
5099 }
5100 field_content_hash = Some(map.next_value()?);
5101 }
5102 "file_lock_info" => {
5103 if field_file_lock_info.is_some() {
5104 return Err(::serde::de::Error::duplicate_field("file_lock_info"));
5105 }
5106 field_file_lock_info = Some(map.next_value()?);
5107 }
5108 _ => {
5109 map.next_value::<::serde_json::Value>()?;
5111 }
5112 }
5113 }
5114 if optional && nothing {
5115 return Ok(None);
5116 }
5117 let result = FileMetadata {
5118 name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
5119 id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
5120 client_modified: field_client_modified.ok_or_else(|| ::serde::de::Error::missing_field("client_modified"))?,
5121 server_modified: field_server_modified.ok_or_else(|| ::serde::de::Error::missing_field("server_modified"))?,
5122 rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
5123 size: field_size.ok_or_else(|| ::serde::de::Error::missing_field("size"))?,
5124 path_lower: field_path_lower.and_then(Option::flatten),
5125 path_display: field_path_display.and_then(Option::flatten),
5126 #[allow(deprecated)] parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
5127 preview_url: field_preview_url.and_then(Option::flatten),
5128 media_info: field_media_info.and_then(Option::flatten),
5129 symlink_info: field_symlink_info.and_then(Option::flatten),
5130 sharing_info: field_sharing_info.and_then(Option::flatten),
5131 is_downloadable: field_is_downloadable.unwrap_or(true),
5132 export_info: field_export_info.and_then(Option::flatten),
5133 property_groups: field_property_groups.and_then(Option::flatten),
5134 has_explicit_shared_members: field_has_explicit_shared_members.and_then(Option::flatten),
5135 content_hash: field_content_hash.and_then(Option::flatten),
5136 file_lock_info: field_file_lock_info.and_then(Option::flatten),
5137 };
5138 Ok(Some(result))
5139 }
5140
5141 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5142 &self,
5143 s: &mut S::SerializeStruct,
5144 ) -> Result<(), S::Error> {
5145 use serde::ser::SerializeStruct;
5146 s.serialize_field("name", &self.name)?;
5147 s.serialize_field("id", &self.id)?;
5148 s.serialize_field("client_modified", &self.client_modified)?;
5149 s.serialize_field("server_modified", &self.server_modified)?;
5150 s.serialize_field("rev", &self.rev)?;
5151 s.serialize_field("size", &self.size)?;
5152 if let Some(val) = &self.path_lower {
5153 s.serialize_field("path_lower", val)?;
5154 }
5155 if let Some(val) = &self.path_display {
5156 s.serialize_field("path_display", val)?;
5157 }
5158 #[allow(deprecated)]
5159 if let Some(val) = &self.parent_shared_folder_id {
5160 s.serialize_field("parent_shared_folder_id", val)?;
5161 }
5162 if let Some(val) = &self.preview_url {
5163 s.serialize_field("preview_url", val)?;
5164 }
5165 if let Some(val) = &self.media_info {
5166 s.serialize_field("media_info", val)?;
5167 }
5168 if let Some(val) = &self.symlink_info {
5169 s.serialize_field("symlink_info", val)?;
5170 }
5171 if let Some(val) = &self.sharing_info {
5172 s.serialize_field("sharing_info", val)?;
5173 }
5174 if !self.is_downloadable {
5175 s.serialize_field("is_downloadable", &self.is_downloadable)?;
5176 }
5177 if let Some(val) = &self.export_info {
5178 s.serialize_field("export_info", val)?;
5179 }
5180 if let Some(val) = &self.property_groups {
5181 s.serialize_field("property_groups", val)?;
5182 }
5183 if let Some(val) = &self.has_explicit_shared_members {
5184 s.serialize_field("has_explicit_shared_members", val)?;
5185 }
5186 if let Some(val) = &self.content_hash {
5187 s.serialize_field("content_hash", val)?;
5188 }
5189 if let Some(val) = &self.file_lock_info {
5190 s.serialize_field("file_lock_info", val)?;
5191 }
5192 Ok(())
5193 }
5194}
5195
5196impl<'de> ::serde::de::Deserialize<'de> for FileMetadata {
5197 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5198 use serde::de::{MapAccess, Visitor};
5200 struct StructVisitor;
5201 impl<'de> Visitor<'de> for StructVisitor {
5202 type Value = FileMetadata;
5203 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5204 f.write_str("a FileMetadata struct")
5205 }
5206 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5207 FileMetadata::internal_deserialize(map)
5208 }
5209 }
5210 deserializer.deserialize_struct("FileMetadata", FILE_METADATA_FIELDS, StructVisitor)
5211 }
5212}
5213
5214impl ::serde::ser::Serialize for FileMetadata {
5215 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5216 use serde::ser::SerializeStruct;
5218 let mut s = serializer.serialize_struct("FileMetadata", 19)?;
5219 self.internal_serialize::<S>(&mut s)?;
5220 s.end()
5221 }
5222}
5223
5224impl From<FileMetadata> for Metadata {
5226 fn from(subtype: FileMetadata) -> Self {
5227 Metadata::File(subtype)
5228 }
5229}
5230#[derive(Debug, Clone, PartialEq, Eq, Default)]
5232#[non_exhaustive] pub struct FileOpsResult {
5234}
5235
5236const FILE_OPS_RESULT_FIELDS: &[&str] = &[];
5237impl FileOpsResult {
5238 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5240 mut map: V,
5241 ) -> Result<FileOpsResult, V::Error> {
5242 crate::eat_json_fields(&mut map)?;
5244 Ok(FileOpsResult {})
5245 }
5246}
5247
5248impl<'de> ::serde::de::Deserialize<'de> for FileOpsResult {
5249 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5250 use serde::de::{MapAccess, Visitor};
5252 struct StructVisitor;
5253 impl<'de> Visitor<'de> for StructVisitor {
5254 type Value = FileOpsResult;
5255 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5256 f.write_str("a FileOpsResult struct")
5257 }
5258 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5259 FileOpsResult::internal_deserialize(map)
5260 }
5261 }
5262 deserializer.deserialize_struct("FileOpsResult", FILE_OPS_RESULT_FIELDS, StructVisitor)
5263 }
5264}
5265
5266impl ::serde::ser::Serialize for FileOpsResult {
5267 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5268 use serde::ser::SerializeStruct;
5270 serializer.serialize_struct("FileOpsResult", 0)?.end()
5271 }
5272}
5273
5274#[derive(Debug, Clone, PartialEq, Eq)]
5276#[non_exhaustive] pub struct FileSharingInfo {
5278 pub read_only: bool,
5280 pub parent_shared_folder_id: crate::types::common::SharedFolderId,
5282 pub modified_by: Option<crate::types::users_common::AccountId>,
5285}
5286
5287impl FileSharingInfo {
5288 pub fn new(
5289 read_only: bool,
5290 parent_shared_folder_id: crate::types::common::SharedFolderId,
5291 ) -> Self {
5292 FileSharingInfo {
5293 read_only,
5294 parent_shared_folder_id,
5295 modified_by: None,
5296 }
5297 }
5298
5299 pub fn with_modified_by(mut self, value: crate::types::users_common::AccountId) -> Self {
5300 self.modified_by = Some(value);
5301 self
5302 }
5303}
5304
5305const FILE_SHARING_INFO_FIELDS: &[&str] = &["read_only",
5306 "parent_shared_folder_id",
5307 "modified_by"];
5308impl FileSharingInfo {
5309 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5310 map: V,
5311 ) -> Result<FileSharingInfo, V::Error> {
5312 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5313 }
5314
5315 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5316 mut map: V,
5317 optional: bool,
5318 ) -> Result<Option<FileSharingInfo>, V::Error> {
5319 let mut field_read_only = None;
5320 let mut field_parent_shared_folder_id = None;
5321 let mut field_modified_by = None;
5322 let mut nothing = true;
5323 while let Some(key) = map.next_key::<&str>()? {
5324 nothing = false;
5325 match key {
5326 "read_only" => {
5327 if field_read_only.is_some() {
5328 return Err(::serde::de::Error::duplicate_field("read_only"));
5329 }
5330 field_read_only = Some(map.next_value()?);
5331 }
5332 "parent_shared_folder_id" => {
5333 if field_parent_shared_folder_id.is_some() {
5334 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5335 }
5336 field_parent_shared_folder_id = Some(map.next_value()?);
5337 }
5338 "modified_by" => {
5339 if field_modified_by.is_some() {
5340 return Err(::serde::de::Error::duplicate_field("modified_by"));
5341 }
5342 field_modified_by = Some(map.next_value()?);
5343 }
5344 _ => {
5345 map.next_value::<::serde_json::Value>()?;
5347 }
5348 }
5349 }
5350 if optional && nothing {
5351 return Ok(None);
5352 }
5353 let result = FileSharingInfo {
5354 read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
5355 parent_shared_folder_id: field_parent_shared_folder_id.ok_or_else(|| ::serde::de::Error::missing_field("parent_shared_folder_id"))?,
5356 modified_by: field_modified_by.and_then(Option::flatten),
5357 };
5358 Ok(Some(result))
5359 }
5360
5361 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5362 &self,
5363 s: &mut S::SerializeStruct,
5364 ) -> Result<(), S::Error> {
5365 use serde::ser::SerializeStruct;
5366 s.serialize_field("read_only", &self.read_only)?;
5367 s.serialize_field("parent_shared_folder_id", &self.parent_shared_folder_id)?;
5368 if let Some(val) = &self.modified_by {
5369 s.serialize_field("modified_by", val)?;
5370 }
5371 Ok(())
5372 }
5373}
5374
5375impl<'de> ::serde::de::Deserialize<'de> for FileSharingInfo {
5376 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5377 use serde::de::{MapAccess, Visitor};
5379 struct StructVisitor;
5380 impl<'de> Visitor<'de> for StructVisitor {
5381 type Value = FileSharingInfo;
5382 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5383 f.write_str("a FileSharingInfo struct")
5384 }
5385 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5386 FileSharingInfo::internal_deserialize(map)
5387 }
5388 }
5389 deserializer.deserialize_struct("FileSharingInfo", FILE_SHARING_INFO_FIELDS, StructVisitor)
5390 }
5391}
5392
5393impl ::serde::ser::Serialize for FileSharingInfo {
5394 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5395 use serde::ser::SerializeStruct;
5397 let mut s = serializer.serialize_struct("FileSharingInfo", 3)?;
5398 self.internal_serialize::<S>(&mut s)?;
5399 s.end()
5400 }
5401}
5402
5403impl From<FileSharingInfo> for SharingInfo {
5405 fn from(subtype: FileSharingInfo) -> Self {
5406 Self {
5407 read_only: subtype.read_only,
5408 }
5409 }
5410}
5411#[derive(Debug, Clone, PartialEq, Eq)]
5412#[non_exhaustive] pub enum FileStatus {
5414 Active,
5415 Deleted,
5416 Other,
5419}
5420
5421impl<'de> ::serde::de::Deserialize<'de> for FileStatus {
5422 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5423 use serde::de::{self, MapAccess, Visitor};
5425 struct EnumVisitor;
5426 impl<'de> Visitor<'de> for EnumVisitor {
5427 type Value = FileStatus;
5428 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5429 f.write_str("a FileStatus structure")
5430 }
5431 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
5432 let tag: &str = match map.next_key()? {
5433 Some(".tag") => map.next_value()?,
5434 _ => return Err(de::Error::missing_field(".tag"))
5435 };
5436 let value = match tag {
5437 "active" => FileStatus::Active,
5438 "deleted" => FileStatus::Deleted,
5439 _ => FileStatus::Other,
5440 };
5441 crate::eat_json_fields(&mut map)?;
5442 Ok(value)
5443 }
5444 }
5445 const VARIANTS: &[&str] = &["active",
5446 "deleted",
5447 "other"];
5448 deserializer.deserialize_struct("FileStatus", VARIANTS, EnumVisitor)
5449 }
5450}
5451
5452impl ::serde::ser::Serialize for FileStatus {
5453 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5454 use serde::ser::SerializeStruct;
5456 match self {
5457 FileStatus::Active => {
5458 let mut s = serializer.serialize_struct("FileStatus", 1)?;
5460 s.serialize_field(".tag", "active")?;
5461 s.end()
5462 }
5463 FileStatus::Deleted => {
5464 let mut s = serializer.serialize_struct("FileStatus", 1)?;
5466 s.serialize_field(".tag", "deleted")?;
5467 s.end()
5468 }
5469 FileStatus::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
5470 }
5471 }
5472}
5473
5474#[derive(Debug, Clone, PartialEq, Eq)]
5475#[non_exhaustive] pub struct FolderMetadata {
5477 pub name: String,
5479 pub id: Id,
5481 pub path_lower: Option<String>,
5484 pub path_display: Option<String>,
5491 #[deprecated]
5495 pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
5496 pub preview_url: Option<String>,
5498 #[deprecated]
5500 pub shared_folder_id: Option<crate::types::common::SharedFolderId>,
5501 pub sharing_info: Option<FolderSharingInfo>,
5503 pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
5507}
5508
5509impl FolderMetadata {
5510 pub fn new(name: String, id: Id) -> Self {
5511 FolderMetadata {
5512 name,
5513 id,
5514 path_lower: None,
5515 path_display: None,
5516 #[allow(deprecated)] parent_shared_folder_id: None,
5517 preview_url: None,
5518 #[allow(deprecated)] shared_folder_id: None,
5519 sharing_info: None,
5520 property_groups: None,
5521 }
5522 }
5523
5524 pub fn with_path_lower(mut self, value: String) -> Self {
5525 self.path_lower = Some(value);
5526 self
5527 }
5528
5529 pub fn with_path_display(mut self, value: String) -> Self {
5530 self.path_display = Some(value);
5531 self
5532 }
5533
5534 #[deprecated]
5535 #[allow(deprecated)]
5536 pub fn with_parent_shared_folder_id(
5537 mut self,
5538 value: crate::types::common::SharedFolderId,
5539 ) -> Self {
5540 self.parent_shared_folder_id = Some(value);
5541 self
5542 }
5543
5544 pub fn with_preview_url(mut self, value: String) -> Self {
5545 self.preview_url = Some(value);
5546 self
5547 }
5548
5549 #[deprecated]
5550 #[allow(deprecated)]
5551 pub fn with_shared_folder_id(mut self, value: crate::types::common::SharedFolderId) -> Self {
5552 self.shared_folder_id = Some(value);
5553 self
5554 }
5555
5556 pub fn with_sharing_info(mut self, value: FolderSharingInfo) -> Self {
5557 self.sharing_info = Some(value);
5558 self
5559 }
5560
5561 pub fn with_property_groups(
5562 mut self,
5563 value: Vec<crate::types::file_properties::PropertyGroup>,
5564 ) -> Self {
5565 self.property_groups = Some(value);
5566 self
5567 }
5568}
5569
5570const FOLDER_METADATA_FIELDS: &[&str] = &["name",
5571 "id",
5572 "path_lower",
5573 "path_display",
5574 "parent_shared_folder_id",
5575 "preview_url",
5576 "shared_folder_id",
5577 "sharing_info",
5578 "property_groups"];
5579impl FolderMetadata {
5580 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5581 map: V,
5582 ) -> Result<FolderMetadata, V::Error> {
5583 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5584 }
5585
5586 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5587 mut map: V,
5588 optional: bool,
5589 ) -> Result<Option<FolderMetadata>, V::Error> {
5590 let mut field_name = None;
5591 let mut field_id = None;
5592 let mut field_path_lower = None;
5593 let mut field_path_display = None;
5594 let mut field_parent_shared_folder_id = None;
5595 let mut field_preview_url = None;
5596 let mut field_shared_folder_id = None;
5597 let mut field_sharing_info = None;
5598 let mut field_property_groups = None;
5599 let mut nothing = true;
5600 while let Some(key) = map.next_key::<&str>()? {
5601 nothing = false;
5602 match key {
5603 "name" => {
5604 if field_name.is_some() {
5605 return Err(::serde::de::Error::duplicate_field("name"));
5606 }
5607 field_name = Some(map.next_value()?);
5608 }
5609 "id" => {
5610 if field_id.is_some() {
5611 return Err(::serde::de::Error::duplicate_field("id"));
5612 }
5613 field_id = Some(map.next_value()?);
5614 }
5615 "path_lower" => {
5616 if field_path_lower.is_some() {
5617 return Err(::serde::de::Error::duplicate_field("path_lower"));
5618 }
5619 field_path_lower = Some(map.next_value()?);
5620 }
5621 "path_display" => {
5622 if field_path_display.is_some() {
5623 return Err(::serde::de::Error::duplicate_field("path_display"));
5624 }
5625 field_path_display = Some(map.next_value()?);
5626 }
5627 "parent_shared_folder_id" => {
5628 if field_parent_shared_folder_id.is_some() {
5629 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5630 }
5631 field_parent_shared_folder_id = Some(map.next_value()?);
5632 }
5633 "preview_url" => {
5634 if field_preview_url.is_some() {
5635 return Err(::serde::de::Error::duplicate_field("preview_url"));
5636 }
5637 field_preview_url = Some(map.next_value()?);
5638 }
5639 "shared_folder_id" => {
5640 if field_shared_folder_id.is_some() {
5641 return Err(::serde::de::Error::duplicate_field("shared_folder_id"));
5642 }
5643 field_shared_folder_id = Some(map.next_value()?);
5644 }
5645 "sharing_info" => {
5646 if field_sharing_info.is_some() {
5647 return Err(::serde::de::Error::duplicate_field("sharing_info"));
5648 }
5649 field_sharing_info = Some(map.next_value()?);
5650 }
5651 "property_groups" => {
5652 if field_property_groups.is_some() {
5653 return Err(::serde::de::Error::duplicate_field("property_groups"));
5654 }
5655 field_property_groups = Some(map.next_value()?);
5656 }
5657 _ => {
5658 map.next_value::<::serde_json::Value>()?;
5660 }
5661 }
5662 }
5663 if optional && nothing {
5664 return Ok(None);
5665 }
5666 let result = FolderMetadata {
5667 name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
5668 id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
5669 path_lower: field_path_lower.and_then(Option::flatten),
5670 path_display: field_path_display.and_then(Option::flatten),
5671 #[allow(deprecated)] parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
5672 preview_url: field_preview_url.and_then(Option::flatten),
5673 #[allow(deprecated)] shared_folder_id: field_shared_folder_id.and_then(Option::flatten),
5674 sharing_info: field_sharing_info.and_then(Option::flatten),
5675 property_groups: field_property_groups.and_then(Option::flatten),
5676 };
5677 Ok(Some(result))
5678 }
5679
5680 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5681 &self,
5682 s: &mut S::SerializeStruct,
5683 ) -> Result<(), S::Error> {
5684 use serde::ser::SerializeStruct;
5685 s.serialize_field("name", &self.name)?;
5686 s.serialize_field("id", &self.id)?;
5687 if let Some(val) = &self.path_lower {
5688 s.serialize_field("path_lower", val)?;
5689 }
5690 if let Some(val) = &self.path_display {
5691 s.serialize_field("path_display", val)?;
5692 }
5693 #[allow(deprecated)]
5694 if let Some(val) = &self.parent_shared_folder_id {
5695 s.serialize_field("parent_shared_folder_id", val)?;
5696 }
5697 if let Some(val) = &self.preview_url {
5698 s.serialize_field("preview_url", val)?;
5699 }
5700 #[allow(deprecated)]
5701 if let Some(val) = &self.shared_folder_id {
5702 s.serialize_field("shared_folder_id", val)?;
5703 }
5704 if let Some(val) = &self.sharing_info {
5705 s.serialize_field("sharing_info", val)?;
5706 }
5707 if let Some(val) = &self.property_groups {
5708 s.serialize_field("property_groups", val)?;
5709 }
5710 Ok(())
5711 }
5712}
5713
5714impl<'de> ::serde::de::Deserialize<'de> for FolderMetadata {
5715 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5716 use serde::de::{MapAccess, Visitor};
5718 struct StructVisitor;
5719 impl<'de> Visitor<'de> for StructVisitor {
5720 type Value = FolderMetadata;
5721 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5722 f.write_str("a FolderMetadata struct")
5723 }
5724 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5725 FolderMetadata::internal_deserialize(map)
5726 }
5727 }
5728 deserializer.deserialize_struct("FolderMetadata", FOLDER_METADATA_FIELDS, StructVisitor)
5729 }
5730}
5731
5732impl ::serde::ser::Serialize for FolderMetadata {
5733 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5734 use serde::ser::SerializeStruct;
5736 let mut s = serializer.serialize_struct("FolderMetadata", 9)?;
5737 self.internal_serialize::<S>(&mut s)?;
5738 s.end()
5739 }
5740}
5741
5742impl From<FolderMetadata> for Metadata {
5744 fn from(subtype: FolderMetadata) -> Self {
5745 Metadata::Folder(subtype)
5746 }
5747}
5748#[derive(Debug, Clone, PartialEq, Eq)]
5751#[non_exhaustive] pub struct FolderSharingInfo {
5753 pub read_only: bool,
5755 pub parent_shared_folder_id: Option<crate::types::common::SharedFolderId>,
5757 pub shared_folder_id: Option<crate::types::common::SharedFolderId>,
5760 pub traverse_only: bool,
5764 pub no_access: bool,
5766}
5767
5768impl FolderSharingInfo {
5769 pub fn new(read_only: bool) -> Self {
5770 FolderSharingInfo {
5771 read_only,
5772 parent_shared_folder_id: None,
5773 shared_folder_id: None,
5774 traverse_only: false,
5775 no_access: false,
5776 }
5777 }
5778
5779 pub fn with_parent_shared_folder_id(
5780 mut self,
5781 value: crate::types::common::SharedFolderId,
5782 ) -> Self {
5783 self.parent_shared_folder_id = Some(value);
5784 self
5785 }
5786
5787 pub fn with_shared_folder_id(mut self, value: crate::types::common::SharedFolderId) -> Self {
5788 self.shared_folder_id = Some(value);
5789 self
5790 }
5791
5792 pub fn with_traverse_only(mut self, value: bool) -> Self {
5793 self.traverse_only = value;
5794 self
5795 }
5796
5797 pub fn with_no_access(mut self, value: bool) -> Self {
5798 self.no_access = value;
5799 self
5800 }
5801}
5802
5803const FOLDER_SHARING_INFO_FIELDS: &[&str] = &["read_only",
5804 "parent_shared_folder_id",
5805 "shared_folder_id",
5806 "traverse_only",
5807 "no_access"];
5808impl FolderSharingInfo {
5809 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5810 map: V,
5811 ) -> Result<FolderSharingInfo, V::Error> {
5812 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5813 }
5814
5815 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5816 mut map: V,
5817 optional: bool,
5818 ) -> Result<Option<FolderSharingInfo>, V::Error> {
5819 let mut field_read_only = None;
5820 let mut field_parent_shared_folder_id = None;
5821 let mut field_shared_folder_id = None;
5822 let mut field_traverse_only = None;
5823 let mut field_no_access = None;
5824 let mut nothing = true;
5825 while let Some(key) = map.next_key::<&str>()? {
5826 nothing = false;
5827 match key {
5828 "read_only" => {
5829 if field_read_only.is_some() {
5830 return Err(::serde::de::Error::duplicate_field("read_only"));
5831 }
5832 field_read_only = Some(map.next_value()?);
5833 }
5834 "parent_shared_folder_id" => {
5835 if field_parent_shared_folder_id.is_some() {
5836 return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
5837 }
5838 field_parent_shared_folder_id = Some(map.next_value()?);
5839 }
5840 "shared_folder_id" => {
5841 if field_shared_folder_id.is_some() {
5842 return Err(::serde::de::Error::duplicate_field("shared_folder_id"));
5843 }
5844 field_shared_folder_id = Some(map.next_value()?);
5845 }
5846 "traverse_only" => {
5847 if field_traverse_only.is_some() {
5848 return Err(::serde::de::Error::duplicate_field("traverse_only"));
5849 }
5850 field_traverse_only = Some(map.next_value()?);
5851 }
5852 "no_access" => {
5853 if field_no_access.is_some() {
5854 return Err(::serde::de::Error::duplicate_field("no_access"));
5855 }
5856 field_no_access = Some(map.next_value()?);
5857 }
5858 _ => {
5859 map.next_value::<::serde_json::Value>()?;
5861 }
5862 }
5863 }
5864 if optional && nothing {
5865 return Ok(None);
5866 }
5867 let result = FolderSharingInfo {
5868 read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
5869 parent_shared_folder_id: field_parent_shared_folder_id.and_then(Option::flatten),
5870 shared_folder_id: field_shared_folder_id.and_then(Option::flatten),
5871 traverse_only: field_traverse_only.unwrap_or(false),
5872 no_access: field_no_access.unwrap_or(false),
5873 };
5874 Ok(Some(result))
5875 }
5876
5877 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5878 &self,
5879 s: &mut S::SerializeStruct,
5880 ) -> Result<(), S::Error> {
5881 use serde::ser::SerializeStruct;
5882 s.serialize_field("read_only", &self.read_only)?;
5883 if let Some(val) = &self.parent_shared_folder_id {
5884 s.serialize_field("parent_shared_folder_id", val)?;
5885 }
5886 if let Some(val) = &self.shared_folder_id {
5887 s.serialize_field("shared_folder_id", val)?;
5888 }
5889 if self.traverse_only {
5890 s.serialize_field("traverse_only", &self.traverse_only)?;
5891 }
5892 if self.no_access {
5893 s.serialize_field("no_access", &self.no_access)?;
5894 }
5895 Ok(())
5896 }
5897}
5898
5899impl<'de> ::serde::de::Deserialize<'de> for FolderSharingInfo {
5900 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
5901 use serde::de::{MapAccess, Visitor};
5903 struct StructVisitor;
5904 impl<'de> Visitor<'de> for StructVisitor {
5905 type Value = FolderSharingInfo;
5906 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
5907 f.write_str("a FolderSharingInfo struct")
5908 }
5909 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
5910 FolderSharingInfo::internal_deserialize(map)
5911 }
5912 }
5913 deserializer.deserialize_struct("FolderSharingInfo", FOLDER_SHARING_INFO_FIELDS, StructVisitor)
5914 }
5915}
5916
5917impl ::serde::ser::Serialize for FolderSharingInfo {
5918 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
5919 use serde::ser::SerializeStruct;
5921 let mut s = serializer.serialize_struct("FolderSharingInfo", 5)?;
5922 self.internal_serialize::<S>(&mut s)?;
5923 s.end()
5924 }
5925}
5926
5927impl From<FolderSharingInfo> for SharingInfo {
5929 fn from(subtype: FolderSharingInfo) -> Self {
5930 Self {
5931 read_only: subtype.read_only,
5932 }
5933 }
5934}
5935#[derive(Debug, Clone, PartialEq, Eq)]
5936#[non_exhaustive] pub struct GetCopyReferenceArg {
5938 pub path: ReadPath,
5940}
5941
5942impl GetCopyReferenceArg {
5943 pub fn new(path: ReadPath) -> Self {
5944 GetCopyReferenceArg {
5945 path,
5946 }
5947 }
5948}
5949
5950const GET_COPY_REFERENCE_ARG_FIELDS: &[&str] = &["path"];
5951impl GetCopyReferenceArg {
5952 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
5953 map: V,
5954 ) -> Result<GetCopyReferenceArg, V::Error> {
5955 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
5956 }
5957
5958 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
5959 mut map: V,
5960 optional: bool,
5961 ) -> Result<Option<GetCopyReferenceArg>, V::Error> {
5962 let mut field_path = None;
5963 let mut nothing = true;
5964 while let Some(key) = map.next_key::<&str>()? {
5965 nothing = false;
5966 match key {
5967 "path" => {
5968 if field_path.is_some() {
5969 return Err(::serde::de::Error::duplicate_field("path"));
5970 }
5971 field_path = Some(map.next_value()?);
5972 }
5973 _ => {
5974 map.next_value::<::serde_json::Value>()?;
5976 }
5977 }
5978 }
5979 if optional && nothing {
5980 return Ok(None);
5981 }
5982 let result = GetCopyReferenceArg {
5983 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
5984 };
5985 Ok(Some(result))
5986 }
5987
5988 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
5989 &self,
5990 s: &mut S::SerializeStruct,
5991 ) -> Result<(), S::Error> {
5992 use serde::ser::SerializeStruct;
5993 s.serialize_field("path", &self.path)?;
5994 Ok(())
5995 }
5996}
5997
5998impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceArg {
5999 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6000 use serde::de::{MapAccess, Visitor};
6002 struct StructVisitor;
6003 impl<'de> Visitor<'de> for StructVisitor {
6004 type Value = GetCopyReferenceArg;
6005 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6006 f.write_str("a GetCopyReferenceArg struct")
6007 }
6008 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6009 GetCopyReferenceArg::internal_deserialize(map)
6010 }
6011 }
6012 deserializer.deserialize_struct("GetCopyReferenceArg", GET_COPY_REFERENCE_ARG_FIELDS, StructVisitor)
6013 }
6014}
6015
6016impl ::serde::ser::Serialize for GetCopyReferenceArg {
6017 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6018 use serde::ser::SerializeStruct;
6020 let mut s = serializer.serialize_struct("GetCopyReferenceArg", 1)?;
6021 self.internal_serialize::<S>(&mut s)?;
6022 s.end()
6023 }
6024}
6025
6026#[derive(Debug, Clone, PartialEq, Eq)]
6027#[non_exhaustive] pub enum GetCopyReferenceError {
6029 Path(LookupError),
6030 Other,
6033}
6034
6035impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceError {
6036 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6037 use serde::de::{self, MapAccess, Visitor};
6039 struct EnumVisitor;
6040 impl<'de> Visitor<'de> for EnumVisitor {
6041 type Value = GetCopyReferenceError;
6042 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6043 f.write_str("a GetCopyReferenceError structure")
6044 }
6045 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
6046 let tag: &str = match map.next_key()? {
6047 Some(".tag") => map.next_value()?,
6048 _ => return Err(de::Error::missing_field(".tag"))
6049 };
6050 let value = match tag {
6051 "path" => {
6052 match map.next_key()? {
6053 Some("path") => GetCopyReferenceError::Path(map.next_value()?),
6054 None => return Err(de::Error::missing_field("path")),
6055 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
6056 }
6057 }
6058 _ => GetCopyReferenceError::Other,
6059 };
6060 crate::eat_json_fields(&mut map)?;
6061 Ok(value)
6062 }
6063 }
6064 const VARIANTS: &[&str] = &["path",
6065 "other"];
6066 deserializer.deserialize_struct("GetCopyReferenceError", VARIANTS, EnumVisitor)
6067 }
6068}
6069
6070impl ::serde::ser::Serialize for GetCopyReferenceError {
6071 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6072 use serde::ser::SerializeStruct;
6074 match self {
6075 GetCopyReferenceError::Path(x) => {
6076 let mut s = serializer.serialize_struct("GetCopyReferenceError", 2)?;
6078 s.serialize_field(".tag", "path")?;
6079 s.serialize_field("path", x)?;
6080 s.end()
6081 }
6082 GetCopyReferenceError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
6083 }
6084 }
6085}
6086
6087impl ::std::error::Error for GetCopyReferenceError {
6088 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
6089 match self {
6090 GetCopyReferenceError::Path(inner) => Some(inner),
6091 _ => None,
6092 }
6093 }
6094}
6095
6096impl ::std::fmt::Display for GetCopyReferenceError {
6097 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6098 match self {
6099 GetCopyReferenceError::Path(inner) => write!(f, "GetCopyReferenceError: {}", inner),
6100 _ => write!(f, "{:?}", *self),
6101 }
6102 }
6103}
6104
6105#[derive(Debug, Clone, PartialEq)]
6106#[non_exhaustive] pub struct GetCopyReferenceResult {
6108 pub metadata: Metadata,
6110 pub copy_reference: String,
6112 pub expires: crate::types::common::DropboxTimestamp,
6115}
6116
6117impl GetCopyReferenceResult {
6118 pub fn new(
6119 metadata: Metadata,
6120 copy_reference: String,
6121 expires: crate::types::common::DropboxTimestamp,
6122 ) -> Self {
6123 GetCopyReferenceResult {
6124 metadata,
6125 copy_reference,
6126 expires,
6127 }
6128 }
6129}
6130
6131const GET_COPY_REFERENCE_RESULT_FIELDS: &[&str] = &["metadata",
6132 "copy_reference",
6133 "expires"];
6134impl GetCopyReferenceResult {
6135 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6136 map: V,
6137 ) -> Result<GetCopyReferenceResult, V::Error> {
6138 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6139 }
6140
6141 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6142 mut map: V,
6143 optional: bool,
6144 ) -> Result<Option<GetCopyReferenceResult>, V::Error> {
6145 let mut field_metadata = None;
6146 let mut field_copy_reference = None;
6147 let mut field_expires = None;
6148 let mut nothing = true;
6149 while let Some(key) = map.next_key::<&str>()? {
6150 nothing = false;
6151 match key {
6152 "metadata" => {
6153 if field_metadata.is_some() {
6154 return Err(::serde::de::Error::duplicate_field("metadata"));
6155 }
6156 field_metadata = Some(map.next_value()?);
6157 }
6158 "copy_reference" => {
6159 if field_copy_reference.is_some() {
6160 return Err(::serde::de::Error::duplicate_field("copy_reference"));
6161 }
6162 field_copy_reference = Some(map.next_value()?);
6163 }
6164 "expires" => {
6165 if field_expires.is_some() {
6166 return Err(::serde::de::Error::duplicate_field("expires"));
6167 }
6168 field_expires = Some(map.next_value()?);
6169 }
6170 _ => {
6171 map.next_value::<::serde_json::Value>()?;
6173 }
6174 }
6175 }
6176 if optional && nothing {
6177 return Ok(None);
6178 }
6179 let result = GetCopyReferenceResult {
6180 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
6181 copy_reference: field_copy_reference.ok_or_else(|| ::serde::de::Error::missing_field("copy_reference"))?,
6182 expires: field_expires.ok_or_else(|| ::serde::de::Error::missing_field("expires"))?,
6183 };
6184 Ok(Some(result))
6185 }
6186
6187 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6188 &self,
6189 s: &mut S::SerializeStruct,
6190 ) -> Result<(), S::Error> {
6191 use serde::ser::SerializeStruct;
6192 s.serialize_field("metadata", &self.metadata)?;
6193 s.serialize_field("copy_reference", &self.copy_reference)?;
6194 s.serialize_field("expires", &self.expires)?;
6195 Ok(())
6196 }
6197}
6198
6199impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceResult {
6200 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6201 use serde::de::{MapAccess, Visitor};
6203 struct StructVisitor;
6204 impl<'de> Visitor<'de> for StructVisitor {
6205 type Value = GetCopyReferenceResult;
6206 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6207 f.write_str("a GetCopyReferenceResult struct")
6208 }
6209 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6210 GetCopyReferenceResult::internal_deserialize(map)
6211 }
6212 }
6213 deserializer.deserialize_struct("GetCopyReferenceResult", GET_COPY_REFERENCE_RESULT_FIELDS, StructVisitor)
6214 }
6215}
6216
6217impl ::serde::ser::Serialize for GetCopyReferenceResult {
6218 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6219 use serde::ser::SerializeStruct;
6221 let mut s = serializer.serialize_struct("GetCopyReferenceResult", 3)?;
6222 self.internal_serialize::<S>(&mut s)?;
6223 s.end()
6224 }
6225}
6226
6227#[derive(Debug, Clone, PartialEq, Eq)]
6228#[non_exhaustive] pub struct GetMetadataArg {
6230 pub path: ReadPath,
6232 pub include_media_info: bool,
6234 pub include_deleted: bool,
6237 pub include_has_explicit_shared_members: bool,
6240 pub include_property_groups: Option<crate::types::file_properties::TemplateFilterBase>,
6243}
6244
6245impl GetMetadataArg {
6246 pub fn new(path: ReadPath) -> Self {
6247 GetMetadataArg {
6248 path,
6249 include_media_info: false,
6250 include_deleted: false,
6251 include_has_explicit_shared_members: false,
6252 include_property_groups: None,
6253 }
6254 }
6255
6256 pub fn with_include_media_info(mut self, value: bool) -> Self {
6257 self.include_media_info = value;
6258 self
6259 }
6260
6261 pub fn with_include_deleted(mut self, value: bool) -> Self {
6262 self.include_deleted = value;
6263 self
6264 }
6265
6266 pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
6267 self.include_has_explicit_shared_members = value;
6268 self
6269 }
6270
6271 pub fn with_include_property_groups(
6272 mut self,
6273 value: crate::types::file_properties::TemplateFilterBase,
6274 ) -> Self {
6275 self.include_property_groups = Some(value);
6276 self
6277 }
6278}
6279
6280const GET_METADATA_ARG_FIELDS: &[&str] = &["path",
6281 "include_media_info",
6282 "include_deleted",
6283 "include_has_explicit_shared_members",
6284 "include_property_groups"];
6285impl GetMetadataArg {
6286 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6287 map: V,
6288 ) -> Result<GetMetadataArg, V::Error> {
6289 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6290 }
6291
6292 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6293 mut map: V,
6294 optional: bool,
6295 ) -> Result<Option<GetMetadataArg>, V::Error> {
6296 let mut field_path = None;
6297 let mut field_include_media_info = None;
6298 let mut field_include_deleted = None;
6299 let mut field_include_has_explicit_shared_members = None;
6300 let mut field_include_property_groups = None;
6301 let mut nothing = true;
6302 while let Some(key) = map.next_key::<&str>()? {
6303 nothing = false;
6304 match key {
6305 "path" => {
6306 if field_path.is_some() {
6307 return Err(::serde::de::Error::duplicate_field("path"));
6308 }
6309 field_path = Some(map.next_value()?);
6310 }
6311 "include_media_info" => {
6312 if field_include_media_info.is_some() {
6313 return Err(::serde::de::Error::duplicate_field("include_media_info"));
6314 }
6315 field_include_media_info = Some(map.next_value()?);
6316 }
6317 "include_deleted" => {
6318 if field_include_deleted.is_some() {
6319 return Err(::serde::de::Error::duplicate_field("include_deleted"));
6320 }
6321 field_include_deleted = Some(map.next_value()?);
6322 }
6323 "include_has_explicit_shared_members" => {
6324 if field_include_has_explicit_shared_members.is_some() {
6325 return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
6326 }
6327 field_include_has_explicit_shared_members = Some(map.next_value()?);
6328 }
6329 "include_property_groups" => {
6330 if field_include_property_groups.is_some() {
6331 return Err(::serde::de::Error::duplicate_field("include_property_groups"));
6332 }
6333 field_include_property_groups = Some(map.next_value()?);
6334 }
6335 _ => {
6336 map.next_value::<::serde_json::Value>()?;
6338 }
6339 }
6340 }
6341 if optional && nothing {
6342 return Ok(None);
6343 }
6344 let result = GetMetadataArg {
6345 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
6346 include_media_info: field_include_media_info.unwrap_or(false),
6347 include_deleted: field_include_deleted.unwrap_or(false),
6348 include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
6349 include_property_groups: field_include_property_groups.and_then(Option::flatten),
6350 };
6351 Ok(Some(result))
6352 }
6353
6354 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6355 &self,
6356 s: &mut S::SerializeStruct,
6357 ) -> Result<(), S::Error> {
6358 use serde::ser::SerializeStruct;
6359 s.serialize_field("path", &self.path)?;
6360 if self.include_media_info {
6361 s.serialize_field("include_media_info", &self.include_media_info)?;
6362 }
6363 if self.include_deleted {
6364 s.serialize_field("include_deleted", &self.include_deleted)?;
6365 }
6366 if self.include_has_explicit_shared_members {
6367 s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
6368 }
6369 if let Some(val) = &self.include_property_groups {
6370 s.serialize_field("include_property_groups", val)?;
6371 }
6372 Ok(())
6373 }
6374}
6375
6376impl<'de> ::serde::de::Deserialize<'de> for GetMetadataArg {
6377 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6378 use serde::de::{MapAccess, Visitor};
6380 struct StructVisitor;
6381 impl<'de> Visitor<'de> for StructVisitor {
6382 type Value = GetMetadataArg;
6383 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6384 f.write_str("a GetMetadataArg struct")
6385 }
6386 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6387 GetMetadataArg::internal_deserialize(map)
6388 }
6389 }
6390 deserializer.deserialize_struct("GetMetadataArg", GET_METADATA_ARG_FIELDS, StructVisitor)
6391 }
6392}
6393
6394impl ::serde::ser::Serialize for GetMetadataArg {
6395 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6396 use serde::ser::SerializeStruct;
6398 let mut s = serializer.serialize_struct("GetMetadataArg", 5)?;
6399 self.internal_serialize::<S>(&mut s)?;
6400 s.end()
6401 }
6402}
6403
6404#[derive(Debug, Clone, PartialEq, Eq)]
6405pub enum GetMetadataError {
6406 Path(LookupError),
6407}
6408
6409impl<'de> ::serde::de::Deserialize<'de> for GetMetadataError {
6410 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6411 use serde::de::{self, MapAccess, Visitor};
6413 struct EnumVisitor;
6414 impl<'de> Visitor<'de> for EnumVisitor {
6415 type Value = GetMetadataError;
6416 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6417 f.write_str("a GetMetadataError structure")
6418 }
6419 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
6420 let tag: &str = match map.next_key()? {
6421 Some(".tag") => map.next_value()?,
6422 _ => return Err(de::Error::missing_field(".tag"))
6423 };
6424 let value = match tag {
6425 "path" => {
6426 match map.next_key()? {
6427 Some("path") => GetMetadataError::Path(map.next_value()?),
6428 None => return Err(de::Error::missing_field("path")),
6429 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
6430 }
6431 }
6432 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
6433 };
6434 crate::eat_json_fields(&mut map)?;
6435 Ok(value)
6436 }
6437 }
6438 const VARIANTS: &[&str] = &["path"];
6439 deserializer.deserialize_struct("GetMetadataError", VARIANTS, EnumVisitor)
6440 }
6441}
6442
6443impl ::serde::ser::Serialize for GetMetadataError {
6444 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6445 use serde::ser::SerializeStruct;
6447 match self {
6448 GetMetadataError::Path(x) => {
6449 let mut s = serializer.serialize_struct("GetMetadataError", 2)?;
6451 s.serialize_field(".tag", "path")?;
6452 s.serialize_field("path", x)?;
6453 s.end()
6454 }
6455 }
6456 }
6457}
6458
6459impl ::std::error::Error for GetMetadataError {
6460 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
6461 match self {
6462 GetMetadataError::Path(inner) => Some(inner),
6463 }
6464 }
6465}
6466
6467impl ::std::fmt::Display for GetMetadataError {
6468 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6469 match self {
6470 GetMetadataError::Path(inner) => write!(f, "GetMetadataError: {}", inner),
6471 }
6472 }
6473}
6474
6475#[derive(Debug, Clone, PartialEq, Eq)]
6476#[non_exhaustive] pub struct GetTagsArg {
6478 pub paths: Vec<Path>,
6480}
6481
6482impl GetTagsArg {
6483 pub fn new(paths: Vec<Path>) -> Self {
6484 GetTagsArg {
6485 paths,
6486 }
6487 }
6488}
6489
6490const GET_TAGS_ARG_FIELDS: &[&str] = &["paths"];
6491impl GetTagsArg {
6492 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6493 map: V,
6494 ) -> Result<GetTagsArg, V::Error> {
6495 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6496 }
6497
6498 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6499 mut map: V,
6500 optional: bool,
6501 ) -> Result<Option<GetTagsArg>, V::Error> {
6502 let mut field_paths = None;
6503 let mut nothing = true;
6504 while let Some(key) = map.next_key::<&str>()? {
6505 nothing = false;
6506 match key {
6507 "paths" => {
6508 if field_paths.is_some() {
6509 return Err(::serde::de::Error::duplicate_field("paths"));
6510 }
6511 field_paths = Some(map.next_value()?);
6512 }
6513 _ => {
6514 map.next_value::<::serde_json::Value>()?;
6516 }
6517 }
6518 }
6519 if optional && nothing {
6520 return Ok(None);
6521 }
6522 let result = GetTagsArg {
6523 paths: field_paths.ok_or_else(|| ::serde::de::Error::missing_field("paths"))?,
6524 };
6525 Ok(Some(result))
6526 }
6527
6528 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6529 &self,
6530 s: &mut S::SerializeStruct,
6531 ) -> Result<(), S::Error> {
6532 use serde::ser::SerializeStruct;
6533 s.serialize_field("paths", &self.paths)?;
6534 Ok(())
6535 }
6536}
6537
6538impl<'de> ::serde::de::Deserialize<'de> for GetTagsArg {
6539 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6540 use serde::de::{MapAccess, Visitor};
6542 struct StructVisitor;
6543 impl<'de> Visitor<'de> for StructVisitor {
6544 type Value = GetTagsArg;
6545 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6546 f.write_str("a GetTagsArg struct")
6547 }
6548 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6549 GetTagsArg::internal_deserialize(map)
6550 }
6551 }
6552 deserializer.deserialize_struct("GetTagsArg", GET_TAGS_ARG_FIELDS, StructVisitor)
6553 }
6554}
6555
6556impl ::serde::ser::Serialize for GetTagsArg {
6557 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6558 use serde::ser::SerializeStruct;
6560 let mut s = serializer.serialize_struct("GetTagsArg", 1)?;
6561 self.internal_serialize::<S>(&mut s)?;
6562 s.end()
6563 }
6564}
6565
6566#[derive(Debug, Clone, PartialEq, Eq)]
6567#[non_exhaustive] pub struct GetTagsResult {
6569 pub paths_to_tags: Vec<PathToTags>,
6571}
6572
6573impl GetTagsResult {
6574 pub fn new(paths_to_tags: Vec<PathToTags>) -> Self {
6575 GetTagsResult {
6576 paths_to_tags,
6577 }
6578 }
6579}
6580
6581const GET_TAGS_RESULT_FIELDS: &[&str] = &["paths_to_tags"];
6582impl GetTagsResult {
6583 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6584 map: V,
6585 ) -> Result<GetTagsResult, V::Error> {
6586 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6587 }
6588
6589 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6590 mut map: V,
6591 optional: bool,
6592 ) -> Result<Option<GetTagsResult>, V::Error> {
6593 let mut field_paths_to_tags = None;
6594 let mut nothing = true;
6595 while let Some(key) = map.next_key::<&str>()? {
6596 nothing = false;
6597 match key {
6598 "paths_to_tags" => {
6599 if field_paths_to_tags.is_some() {
6600 return Err(::serde::de::Error::duplicate_field("paths_to_tags"));
6601 }
6602 field_paths_to_tags = Some(map.next_value()?);
6603 }
6604 _ => {
6605 map.next_value::<::serde_json::Value>()?;
6607 }
6608 }
6609 }
6610 if optional && nothing {
6611 return Ok(None);
6612 }
6613 let result = GetTagsResult {
6614 paths_to_tags: field_paths_to_tags.ok_or_else(|| ::serde::de::Error::missing_field("paths_to_tags"))?,
6615 };
6616 Ok(Some(result))
6617 }
6618
6619 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6620 &self,
6621 s: &mut S::SerializeStruct,
6622 ) -> Result<(), S::Error> {
6623 use serde::ser::SerializeStruct;
6624 s.serialize_field("paths_to_tags", &self.paths_to_tags)?;
6625 Ok(())
6626 }
6627}
6628
6629impl<'de> ::serde::de::Deserialize<'de> for GetTagsResult {
6630 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6631 use serde::de::{MapAccess, Visitor};
6633 struct StructVisitor;
6634 impl<'de> Visitor<'de> for StructVisitor {
6635 type Value = GetTagsResult;
6636 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6637 f.write_str("a GetTagsResult struct")
6638 }
6639 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6640 GetTagsResult::internal_deserialize(map)
6641 }
6642 }
6643 deserializer.deserialize_struct("GetTagsResult", GET_TAGS_RESULT_FIELDS, StructVisitor)
6644 }
6645}
6646
6647impl ::serde::ser::Serialize for GetTagsResult {
6648 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6649 use serde::ser::SerializeStruct;
6651 let mut s = serializer.serialize_struct("GetTagsResult", 1)?;
6652 self.internal_serialize::<S>(&mut s)?;
6653 s.end()
6654 }
6655}
6656
6657#[derive(Debug, Clone, PartialEq, Eq)]
6658#[non_exhaustive] pub struct GetTemporaryLinkArg {
6660 pub path: ReadPath,
6662}
6663
6664impl GetTemporaryLinkArg {
6665 pub fn new(path: ReadPath) -> Self {
6666 GetTemporaryLinkArg {
6667 path,
6668 }
6669 }
6670}
6671
6672const GET_TEMPORARY_LINK_ARG_FIELDS: &[&str] = &["path"];
6673impl GetTemporaryLinkArg {
6674 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6675 map: V,
6676 ) -> Result<GetTemporaryLinkArg, V::Error> {
6677 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6678 }
6679
6680 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6681 mut map: V,
6682 optional: bool,
6683 ) -> Result<Option<GetTemporaryLinkArg>, V::Error> {
6684 let mut field_path = None;
6685 let mut nothing = true;
6686 while let Some(key) = map.next_key::<&str>()? {
6687 nothing = false;
6688 match key {
6689 "path" => {
6690 if field_path.is_some() {
6691 return Err(::serde::de::Error::duplicate_field("path"));
6692 }
6693 field_path = Some(map.next_value()?);
6694 }
6695 _ => {
6696 map.next_value::<::serde_json::Value>()?;
6698 }
6699 }
6700 }
6701 if optional && nothing {
6702 return Ok(None);
6703 }
6704 let result = GetTemporaryLinkArg {
6705 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
6706 };
6707 Ok(Some(result))
6708 }
6709
6710 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6711 &self,
6712 s: &mut S::SerializeStruct,
6713 ) -> Result<(), S::Error> {
6714 use serde::ser::SerializeStruct;
6715 s.serialize_field("path", &self.path)?;
6716 Ok(())
6717 }
6718}
6719
6720impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkArg {
6721 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6722 use serde::de::{MapAccess, Visitor};
6724 struct StructVisitor;
6725 impl<'de> Visitor<'de> for StructVisitor {
6726 type Value = GetTemporaryLinkArg;
6727 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6728 f.write_str("a GetTemporaryLinkArg struct")
6729 }
6730 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6731 GetTemporaryLinkArg::internal_deserialize(map)
6732 }
6733 }
6734 deserializer.deserialize_struct("GetTemporaryLinkArg", GET_TEMPORARY_LINK_ARG_FIELDS, StructVisitor)
6735 }
6736}
6737
6738impl ::serde::ser::Serialize for GetTemporaryLinkArg {
6739 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6740 use serde::ser::SerializeStruct;
6742 let mut s = serializer.serialize_struct("GetTemporaryLinkArg", 1)?;
6743 self.internal_serialize::<S>(&mut s)?;
6744 s.end()
6745 }
6746}
6747
6748#[derive(Debug, Clone, PartialEq, Eq)]
6749#[non_exhaustive] pub enum GetTemporaryLinkError {
6751 Path(LookupError),
6752 EmailNotVerified,
6756 UnsupportedFile,
6758 NotAllowed,
6762 Other,
6765}
6766
6767impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkError {
6768 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6769 use serde::de::{self, MapAccess, Visitor};
6771 struct EnumVisitor;
6772 impl<'de> Visitor<'de> for EnumVisitor {
6773 type Value = GetTemporaryLinkError;
6774 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6775 f.write_str("a GetTemporaryLinkError structure")
6776 }
6777 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
6778 let tag: &str = match map.next_key()? {
6779 Some(".tag") => map.next_value()?,
6780 _ => return Err(de::Error::missing_field(".tag"))
6781 };
6782 let value = match tag {
6783 "path" => {
6784 match map.next_key()? {
6785 Some("path") => GetTemporaryLinkError::Path(map.next_value()?),
6786 None => return Err(de::Error::missing_field("path")),
6787 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
6788 }
6789 }
6790 "email_not_verified" => GetTemporaryLinkError::EmailNotVerified,
6791 "unsupported_file" => GetTemporaryLinkError::UnsupportedFile,
6792 "not_allowed" => GetTemporaryLinkError::NotAllowed,
6793 _ => GetTemporaryLinkError::Other,
6794 };
6795 crate::eat_json_fields(&mut map)?;
6796 Ok(value)
6797 }
6798 }
6799 const VARIANTS: &[&str] = &["path",
6800 "email_not_verified",
6801 "unsupported_file",
6802 "not_allowed",
6803 "other"];
6804 deserializer.deserialize_struct("GetTemporaryLinkError", VARIANTS, EnumVisitor)
6805 }
6806}
6807
6808impl ::serde::ser::Serialize for GetTemporaryLinkError {
6809 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6810 use serde::ser::SerializeStruct;
6812 match self {
6813 GetTemporaryLinkError::Path(x) => {
6814 let mut s = serializer.serialize_struct("GetTemporaryLinkError", 2)?;
6816 s.serialize_field(".tag", "path")?;
6817 s.serialize_field("path", x)?;
6818 s.end()
6819 }
6820 GetTemporaryLinkError::EmailNotVerified => {
6821 let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
6823 s.serialize_field(".tag", "email_not_verified")?;
6824 s.end()
6825 }
6826 GetTemporaryLinkError::UnsupportedFile => {
6827 let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
6829 s.serialize_field(".tag", "unsupported_file")?;
6830 s.end()
6831 }
6832 GetTemporaryLinkError::NotAllowed => {
6833 let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
6835 s.serialize_field(".tag", "not_allowed")?;
6836 s.end()
6837 }
6838 GetTemporaryLinkError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
6839 }
6840 }
6841}
6842
6843impl ::std::error::Error for GetTemporaryLinkError {
6844 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
6845 match self {
6846 GetTemporaryLinkError::Path(inner) => Some(inner),
6847 _ => None,
6848 }
6849 }
6850}
6851
6852impl ::std::fmt::Display for GetTemporaryLinkError {
6853 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6854 match self {
6855 GetTemporaryLinkError::Path(inner) => write!(f, "GetTemporaryLinkError: {}", inner),
6856 _ => write!(f, "{:?}", *self),
6857 }
6858 }
6859}
6860
6861#[derive(Debug, Clone, PartialEq)]
6862#[non_exhaustive] pub struct GetTemporaryLinkResult {
6864 pub metadata: FileMetadata,
6866 pub link: String,
6868}
6869
6870impl GetTemporaryLinkResult {
6871 pub fn new(metadata: FileMetadata, link: String) -> Self {
6872 GetTemporaryLinkResult {
6873 metadata,
6874 link,
6875 }
6876 }
6877}
6878
6879const GET_TEMPORARY_LINK_RESULT_FIELDS: &[&str] = &["metadata",
6880 "link"];
6881impl GetTemporaryLinkResult {
6882 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6883 map: V,
6884 ) -> Result<GetTemporaryLinkResult, V::Error> {
6885 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6886 }
6887
6888 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
6889 mut map: V,
6890 optional: bool,
6891 ) -> Result<Option<GetTemporaryLinkResult>, V::Error> {
6892 let mut field_metadata = None;
6893 let mut field_link = None;
6894 let mut nothing = true;
6895 while let Some(key) = map.next_key::<&str>()? {
6896 nothing = false;
6897 match key {
6898 "metadata" => {
6899 if field_metadata.is_some() {
6900 return Err(::serde::de::Error::duplicate_field("metadata"));
6901 }
6902 field_metadata = Some(map.next_value()?);
6903 }
6904 "link" => {
6905 if field_link.is_some() {
6906 return Err(::serde::de::Error::duplicate_field("link"));
6907 }
6908 field_link = Some(map.next_value()?);
6909 }
6910 _ => {
6911 map.next_value::<::serde_json::Value>()?;
6913 }
6914 }
6915 }
6916 if optional && nothing {
6917 return Ok(None);
6918 }
6919 let result = GetTemporaryLinkResult {
6920 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
6921 link: field_link.ok_or_else(|| ::serde::de::Error::missing_field("link"))?,
6922 };
6923 Ok(Some(result))
6924 }
6925
6926 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
6927 &self,
6928 s: &mut S::SerializeStruct,
6929 ) -> Result<(), S::Error> {
6930 use serde::ser::SerializeStruct;
6931 s.serialize_field("metadata", &self.metadata)?;
6932 s.serialize_field("link", &self.link)?;
6933 Ok(())
6934 }
6935}
6936
6937impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkResult {
6938 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
6939 use serde::de::{MapAccess, Visitor};
6941 struct StructVisitor;
6942 impl<'de> Visitor<'de> for StructVisitor {
6943 type Value = GetTemporaryLinkResult;
6944 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
6945 f.write_str("a GetTemporaryLinkResult struct")
6946 }
6947 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
6948 GetTemporaryLinkResult::internal_deserialize(map)
6949 }
6950 }
6951 deserializer.deserialize_struct("GetTemporaryLinkResult", GET_TEMPORARY_LINK_RESULT_FIELDS, StructVisitor)
6952 }
6953}
6954
6955impl ::serde::ser::Serialize for GetTemporaryLinkResult {
6956 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
6957 use serde::ser::SerializeStruct;
6959 let mut s = serializer.serialize_struct("GetTemporaryLinkResult", 2)?;
6960 self.internal_serialize::<S>(&mut s)?;
6961 s.end()
6962 }
6963}
6964
6965#[derive(Debug, Clone, PartialEq)]
6966#[non_exhaustive] pub struct GetTemporaryUploadLinkArg {
6968 pub commit_info: CommitInfo,
6971 pub duration: f64,
6974}
6975
6976impl GetTemporaryUploadLinkArg {
6977 pub fn new(commit_info: CommitInfo) -> Self {
6978 GetTemporaryUploadLinkArg {
6979 commit_info,
6980 duration: 14400.0,
6981 }
6982 }
6983
6984 pub fn with_duration(mut self, value: f64) -> Self {
6985 self.duration = value;
6986 self
6987 }
6988}
6989
6990const GET_TEMPORARY_UPLOAD_LINK_ARG_FIELDS: &[&str] = &["commit_info",
6991 "duration"];
6992impl GetTemporaryUploadLinkArg {
6993 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
6994 map: V,
6995 ) -> Result<GetTemporaryUploadLinkArg, V::Error> {
6996 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
6997 }
6998
6999 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7000 mut map: V,
7001 optional: bool,
7002 ) -> Result<Option<GetTemporaryUploadLinkArg>, V::Error> {
7003 let mut field_commit_info = None;
7004 let mut field_duration = None;
7005 let mut nothing = true;
7006 while let Some(key) = map.next_key::<&str>()? {
7007 nothing = false;
7008 match key {
7009 "commit_info" => {
7010 if field_commit_info.is_some() {
7011 return Err(::serde::de::Error::duplicate_field("commit_info"));
7012 }
7013 field_commit_info = Some(map.next_value()?);
7014 }
7015 "duration" => {
7016 if field_duration.is_some() {
7017 return Err(::serde::de::Error::duplicate_field("duration"));
7018 }
7019 field_duration = Some(map.next_value()?);
7020 }
7021 _ => {
7022 map.next_value::<::serde_json::Value>()?;
7024 }
7025 }
7026 }
7027 if optional && nothing {
7028 return Ok(None);
7029 }
7030 let result = GetTemporaryUploadLinkArg {
7031 commit_info: field_commit_info.ok_or_else(|| ::serde::de::Error::missing_field("commit_info"))?,
7032 duration: field_duration.unwrap_or(14400.0),
7033 };
7034 Ok(Some(result))
7035 }
7036
7037 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7038 &self,
7039 s: &mut S::SerializeStruct,
7040 ) -> Result<(), S::Error> {
7041 use serde::ser::SerializeStruct;
7042 s.serialize_field("commit_info", &self.commit_info)?;
7043 if self.duration != 14400.0 {
7044 s.serialize_field("duration", &self.duration)?;
7045 }
7046 Ok(())
7047 }
7048}
7049
7050impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryUploadLinkArg {
7051 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7052 use serde::de::{MapAccess, Visitor};
7054 struct StructVisitor;
7055 impl<'de> Visitor<'de> for StructVisitor {
7056 type Value = GetTemporaryUploadLinkArg;
7057 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7058 f.write_str("a GetTemporaryUploadLinkArg struct")
7059 }
7060 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7061 GetTemporaryUploadLinkArg::internal_deserialize(map)
7062 }
7063 }
7064 deserializer.deserialize_struct("GetTemporaryUploadLinkArg", GET_TEMPORARY_UPLOAD_LINK_ARG_FIELDS, StructVisitor)
7065 }
7066}
7067
7068impl ::serde::ser::Serialize for GetTemporaryUploadLinkArg {
7069 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7070 use serde::ser::SerializeStruct;
7072 let mut s = serializer.serialize_struct("GetTemporaryUploadLinkArg", 2)?;
7073 self.internal_serialize::<S>(&mut s)?;
7074 s.end()
7075 }
7076}
7077
7078#[derive(Debug, Clone, PartialEq, Eq)]
7079#[non_exhaustive] pub struct GetTemporaryUploadLinkResult {
7081 pub link: String,
7083}
7084
7085impl GetTemporaryUploadLinkResult {
7086 pub fn new(link: String) -> Self {
7087 GetTemporaryUploadLinkResult {
7088 link,
7089 }
7090 }
7091}
7092
7093const GET_TEMPORARY_UPLOAD_LINK_RESULT_FIELDS: &[&str] = &["link"];
7094impl GetTemporaryUploadLinkResult {
7095 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7096 map: V,
7097 ) -> Result<GetTemporaryUploadLinkResult, V::Error> {
7098 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7099 }
7100
7101 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7102 mut map: V,
7103 optional: bool,
7104 ) -> Result<Option<GetTemporaryUploadLinkResult>, V::Error> {
7105 let mut field_link = None;
7106 let mut nothing = true;
7107 while let Some(key) = map.next_key::<&str>()? {
7108 nothing = false;
7109 match key {
7110 "link" => {
7111 if field_link.is_some() {
7112 return Err(::serde::de::Error::duplicate_field("link"));
7113 }
7114 field_link = Some(map.next_value()?);
7115 }
7116 _ => {
7117 map.next_value::<::serde_json::Value>()?;
7119 }
7120 }
7121 }
7122 if optional && nothing {
7123 return Ok(None);
7124 }
7125 let result = GetTemporaryUploadLinkResult {
7126 link: field_link.ok_or_else(|| ::serde::de::Error::missing_field("link"))?,
7127 };
7128 Ok(Some(result))
7129 }
7130
7131 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7132 &self,
7133 s: &mut S::SerializeStruct,
7134 ) -> Result<(), S::Error> {
7135 use serde::ser::SerializeStruct;
7136 s.serialize_field("link", &self.link)?;
7137 Ok(())
7138 }
7139}
7140
7141impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryUploadLinkResult {
7142 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7143 use serde::de::{MapAccess, Visitor};
7145 struct StructVisitor;
7146 impl<'de> Visitor<'de> for StructVisitor {
7147 type Value = GetTemporaryUploadLinkResult;
7148 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7149 f.write_str("a GetTemporaryUploadLinkResult struct")
7150 }
7151 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7152 GetTemporaryUploadLinkResult::internal_deserialize(map)
7153 }
7154 }
7155 deserializer.deserialize_struct("GetTemporaryUploadLinkResult", GET_TEMPORARY_UPLOAD_LINK_RESULT_FIELDS, StructVisitor)
7156 }
7157}
7158
7159impl ::serde::ser::Serialize for GetTemporaryUploadLinkResult {
7160 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7161 use serde::ser::SerializeStruct;
7163 let mut s = serializer.serialize_struct("GetTemporaryUploadLinkResult", 1)?;
7164 self.internal_serialize::<S>(&mut s)?;
7165 s.end()
7166 }
7167}
7168
7169#[derive(Debug, Clone, PartialEq, Eq)]
7171#[non_exhaustive] pub struct GetThumbnailBatchArg {
7173 pub entries: Vec<ThumbnailArg>,
7175}
7176
7177impl GetThumbnailBatchArg {
7178 pub fn new(entries: Vec<ThumbnailArg>) -> Self {
7179 GetThumbnailBatchArg {
7180 entries,
7181 }
7182 }
7183}
7184
7185const GET_THUMBNAIL_BATCH_ARG_FIELDS: &[&str] = &["entries"];
7186impl GetThumbnailBatchArg {
7187 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7188 map: V,
7189 ) -> Result<GetThumbnailBatchArg, V::Error> {
7190 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7191 }
7192
7193 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7194 mut map: V,
7195 optional: bool,
7196 ) -> Result<Option<GetThumbnailBatchArg>, V::Error> {
7197 let mut field_entries = None;
7198 let mut nothing = true;
7199 while let Some(key) = map.next_key::<&str>()? {
7200 nothing = false;
7201 match key {
7202 "entries" => {
7203 if field_entries.is_some() {
7204 return Err(::serde::de::Error::duplicate_field("entries"));
7205 }
7206 field_entries = Some(map.next_value()?);
7207 }
7208 _ => {
7209 map.next_value::<::serde_json::Value>()?;
7211 }
7212 }
7213 }
7214 if optional && nothing {
7215 return Ok(None);
7216 }
7217 let result = GetThumbnailBatchArg {
7218 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
7219 };
7220 Ok(Some(result))
7221 }
7222
7223 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7224 &self,
7225 s: &mut S::SerializeStruct,
7226 ) -> Result<(), S::Error> {
7227 use serde::ser::SerializeStruct;
7228 s.serialize_field("entries", &self.entries)?;
7229 Ok(())
7230 }
7231}
7232
7233impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchArg {
7234 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7235 use serde::de::{MapAccess, Visitor};
7237 struct StructVisitor;
7238 impl<'de> Visitor<'de> for StructVisitor {
7239 type Value = GetThumbnailBatchArg;
7240 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7241 f.write_str("a GetThumbnailBatchArg struct")
7242 }
7243 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7244 GetThumbnailBatchArg::internal_deserialize(map)
7245 }
7246 }
7247 deserializer.deserialize_struct("GetThumbnailBatchArg", GET_THUMBNAIL_BATCH_ARG_FIELDS, StructVisitor)
7248 }
7249}
7250
7251impl ::serde::ser::Serialize for GetThumbnailBatchArg {
7252 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7253 use serde::ser::SerializeStruct;
7255 let mut s = serializer.serialize_struct("GetThumbnailBatchArg", 1)?;
7256 self.internal_serialize::<S>(&mut s)?;
7257 s.end()
7258 }
7259}
7260
7261#[derive(Debug, Clone, PartialEq, Eq)]
7262#[non_exhaustive] pub enum GetThumbnailBatchError {
7264 TooManyFiles,
7266 Other,
7269}
7270
7271impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchError {
7272 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7273 use serde::de::{self, MapAccess, Visitor};
7275 struct EnumVisitor;
7276 impl<'de> Visitor<'de> for EnumVisitor {
7277 type Value = GetThumbnailBatchError;
7278 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7279 f.write_str("a GetThumbnailBatchError structure")
7280 }
7281 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
7282 let tag: &str = match map.next_key()? {
7283 Some(".tag") => map.next_value()?,
7284 _ => return Err(de::Error::missing_field(".tag"))
7285 };
7286 let value = match tag {
7287 "too_many_files" => GetThumbnailBatchError::TooManyFiles,
7288 _ => GetThumbnailBatchError::Other,
7289 };
7290 crate::eat_json_fields(&mut map)?;
7291 Ok(value)
7292 }
7293 }
7294 const VARIANTS: &[&str] = &["too_many_files",
7295 "other"];
7296 deserializer.deserialize_struct("GetThumbnailBatchError", VARIANTS, EnumVisitor)
7297 }
7298}
7299
7300impl ::serde::ser::Serialize for GetThumbnailBatchError {
7301 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7302 use serde::ser::SerializeStruct;
7304 match self {
7305 GetThumbnailBatchError::TooManyFiles => {
7306 let mut s = serializer.serialize_struct("GetThumbnailBatchError", 1)?;
7308 s.serialize_field(".tag", "too_many_files")?;
7309 s.end()
7310 }
7311 GetThumbnailBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
7312 }
7313 }
7314}
7315
7316impl ::std::error::Error for GetThumbnailBatchError {
7317}
7318
7319impl ::std::fmt::Display for GetThumbnailBatchError {
7320 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7321 match self {
7322 GetThumbnailBatchError::TooManyFiles => f.write_str("The operation involves more than 25 files."),
7323 _ => write!(f, "{:?}", *self),
7324 }
7325 }
7326}
7327
7328#[derive(Debug, Clone, PartialEq)]
7329#[non_exhaustive] pub struct GetThumbnailBatchResult {
7331 pub entries: Vec<GetThumbnailBatchResultEntry>,
7333}
7334
7335impl GetThumbnailBatchResult {
7336 pub fn new(entries: Vec<GetThumbnailBatchResultEntry>) -> Self {
7337 GetThumbnailBatchResult {
7338 entries,
7339 }
7340 }
7341}
7342
7343const GET_THUMBNAIL_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
7344impl GetThumbnailBatchResult {
7345 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7346 map: V,
7347 ) -> Result<GetThumbnailBatchResult, V::Error> {
7348 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7349 }
7350
7351 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7352 mut map: V,
7353 optional: bool,
7354 ) -> Result<Option<GetThumbnailBatchResult>, V::Error> {
7355 let mut field_entries = None;
7356 let mut nothing = true;
7357 while let Some(key) = map.next_key::<&str>()? {
7358 nothing = false;
7359 match key {
7360 "entries" => {
7361 if field_entries.is_some() {
7362 return Err(::serde::de::Error::duplicate_field("entries"));
7363 }
7364 field_entries = Some(map.next_value()?);
7365 }
7366 _ => {
7367 map.next_value::<::serde_json::Value>()?;
7369 }
7370 }
7371 }
7372 if optional && nothing {
7373 return Ok(None);
7374 }
7375 let result = GetThumbnailBatchResult {
7376 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
7377 };
7378 Ok(Some(result))
7379 }
7380
7381 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7382 &self,
7383 s: &mut S::SerializeStruct,
7384 ) -> Result<(), S::Error> {
7385 use serde::ser::SerializeStruct;
7386 s.serialize_field("entries", &self.entries)?;
7387 Ok(())
7388 }
7389}
7390
7391impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResult {
7392 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7393 use serde::de::{MapAccess, Visitor};
7395 struct StructVisitor;
7396 impl<'de> Visitor<'de> for StructVisitor {
7397 type Value = GetThumbnailBatchResult;
7398 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7399 f.write_str("a GetThumbnailBatchResult struct")
7400 }
7401 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7402 GetThumbnailBatchResult::internal_deserialize(map)
7403 }
7404 }
7405 deserializer.deserialize_struct("GetThumbnailBatchResult", GET_THUMBNAIL_BATCH_RESULT_FIELDS, StructVisitor)
7406 }
7407}
7408
7409impl ::serde::ser::Serialize for GetThumbnailBatchResult {
7410 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7411 use serde::ser::SerializeStruct;
7413 let mut s = serializer.serialize_struct("GetThumbnailBatchResult", 1)?;
7414 self.internal_serialize::<S>(&mut s)?;
7415 s.end()
7416 }
7417}
7418
7419#[derive(Debug, Clone, PartialEq)]
7420#[non_exhaustive] pub struct GetThumbnailBatchResultData {
7422 pub metadata: FileMetadata,
7423 pub thumbnail: String,
7425}
7426
7427impl GetThumbnailBatchResultData {
7428 pub fn new(metadata: FileMetadata, thumbnail: String) -> Self {
7429 GetThumbnailBatchResultData {
7430 metadata,
7431 thumbnail,
7432 }
7433 }
7434}
7435
7436const GET_THUMBNAIL_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata",
7437 "thumbnail"];
7438impl GetThumbnailBatchResultData {
7439 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7440 map: V,
7441 ) -> Result<GetThumbnailBatchResultData, V::Error> {
7442 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7443 }
7444
7445 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7446 mut map: V,
7447 optional: bool,
7448 ) -> Result<Option<GetThumbnailBatchResultData>, V::Error> {
7449 let mut field_metadata = None;
7450 let mut field_thumbnail = None;
7451 let mut nothing = true;
7452 while let Some(key) = map.next_key::<&str>()? {
7453 nothing = false;
7454 match key {
7455 "metadata" => {
7456 if field_metadata.is_some() {
7457 return Err(::serde::de::Error::duplicate_field("metadata"));
7458 }
7459 field_metadata = Some(map.next_value()?);
7460 }
7461 "thumbnail" => {
7462 if field_thumbnail.is_some() {
7463 return Err(::serde::de::Error::duplicate_field("thumbnail"));
7464 }
7465 field_thumbnail = Some(map.next_value()?);
7466 }
7467 _ => {
7468 map.next_value::<::serde_json::Value>()?;
7470 }
7471 }
7472 }
7473 if optional && nothing {
7474 return Ok(None);
7475 }
7476 let result = GetThumbnailBatchResultData {
7477 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
7478 thumbnail: field_thumbnail.ok_or_else(|| ::serde::de::Error::missing_field("thumbnail"))?,
7479 };
7480 Ok(Some(result))
7481 }
7482
7483 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7484 &self,
7485 s: &mut S::SerializeStruct,
7486 ) -> Result<(), S::Error> {
7487 use serde::ser::SerializeStruct;
7488 s.serialize_field("metadata", &self.metadata)?;
7489 s.serialize_field("thumbnail", &self.thumbnail)?;
7490 Ok(())
7491 }
7492}
7493
7494impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResultData {
7495 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7496 use serde::de::{MapAccess, Visitor};
7498 struct StructVisitor;
7499 impl<'de> Visitor<'de> for StructVisitor {
7500 type Value = GetThumbnailBatchResultData;
7501 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7502 f.write_str("a GetThumbnailBatchResultData struct")
7503 }
7504 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7505 GetThumbnailBatchResultData::internal_deserialize(map)
7506 }
7507 }
7508 deserializer.deserialize_struct("GetThumbnailBatchResultData", GET_THUMBNAIL_BATCH_RESULT_DATA_FIELDS, StructVisitor)
7509 }
7510}
7511
7512impl ::serde::ser::Serialize for GetThumbnailBatchResultData {
7513 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7514 use serde::ser::SerializeStruct;
7516 let mut s = serializer.serialize_struct("GetThumbnailBatchResultData", 2)?;
7517 self.internal_serialize::<S>(&mut s)?;
7518 s.end()
7519 }
7520}
7521
7522#[derive(Debug, Clone, PartialEq)]
7523#[non_exhaustive] pub enum GetThumbnailBatchResultEntry {
7525 Success(GetThumbnailBatchResultData),
7526 Failure(ThumbnailError),
7528 Other,
7531}
7532
7533impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResultEntry {
7534 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7535 use serde::de::{self, MapAccess, Visitor};
7537 struct EnumVisitor;
7538 impl<'de> Visitor<'de> for EnumVisitor {
7539 type Value = GetThumbnailBatchResultEntry;
7540 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7541 f.write_str("a GetThumbnailBatchResultEntry structure")
7542 }
7543 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
7544 let tag: &str = match map.next_key()? {
7545 Some(".tag") => map.next_value()?,
7546 _ => return Err(de::Error::missing_field(".tag"))
7547 };
7548 let value = match tag {
7549 "success" => GetThumbnailBatchResultEntry::Success(GetThumbnailBatchResultData::internal_deserialize(&mut map)?),
7550 "failure" => {
7551 match map.next_key()? {
7552 Some("failure") => GetThumbnailBatchResultEntry::Failure(map.next_value()?),
7553 None => return Err(de::Error::missing_field("failure")),
7554 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
7555 }
7556 }
7557 _ => GetThumbnailBatchResultEntry::Other,
7558 };
7559 crate::eat_json_fields(&mut map)?;
7560 Ok(value)
7561 }
7562 }
7563 const VARIANTS: &[&str] = &["success",
7564 "failure",
7565 "other"];
7566 deserializer.deserialize_struct("GetThumbnailBatchResultEntry", VARIANTS, EnumVisitor)
7567 }
7568}
7569
7570impl ::serde::ser::Serialize for GetThumbnailBatchResultEntry {
7571 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7572 use serde::ser::SerializeStruct;
7574 match self {
7575 GetThumbnailBatchResultEntry::Success(x) => {
7576 let mut s = serializer.serialize_struct("GetThumbnailBatchResultEntry", 3)?;
7578 s.serialize_field(".tag", "success")?;
7579 x.internal_serialize::<S>(&mut s)?;
7580 s.end()
7581 }
7582 GetThumbnailBatchResultEntry::Failure(x) => {
7583 let mut s = serializer.serialize_struct("GetThumbnailBatchResultEntry", 2)?;
7585 s.serialize_field(".tag", "failure")?;
7586 s.serialize_field("failure", x)?;
7587 s.end()
7588 }
7589 GetThumbnailBatchResultEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
7590 }
7591 }
7592}
7593
7594#[derive(Debug, Clone, PartialEq)]
7596#[non_exhaustive] pub struct GpsCoordinates {
7598 pub latitude: f64,
7600 pub longitude: f64,
7602}
7603
7604impl GpsCoordinates {
7605 pub fn new(latitude: f64, longitude: f64) -> Self {
7606 GpsCoordinates {
7607 latitude,
7608 longitude,
7609 }
7610 }
7611}
7612
7613const GPS_COORDINATES_FIELDS: &[&str] = &["latitude",
7614 "longitude"];
7615impl GpsCoordinates {
7616 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7617 map: V,
7618 ) -> Result<GpsCoordinates, V::Error> {
7619 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7620 }
7621
7622 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7623 mut map: V,
7624 optional: bool,
7625 ) -> Result<Option<GpsCoordinates>, V::Error> {
7626 let mut field_latitude = None;
7627 let mut field_longitude = None;
7628 let mut nothing = true;
7629 while let Some(key) = map.next_key::<&str>()? {
7630 nothing = false;
7631 match key {
7632 "latitude" => {
7633 if field_latitude.is_some() {
7634 return Err(::serde::de::Error::duplicate_field("latitude"));
7635 }
7636 field_latitude = Some(map.next_value()?);
7637 }
7638 "longitude" => {
7639 if field_longitude.is_some() {
7640 return Err(::serde::de::Error::duplicate_field("longitude"));
7641 }
7642 field_longitude = Some(map.next_value()?);
7643 }
7644 _ => {
7645 map.next_value::<::serde_json::Value>()?;
7647 }
7648 }
7649 }
7650 if optional && nothing {
7651 return Ok(None);
7652 }
7653 let result = GpsCoordinates {
7654 latitude: field_latitude.ok_or_else(|| ::serde::de::Error::missing_field("latitude"))?,
7655 longitude: field_longitude.ok_or_else(|| ::serde::de::Error::missing_field("longitude"))?,
7656 };
7657 Ok(Some(result))
7658 }
7659
7660 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7661 &self,
7662 s: &mut S::SerializeStruct,
7663 ) -> Result<(), S::Error> {
7664 use serde::ser::SerializeStruct;
7665 s.serialize_field("latitude", &self.latitude)?;
7666 s.serialize_field("longitude", &self.longitude)?;
7667 Ok(())
7668 }
7669}
7670
7671impl<'de> ::serde::de::Deserialize<'de> for GpsCoordinates {
7672 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7673 use serde::de::{MapAccess, Visitor};
7675 struct StructVisitor;
7676 impl<'de> Visitor<'de> for StructVisitor {
7677 type Value = GpsCoordinates;
7678 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7679 f.write_str("a GpsCoordinates struct")
7680 }
7681 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7682 GpsCoordinates::internal_deserialize(map)
7683 }
7684 }
7685 deserializer.deserialize_struct("GpsCoordinates", GPS_COORDINATES_FIELDS, StructVisitor)
7686 }
7687}
7688
7689impl ::serde::ser::Serialize for GpsCoordinates {
7690 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7691 use serde::ser::SerializeStruct;
7693 let mut s = serializer.serialize_struct("GpsCoordinates", 2)?;
7694 self.internal_serialize::<S>(&mut s)?;
7695 s.end()
7696 }
7697}
7698
7699#[derive(Debug, Clone, PartialEq, Eq)]
7700#[non_exhaustive] pub struct HighlightSpan {
7702 pub highlight_str: String,
7704 pub is_highlighted: bool,
7706}
7707
7708impl HighlightSpan {
7709 pub fn new(highlight_str: String, is_highlighted: bool) -> Self {
7710 HighlightSpan {
7711 highlight_str,
7712 is_highlighted,
7713 }
7714 }
7715}
7716
7717const HIGHLIGHT_SPAN_FIELDS: &[&str] = &["highlight_str",
7718 "is_highlighted"];
7719impl HighlightSpan {
7720 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7721 map: V,
7722 ) -> Result<HighlightSpan, V::Error> {
7723 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
7724 }
7725
7726 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
7727 mut map: V,
7728 optional: bool,
7729 ) -> Result<Option<HighlightSpan>, V::Error> {
7730 let mut field_highlight_str = None;
7731 let mut field_is_highlighted = None;
7732 let mut nothing = true;
7733 while let Some(key) = map.next_key::<&str>()? {
7734 nothing = false;
7735 match key {
7736 "highlight_str" => {
7737 if field_highlight_str.is_some() {
7738 return Err(::serde::de::Error::duplicate_field("highlight_str"));
7739 }
7740 field_highlight_str = Some(map.next_value()?);
7741 }
7742 "is_highlighted" => {
7743 if field_is_highlighted.is_some() {
7744 return Err(::serde::de::Error::duplicate_field("is_highlighted"));
7745 }
7746 field_is_highlighted = Some(map.next_value()?);
7747 }
7748 _ => {
7749 map.next_value::<::serde_json::Value>()?;
7751 }
7752 }
7753 }
7754 if optional && nothing {
7755 return Ok(None);
7756 }
7757 let result = HighlightSpan {
7758 highlight_str: field_highlight_str.ok_or_else(|| ::serde::de::Error::missing_field("highlight_str"))?,
7759 is_highlighted: field_is_highlighted.ok_or_else(|| ::serde::de::Error::missing_field("is_highlighted"))?,
7760 };
7761 Ok(Some(result))
7762 }
7763
7764 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
7765 &self,
7766 s: &mut S::SerializeStruct,
7767 ) -> Result<(), S::Error> {
7768 use serde::ser::SerializeStruct;
7769 s.serialize_field("highlight_str", &self.highlight_str)?;
7770 s.serialize_field("is_highlighted", &self.is_highlighted)?;
7771 Ok(())
7772 }
7773}
7774
7775impl<'de> ::serde::de::Deserialize<'de> for HighlightSpan {
7776 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7777 use serde::de::{MapAccess, Visitor};
7779 struct StructVisitor;
7780 impl<'de> Visitor<'de> for StructVisitor {
7781 type Value = HighlightSpan;
7782 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7783 f.write_str("a HighlightSpan struct")
7784 }
7785 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
7786 HighlightSpan::internal_deserialize(map)
7787 }
7788 }
7789 deserializer.deserialize_struct("HighlightSpan", HIGHLIGHT_SPAN_FIELDS, StructVisitor)
7790 }
7791}
7792
7793impl ::serde::ser::Serialize for HighlightSpan {
7794 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7795 use serde::ser::SerializeStruct;
7797 let mut s = serializer.serialize_struct("HighlightSpan", 2)?;
7798 self.internal_serialize::<S>(&mut s)?;
7799 s.end()
7800 }
7801}
7802
7803#[derive(Debug, Clone, PartialEq, Eq)]
7805#[non_exhaustive] pub enum ImportFormat {
7807 Html,
7809 Markdown,
7811 PlainText,
7813 Other,
7816}
7817
7818impl<'de> ::serde::de::Deserialize<'de> for ImportFormat {
7819 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
7820 use serde::de::{self, MapAccess, Visitor};
7822 struct EnumVisitor;
7823 impl<'de> Visitor<'de> for EnumVisitor {
7824 type Value = ImportFormat;
7825 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
7826 f.write_str("a ImportFormat structure")
7827 }
7828 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
7829 let tag: &str = match map.next_key()? {
7830 Some(".tag") => map.next_value()?,
7831 _ => return Err(de::Error::missing_field(".tag"))
7832 };
7833 let value = match tag {
7834 "html" => ImportFormat::Html,
7835 "markdown" => ImportFormat::Markdown,
7836 "plain_text" => ImportFormat::PlainText,
7837 _ => ImportFormat::Other,
7838 };
7839 crate::eat_json_fields(&mut map)?;
7840 Ok(value)
7841 }
7842 }
7843 const VARIANTS: &[&str] = &["html",
7844 "markdown",
7845 "plain_text",
7846 "other"];
7847 deserializer.deserialize_struct("ImportFormat", VARIANTS, EnumVisitor)
7848 }
7849}
7850
7851impl ::serde::ser::Serialize for ImportFormat {
7852 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
7853 use serde::ser::SerializeStruct;
7855 match self {
7856 ImportFormat::Html => {
7857 let mut s = serializer.serialize_struct("ImportFormat", 1)?;
7859 s.serialize_field(".tag", "html")?;
7860 s.end()
7861 }
7862 ImportFormat::Markdown => {
7863 let mut s = serializer.serialize_struct("ImportFormat", 1)?;
7865 s.serialize_field(".tag", "markdown")?;
7866 s.end()
7867 }
7868 ImportFormat::PlainText => {
7869 let mut s = serializer.serialize_struct("ImportFormat", 1)?;
7871 s.serialize_field(".tag", "plain_text")?;
7872 s.end()
7873 }
7874 ImportFormat::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
7875 }
7876 }
7877}
7878
7879#[derive(Debug, Clone, PartialEq, Eq)]
7880#[non_exhaustive] pub struct ListFolderArg {
7882 pub path: PathROrId,
7884 pub recursive: bool,
7891 #[deprecated]
7894 pub include_media_info: bool,
7895 pub include_deleted: bool,
7898 pub include_has_explicit_shared_members: bool,
7901 pub include_mounted_folders: bool,
7904 pub limit: Option<u32>,
7907 pub shared_link: Option<SharedLink>,
7911 pub include_property_groups: Option<crate::types::file_properties::TemplateFilterBase>,
7914 pub include_non_downloadable_files: bool,
7916}
7917
7918impl ListFolderArg {
7919 pub fn new(path: PathROrId) -> Self {
7920 ListFolderArg {
7921 path,
7922 recursive: false,
7923 #[allow(deprecated)] include_media_info: false,
7924 include_deleted: false,
7925 include_has_explicit_shared_members: false,
7926 include_mounted_folders: true,
7927 limit: None,
7928 shared_link: None,
7929 include_property_groups: None,
7930 include_non_downloadable_files: true,
7931 }
7932 }
7933
7934 pub fn with_recursive(mut self, value: bool) -> Self {
7935 self.recursive = value;
7936 self
7937 }
7938
7939 #[deprecated]
7940 #[allow(deprecated)]
7941 pub fn with_include_media_info(mut self, value: bool) -> Self {
7942 self.include_media_info = value;
7943 self
7944 }
7945
7946 pub fn with_include_deleted(mut self, value: bool) -> Self {
7947 self.include_deleted = value;
7948 self
7949 }
7950
7951 pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
7952 self.include_has_explicit_shared_members = value;
7953 self
7954 }
7955
7956 pub fn with_include_mounted_folders(mut self, value: bool) -> Self {
7957 self.include_mounted_folders = value;
7958 self
7959 }
7960
7961 pub fn with_limit(mut self, value: u32) -> Self {
7962 self.limit = Some(value);
7963 self
7964 }
7965
7966 pub fn with_shared_link(mut self, value: SharedLink) -> Self {
7967 self.shared_link = Some(value);
7968 self
7969 }
7970
7971 pub fn with_include_property_groups(
7972 mut self,
7973 value: crate::types::file_properties::TemplateFilterBase,
7974 ) -> Self {
7975 self.include_property_groups = Some(value);
7976 self
7977 }
7978
7979 pub fn with_include_non_downloadable_files(mut self, value: bool) -> Self {
7980 self.include_non_downloadable_files = value;
7981 self
7982 }
7983}
7984
7985const LIST_FOLDER_ARG_FIELDS: &[&str] = &["path",
7986 "recursive",
7987 "include_media_info",
7988 "include_deleted",
7989 "include_has_explicit_shared_members",
7990 "include_mounted_folders",
7991 "limit",
7992 "shared_link",
7993 "include_property_groups",
7994 "include_non_downloadable_files"];
7995impl ListFolderArg {
7996 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
7997 map: V,
7998 ) -> Result<ListFolderArg, V::Error> {
7999 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8000 }
8001
8002 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8003 mut map: V,
8004 optional: bool,
8005 ) -> Result<Option<ListFolderArg>, V::Error> {
8006 let mut field_path = None;
8007 let mut field_recursive = None;
8008 let mut field_include_media_info = None;
8009 let mut field_include_deleted = None;
8010 let mut field_include_has_explicit_shared_members = None;
8011 let mut field_include_mounted_folders = None;
8012 let mut field_limit = None;
8013 let mut field_shared_link = None;
8014 let mut field_include_property_groups = None;
8015 let mut field_include_non_downloadable_files = None;
8016 let mut nothing = true;
8017 while let Some(key) = map.next_key::<&str>()? {
8018 nothing = false;
8019 match key {
8020 "path" => {
8021 if field_path.is_some() {
8022 return Err(::serde::de::Error::duplicate_field("path"));
8023 }
8024 field_path = Some(map.next_value()?);
8025 }
8026 "recursive" => {
8027 if field_recursive.is_some() {
8028 return Err(::serde::de::Error::duplicate_field("recursive"));
8029 }
8030 field_recursive = Some(map.next_value()?);
8031 }
8032 "include_media_info" => {
8033 if field_include_media_info.is_some() {
8034 return Err(::serde::de::Error::duplicate_field("include_media_info"));
8035 }
8036 field_include_media_info = Some(map.next_value()?);
8037 }
8038 "include_deleted" => {
8039 if field_include_deleted.is_some() {
8040 return Err(::serde::de::Error::duplicate_field("include_deleted"));
8041 }
8042 field_include_deleted = Some(map.next_value()?);
8043 }
8044 "include_has_explicit_shared_members" => {
8045 if field_include_has_explicit_shared_members.is_some() {
8046 return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
8047 }
8048 field_include_has_explicit_shared_members = Some(map.next_value()?);
8049 }
8050 "include_mounted_folders" => {
8051 if field_include_mounted_folders.is_some() {
8052 return Err(::serde::de::Error::duplicate_field("include_mounted_folders"));
8053 }
8054 field_include_mounted_folders = Some(map.next_value()?);
8055 }
8056 "limit" => {
8057 if field_limit.is_some() {
8058 return Err(::serde::de::Error::duplicate_field("limit"));
8059 }
8060 field_limit = Some(map.next_value()?);
8061 }
8062 "shared_link" => {
8063 if field_shared_link.is_some() {
8064 return Err(::serde::de::Error::duplicate_field("shared_link"));
8065 }
8066 field_shared_link = Some(map.next_value()?);
8067 }
8068 "include_property_groups" => {
8069 if field_include_property_groups.is_some() {
8070 return Err(::serde::de::Error::duplicate_field("include_property_groups"));
8071 }
8072 field_include_property_groups = Some(map.next_value()?);
8073 }
8074 "include_non_downloadable_files" => {
8075 if field_include_non_downloadable_files.is_some() {
8076 return Err(::serde::de::Error::duplicate_field("include_non_downloadable_files"));
8077 }
8078 field_include_non_downloadable_files = Some(map.next_value()?);
8079 }
8080 _ => {
8081 map.next_value::<::serde_json::Value>()?;
8083 }
8084 }
8085 }
8086 if optional && nothing {
8087 return Ok(None);
8088 }
8089 let result = ListFolderArg {
8090 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
8091 recursive: field_recursive.unwrap_or(false),
8092 #[allow(deprecated)] include_media_info: field_include_media_info.unwrap_or(false),
8093 include_deleted: field_include_deleted.unwrap_or(false),
8094 include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
8095 include_mounted_folders: field_include_mounted_folders.unwrap_or(true),
8096 limit: field_limit.and_then(Option::flatten),
8097 shared_link: field_shared_link.and_then(Option::flatten),
8098 include_property_groups: field_include_property_groups.and_then(Option::flatten),
8099 include_non_downloadable_files: field_include_non_downloadable_files.unwrap_or(true),
8100 };
8101 Ok(Some(result))
8102 }
8103
8104 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8105 &self,
8106 s: &mut S::SerializeStruct,
8107 ) -> Result<(), S::Error> {
8108 use serde::ser::SerializeStruct;
8109 s.serialize_field("path", &self.path)?;
8110 if self.recursive {
8111 s.serialize_field("recursive", &self.recursive)?;
8112 }
8113 #[allow(deprecated)]
8114 if self.include_media_info {
8115 s.serialize_field("include_media_info", &self.include_media_info)?;
8116 }
8117 if self.include_deleted {
8118 s.serialize_field("include_deleted", &self.include_deleted)?;
8119 }
8120 if self.include_has_explicit_shared_members {
8121 s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
8122 }
8123 if !self.include_mounted_folders {
8124 s.serialize_field("include_mounted_folders", &self.include_mounted_folders)?;
8125 }
8126 if let Some(val) = &self.limit {
8127 s.serialize_field("limit", val)?;
8128 }
8129 if let Some(val) = &self.shared_link {
8130 s.serialize_field("shared_link", val)?;
8131 }
8132 if let Some(val) = &self.include_property_groups {
8133 s.serialize_field("include_property_groups", val)?;
8134 }
8135 if !self.include_non_downloadable_files {
8136 s.serialize_field("include_non_downloadable_files", &self.include_non_downloadable_files)?;
8137 }
8138 Ok(())
8139 }
8140}
8141
8142impl<'de> ::serde::de::Deserialize<'de> for ListFolderArg {
8143 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8144 use serde::de::{MapAccess, Visitor};
8146 struct StructVisitor;
8147 impl<'de> Visitor<'de> for StructVisitor {
8148 type Value = ListFolderArg;
8149 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8150 f.write_str("a ListFolderArg struct")
8151 }
8152 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8153 ListFolderArg::internal_deserialize(map)
8154 }
8155 }
8156 deserializer.deserialize_struct("ListFolderArg", LIST_FOLDER_ARG_FIELDS, StructVisitor)
8157 }
8158}
8159
8160impl ::serde::ser::Serialize for ListFolderArg {
8161 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8162 use serde::ser::SerializeStruct;
8164 let mut s = serializer.serialize_struct("ListFolderArg", 10)?;
8165 self.internal_serialize::<S>(&mut s)?;
8166 s.end()
8167 }
8168}
8169
8170#[derive(Debug, Clone, PartialEq, Eq)]
8171#[non_exhaustive] pub struct ListFolderContinueArg {
8173 pub cursor: ListFolderCursor,
8176}
8177
8178impl ListFolderContinueArg {
8179 pub fn new(cursor: ListFolderCursor) -> Self {
8180 ListFolderContinueArg {
8181 cursor,
8182 }
8183 }
8184}
8185
8186const LIST_FOLDER_CONTINUE_ARG_FIELDS: &[&str] = &["cursor"];
8187impl ListFolderContinueArg {
8188 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8189 map: V,
8190 ) -> Result<ListFolderContinueArg, V::Error> {
8191 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8192 }
8193
8194 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8195 mut map: V,
8196 optional: bool,
8197 ) -> Result<Option<ListFolderContinueArg>, V::Error> {
8198 let mut field_cursor = None;
8199 let mut nothing = true;
8200 while let Some(key) = map.next_key::<&str>()? {
8201 nothing = false;
8202 match key {
8203 "cursor" => {
8204 if field_cursor.is_some() {
8205 return Err(::serde::de::Error::duplicate_field("cursor"));
8206 }
8207 field_cursor = Some(map.next_value()?);
8208 }
8209 _ => {
8210 map.next_value::<::serde_json::Value>()?;
8212 }
8213 }
8214 }
8215 if optional && nothing {
8216 return Ok(None);
8217 }
8218 let result = ListFolderContinueArg {
8219 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8220 };
8221 Ok(Some(result))
8222 }
8223
8224 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8225 &self,
8226 s: &mut S::SerializeStruct,
8227 ) -> Result<(), S::Error> {
8228 use serde::ser::SerializeStruct;
8229 s.serialize_field("cursor", &self.cursor)?;
8230 Ok(())
8231 }
8232}
8233
8234impl<'de> ::serde::de::Deserialize<'de> for ListFolderContinueArg {
8235 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8236 use serde::de::{MapAccess, Visitor};
8238 struct StructVisitor;
8239 impl<'de> Visitor<'de> for StructVisitor {
8240 type Value = ListFolderContinueArg;
8241 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8242 f.write_str("a ListFolderContinueArg struct")
8243 }
8244 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8245 ListFolderContinueArg::internal_deserialize(map)
8246 }
8247 }
8248 deserializer.deserialize_struct("ListFolderContinueArg", LIST_FOLDER_CONTINUE_ARG_FIELDS, StructVisitor)
8249 }
8250}
8251
8252impl ::serde::ser::Serialize for ListFolderContinueArg {
8253 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8254 use serde::ser::SerializeStruct;
8256 let mut s = serializer.serialize_struct("ListFolderContinueArg", 1)?;
8257 self.internal_serialize::<S>(&mut s)?;
8258 s.end()
8259 }
8260}
8261
8262#[derive(Debug, Clone, PartialEq, Eq)]
8263#[non_exhaustive] pub enum ListFolderContinueError {
8265 Path(LookupError),
8266 Reset,
8269 Other,
8272}
8273
8274impl<'de> ::serde::de::Deserialize<'de> for ListFolderContinueError {
8275 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8276 use serde::de::{self, MapAccess, Visitor};
8278 struct EnumVisitor;
8279 impl<'de> Visitor<'de> for EnumVisitor {
8280 type Value = ListFolderContinueError;
8281 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8282 f.write_str("a ListFolderContinueError structure")
8283 }
8284 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
8285 let tag: &str = match map.next_key()? {
8286 Some(".tag") => map.next_value()?,
8287 _ => return Err(de::Error::missing_field(".tag"))
8288 };
8289 let value = match tag {
8290 "path" => {
8291 match map.next_key()? {
8292 Some("path") => ListFolderContinueError::Path(map.next_value()?),
8293 None => return Err(de::Error::missing_field("path")),
8294 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
8295 }
8296 }
8297 "reset" => ListFolderContinueError::Reset,
8298 _ => ListFolderContinueError::Other,
8299 };
8300 crate::eat_json_fields(&mut map)?;
8301 Ok(value)
8302 }
8303 }
8304 const VARIANTS: &[&str] = &["path",
8305 "reset",
8306 "other"];
8307 deserializer.deserialize_struct("ListFolderContinueError", VARIANTS, EnumVisitor)
8308 }
8309}
8310
8311impl ::serde::ser::Serialize for ListFolderContinueError {
8312 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8313 use serde::ser::SerializeStruct;
8315 match self {
8316 ListFolderContinueError::Path(x) => {
8317 let mut s = serializer.serialize_struct("ListFolderContinueError", 2)?;
8319 s.serialize_field(".tag", "path")?;
8320 s.serialize_field("path", x)?;
8321 s.end()
8322 }
8323 ListFolderContinueError::Reset => {
8324 let mut s = serializer.serialize_struct("ListFolderContinueError", 1)?;
8326 s.serialize_field(".tag", "reset")?;
8327 s.end()
8328 }
8329 ListFolderContinueError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
8330 }
8331 }
8332}
8333
8334impl ::std::error::Error for ListFolderContinueError {
8335 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
8336 match self {
8337 ListFolderContinueError::Path(inner) => Some(inner),
8338 _ => None,
8339 }
8340 }
8341}
8342
8343impl ::std::fmt::Display for ListFolderContinueError {
8344 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8345 match self {
8346 ListFolderContinueError::Path(inner) => write!(f, "ListFolderContinueError: {}", inner),
8347 _ => write!(f, "{:?}", *self),
8348 }
8349 }
8350}
8351
8352#[derive(Debug, Clone, PartialEq, Eq)]
8353#[non_exhaustive] pub enum ListFolderError {
8355 Path(LookupError),
8356 TemplateError(crate::types::file_properties::TemplateError),
8357 Other,
8360}
8361
8362impl<'de> ::serde::de::Deserialize<'de> for ListFolderError {
8363 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8364 use serde::de::{self, MapAccess, Visitor};
8366 struct EnumVisitor;
8367 impl<'de> Visitor<'de> for EnumVisitor {
8368 type Value = ListFolderError;
8369 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8370 f.write_str("a ListFolderError structure")
8371 }
8372 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
8373 let tag: &str = match map.next_key()? {
8374 Some(".tag") => map.next_value()?,
8375 _ => return Err(de::Error::missing_field(".tag"))
8376 };
8377 let value = match tag {
8378 "path" => {
8379 match map.next_key()? {
8380 Some("path") => ListFolderError::Path(map.next_value()?),
8381 None => return Err(de::Error::missing_field("path")),
8382 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
8383 }
8384 }
8385 "template_error" => {
8386 match map.next_key()? {
8387 Some("template_error") => ListFolderError::TemplateError(map.next_value()?),
8388 None => return Err(de::Error::missing_field("template_error")),
8389 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
8390 }
8391 }
8392 _ => ListFolderError::Other,
8393 };
8394 crate::eat_json_fields(&mut map)?;
8395 Ok(value)
8396 }
8397 }
8398 const VARIANTS: &[&str] = &["path",
8399 "template_error",
8400 "other"];
8401 deserializer.deserialize_struct("ListFolderError", VARIANTS, EnumVisitor)
8402 }
8403}
8404
8405impl ::serde::ser::Serialize for ListFolderError {
8406 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8407 use serde::ser::SerializeStruct;
8409 match self {
8410 ListFolderError::Path(x) => {
8411 let mut s = serializer.serialize_struct("ListFolderError", 2)?;
8413 s.serialize_field(".tag", "path")?;
8414 s.serialize_field("path", x)?;
8415 s.end()
8416 }
8417 ListFolderError::TemplateError(x) => {
8418 let mut s = serializer.serialize_struct("ListFolderError", 2)?;
8420 s.serialize_field(".tag", "template_error")?;
8421 s.serialize_field("template_error", x)?;
8422 s.end()
8423 }
8424 ListFolderError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
8425 }
8426 }
8427}
8428
8429impl ::std::error::Error for ListFolderError {
8430 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
8431 match self {
8432 ListFolderError::Path(inner) => Some(inner),
8433 ListFolderError::TemplateError(inner) => Some(inner),
8434 _ => None,
8435 }
8436 }
8437}
8438
8439impl ::std::fmt::Display for ListFolderError {
8440 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8441 match self {
8442 ListFolderError::Path(inner) => write!(f, "ListFolderError: {}", inner),
8443 ListFolderError::TemplateError(inner) => write!(f, "ListFolderError: {}", inner),
8444 _ => write!(f, "{:?}", *self),
8445 }
8446 }
8447}
8448
8449#[derive(Debug, Clone, PartialEq, Eq)]
8450#[non_exhaustive] pub struct ListFolderGetLatestCursorResult {
8452 pub cursor: ListFolderCursor,
8455}
8456
8457impl ListFolderGetLatestCursorResult {
8458 pub fn new(cursor: ListFolderCursor) -> Self {
8459 ListFolderGetLatestCursorResult {
8460 cursor,
8461 }
8462 }
8463}
8464
8465const LIST_FOLDER_GET_LATEST_CURSOR_RESULT_FIELDS: &[&str] = &["cursor"];
8466impl ListFolderGetLatestCursorResult {
8467 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8468 map: V,
8469 ) -> Result<ListFolderGetLatestCursorResult, V::Error> {
8470 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8471 }
8472
8473 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8474 mut map: V,
8475 optional: bool,
8476 ) -> Result<Option<ListFolderGetLatestCursorResult>, V::Error> {
8477 let mut field_cursor = None;
8478 let mut nothing = true;
8479 while let Some(key) = map.next_key::<&str>()? {
8480 nothing = false;
8481 match key {
8482 "cursor" => {
8483 if field_cursor.is_some() {
8484 return Err(::serde::de::Error::duplicate_field("cursor"));
8485 }
8486 field_cursor = Some(map.next_value()?);
8487 }
8488 _ => {
8489 map.next_value::<::serde_json::Value>()?;
8491 }
8492 }
8493 }
8494 if optional && nothing {
8495 return Ok(None);
8496 }
8497 let result = ListFolderGetLatestCursorResult {
8498 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8499 };
8500 Ok(Some(result))
8501 }
8502
8503 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8504 &self,
8505 s: &mut S::SerializeStruct,
8506 ) -> Result<(), S::Error> {
8507 use serde::ser::SerializeStruct;
8508 s.serialize_field("cursor", &self.cursor)?;
8509 Ok(())
8510 }
8511}
8512
8513impl<'de> ::serde::de::Deserialize<'de> for ListFolderGetLatestCursorResult {
8514 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8515 use serde::de::{MapAccess, Visitor};
8517 struct StructVisitor;
8518 impl<'de> Visitor<'de> for StructVisitor {
8519 type Value = ListFolderGetLatestCursorResult;
8520 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8521 f.write_str("a ListFolderGetLatestCursorResult struct")
8522 }
8523 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8524 ListFolderGetLatestCursorResult::internal_deserialize(map)
8525 }
8526 }
8527 deserializer.deserialize_struct("ListFolderGetLatestCursorResult", LIST_FOLDER_GET_LATEST_CURSOR_RESULT_FIELDS, StructVisitor)
8528 }
8529}
8530
8531impl ::serde::ser::Serialize for ListFolderGetLatestCursorResult {
8532 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8533 use serde::ser::SerializeStruct;
8535 let mut s = serializer.serialize_struct("ListFolderGetLatestCursorResult", 1)?;
8536 self.internal_serialize::<S>(&mut s)?;
8537 s.end()
8538 }
8539}
8540
8541#[derive(Debug, Clone, PartialEq, Eq)]
8542#[non_exhaustive] pub struct ListFolderLongpollArg {
8544 pub cursor: ListFolderCursor,
8548 pub timeout: u64,
8552}
8553
8554impl ListFolderLongpollArg {
8555 pub fn new(cursor: ListFolderCursor) -> Self {
8556 ListFolderLongpollArg {
8557 cursor,
8558 timeout: 30,
8559 }
8560 }
8561
8562 pub fn with_timeout(mut self, value: u64) -> Self {
8563 self.timeout = value;
8564 self
8565 }
8566}
8567
8568const LIST_FOLDER_LONGPOLL_ARG_FIELDS: &[&str] = &["cursor",
8569 "timeout"];
8570impl ListFolderLongpollArg {
8571 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8572 map: V,
8573 ) -> Result<ListFolderLongpollArg, V::Error> {
8574 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8575 }
8576
8577 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8578 mut map: V,
8579 optional: bool,
8580 ) -> Result<Option<ListFolderLongpollArg>, V::Error> {
8581 let mut field_cursor = None;
8582 let mut field_timeout = None;
8583 let mut nothing = true;
8584 while let Some(key) = map.next_key::<&str>()? {
8585 nothing = false;
8586 match key {
8587 "cursor" => {
8588 if field_cursor.is_some() {
8589 return Err(::serde::de::Error::duplicate_field("cursor"));
8590 }
8591 field_cursor = Some(map.next_value()?);
8592 }
8593 "timeout" => {
8594 if field_timeout.is_some() {
8595 return Err(::serde::de::Error::duplicate_field("timeout"));
8596 }
8597 field_timeout = Some(map.next_value()?);
8598 }
8599 _ => {
8600 map.next_value::<::serde_json::Value>()?;
8602 }
8603 }
8604 }
8605 if optional && nothing {
8606 return Ok(None);
8607 }
8608 let result = ListFolderLongpollArg {
8609 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8610 timeout: field_timeout.unwrap_or(30),
8611 };
8612 Ok(Some(result))
8613 }
8614
8615 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8616 &self,
8617 s: &mut S::SerializeStruct,
8618 ) -> Result<(), S::Error> {
8619 use serde::ser::SerializeStruct;
8620 s.serialize_field("cursor", &self.cursor)?;
8621 if self.timeout != 30 {
8622 s.serialize_field("timeout", &self.timeout)?;
8623 }
8624 Ok(())
8625 }
8626}
8627
8628impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollArg {
8629 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8630 use serde::de::{MapAccess, Visitor};
8632 struct StructVisitor;
8633 impl<'de> Visitor<'de> for StructVisitor {
8634 type Value = ListFolderLongpollArg;
8635 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8636 f.write_str("a ListFolderLongpollArg struct")
8637 }
8638 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8639 ListFolderLongpollArg::internal_deserialize(map)
8640 }
8641 }
8642 deserializer.deserialize_struct("ListFolderLongpollArg", LIST_FOLDER_LONGPOLL_ARG_FIELDS, StructVisitor)
8643 }
8644}
8645
8646impl ::serde::ser::Serialize for ListFolderLongpollArg {
8647 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8648 use serde::ser::SerializeStruct;
8650 let mut s = serializer.serialize_struct("ListFolderLongpollArg", 2)?;
8651 self.internal_serialize::<S>(&mut s)?;
8652 s.end()
8653 }
8654}
8655
8656#[derive(Debug, Clone, PartialEq, Eq)]
8657#[non_exhaustive] pub enum ListFolderLongpollError {
8659 Reset,
8662 Other,
8665}
8666
8667impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollError {
8668 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8669 use serde::de::{self, MapAccess, Visitor};
8671 struct EnumVisitor;
8672 impl<'de> Visitor<'de> for EnumVisitor {
8673 type Value = ListFolderLongpollError;
8674 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8675 f.write_str("a ListFolderLongpollError structure")
8676 }
8677 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
8678 let tag: &str = match map.next_key()? {
8679 Some(".tag") => map.next_value()?,
8680 _ => return Err(de::Error::missing_field(".tag"))
8681 };
8682 let value = match tag {
8683 "reset" => ListFolderLongpollError::Reset,
8684 _ => ListFolderLongpollError::Other,
8685 };
8686 crate::eat_json_fields(&mut map)?;
8687 Ok(value)
8688 }
8689 }
8690 const VARIANTS: &[&str] = &["reset",
8691 "other"];
8692 deserializer.deserialize_struct("ListFolderLongpollError", VARIANTS, EnumVisitor)
8693 }
8694}
8695
8696impl ::serde::ser::Serialize for ListFolderLongpollError {
8697 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8698 use serde::ser::SerializeStruct;
8700 match self {
8701 ListFolderLongpollError::Reset => {
8702 let mut s = serializer.serialize_struct("ListFolderLongpollError", 1)?;
8704 s.serialize_field(".tag", "reset")?;
8705 s.end()
8706 }
8707 ListFolderLongpollError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
8708 }
8709 }
8710}
8711
8712impl ::std::error::Error for ListFolderLongpollError {
8713}
8714
8715impl ::std::fmt::Display for ListFolderLongpollError {
8716 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8717 write!(f, "{:?}", *self)
8718 }
8719}
8720
8721#[derive(Debug, Clone, PartialEq, Eq)]
8722#[non_exhaustive] pub struct ListFolderLongpollResult {
8724 pub changes: bool,
8727 pub backoff: Option<u64>,
8730}
8731
8732impl ListFolderLongpollResult {
8733 pub fn new(changes: bool) -> Self {
8734 ListFolderLongpollResult {
8735 changes,
8736 backoff: None,
8737 }
8738 }
8739
8740 pub fn with_backoff(mut self, value: u64) -> Self {
8741 self.backoff = Some(value);
8742 self
8743 }
8744}
8745
8746const LIST_FOLDER_LONGPOLL_RESULT_FIELDS: &[&str] = &["changes",
8747 "backoff"];
8748impl ListFolderLongpollResult {
8749 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8750 map: V,
8751 ) -> Result<ListFolderLongpollResult, V::Error> {
8752 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8753 }
8754
8755 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8756 mut map: V,
8757 optional: bool,
8758 ) -> Result<Option<ListFolderLongpollResult>, V::Error> {
8759 let mut field_changes = None;
8760 let mut field_backoff = None;
8761 let mut nothing = true;
8762 while let Some(key) = map.next_key::<&str>()? {
8763 nothing = false;
8764 match key {
8765 "changes" => {
8766 if field_changes.is_some() {
8767 return Err(::serde::de::Error::duplicate_field("changes"));
8768 }
8769 field_changes = Some(map.next_value()?);
8770 }
8771 "backoff" => {
8772 if field_backoff.is_some() {
8773 return Err(::serde::de::Error::duplicate_field("backoff"));
8774 }
8775 field_backoff = Some(map.next_value()?);
8776 }
8777 _ => {
8778 map.next_value::<::serde_json::Value>()?;
8780 }
8781 }
8782 }
8783 if optional && nothing {
8784 return Ok(None);
8785 }
8786 let result = ListFolderLongpollResult {
8787 changes: field_changes.ok_or_else(|| ::serde::de::Error::missing_field("changes"))?,
8788 backoff: field_backoff.and_then(Option::flatten),
8789 };
8790 Ok(Some(result))
8791 }
8792
8793 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8794 &self,
8795 s: &mut S::SerializeStruct,
8796 ) -> Result<(), S::Error> {
8797 use serde::ser::SerializeStruct;
8798 s.serialize_field("changes", &self.changes)?;
8799 if let Some(val) = &self.backoff {
8800 s.serialize_field("backoff", val)?;
8801 }
8802 Ok(())
8803 }
8804}
8805
8806impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollResult {
8807 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8808 use serde::de::{MapAccess, Visitor};
8810 struct StructVisitor;
8811 impl<'de> Visitor<'de> for StructVisitor {
8812 type Value = ListFolderLongpollResult;
8813 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8814 f.write_str("a ListFolderLongpollResult struct")
8815 }
8816 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8817 ListFolderLongpollResult::internal_deserialize(map)
8818 }
8819 }
8820 deserializer.deserialize_struct("ListFolderLongpollResult", LIST_FOLDER_LONGPOLL_RESULT_FIELDS, StructVisitor)
8821 }
8822}
8823
8824impl ::serde::ser::Serialize for ListFolderLongpollResult {
8825 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8826 use serde::ser::SerializeStruct;
8828 let mut s = serializer.serialize_struct("ListFolderLongpollResult", 2)?;
8829 self.internal_serialize::<S>(&mut s)?;
8830 s.end()
8831 }
8832}
8833
8834#[derive(Debug, Clone, PartialEq)]
8835#[non_exhaustive] pub struct ListFolderResult {
8837 pub entries: Vec<Metadata>,
8839 pub cursor: ListFolderCursor,
8842 pub has_more: bool,
8845}
8846
8847impl ListFolderResult {
8848 pub fn new(entries: Vec<Metadata>, cursor: ListFolderCursor, has_more: bool) -> Self {
8849 ListFolderResult {
8850 entries,
8851 cursor,
8852 has_more,
8853 }
8854 }
8855}
8856
8857const LIST_FOLDER_RESULT_FIELDS: &[&str] = &["entries",
8858 "cursor",
8859 "has_more"];
8860impl ListFolderResult {
8861 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
8862 map: V,
8863 ) -> Result<ListFolderResult, V::Error> {
8864 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
8865 }
8866
8867 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
8868 mut map: V,
8869 optional: bool,
8870 ) -> Result<Option<ListFolderResult>, V::Error> {
8871 let mut field_entries = None;
8872 let mut field_cursor = None;
8873 let mut field_has_more = None;
8874 let mut nothing = true;
8875 while let Some(key) = map.next_key::<&str>()? {
8876 nothing = false;
8877 match key {
8878 "entries" => {
8879 if field_entries.is_some() {
8880 return Err(::serde::de::Error::duplicate_field("entries"));
8881 }
8882 field_entries = Some(map.next_value()?);
8883 }
8884 "cursor" => {
8885 if field_cursor.is_some() {
8886 return Err(::serde::de::Error::duplicate_field("cursor"));
8887 }
8888 field_cursor = Some(map.next_value()?);
8889 }
8890 "has_more" => {
8891 if field_has_more.is_some() {
8892 return Err(::serde::de::Error::duplicate_field("has_more"));
8893 }
8894 field_has_more = Some(map.next_value()?);
8895 }
8896 _ => {
8897 map.next_value::<::serde_json::Value>()?;
8899 }
8900 }
8901 }
8902 if optional && nothing {
8903 return Ok(None);
8904 }
8905 let result = ListFolderResult {
8906 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
8907 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
8908 has_more: field_has_more.ok_or_else(|| ::serde::de::Error::missing_field("has_more"))?,
8909 };
8910 Ok(Some(result))
8911 }
8912
8913 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
8914 &self,
8915 s: &mut S::SerializeStruct,
8916 ) -> Result<(), S::Error> {
8917 use serde::ser::SerializeStruct;
8918 s.serialize_field("entries", &self.entries)?;
8919 s.serialize_field("cursor", &self.cursor)?;
8920 s.serialize_field("has_more", &self.has_more)?;
8921 Ok(())
8922 }
8923}
8924
8925impl<'de> ::serde::de::Deserialize<'de> for ListFolderResult {
8926 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
8927 use serde::de::{MapAccess, Visitor};
8929 struct StructVisitor;
8930 impl<'de> Visitor<'de> for StructVisitor {
8931 type Value = ListFolderResult;
8932 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
8933 f.write_str("a ListFolderResult struct")
8934 }
8935 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
8936 ListFolderResult::internal_deserialize(map)
8937 }
8938 }
8939 deserializer.deserialize_struct("ListFolderResult", LIST_FOLDER_RESULT_FIELDS, StructVisitor)
8940 }
8941}
8942
8943impl ::serde::ser::Serialize for ListFolderResult {
8944 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
8945 use serde::ser::SerializeStruct;
8947 let mut s = serializer.serialize_struct("ListFolderResult", 3)?;
8948 self.internal_serialize::<S>(&mut s)?;
8949 s.end()
8950 }
8951}
8952
8953#[derive(Debug, Clone, PartialEq, Eq)]
8954#[non_exhaustive] pub struct ListRevisionsArg {
8956 pub path: PathOrId,
8958 pub mode: ListRevisionsMode,
8960 pub limit: u64,
8962 pub before_rev: Option<Rev>,
8966}
8967
8968impl ListRevisionsArg {
8969 pub fn new(path: PathOrId) -> Self {
8970 ListRevisionsArg {
8971 path,
8972 mode: ListRevisionsMode::Path,
8973 limit: 10,
8974 before_rev: None,
8975 }
8976 }
8977
8978 pub fn with_mode(mut self, value: ListRevisionsMode) -> Self {
8979 self.mode = value;
8980 self
8981 }
8982
8983 pub fn with_limit(mut self, value: u64) -> Self {
8984 self.limit = value;
8985 self
8986 }
8987
8988 pub fn with_before_rev(mut self, value: Rev) -> Self {
8989 self.before_rev = Some(value);
8990 self
8991 }
8992}
8993
8994const LIST_REVISIONS_ARG_FIELDS: &[&str] = &["path",
8995 "mode",
8996 "limit",
8997 "before_rev"];
8998impl ListRevisionsArg {
8999 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9000 map: V,
9001 ) -> Result<ListRevisionsArg, V::Error> {
9002 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9003 }
9004
9005 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9006 mut map: V,
9007 optional: bool,
9008 ) -> Result<Option<ListRevisionsArg>, V::Error> {
9009 let mut field_path = None;
9010 let mut field_mode = None;
9011 let mut field_limit = None;
9012 let mut field_before_rev = None;
9013 let mut nothing = true;
9014 while let Some(key) = map.next_key::<&str>()? {
9015 nothing = false;
9016 match key {
9017 "path" => {
9018 if field_path.is_some() {
9019 return Err(::serde::de::Error::duplicate_field("path"));
9020 }
9021 field_path = Some(map.next_value()?);
9022 }
9023 "mode" => {
9024 if field_mode.is_some() {
9025 return Err(::serde::de::Error::duplicate_field("mode"));
9026 }
9027 field_mode = Some(map.next_value()?);
9028 }
9029 "limit" => {
9030 if field_limit.is_some() {
9031 return Err(::serde::de::Error::duplicate_field("limit"));
9032 }
9033 field_limit = Some(map.next_value()?);
9034 }
9035 "before_rev" => {
9036 if field_before_rev.is_some() {
9037 return Err(::serde::de::Error::duplicate_field("before_rev"));
9038 }
9039 field_before_rev = Some(map.next_value()?);
9040 }
9041 _ => {
9042 map.next_value::<::serde_json::Value>()?;
9044 }
9045 }
9046 }
9047 if optional && nothing {
9048 return Ok(None);
9049 }
9050 let result = ListRevisionsArg {
9051 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
9052 mode: field_mode.unwrap_or(ListRevisionsMode::Path),
9053 limit: field_limit.unwrap_or(10),
9054 before_rev: field_before_rev.and_then(Option::flatten),
9055 };
9056 Ok(Some(result))
9057 }
9058
9059 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9060 &self,
9061 s: &mut S::SerializeStruct,
9062 ) -> Result<(), S::Error> {
9063 use serde::ser::SerializeStruct;
9064 s.serialize_field("path", &self.path)?;
9065 if self.mode != ListRevisionsMode::Path {
9066 s.serialize_field("mode", &self.mode)?;
9067 }
9068 if self.limit != 10 {
9069 s.serialize_field("limit", &self.limit)?;
9070 }
9071 if let Some(val) = &self.before_rev {
9072 s.serialize_field("before_rev", val)?;
9073 }
9074 Ok(())
9075 }
9076}
9077
9078impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsArg {
9079 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9080 use serde::de::{MapAccess, Visitor};
9082 struct StructVisitor;
9083 impl<'de> Visitor<'de> for StructVisitor {
9084 type Value = ListRevisionsArg;
9085 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9086 f.write_str("a ListRevisionsArg struct")
9087 }
9088 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9089 ListRevisionsArg::internal_deserialize(map)
9090 }
9091 }
9092 deserializer.deserialize_struct("ListRevisionsArg", LIST_REVISIONS_ARG_FIELDS, StructVisitor)
9093 }
9094}
9095
9096impl ::serde::ser::Serialize for ListRevisionsArg {
9097 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9098 use serde::ser::SerializeStruct;
9100 let mut s = serializer.serialize_struct("ListRevisionsArg", 4)?;
9101 self.internal_serialize::<S>(&mut s)?;
9102 s.end()
9103 }
9104}
9105
9106#[derive(Debug, Clone, PartialEq, Eq)]
9107#[non_exhaustive] pub enum ListRevisionsError {
9109 Path(LookupError),
9110 InvalidBeforeRev,
9112 BeforeRevNotSupported,
9114 Other,
9117}
9118
9119impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsError {
9120 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9121 use serde::de::{self, MapAccess, Visitor};
9123 struct EnumVisitor;
9124 impl<'de> Visitor<'de> for EnumVisitor {
9125 type Value = ListRevisionsError;
9126 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9127 f.write_str("a ListRevisionsError structure")
9128 }
9129 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
9130 let tag: &str = match map.next_key()? {
9131 Some(".tag") => map.next_value()?,
9132 _ => return Err(de::Error::missing_field(".tag"))
9133 };
9134 let value = match tag {
9135 "path" => {
9136 match map.next_key()? {
9137 Some("path") => ListRevisionsError::Path(map.next_value()?),
9138 None => return Err(de::Error::missing_field("path")),
9139 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
9140 }
9141 }
9142 "invalid_before_rev" => ListRevisionsError::InvalidBeforeRev,
9143 "before_rev_not_supported" => ListRevisionsError::BeforeRevNotSupported,
9144 _ => ListRevisionsError::Other,
9145 };
9146 crate::eat_json_fields(&mut map)?;
9147 Ok(value)
9148 }
9149 }
9150 const VARIANTS: &[&str] = &["path",
9151 "invalid_before_rev",
9152 "before_rev_not_supported",
9153 "other"];
9154 deserializer.deserialize_struct("ListRevisionsError", VARIANTS, EnumVisitor)
9155 }
9156}
9157
9158impl ::serde::ser::Serialize for ListRevisionsError {
9159 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9160 use serde::ser::SerializeStruct;
9162 match self {
9163 ListRevisionsError::Path(x) => {
9164 let mut s = serializer.serialize_struct("ListRevisionsError", 2)?;
9166 s.serialize_field(".tag", "path")?;
9167 s.serialize_field("path", x)?;
9168 s.end()
9169 }
9170 ListRevisionsError::InvalidBeforeRev => {
9171 let mut s = serializer.serialize_struct("ListRevisionsError", 1)?;
9173 s.serialize_field(".tag", "invalid_before_rev")?;
9174 s.end()
9175 }
9176 ListRevisionsError::BeforeRevNotSupported => {
9177 let mut s = serializer.serialize_struct("ListRevisionsError", 1)?;
9179 s.serialize_field(".tag", "before_rev_not_supported")?;
9180 s.end()
9181 }
9182 ListRevisionsError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
9183 }
9184 }
9185}
9186
9187impl ::std::error::Error for ListRevisionsError {
9188 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
9189 match self {
9190 ListRevisionsError::Path(inner) => Some(inner),
9191 _ => None,
9192 }
9193 }
9194}
9195
9196impl ::std::fmt::Display for ListRevisionsError {
9197 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9198 match self {
9199 ListRevisionsError::Path(inner) => write!(f, "ListRevisionsError: {}", inner),
9200 ListRevisionsError::InvalidBeforeRev => f.write_str("The revision in before_rev is invalid."),
9201 ListRevisionsError::BeforeRevNotSupported => f.write_str("The before_rev argument is only supported in path mode."),
9202 _ => write!(f, "{:?}", *self),
9203 }
9204 }
9205}
9206
9207#[derive(Debug, Clone, PartialEq, Eq)]
9208#[non_exhaustive] pub enum ListRevisionsMode {
9210 Path,
9213 Id,
9216 Other,
9219}
9220
9221impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsMode {
9222 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9223 use serde::de::{self, MapAccess, Visitor};
9225 struct EnumVisitor;
9226 impl<'de> Visitor<'de> for EnumVisitor {
9227 type Value = ListRevisionsMode;
9228 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9229 f.write_str("a ListRevisionsMode structure")
9230 }
9231 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
9232 let tag: &str = match map.next_key()? {
9233 Some(".tag") => map.next_value()?,
9234 _ => return Err(de::Error::missing_field(".tag"))
9235 };
9236 let value = match tag {
9237 "path" => ListRevisionsMode::Path,
9238 "id" => ListRevisionsMode::Id,
9239 _ => ListRevisionsMode::Other,
9240 };
9241 crate::eat_json_fields(&mut map)?;
9242 Ok(value)
9243 }
9244 }
9245 const VARIANTS: &[&str] = &["path",
9246 "id",
9247 "other"];
9248 deserializer.deserialize_struct("ListRevisionsMode", VARIANTS, EnumVisitor)
9249 }
9250}
9251
9252impl ::serde::ser::Serialize for ListRevisionsMode {
9253 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9254 use serde::ser::SerializeStruct;
9256 match self {
9257 ListRevisionsMode::Path => {
9258 let mut s = serializer.serialize_struct("ListRevisionsMode", 1)?;
9260 s.serialize_field(".tag", "path")?;
9261 s.end()
9262 }
9263 ListRevisionsMode::Id => {
9264 let mut s = serializer.serialize_struct("ListRevisionsMode", 1)?;
9266 s.serialize_field(".tag", "id")?;
9267 s.end()
9268 }
9269 ListRevisionsMode::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
9270 }
9271 }
9272}
9273
9274#[derive(Debug, Clone, PartialEq)]
9275#[non_exhaustive] pub struct ListRevisionsResult {
9277 pub is_deleted: bool,
9280 pub entries: Vec<FileMetadata>,
9282 pub has_more: bool,
9285 pub server_deleted: Option<crate::types::common::DropboxTimestamp>,
9287}
9288
9289impl ListRevisionsResult {
9290 pub fn new(is_deleted: bool, entries: Vec<FileMetadata>, has_more: bool) -> Self {
9291 ListRevisionsResult {
9292 is_deleted,
9293 entries,
9294 has_more,
9295 server_deleted: None,
9296 }
9297 }
9298
9299 pub fn with_server_deleted(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
9300 self.server_deleted = Some(value);
9301 self
9302 }
9303}
9304
9305const LIST_REVISIONS_RESULT_FIELDS: &[&str] = &["is_deleted",
9306 "entries",
9307 "has_more",
9308 "server_deleted"];
9309impl ListRevisionsResult {
9310 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9311 map: V,
9312 ) -> Result<ListRevisionsResult, V::Error> {
9313 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9314 }
9315
9316 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9317 mut map: V,
9318 optional: bool,
9319 ) -> Result<Option<ListRevisionsResult>, V::Error> {
9320 let mut field_is_deleted = None;
9321 let mut field_entries = None;
9322 let mut field_has_more = None;
9323 let mut field_server_deleted = None;
9324 let mut nothing = true;
9325 while let Some(key) = map.next_key::<&str>()? {
9326 nothing = false;
9327 match key {
9328 "is_deleted" => {
9329 if field_is_deleted.is_some() {
9330 return Err(::serde::de::Error::duplicate_field("is_deleted"));
9331 }
9332 field_is_deleted = Some(map.next_value()?);
9333 }
9334 "entries" => {
9335 if field_entries.is_some() {
9336 return Err(::serde::de::Error::duplicate_field("entries"));
9337 }
9338 field_entries = Some(map.next_value()?);
9339 }
9340 "has_more" => {
9341 if field_has_more.is_some() {
9342 return Err(::serde::de::Error::duplicate_field("has_more"));
9343 }
9344 field_has_more = Some(map.next_value()?);
9345 }
9346 "server_deleted" => {
9347 if field_server_deleted.is_some() {
9348 return Err(::serde::de::Error::duplicate_field("server_deleted"));
9349 }
9350 field_server_deleted = Some(map.next_value()?);
9351 }
9352 _ => {
9353 map.next_value::<::serde_json::Value>()?;
9355 }
9356 }
9357 }
9358 if optional && nothing {
9359 return Ok(None);
9360 }
9361 let result = ListRevisionsResult {
9362 is_deleted: field_is_deleted.ok_or_else(|| ::serde::de::Error::missing_field("is_deleted"))?,
9363 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
9364 has_more: field_has_more.ok_or_else(|| ::serde::de::Error::missing_field("has_more"))?,
9365 server_deleted: field_server_deleted.and_then(Option::flatten),
9366 };
9367 Ok(Some(result))
9368 }
9369
9370 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9371 &self,
9372 s: &mut S::SerializeStruct,
9373 ) -> Result<(), S::Error> {
9374 use serde::ser::SerializeStruct;
9375 s.serialize_field("is_deleted", &self.is_deleted)?;
9376 s.serialize_field("entries", &self.entries)?;
9377 s.serialize_field("has_more", &self.has_more)?;
9378 if let Some(val) = &self.server_deleted {
9379 s.serialize_field("server_deleted", val)?;
9380 }
9381 Ok(())
9382 }
9383}
9384
9385impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsResult {
9386 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9387 use serde::de::{MapAccess, Visitor};
9389 struct StructVisitor;
9390 impl<'de> Visitor<'de> for StructVisitor {
9391 type Value = ListRevisionsResult;
9392 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9393 f.write_str("a ListRevisionsResult struct")
9394 }
9395 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9396 ListRevisionsResult::internal_deserialize(map)
9397 }
9398 }
9399 deserializer.deserialize_struct("ListRevisionsResult", LIST_REVISIONS_RESULT_FIELDS, StructVisitor)
9400 }
9401}
9402
9403impl ::serde::ser::Serialize for ListRevisionsResult {
9404 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9405 use serde::ser::SerializeStruct;
9407 let mut s = serializer.serialize_struct("ListRevisionsResult", 4)?;
9408 self.internal_serialize::<S>(&mut s)?;
9409 s.end()
9410 }
9411}
9412
9413#[derive(Debug, Clone, PartialEq, Eq)]
9414#[non_exhaustive] pub struct LockConflictError {
9416 pub lock: FileLock,
9418}
9419
9420impl LockConflictError {
9421 pub fn new(lock: FileLock) -> Self {
9422 LockConflictError {
9423 lock,
9424 }
9425 }
9426}
9427
9428const LOCK_CONFLICT_ERROR_FIELDS: &[&str] = &["lock"];
9429impl LockConflictError {
9430 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9431 map: V,
9432 ) -> Result<LockConflictError, V::Error> {
9433 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9434 }
9435
9436 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9437 mut map: V,
9438 optional: bool,
9439 ) -> Result<Option<LockConflictError>, V::Error> {
9440 let mut field_lock = None;
9441 let mut nothing = true;
9442 while let Some(key) = map.next_key::<&str>()? {
9443 nothing = false;
9444 match key {
9445 "lock" => {
9446 if field_lock.is_some() {
9447 return Err(::serde::de::Error::duplicate_field("lock"));
9448 }
9449 field_lock = Some(map.next_value()?);
9450 }
9451 _ => {
9452 map.next_value::<::serde_json::Value>()?;
9454 }
9455 }
9456 }
9457 if optional && nothing {
9458 return Ok(None);
9459 }
9460 let result = LockConflictError {
9461 lock: field_lock.ok_or_else(|| ::serde::de::Error::missing_field("lock"))?,
9462 };
9463 Ok(Some(result))
9464 }
9465
9466 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9467 &self,
9468 s: &mut S::SerializeStruct,
9469 ) -> Result<(), S::Error> {
9470 use serde::ser::SerializeStruct;
9471 s.serialize_field("lock", &self.lock)?;
9472 Ok(())
9473 }
9474}
9475
9476impl<'de> ::serde::de::Deserialize<'de> for LockConflictError {
9477 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9478 use serde::de::{MapAccess, Visitor};
9480 struct StructVisitor;
9481 impl<'de> Visitor<'de> for StructVisitor {
9482 type Value = LockConflictError;
9483 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9484 f.write_str("a LockConflictError struct")
9485 }
9486 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9487 LockConflictError::internal_deserialize(map)
9488 }
9489 }
9490 deserializer.deserialize_struct("LockConflictError", LOCK_CONFLICT_ERROR_FIELDS, StructVisitor)
9491 }
9492}
9493
9494impl ::serde::ser::Serialize for LockConflictError {
9495 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9496 use serde::ser::SerializeStruct;
9498 let mut s = serializer.serialize_struct("LockConflictError", 1)?;
9499 self.internal_serialize::<S>(&mut s)?;
9500 s.end()
9501 }
9502}
9503
9504#[derive(Debug, Clone, PartialEq, Eq)]
9505#[non_exhaustive] pub struct LockFileArg {
9507 pub path: WritePathOrId,
9509}
9510
9511impl LockFileArg {
9512 pub fn new(path: WritePathOrId) -> Self {
9513 LockFileArg {
9514 path,
9515 }
9516 }
9517}
9518
9519const LOCK_FILE_ARG_FIELDS: &[&str] = &["path"];
9520impl LockFileArg {
9521 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9522 map: V,
9523 ) -> Result<LockFileArg, V::Error> {
9524 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9525 }
9526
9527 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9528 mut map: V,
9529 optional: bool,
9530 ) -> Result<Option<LockFileArg>, V::Error> {
9531 let mut field_path = None;
9532 let mut nothing = true;
9533 while let Some(key) = map.next_key::<&str>()? {
9534 nothing = false;
9535 match key {
9536 "path" => {
9537 if field_path.is_some() {
9538 return Err(::serde::de::Error::duplicate_field("path"));
9539 }
9540 field_path = Some(map.next_value()?);
9541 }
9542 _ => {
9543 map.next_value::<::serde_json::Value>()?;
9545 }
9546 }
9547 }
9548 if optional && nothing {
9549 return Ok(None);
9550 }
9551 let result = LockFileArg {
9552 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
9553 };
9554 Ok(Some(result))
9555 }
9556
9557 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9558 &self,
9559 s: &mut S::SerializeStruct,
9560 ) -> Result<(), S::Error> {
9561 use serde::ser::SerializeStruct;
9562 s.serialize_field("path", &self.path)?;
9563 Ok(())
9564 }
9565}
9566
9567impl<'de> ::serde::de::Deserialize<'de> for LockFileArg {
9568 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9569 use serde::de::{MapAccess, Visitor};
9571 struct StructVisitor;
9572 impl<'de> Visitor<'de> for StructVisitor {
9573 type Value = LockFileArg;
9574 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9575 f.write_str("a LockFileArg struct")
9576 }
9577 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9578 LockFileArg::internal_deserialize(map)
9579 }
9580 }
9581 deserializer.deserialize_struct("LockFileArg", LOCK_FILE_ARG_FIELDS, StructVisitor)
9582 }
9583}
9584
9585impl ::serde::ser::Serialize for LockFileArg {
9586 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9587 use serde::ser::SerializeStruct;
9589 let mut s = serializer.serialize_struct("LockFileArg", 1)?;
9590 self.internal_serialize::<S>(&mut s)?;
9591 s.end()
9592 }
9593}
9594
9595#[derive(Debug, Clone, PartialEq, Eq)]
9596#[non_exhaustive] pub struct LockFileBatchArg {
9598 pub entries: Vec<LockFileArg>,
9601}
9602
9603impl LockFileBatchArg {
9604 pub fn new(entries: Vec<LockFileArg>) -> Self {
9605 LockFileBatchArg {
9606 entries,
9607 }
9608 }
9609}
9610
9611const LOCK_FILE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
9612impl LockFileBatchArg {
9613 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9614 map: V,
9615 ) -> Result<LockFileBatchArg, V::Error> {
9616 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9617 }
9618
9619 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9620 mut map: V,
9621 optional: bool,
9622 ) -> Result<Option<LockFileBatchArg>, V::Error> {
9623 let mut field_entries = None;
9624 let mut nothing = true;
9625 while let Some(key) = map.next_key::<&str>()? {
9626 nothing = false;
9627 match key {
9628 "entries" => {
9629 if field_entries.is_some() {
9630 return Err(::serde::de::Error::duplicate_field("entries"));
9631 }
9632 field_entries = Some(map.next_value()?);
9633 }
9634 _ => {
9635 map.next_value::<::serde_json::Value>()?;
9637 }
9638 }
9639 }
9640 if optional && nothing {
9641 return Ok(None);
9642 }
9643 let result = LockFileBatchArg {
9644 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
9645 };
9646 Ok(Some(result))
9647 }
9648
9649 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9650 &self,
9651 s: &mut S::SerializeStruct,
9652 ) -> Result<(), S::Error> {
9653 use serde::ser::SerializeStruct;
9654 s.serialize_field("entries", &self.entries)?;
9655 Ok(())
9656 }
9657}
9658
9659impl<'de> ::serde::de::Deserialize<'de> for LockFileBatchArg {
9660 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9661 use serde::de::{MapAccess, Visitor};
9663 struct StructVisitor;
9664 impl<'de> Visitor<'de> for StructVisitor {
9665 type Value = LockFileBatchArg;
9666 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9667 f.write_str("a LockFileBatchArg struct")
9668 }
9669 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9670 LockFileBatchArg::internal_deserialize(map)
9671 }
9672 }
9673 deserializer.deserialize_struct("LockFileBatchArg", LOCK_FILE_BATCH_ARG_FIELDS, StructVisitor)
9674 }
9675}
9676
9677impl ::serde::ser::Serialize for LockFileBatchArg {
9678 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9679 use serde::ser::SerializeStruct;
9681 let mut s = serializer.serialize_struct("LockFileBatchArg", 1)?;
9682 self.internal_serialize::<S>(&mut s)?;
9683 s.end()
9684 }
9685}
9686
9687#[derive(Debug, Clone, PartialEq)]
9688#[non_exhaustive] pub struct LockFileBatchResult {
9690 pub entries: Vec<LockFileResultEntry>,
9693}
9694
9695impl LockFileBatchResult {
9696 pub fn new(entries: Vec<LockFileResultEntry>) -> Self {
9697 LockFileBatchResult {
9698 entries,
9699 }
9700 }
9701}
9702
9703const LOCK_FILE_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
9704impl LockFileBatchResult {
9705 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9706 map: V,
9707 ) -> Result<LockFileBatchResult, V::Error> {
9708 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9709 }
9710
9711 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9712 mut map: V,
9713 optional: bool,
9714 ) -> Result<Option<LockFileBatchResult>, V::Error> {
9715 let mut field_entries = None;
9716 let mut nothing = true;
9717 while let Some(key) = map.next_key::<&str>()? {
9718 nothing = false;
9719 match key {
9720 "entries" => {
9721 if field_entries.is_some() {
9722 return Err(::serde::de::Error::duplicate_field("entries"));
9723 }
9724 field_entries = Some(map.next_value()?);
9725 }
9726 _ => {
9727 map.next_value::<::serde_json::Value>()?;
9729 }
9730 }
9731 }
9732 if optional && nothing {
9733 return Ok(None);
9734 }
9735 let result = LockFileBatchResult {
9736 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
9737 };
9738 Ok(Some(result))
9739 }
9740
9741 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
9742 &self,
9743 s: &mut S::SerializeStruct,
9744 ) -> Result<(), S::Error> {
9745 use serde::ser::SerializeStruct;
9746 s.serialize_field("entries", &self.entries)?;
9747 Ok(())
9748 }
9749}
9750
9751impl<'de> ::serde::de::Deserialize<'de> for LockFileBatchResult {
9752 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9753 use serde::de::{MapAccess, Visitor};
9755 struct StructVisitor;
9756 impl<'de> Visitor<'de> for StructVisitor {
9757 type Value = LockFileBatchResult;
9758 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9759 f.write_str("a LockFileBatchResult struct")
9760 }
9761 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
9762 LockFileBatchResult::internal_deserialize(map)
9763 }
9764 }
9765 deserializer.deserialize_struct("LockFileBatchResult", LOCK_FILE_BATCH_RESULT_FIELDS, StructVisitor)
9766 }
9767}
9768
9769impl ::serde::ser::Serialize for LockFileBatchResult {
9770 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9771 use serde::ser::SerializeStruct;
9773 let mut s = serializer.serialize_struct("LockFileBatchResult", 1)?;
9774 self.internal_serialize::<S>(&mut s)?;
9775 s.end()
9776 }
9777}
9778
9779impl From<LockFileBatchResult> for FileOpsResult {
9781 fn from(_: LockFileBatchResult) -> Self {
9782 Self {}
9783 }
9784}
9785#[derive(Debug, Clone, PartialEq, Eq)]
9786#[non_exhaustive] pub enum LockFileError {
9788 PathLookup(LookupError),
9790 TooManyWriteOperations,
9792 TooManyFiles,
9794 NoWritePermission,
9796 CannotBeLocked,
9798 FileNotShared,
9800 LockConflict(LockConflictError),
9802 InternalError,
9805 Other,
9808}
9809
9810impl<'de> ::serde::de::Deserialize<'de> for LockFileError {
9811 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
9812 use serde::de::{self, MapAccess, Visitor};
9814 struct EnumVisitor;
9815 impl<'de> Visitor<'de> for EnumVisitor {
9816 type Value = LockFileError;
9817 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9818 f.write_str("a LockFileError structure")
9819 }
9820 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
9821 let tag: &str = match map.next_key()? {
9822 Some(".tag") => map.next_value()?,
9823 _ => return Err(de::Error::missing_field(".tag"))
9824 };
9825 let value = match tag {
9826 "path_lookup" => {
9827 match map.next_key()? {
9828 Some("path_lookup") => LockFileError::PathLookup(map.next_value()?),
9829 None => return Err(de::Error::missing_field("path_lookup")),
9830 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
9831 }
9832 }
9833 "too_many_write_operations" => LockFileError::TooManyWriteOperations,
9834 "too_many_files" => LockFileError::TooManyFiles,
9835 "no_write_permission" => LockFileError::NoWritePermission,
9836 "cannot_be_locked" => LockFileError::CannotBeLocked,
9837 "file_not_shared" => LockFileError::FileNotShared,
9838 "lock_conflict" => LockFileError::LockConflict(LockConflictError::internal_deserialize(&mut map)?),
9839 "internal_error" => LockFileError::InternalError,
9840 _ => LockFileError::Other,
9841 };
9842 crate::eat_json_fields(&mut map)?;
9843 Ok(value)
9844 }
9845 }
9846 const VARIANTS: &[&str] = &["path_lookup",
9847 "too_many_write_operations",
9848 "too_many_files",
9849 "no_write_permission",
9850 "cannot_be_locked",
9851 "file_not_shared",
9852 "lock_conflict",
9853 "internal_error",
9854 "other"];
9855 deserializer.deserialize_struct("LockFileError", VARIANTS, EnumVisitor)
9856 }
9857}
9858
9859impl ::serde::ser::Serialize for LockFileError {
9860 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
9861 use serde::ser::SerializeStruct;
9863 match self {
9864 LockFileError::PathLookup(x) => {
9865 let mut s = serializer.serialize_struct("LockFileError", 2)?;
9867 s.serialize_field(".tag", "path_lookup")?;
9868 s.serialize_field("path_lookup", x)?;
9869 s.end()
9870 }
9871 LockFileError::TooManyWriteOperations => {
9872 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9874 s.serialize_field(".tag", "too_many_write_operations")?;
9875 s.end()
9876 }
9877 LockFileError::TooManyFiles => {
9878 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9880 s.serialize_field(".tag", "too_many_files")?;
9881 s.end()
9882 }
9883 LockFileError::NoWritePermission => {
9884 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9886 s.serialize_field(".tag", "no_write_permission")?;
9887 s.end()
9888 }
9889 LockFileError::CannotBeLocked => {
9890 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9892 s.serialize_field(".tag", "cannot_be_locked")?;
9893 s.end()
9894 }
9895 LockFileError::FileNotShared => {
9896 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9898 s.serialize_field(".tag", "file_not_shared")?;
9899 s.end()
9900 }
9901 LockFileError::LockConflict(x) => {
9902 let mut s = serializer.serialize_struct("LockFileError", 2)?;
9904 s.serialize_field(".tag", "lock_conflict")?;
9905 x.internal_serialize::<S>(&mut s)?;
9906 s.end()
9907 }
9908 LockFileError::InternalError => {
9909 let mut s = serializer.serialize_struct("LockFileError", 1)?;
9911 s.serialize_field(".tag", "internal_error")?;
9912 s.end()
9913 }
9914 LockFileError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
9915 }
9916 }
9917}
9918
9919impl ::std::error::Error for LockFileError {
9920 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
9921 match self {
9922 LockFileError::PathLookup(inner) => Some(inner),
9923 _ => None,
9924 }
9925 }
9926}
9927
9928impl ::std::fmt::Display for LockFileError {
9929 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
9930 match self {
9931 LockFileError::PathLookup(inner) => write!(f, "Could not find the specified resource: {}", inner),
9932 LockFileError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
9933 LockFileError::TooManyFiles => f.write_str("There are too many files in one request. Please retry with fewer files."),
9934 LockFileError::NoWritePermission => f.write_str("The user does not have permissions to change the lock state or access the file."),
9935 LockFileError::CannotBeLocked => f.write_str("Item is a type that cannot be locked."),
9936 LockFileError::FileNotShared => f.write_str("Requested file is not currently shared."),
9937 LockFileError::LockConflict(inner) => write!(f, "The user action conflicts with an existing lock on the file: {:?}", inner),
9938 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."),
9939 _ => write!(f, "{:?}", *self),
9940 }
9941 }
9942}
9943
9944#[derive(Debug, Clone, PartialEq)]
9945#[non_exhaustive] pub struct LockFileResult {
9947 pub metadata: Metadata,
9949 #[deprecated]
9951 pub lock: FileLock,
9952}
9953
9954impl LockFileResult {
9955 pub fn new(metadata: Metadata, lock: FileLock) -> Self {
9956 LockFileResult {
9957 metadata,
9958 #[allow(deprecated)] lock,
9959 }
9960 }
9961}
9962
9963const LOCK_FILE_RESULT_FIELDS: &[&str] = &["metadata",
9964 "lock"];
9965impl LockFileResult {
9966 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
9967 map: V,
9968 ) -> Result<LockFileResult, V::Error> {
9969 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
9970 }
9971
9972 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
9973 mut map: V,
9974 optional: bool,
9975 ) -> Result<Option<LockFileResult>, V::Error> {
9976 let mut field_metadata = None;
9977 let mut field_lock = None;
9978 let mut nothing = true;
9979 while let Some(key) = map.next_key::<&str>()? {
9980 nothing = false;
9981 match key {
9982 "metadata" => {
9983 if field_metadata.is_some() {
9984 return Err(::serde::de::Error::duplicate_field("metadata"));
9985 }
9986 field_metadata = Some(map.next_value()?);
9987 }
9988 "lock" => {
9989 if field_lock.is_some() {
9990 return Err(::serde::de::Error::duplicate_field("lock"));
9991 }
9992 field_lock = Some(map.next_value()?);
9993 }
9994 _ => {
9995 map.next_value::<::serde_json::Value>()?;
9997 }
9998 }
9999 }
10000 if optional && nothing {
10001 return Ok(None);
10002 }
10003 let result = LockFileResult {
10004 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
10005 #[allow(deprecated)] lock: field_lock.ok_or_else(|| ::serde::de::Error::missing_field("lock"))?,
10006 };
10007 Ok(Some(result))
10008 }
10009
10010 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
10011 &self,
10012 s: &mut S::SerializeStruct,
10013 ) -> Result<(), S::Error> {
10014 use serde::ser::SerializeStruct;
10015 s.serialize_field("metadata", &self.metadata)?;
10016 #[allow(deprecated)]
10017 s.serialize_field("lock", &self.lock)?;
10018 Ok(())
10019 }
10020}
10021
10022impl<'de> ::serde::de::Deserialize<'de> for LockFileResult {
10023 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10024 use serde::de::{MapAccess, Visitor};
10026 struct StructVisitor;
10027 impl<'de> Visitor<'de> for StructVisitor {
10028 type Value = LockFileResult;
10029 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10030 f.write_str("a LockFileResult struct")
10031 }
10032 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
10033 LockFileResult::internal_deserialize(map)
10034 }
10035 }
10036 deserializer.deserialize_struct("LockFileResult", LOCK_FILE_RESULT_FIELDS, StructVisitor)
10037 }
10038}
10039
10040impl ::serde::ser::Serialize for LockFileResult {
10041 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10042 use serde::ser::SerializeStruct;
10044 let mut s = serializer.serialize_struct("LockFileResult", 2)?;
10045 self.internal_serialize::<S>(&mut s)?;
10046 s.end()
10047 }
10048}
10049
10050#[derive(Debug, Clone, PartialEq)]
10051pub enum LockFileResultEntry {
10052 Success(LockFileResult),
10053 Failure(LockFileError),
10054}
10055
10056impl<'de> ::serde::de::Deserialize<'de> for LockFileResultEntry {
10057 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10058 use serde::de::{self, MapAccess, Visitor};
10060 struct EnumVisitor;
10061 impl<'de> Visitor<'de> for EnumVisitor {
10062 type Value = LockFileResultEntry;
10063 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10064 f.write_str("a LockFileResultEntry structure")
10065 }
10066 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10067 let tag: &str = match map.next_key()? {
10068 Some(".tag") => map.next_value()?,
10069 _ => return Err(de::Error::missing_field(".tag"))
10070 };
10071 let value = match tag {
10072 "success" => LockFileResultEntry::Success(LockFileResult::internal_deserialize(&mut map)?),
10073 "failure" => {
10074 match map.next_key()? {
10075 Some("failure") => LockFileResultEntry::Failure(map.next_value()?),
10076 None => return Err(de::Error::missing_field("failure")),
10077 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10078 }
10079 }
10080 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
10081 };
10082 crate::eat_json_fields(&mut map)?;
10083 Ok(value)
10084 }
10085 }
10086 const VARIANTS: &[&str] = &["success",
10087 "failure"];
10088 deserializer.deserialize_struct("LockFileResultEntry", VARIANTS, EnumVisitor)
10089 }
10090}
10091
10092impl ::serde::ser::Serialize for LockFileResultEntry {
10093 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10094 use serde::ser::SerializeStruct;
10096 match self {
10097 LockFileResultEntry::Success(x) => {
10098 let mut s = serializer.serialize_struct("LockFileResultEntry", 3)?;
10100 s.serialize_field(".tag", "success")?;
10101 x.internal_serialize::<S>(&mut s)?;
10102 s.end()
10103 }
10104 LockFileResultEntry::Failure(x) => {
10105 let mut s = serializer.serialize_struct("LockFileResultEntry", 2)?;
10107 s.serialize_field(".tag", "failure")?;
10108 s.serialize_field("failure", x)?;
10109 s.end()
10110 }
10111 }
10112 }
10113}
10114
10115#[derive(Debug, Clone, PartialEq, Eq)]
10116#[non_exhaustive] pub enum LookupError {
10118 MalformedPath(MalformedPathError),
10122 NotFound,
10124 NotFile,
10126 NotFolder,
10128 RestrictedContent,
10131 UnsupportedContentType,
10133 Locked,
10135 Other,
10138}
10139
10140impl<'de> ::serde::de::Deserialize<'de> for LookupError {
10141 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10142 use serde::de::{self, MapAccess, Visitor};
10144 struct EnumVisitor;
10145 impl<'de> Visitor<'de> for EnumVisitor {
10146 type Value = LookupError;
10147 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10148 f.write_str("a LookupError structure")
10149 }
10150 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10151 let tag: &str = match map.next_key()? {
10152 Some(".tag") => map.next_value()?,
10153 _ => return Err(de::Error::missing_field(".tag"))
10154 };
10155 let value = match tag {
10156 "malformed_path" => {
10157 match map.next_key()? {
10158 Some("malformed_path") => LookupError::MalformedPath(map.next_value()?),
10159 None => LookupError::MalformedPath(None),
10160 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10161 }
10162 }
10163 "not_found" => LookupError::NotFound,
10164 "not_file" => LookupError::NotFile,
10165 "not_folder" => LookupError::NotFolder,
10166 "restricted_content" => LookupError::RestrictedContent,
10167 "unsupported_content_type" => LookupError::UnsupportedContentType,
10168 "locked" => LookupError::Locked,
10169 _ => LookupError::Other,
10170 };
10171 crate::eat_json_fields(&mut map)?;
10172 Ok(value)
10173 }
10174 }
10175 const VARIANTS: &[&str] = &["malformed_path",
10176 "not_found",
10177 "not_file",
10178 "not_folder",
10179 "restricted_content",
10180 "unsupported_content_type",
10181 "locked",
10182 "other"];
10183 deserializer.deserialize_struct("LookupError", VARIANTS, EnumVisitor)
10184 }
10185}
10186
10187impl ::serde::ser::Serialize for LookupError {
10188 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10189 use serde::ser::SerializeStruct;
10191 match self {
10192 LookupError::MalformedPath(x) => {
10193 let n = if x.is_some() { 2 } else { 1 };
10195 let mut s = serializer.serialize_struct("LookupError", n)?;
10196 s.serialize_field(".tag", "malformed_path")?;
10197 if let Some(x) = x {
10198 s.serialize_field("malformed_path", &x)?;
10199 }
10200 s.end()
10201 }
10202 LookupError::NotFound => {
10203 let mut s = serializer.serialize_struct("LookupError", 1)?;
10205 s.serialize_field(".tag", "not_found")?;
10206 s.end()
10207 }
10208 LookupError::NotFile => {
10209 let mut s = serializer.serialize_struct("LookupError", 1)?;
10211 s.serialize_field(".tag", "not_file")?;
10212 s.end()
10213 }
10214 LookupError::NotFolder => {
10215 let mut s = serializer.serialize_struct("LookupError", 1)?;
10217 s.serialize_field(".tag", "not_folder")?;
10218 s.end()
10219 }
10220 LookupError::RestrictedContent => {
10221 let mut s = serializer.serialize_struct("LookupError", 1)?;
10223 s.serialize_field(".tag", "restricted_content")?;
10224 s.end()
10225 }
10226 LookupError::UnsupportedContentType => {
10227 let mut s = serializer.serialize_struct("LookupError", 1)?;
10229 s.serialize_field(".tag", "unsupported_content_type")?;
10230 s.end()
10231 }
10232 LookupError::Locked => {
10233 let mut s = serializer.serialize_struct("LookupError", 1)?;
10235 s.serialize_field(".tag", "locked")?;
10236 s.end()
10237 }
10238 LookupError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10239 }
10240 }
10241}
10242
10243impl ::std::error::Error for LookupError {
10244}
10245
10246impl ::std::fmt::Display for LookupError {
10247 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10248 match self {
10249 LookupError::MalformedPath(inner) => write!(f, "malformed_path: {:?}", inner),
10250 LookupError::NotFound => f.write_str("There is nothing at the given path."),
10251 LookupError::NotFile => f.write_str("We were expecting a file, but the given path refers to something that isn't a file."),
10252 LookupError::NotFolder => f.write_str("We were expecting a folder, but the given path refers to something that isn't a folder."),
10253 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."),
10254 LookupError::UnsupportedContentType => f.write_str("This operation is not supported for this content type."),
10255 LookupError::Locked => f.write_str("The given path is locked."),
10256 _ => write!(f, "{:?}", *self),
10257 }
10258 }
10259}
10260
10261#[derive(Debug, Clone, PartialEq)]
10262pub enum MediaInfo {
10263 Pending,
10265 Metadata(MediaMetadata),
10268}
10269
10270impl<'de> ::serde::de::Deserialize<'de> for MediaInfo {
10271 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10272 use serde::de::{self, MapAccess, Visitor};
10274 struct EnumVisitor;
10275 impl<'de> Visitor<'de> for EnumVisitor {
10276 type Value = MediaInfo;
10277 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10278 f.write_str("a MediaInfo structure")
10279 }
10280 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10281 let tag: &str = match map.next_key()? {
10282 Some(".tag") => map.next_value()?,
10283 _ => return Err(de::Error::missing_field(".tag"))
10284 };
10285 let value = match tag {
10286 "pending" => MediaInfo::Pending,
10287 "metadata" => {
10288 match map.next_key()? {
10289 Some("metadata") => MediaInfo::Metadata(map.next_value()?),
10290 None => return Err(de::Error::missing_field("metadata")),
10291 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10292 }
10293 }
10294 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
10295 };
10296 crate::eat_json_fields(&mut map)?;
10297 Ok(value)
10298 }
10299 }
10300 const VARIANTS: &[&str] = &["pending",
10301 "metadata"];
10302 deserializer.deserialize_struct("MediaInfo", VARIANTS, EnumVisitor)
10303 }
10304}
10305
10306impl ::serde::ser::Serialize for MediaInfo {
10307 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10308 use serde::ser::SerializeStruct;
10310 match self {
10311 MediaInfo::Pending => {
10312 let mut s = serializer.serialize_struct("MediaInfo", 1)?;
10314 s.serialize_field(".tag", "pending")?;
10315 s.end()
10316 }
10317 MediaInfo::Metadata(x) => {
10318 let mut s = serializer.serialize_struct("MediaInfo", 2)?;
10320 s.serialize_field(".tag", "metadata")?;
10321 s.serialize_field("metadata", x)?;
10322 s.end()
10323 }
10324 }
10325 }
10326}
10327
10328#[derive(Debug, Clone, PartialEq)]
10330pub enum MediaMetadata {
10331 Photo(PhotoMetadata),
10332 Video(VideoMetadata),
10333}
10334
10335impl<'de> ::serde::de::Deserialize<'de> for MediaMetadata {
10336 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10337 use serde::de::{self, MapAccess, Visitor};
10339 struct EnumVisitor;
10340 impl<'de> Visitor<'de> for EnumVisitor {
10341 type Value = MediaMetadata;
10342 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10343 f.write_str("a MediaMetadata structure")
10344 }
10345 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10346 let tag = match map.next_key()? {
10347 Some(".tag") => map.next_value()?,
10348 _ => return Err(de::Error::missing_field(".tag"))
10349 };
10350 match tag {
10351 "photo" => Ok(MediaMetadata::Photo(PhotoMetadata::internal_deserialize(map)?)),
10352 "video" => Ok(MediaMetadata::Video(VideoMetadata::internal_deserialize(map)?)),
10353 _ => Err(de::Error::unknown_variant(tag, VARIANTS))
10354 }
10355 }
10356 }
10357 const VARIANTS: &[&str] = &["photo",
10358 "video"];
10359 deserializer.deserialize_struct("MediaMetadata", VARIANTS, EnumVisitor)
10360 }
10361}
10362
10363impl ::serde::ser::Serialize for MediaMetadata {
10364 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10365 use serde::ser::SerializeStruct;
10367 match self {
10368 MediaMetadata::Photo(x) => {
10369 let mut s = serializer.serialize_struct("MediaMetadata", 4)?;
10370 s.serialize_field(".tag", "photo")?;
10371 x.internal_serialize::<S>(&mut s)?;
10372 s.end()
10373 }
10374 MediaMetadata::Video(x) => {
10375 let mut s = serializer.serialize_struct("MediaMetadata", 5)?;
10376 s.serialize_field(".tag", "video")?;
10377 x.internal_serialize::<S>(&mut s)?;
10378 s.end()
10379 }
10380 }
10381 }
10382}
10383
10384#[derive(Debug, Clone, PartialEq)]
10386pub enum Metadata {
10387 File(FileMetadata),
10388 Folder(FolderMetadata),
10389 Deleted(DeletedMetadata),
10390}
10391
10392impl<'de> ::serde::de::Deserialize<'de> for Metadata {
10393 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10394 use serde::de::{self, MapAccess, Visitor};
10396 struct EnumVisitor;
10397 impl<'de> Visitor<'de> for EnumVisitor {
10398 type Value = Metadata;
10399 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10400 f.write_str("a Metadata structure")
10401 }
10402 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10403 let tag = match map.next_key()? {
10404 Some(".tag") => map.next_value()?,
10405 _ => return Err(de::Error::missing_field(".tag"))
10406 };
10407 match tag {
10408 "file" => Ok(Metadata::File(FileMetadata::internal_deserialize(map)?)),
10409 "folder" => Ok(Metadata::Folder(FolderMetadata::internal_deserialize(map)?)),
10410 "deleted" => Ok(Metadata::Deleted(DeletedMetadata::internal_deserialize(map)?)),
10411 _ => Err(de::Error::unknown_variant(tag, VARIANTS))
10412 }
10413 }
10414 }
10415 const VARIANTS: &[&str] = &["file",
10416 "folder",
10417 "deleted"];
10418 deserializer.deserialize_struct("Metadata", VARIANTS, EnumVisitor)
10419 }
10420}
10421
10422impl ::serde::ser::Serialize for Metadata {
10423 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10424 use serde::ser::SerializeStruct;
10426 match self {
10427 Metadata::File(x) => {
10428 let mut s = serializer.serialize_struct("Metadata", 20)?;
10429 s.serialize_field(".tag", "file")?;
10430 x.internal_serialize::<S>(&mut s)?;
10431 s.end()
10432 }
10433 Metadata::Folder(x) => {
10434 let mut s = serializer.serialize_struct("Metadata", 10)?;
10435 s.serialize_field(".tag", "folder")?;
10436 x.internal_serialize::<S>(&mut s)?;
10437 s.end()
10438 }
10439 Metadata::Deleted(x) => {
10440 let mut s = serializer.serialize_struct("Metadata", 6)?;
10441 s.serialize_field(".tag", "deleted")?;
10442 x.internal_serialize::<S>(&mut s)?;
10443 s.end()
10444 }
10445 }
10446 }
10447}
10448
10449#[derive(Debug, Clone, PartialEq)]
10451#[non_exhaustive] pub enum MetadataV2 {
10453 Metadata(Metadata),
10454 Other,
10457}
10458
10459impl<'de> ::serde::de::Deserialize<'de> for MetadataV2 {
10460 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10461 use serde::de::{self, MapAccess, Visitor};
10463 struct EnumVisitor;
10464 impl<'de> Visitor<'de> for EnumVisitor {
10465 type Value = MetadataV2;
10466 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10467 f.write_str("a MetadataV2 structure")
10468 }
10469 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10470 let tag: &str = match map.next_key()? {
10471 Some(".tag") => map.next_value()?,
10472 _ => return Err(de::Error::missing_field(".tag"))
10473 };
10474 let value = match tag {
10475 "metadata" => {
10476 match map.next_key()? {
10477 Some("metadata") => MetadataV2::Metadata(map.next_value()?),
10478 None => return Err(de::Error::missing_field("metadata")),
10479 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
10480 }
10481 }
10482 _ => MetadataV2::Other,
10483 };
10484 crate::eat_json_fields(&mut map)?;
10485 Ok(value)
10486 }
10487 }
10488 const VARIANTS: &[&str] = &["metadata",
10489 "other"];
10490 deserializer.deserialize_struct("MetadataV2", VARIANTS, EnumVisitor)
10491 }
10492}
10493
10494impl ::serde::ser::Serialize for MetadataV2 {
10495 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10496 use serde::ser::SerializeStruct;
10498 match self {
10499 MetadataV2::Metadata(x) => {
10500 let mut s = serializer.serialize_struct("MetadataV2", 2)?;
10502 s.serialize_field(".tag", "metadata")?;
10503 s.serialize_field("metadata", x)?;
10504 s.end()
10505 }
10506 MetadataV2::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10507 }
10508 }
10509}
10510
10511#[derive(Debug, Clone, PartialEq, Eq)]
10512#[non_exhaustive] pub struct MinimalFileLinkMetadata {
10514 pub url: String,
10516 pub rev: Rev,
10519 pub id: Option<Id>,
10521 pub path: Option<String>,
10524}
10525
10526impl MinimalFileLinkMetadata {
10527 pub fn new(url: String, rev: Rev) -> Self {
10528 MinimalFileLinkMetadata {
10529 url,
10530 rev,
10531 id: None,
10532 path: None,
10533 }
10534 }
10535
10536 pub fn with_id(mut self, value: Id) -> Self {
10537 self.id = Some(value);
10538 self
10539 }
10540
10541 pub fn with_path(mut self, value: String) -> Self {
10542 self.path = Some(value);
10543 self
10544 }
10545}
10546
10547const MINIMAL_FILE_LINK_METADATA_FIELDS: &[&str] = &["url",
10548 "rev",
10549 "id",
10550 "path"];
10551impl MinimalFileLinkMetadata {
10552 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
10553 map: V,
10554 ) -> Result<MinimalFileLinkMetadata, V::Error> {
10555 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
10556 }
10557
10558 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
10559 mut map: V,
10560 optional: bool,
10561 ) -> Result<Option<MinimalFileLinkMetadata>, V::Error> {
10562 let mut field_url = None;
10563 let mut field_rev = None;
10564 let mut field_id = None;
10565 let mut field_path = None;
10566 let mut nothing = true;
10567 while let Some(key) = map.next_key::<&str>()? {
10568 nothing = false;
10569 match key {
10570 "url" => {
10571 if field_url.is_some() {
10572 return Err(::serde::de::Error::duplicate_field("url"));
10573 }
10574 field_url = Some(map.next_value()?);
10575 }
10576 "rev" => {
10577 if field_rev.is_some() {
10578 return Err(::serde::de::Error::duplicate_field("rev"));
10579 }
10580 field_rev = Some(map.next_value()?);
10581 }
10582 "id" => {
10583 if field_id.is_some() {
10584 return Err(::serde::de::Error::duplicate_field("id"));
10585 }
10586 field_id = Some(map.next_value()?);
10587 }
10588 "path" => {
10589 if field_path.is_some() {
10590 return Err(::serde::de::Error::duplicate_field("path"));
10591 }
10592 field_path = Some(map.next_value()?);
10593 }
10594 _ => {
10595 map.next_value::<::serde_json::Value>()?;
10597 }
10598 }
10599 }
10600 if optional && nothing {
10601 return Ok(None);
10602 }
10603 let result = MinimalFileLinkMetadata {
10604 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
10605 rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
10606 id: field_id.and_then(Option::flatten),
10607 path: field_path.and_then(Option::flatten),
10608 };
10609 Ok(Some(result))
10610 }
10611
10612 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
10613 &self,
10614 s: &mut S::SerializeStruct,
10615 ) -> Result<(), S::Error> {
10616 use serde::ser::SerializeStruct;
10617 s.serialize_field("url", &self.url)?;
10618 s.serialize_field("rev", &self.rev)?;
10619 if let Some(val) = &self.id {
10620 s.serialize_field("id", val)?;
10621 }
10622 if let Some(val) = &self.path {
10623 s.serialize_field("path", val)?;
10624 }
10625 Ok(())
10626 }
10627}
10628
10629impl<'de> ::serde::de::Deserialize<'de> for MinimalFileLinkMetadata {
10630 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10631 use serde::de::{MapAccess, Visitor};
10633 struct StructVisitor;
10634 impl<'de> Visitor<'de> for StructVisitor {
10635 type Value = MinimalFileLinkMetadata;
10636 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10637 f.write_str("a MinimalFileLinkMetadata struct")
10638 }
10639 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
10640 MinimalFileLinkMetadata::internal_deserialize(map)
10641 }
10642 }
10643 deserializer.deserialize_struct("MinimalFileLinkMetadata", MINIMAL_FILE_LINK_METADATA_FIELDS, StructVisitor)
10644 }
10645}
10646
10647impl ::serde::ser::Serialize for MinimalFileLinkMetadata {
10648 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10649 use serde::ser::SerializeStruct;
10651 let mut s = serializer.serialize_struct("MinimalFileLinkMetadata", 4)?;
10652 self.internal_serialize::<S>(&mut s)?;
10653 s.end()
10654 }
10655}
10656
10657#[derive(Debug, Clone, PartialEq, Eq)]
10658#[non_exhaustive] pub struct MoveBatchArg {
10660 pub entries: Vec<RelocationPath>,
10662 pub autorename: bool,
10665 pub allow_ownership_transfer: bool,
10668}
10669
10670impl MoveBatchArg {
10671 pub fn new(entries: Vec<RelocationPath>) -> Self {
10672 MoveBatchArg {
10673 entries,
10674 autorename: false,
10675 allow_ownership_transfer: false,
10676 }
10677 }
10678
10679 pub fn with_autorename(mut self, value: bool) -> Self {
10680 self.autorename = value;
10681 self
10682 }
10683
10684 pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
10685 self.allow_ownership_transfer = value;
10686 self
10687 }
10688}
10689
10690const MOVE_BATCH_ARG_FIELDS: &[&str] = &["entries",
10691 "autorename",
10692 "allow_ownership_transfer"];
10693impl MoveBatchArg {
10694 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
10695 map: V,
10696 ) -> Result<MoveBatchArg, V::Error> {
10697 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
10698 }
10699
10700 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
10701 mut map: V,
10702 optional: bool,
10703 ) -> Result<Option<MoveBatchArg>, V::Error> {
10704 let mut field_entries = None;
10705 let mut field_autorename = None;
10706 let mut field_allow_ownership_transfer = None;
10707 let mut nothing = true;
10708 while let Some(key) = map.next_key::<&str>()? {
10709 nothing = false;
10710 match key {
10711 "entries" => {
10712 if field_entries.is_some() {
10713 return Err(::serde::de::Error::duplicate_field("entries"));
10714 }
10715 field_entries = Some(map.next_value()?);
10716 }
10717 "autorename" => {
10718 if field_autorename.is_some() {
10719 return Err(::serde::de::Error::duplicate_field("autorename"));
10720 }
10721 field_autorename = Some(map.next_value()?);
10722 }
10723 "allow_ownership_transfer" => {
10724 if field_allow_ownership_transfer.is_some() {
10725 return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
10726 }
10727 field_allow_ownership_transfer = Some(map.next_value()?);
10728 }
10729 _ => {
10730 map.next_value::<::serde_json::Value>()?;
10732 }
10733 }
10734 }
10735 if optional && nothing {
10736 return Ok(None);
10737 }
10738 let result = MoveBatchArg {
10739 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
10740 autorename: field_autorename.unwrap_or(false),
10741 allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
10742 };
10743 Ok(Some(result))
10744 }
10745
10746 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
10747 &self,
10748 s: &mut S::SerializeStruct,
10749 ) -> Result<(), S::Error> {
10750 use serde::ser::SerializeStruct;
10751 s.serialize_field("entries", &self.entries)?;
10752 if self.autorename {
10753 s.serialize_field("autorename", &self.autorename)?;
10754 }
10755 if self.allow_ownership_transfer {
10756 s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
10757 }
10758 Ok(())
10759 }
10760}
10761
10762impl<'de> ::serde::de::Deserialize<'de> for MoveBatchArg {
10763 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10764 use serde::de::{MapAccess, Visitor};
10766 struct StructVisitor;
10767 impl<'de> Visitor<'de> for StructVisitor {
10768 type Value = MoveBatchArg;
10769 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10770 f.write_str("a MoveBatchArg struct")
10771 }
10772 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
10773 MoveBatchArg::internal_deserialize(map)
10774 }
10775 }
10776 deserializer.deserialize_struct("MoveBatchArg", MOVE_BATCH_ARG_FIELDS, StructVisitor)
10777 }
10778}
10779
10780impl ::serde::ser::Serialize for MoveBatchArg {
10781 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10782 use serde::ser::SerializeStruct;
10784 let mut s = serializer.serialize_struct("MoveBatchArg", 3)?;
10785 self.internal_serialize::<S>(&mut s)?;
10786 s.end()
10787 }
10788}
10789
10790impl From<MoveBatchArg> for RelocationBatchArgBase {
10792 fn from(subtype: MoveBatchArg) -> Self {
10793 Self {
10794 entries: subtype.entries,
10795 autorename: subtype.autorename,
10796 }
10797 }
10798}
10799#[derive(Debug, Clone, PartialEq, Eq)]
10800#[non_exhaustive] pub enum MoveIntoFamilyError {
10802 IsSharedFolder,
10804 Other,
10807}
10808
10809impl<'de> ::serde::de::Deserialize<'de> for MoveIntoFamilyError {
10810 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10811 use serde::de::{self, MapAccess, Visitor};
10813 struct EnumVisitor;
10814 impl<'de> Visitor<'de> for EnumVisitor {
10815 type Value = MoveIntoFamilyError;
10816 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10817 f.write_str("a MoveIntoFamilyError structure")
10818 }
10819 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10820 let tag: &str = match map.next_key()? {
10821 Some(".tag") => map.next_value()?,
10822 _ => return Err(de::Error::missing_field(".tag"))
10823 };
10824 let value = match tag {
10825 "is_shared_folder" => MoveIntoFamilyError::IsSharedFolder,
10826 _ => MoveIntoFamilyError::Other,
10827 };
10828 crate::eat_json_fields(&mut map)?;
10829 Ok(value)
10830 }
10831 }
10832 const VARIANTS: &[&str] = &["is_shared_folder",
10833 "other"];
10834 deserializer.deserialize_struct("MoveIntoFamilyError", VARIANTS, EnumVisitor)
10835 }
10836}
10837
10838impl ::serde::ser::Serialize for MoveIntoFamilyError {
10839 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10840 use serde::ser::SerializeStruct;
10842 match self {
10843 MoveIntoFamilyError::IsSharedFolder => {
10844 let mut s = serializer.serialize_struct("MoveIntoFamilyError", 1)?;
10846 s.serialize_field(".tag", "is_shared_folder")?;
10847 s.end()
10848 }
10849 MoveIntoFamilyError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10850 }
10851 }
10852}
10853
10854impl ::std::error::Error for MoveIntoFamilyError {
10855}
10856
10857impl ::std::fmt::Display for MoveIntoFamilyError {
10858 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10859 match self {
10860 MoveIntoFamilyError::IsSharedFolder => f.write_str("Moving shared folder into Family Room folder is not allowed."),
10861 _ => write!(f, "{:?}", *self),
10862 }
10863 }
10864}
10865
10866#[derive(Debug, Clone, PartialEq, Eq)]
10867#[non_exhaustive] pub enum MoveIntoVaultError {
10869 IsSharedFolder,
10871 Other,
10874}
10875
10876impl<'de> ::serde::de::Deserialize<'de> for MoveIntoVaultError {
10877 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10878 use serde::de::{self, MapAccess, Visitor};
10880 struct EnumVisitor;
10881 impl<'de> Visitor<'de> for EnumVisitor {
10882 type Value = MoveIntoVaultError;
10883 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10884 f.write_str("a MoveIntoVaultError structure")
10885 }
10886 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10887 let tag: &str = match map.next_key()? {
10888 Some(".tag") => map.next_value()?,
10889 _ => return Err(de::Error::missing_field(".tag"))
10890 };
10891 let value = match tag {
10892 "is_shared_folder" => MoveIntoVaultError::IsSharedFolder,
10893 _ => MoveIntoVaultError::Other,
10894 };
10895 crate::eat_json_fields(&mut map)?;
10896 Ok(value)
10897 }
10898 }
10899 const VARIANTS: &[&str] = &["is_shared_folder",
10900 "other"];
10901 deserializer.deserialize_struct("MoveIntoVaultError", VARIANTS, EnumVisitor)
10902 }
10903}
10904
10905impl ::serde::ser::Serialize for MoveIntoVaultError {
10906 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10907 use serde::ser::SerializeStruct;
10909 match self {
10910 MoveIntoVaultError::IsSharedFolder => {
10911 let mut s = serializer.serialize_struct("MoveIntoVaultError", 1)?;
10913 s.serialize_field(".tag", "is_shared_folder")?;
10914 s.end()
10915 }
10916 MoveIntoVaultError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
10917 }
10918 }
10919}
10920
10921impl ::std::error::Error for MoveIntoVaultError {
10922}
10923
10924impl ::std::fmt::Display for MoveIntoVaultError {
10925 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10926 match self {
10927 MoveIntoVaultError::IsSharedFolder => f.write_str("Moving shared folder into Vault is not allowed."),
10928 _ => write!(f, "{:?}", *self),
10929 }
10930 }
10931}
10932
10933#[derive(Debug, Clone, PartialEq, Eq)]
10934#[non_exhaustive] pub enum PaperContentError {
10936 InsufficientPermissions,
10938 ContentMalformed,
10940 DocLengthExceeded,
10942 ImageSizeExceeded,
10945 Other,
10948}
10949
10950impl<'de> ::serde::de::Deserialize<'de> for PaperContentError {
10951 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
10952 use serde::de::{self, MapAccess, Visitor};
10954 struct EnumVisitor;
10955 impl<'de> Visitor<'de> for EnumVisitor {
10956 type Value = PaperContentError;
10957 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
10958 f.write_str("a PaperContentError structure")
10959 }
10960 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
10961 let tag: &str = match map.next_key()? {
10962 Some(".tag") => map.next_value()?,
10963 _ => return Err(de::Error::missing_field(".tag"))
10964 };
10965 let value = match tag {
10966 "insufficient_permissions" => PaperContentError::InsufficientPermissions,
10967 "content_malformed" => PaperContentError::ContentMalformed,
10968 "doc_length_exceeded" => PaperContentError::DocLengthExceeded,
10969 "image_size_exceeded" => PaperContentError::ImageSizeExceeded,
10970 _ => PaperContentError::Other,
10971 };
10972 crate::eat_json_fields(&mut map)?;
10973 Ok(value)
10974 }
10975 }
10976 const VARIANTS: &[&str] = &["insufficient_permissions",
10977 "content_malformed",
10978 "doc_length_exceeded",
10979 "image_size_exceeded",
10980 "other"];
10981 deserializer.deserialize_struct("PaperContentError", VARIANTS, EnumVisitor)
10982 }
10983}
10984
10985impl ::serde::ser::Serialize for PaperContentError {
10986 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
10987 use serde::ser::SerializeStruct;
10989 match self {
10990 PaperContentError::InsufficientPermissions => {
10991 let mut s = serializer.serialize_struct("PaperContentError", 1)?;
10993 s.serialize_field(".tag", "insufficient_permissions")?;
10994 s.end()
10995 }
10996 PaperContentError::ContentMalformed => {
10997 let mut s = serializer.serialize_struct("PaperContentError", 1)?;
10999 s.serialize_field(".tag", "content_malformed")?;
11000 s.end()
11001 }
11002 PaperContentError::DocLengthExceeded => {
11003 let mut s = serializer.serialize_struct("PaperContentError", 1)?;
11005 s.serialize_field(".tag", "doc_length_exceeded")?;
11006 s.end()
11007 }
11008 PaperContentError::ImageSizeExceeded => {
11009 let mut s = serializer.serialize_struct("PaperContentError", 1)?;
11011 s.serialize_field(".tag", "image_size_exceeded")?;
11012 s.end()
11013 }
11014 PaperContentError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11015 }
11016 }
11017}
11018
11019impl ::std::error::Error for PaperContentError {
11020}
11021
11022impl ::std::fmt::Display for PaperContentError {
11023 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11024 match self {
11025 PaperContentError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
11026 PaperContentError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
11027 PaperContentError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
11028 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."),
11029 _ => write!(f, "{:?}", *self),
11030 }
11031 }
11032}
11033
11034#[derive(Debug, Clone, PartialEq, Eq)]
11035#[non_exhaustive] pub struct PaperCreateArg {
11037 pub path: Path,
11040 pub import_format: ImportFormat,
11042}
11043
11044impl PaperCreateArg {
11045 pub fn new(path: Path, import_format: ImportFormat) -> Self {
11046 PaperCreateArg {
11047 path,
11048 import_format,
11049 }
11050 }
11051}
11052
11053const PAPER_CREATE_ARG_FIELDS: &[&str] = &["path",
11054 "import_format"];
11055impl PaperCreateArg {
11056 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11057 map: V,
11058 ) -> Result<PaperCreateArg, V::Error> {
11059 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11060 }
11061
11062 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11063 mut map: V,
11064 optional: bool,
11065 ) -> Result<Option<PaperCreateArg>, V::Error> {
11066 let mut field_path = None;
11067 let mut field_import_format = None;
11068 let mut nothing = true;
11069 while let Some(key) = map.next_key::<&str>()? {
11070 nothing = false;
11071 match key {
11072 "path" => {
11073 if field_path.is_some() {
11074 return Err(::serde::de::Error::duplicate_field("path"));
11075 }
11076 field_path = Some(map.next_value()?);
11077 }
11078 "import_format" => {
11079 if field_import_format.is_some() {
11080 return Err(::serde::de::Error::duplicate_field("import_format"));
11081 }
11082 field_import_format = Some(map.next_value()?);
11083 }
11084 _ => {
11085 map.next_value::<::serde_json::Value>()?;
11087 }
11088 }
11089 }
11090 if optional && nothing {
11091 return Ok(None);
11092 }
11093 let result = PaperCreateArg {
11094 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
11095 import_format: field_import_format.ok_or_else(|| ::serde::de::Error::missing_field("import_format"))?,
11096 };
11097 Ok(Some(result))
11098 }
11099
11100 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11101 &self,
11102 s: &mut S::SerializeStruct,
11103 ) -> Result<(), S::Error> {
11104 use serde::ser::SerializeStruct;
11105 s.serialize_field("path", &self.path)?;
11106 s.serialize_field("import_format", &self.import_format)?;
11107 Ok(())
11108 }
11109}
11110
11111impl<'de> ::serde::de::Deserialize<'de> for PaperCreateArg {
11112 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11113 use serde::de::{MapAccess, Visitor};
11115 struct StructVisitor;
11116 impl<'de> Visitor<'de> for StructVisitor {
11117 type Value = PaperCreateArg;
11118 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11119 f.write_str("a PaperCreateArg struct")
11120 }
11121 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11122 PaperCreateArg::internal_deserialize(map)
11123 }
11124 }
11125 deserializer.deserialize_struct("PaperCreateArg", PAPER_CREATE_ARG_FIELDS, StructVisitor)
11126 }
11127}
11128
11129impl ::serde::ser::Serialize for PaperCreateArg {
11130 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11131 use serde::ser::SerializeStruct;
11133 let mut s = serializer.serialize_struct("PaperCreateArg", 2)?;
11134 self.internal_serialize::<S>(&mut s)?;
11135 s.end()
11136 }
11137}
11138
11139#[derive(Debug, Clone, PartialEq, Eq)]
11140#[non_exhaustive] pub enum PaperCreateError {
11142 InsufficientPermissions,
11144 ContentMalformed,
11146 DocLengthExceeded,
11148 ImageSizeExceeded,
11151 InvalidPath,
11153 EmailUnverified,
11155 InvalidFileExtension,
11157 PaperDisabled,
11159 Other,
11162}
11163
11164impl<'de> ::serde::de::Deserialize<'de> for PaperCreateError {
11165 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11166 use serde::de::{self, MapAccess, Visitor};
11168 struct EnumVisitor;
11169 impl<'de> Visitor<'de> for EnumVisitor {
11170 type Value = PaperCreateError;
11171 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11172 f.write_str("a PaperCreateError structure")
11173 }
11174 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11175 let tag: &str = match map.next_key()? {
11176 Some(".tag") => map.next_value()?,
11177 _ => return Err(de::Error::missing_field(".tag"))
11178 };
11179 let value = match tag {
11180 "insufficient_permissions" => PaperCreateError::InsufficientPermissions,
11181 "content_malformed" => PaperCreateError::ContentMalformed,
11182 "doc_length_exceeded" => PaperCreateError::DocLengthExceeded,
11183 "image_size_exceeded" => PaperCreateError::ImageSizeExceeded,
11184 "invalid_path" => PaperCreateError::InvalidPath,
11185 "email_unverified" => PaperCreateError::EmailUnverified,
11186 "invalid_file_extension" => PaperCreateError::InvalidFileExtension,
11187 "paper_disabled" => PaperCreateError::PaperDisabled,
11188 _ => PaperCreateError::Other,
11189 };
11190 crate::eat_json_fields(&mut map)?;
11191 Ok(value)
11192 }
11193 }
11194 const VARIANTS: &[&str] = &["insufficient_permissions",
11195 "content_malformed",
11196 "doc_length_exceeded",
11197 "image_size_exceeded",
11198 "other",
11199 "invalid_path",
11200 "email_unverified",
11201 "invalid_file_extension",
11202 "paper_disabled"];
11203 deserializer.deserialize_struct("PaperCreateError", VARIANTS, EnumVisitor)
11204 }
11205}
11206
11207impl ::serde::ser::Serialize for PaperCreateError {
11208 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11209 use serde::ser::SerializeStruct;
11211 match self {
11212 PaperCreateError::InsufficientPermissions => {
11213 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11215 s.serialize_field(".tag", "insufficient_permissions")?;
11216 s.end()
11217 }
11218 PaperCreateError::ContentMalformed => {
11219 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11221 s.serialize_field(".tag", "content_malformed")?;
11222 s.end()
11223 }
11224 PaperCreateError::DocLengthExceeded => {
11225 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11227 s.serialize_field(".tag", "doc_length_exceeded")?;
11228 s.end()
11229 }
11230 PaperCreateError::ImageSizeExceeded => {
11231 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11233 s.serialize_field(".tag", "image_size_exceeded")?;
11234 s.end()
11235 }
11236 PaperCreateError::InvalidPath => {
11237 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11239 s.serialize_field(".tag", "invalid_path")?;
11240 s.end()
11241 }
11242 PaperCreateError::EmailUnverified => {
11243 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11245 s.serialize_field(".tag", "email_unverified")?;
11246 s.end()
11247 }
11248 PaperCreateError::InvalidFileExtension => {
11249 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11251 s.serialize_field(".tag", "invalid_file_extension")?;
11252 s.end()
11253 }
11254 PaperCreateError::PaperDisabled => {
11255 let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
11257 s.serialize_field(".tag", "paper_disabled")?;
11258 s.end()
11259 }
11260 PaperCreateError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11261 }
11262 }
11263}
11264
11265impl ::std::error::Error for PaperCreateError {
11266}
11267
11268impl ::std::fmt::Display for PaperCreateError {
11269 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11270 match self {
11271 PaperCreateError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
11272 PaperCreateError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
11273 PaperCreateError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
11274 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."),
11275 PaperCreateError::InvalidPath => f.write_str("The file could not be saved to the specified location."),
11276 PaperCreateError::EmailUnverified => f.write_str("The user's email must be verified to create Paper docs."),
11277 PaperCreateError::InvalidFileExtension => f.write_str("The file path must end in .paper."),
11278 PaperCreateError::PaperDisabled => f.write_str("Paper is disabled for your team."),
11279 _ => write!(f, "{:?}", *self),
11280 }
11281 }
11282}
11283
11284impl From<PaperContentError> for PaperCreateError {
11286 fn from(parent: PaperContentError) -> Self {
11287 match parent {
11288 PaperContentError::InsufficientPermissions => PaperCreateError::InsufficientPermissions,
11289 PaperContentError::ContentMalformed => PaperCreateError::ContentMalformed,
11290 PaperContentError::DocLengthExceeded => PaperCreateError::DocLengthExceeded,
11291 PaperContentError::ImageSizeExceeded => PaperCreateError::ImageSizeExceeded,
11292 PaperContentError::Other => PaperCreateError::Other,
11293 }
11294 }
11295}
11296#[derive(Debug, Clone, PartialEq, Eq)]
11297#[non_exhaustive] pub struct PaperCreateResult {
11299 pub url: String,
11301 pub result_path: String,
11303 pub file_id: FileId,
11305 pub paper_revision: i64,
11307}
11308
11309impl PaperCreateResult {
11310 pub fn new(url: String, result_path: String, file_id: FileId, paper_revision: i64) -> Self {
11311 PaperCreateResult {
11312 url,
11313 result_path,
11314 file_id,
11315 paper_revision,
11316 }
11317 }
11318}
11319
11320const PAPER_CREATE_RESULT_FIELDS: &[&str] = &["url",
11321 "result_path",
11322 "file_id",
11323 "paper_revision"];
11324impl PaperCreateResult {
11325 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11326 map: V,
11327 ) -> Result<PaperCreateResult, V::Error> {
11328 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11329 }
11330
11331 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11332 mut map: V,
11333 optional: bool,
11334 ) -> Result<Option<PaperCreateResult>, V::Error> {
11335 let mut field_url = None;
11336 let mut field_result_path = None;
11337 let mut field_file_id = None;
11338 let mut field_paper_revision = None;
11339 let mut nothing = true;
11340 while let Some(key) = map.next_key::<&str>()? {
11341 nothing = false;
11342 match key {
11343 "url" => {
11344 if field_url.is_some() {
11345 return Err(::serde::de::Error::duplicate_field("url"));
11346 }
11347 field_url = Some(map.next_value()?);
11348 }
11349 "result_path" => {
11350 if field_result_path.is_some() {
11351 return Err(::serde::de::Error::duplicate_field("result_path"));
11352 }
11353 field_result_path = Some(map.next_value()?);
11354 }
11355 "file_id" => {
11356 if field_file_id.is_some() {
11357 return Err(::serde::de::Error::duplicate_field("file_id"));
11358 }
11359 field_file_id = Some(map.next_value()?);
11360 }
11361 "paper_revision" => {
11362 if field_paper_revision.is_some() {
11363 return Err(::serde::de::Error::duplicate_field("paper_revision"));
11364 }
11365 field_paper_revision = Some(map.next_value()?);
11366 }
11367 _ => {
11368 map.next_value::<::serde_json::Value>()?;
11370 }
11371 }
11372 }
11373 if optional && nothing {
11374 return Ok(None);
11375 }
11376 let result = PaperCreateResult {
11377 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
11378 result_path: field_result_path.ok_or_else(|| ::serde::de::Error::missing_field("result_path"))?,
11379 file_id: field_file_id.ok_or_else(|| ::serde::de::Error::missing_field("file_id"))?,
11380 paper_revision: field_paper_revision.ok_or_else(|| ::serde::de::Error::missing_field("paper_revision"))?,
11381 };
11382 Ok(Some(result))
11383 }
11384
11385 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11386 &self,
11387 s: &mut S::SerializeStruct,
11388 ) -> Result<(), S::Error> {
11389 use serde::ser::SerializeStruct;
11390 s.serialize_field("url", &self.url)?;
11391 s.serialize_field("result_path", &self.result_path)?;
11392 s.serialize_field("file_id", &self.file_id)?;
11393 s.serialize_field("paper_revision", &self.paper_revision)?;
11394 Ok(())
11395 }
11396}
11397
11398impl<'de> ::serde::de::Deserialize<'de> for PaperCreateResult {
11399 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11400 use serde::de::{MapAccess, Visitor};
11402 struct StructVisitor;
11403 impl<'de> Visitor<'de> for StructVisitor {
11404 type Value = PaperCreateResult;
11405 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11406 f.write_str("a PaperCreateResult struct")
11407 }
11408 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11409 PaperCreateResult::internal_deserialize(map)
11410 }
11411 }
11412 deserializer.deserialize_struct("PaperCreateResult", PAPER_CREATE_RESULT_FIELDS, StructVisitor)
11413 }
11414}
11415
11416impl ::serde::ser::Serialize for PaperCreateResult {
11417 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11418 use serde::ser::SerializeStruct;
11420 let mut s = serializer.serialize_struct("PaperCreateResult", 4)?;
11421 self.internal_serialize::<S>(&mut s)?;
11422 s.end()
11423 }
11424}
11425
11426#[derive(Debug, Clone, PartialEq, Eq)]
11427#[non_exhaustive] pub enum PaperDocUpdatePolicy {
11429 Update,
11432 Overwrite,
11434 Prepend,
11436 Append,
11438 Other,
11441}
11442
11443impl<'de> ::serde::de::Deserialize<'de> for PaperDocUpdatePolicy {
11444 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11445 use serde::de::{self, MapAccess, Visitor};
11447 struct EnumVisitor;
11448 impl<'de> Visitor<'de> for EnumVisitor {
11449 type Value = PaperDocUpdatePolicy;
11450 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11451 f.write_str("a PaperDocUpdatePolicy structure")
11452 }
11453 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11454 let tag: &str = match map.next_key()? {
11455 Some(".tag") => map.next_value()?,
11456 _ => return Err(de::Error::missing_field(".tag"))
11457 };
11458 let value = match tag {
11459 "update" => PaperDocUpdatePolicy::Update,
11460 "overwrite" => PaperDocUpdatePolicy::Overwrite,
11461 "prepend" => PaperDocUpdatePolicy::Prepend,
11462 "append" => PaperDocUpdatePolicy::Append,
11463 _ => PaperDocUpdatePolicy::Other,
11464 };
11465 crate::eat_json_fields(&mut map)?;
11466 Ok(value)
11467 }
11468 }
11469 const VARIANTS: &[&str] = &["update",
11470 "overwrite",
11471 "prepend",
11472 "append",
11473 "other"];
11474 deserializer.deserialize_struct("PaperDocUpdatePolicy", VARIANTS, EnumVisitor)
11475 }
11476}
11477
11478impl ::serde::ser::Serialize for PaperDocUpdatePolicy {
11479 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11480 use serde::ser::SerializeStruct;
11482 match self {
11483 PaperDocUpdatePolicy::Update => {
11484 let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11486 s.serialize_field(".tag", "update")?;
11487 s.end()
11488 }
11489 PaperDocUpdatePolicy::Overwrite => {
11490 let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11492 s.serialize_field(".tag", "overwrite")?;
11493 s.end()
11494 }
11495 PaperDocUpdatePolicy::Prepend => {
11496 let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11498 s.serialize_field(".tag", "prepend")?;
11499 s.end()
11500 }
11501 PaperDocUpdatePolicy::Append => {
11502 let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
11504 s.serialize_field(".tag", "append")?;
11505 s.end()
11506 }
11507 PaperDocUpdatePolicy::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11508 }
11509 }
11510}
11511
11512#[derive(Debug, Clone, PartialEq, Eq)]
11513#[non_exhaustive] pub struct PaperUpdateArg {
11515 pub path: WritePathOrId,
11518 pub import_format: ImportFormat,
11520 pub doc_update_policy: PaperDocUpdatePolicy,
11522 pub paper_revision: Option<i64>,
11525}
11526
11527impl PaperUpdateArg {
11528 pub fn new(
11529 path: WritePathOrId,
11530 import_format: ImportFormat,
11531 doc_update_policy: PaperDocUpdatePolicy,
11532 ) -> Self {
11533 PaperUpdateArg {
11534 path,
11535 import_format,
11536 doc_update_policy,
11537 paper_revision: None,
11538 }
11539 }
11540
11541 pub fn with_paper_revision(mut self, value: i64) -> Self {
11542 self.paper_revision = Some(value);
11543 self
11544 }
11545}
11546
11547const PAPER_UPDATE_ARG_FIELDS: &[&str] = &["path",
11548 "import_format",
11549 "doc_update_policy",
11550 "paper_revision"];
11551impl PaperUpdateArg {
11552 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11553 map: V,
11554 ) -> Result<PaperUpdateArg, V::Error> {
11555 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11556 }
11557
11558 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11559 mut map: V,
11560 optional: bool,
11561 ) -> Result<Option<PaperUpdateArg>, V::Error> {
11562 let mut field_path = None;
11563 let mut field_import_format = None;
11564 let mut field_doc_update_policy = None;
11565 let mut field_paper_revision = None;
11566 let mut nothing = true;
11567 while let Some(key) = map.next_key::<&str>()? {
11568 nothing = false;
11569 match key {
11570 "path" => {
11571 if field_path.is_some() {
11572 return Err(::serde::de::Error::duplicate_field("path"));
11573 }
11574 field_path = Some(map.next_value()?);
11575 }
11576 "import_format" => {
11577 if field_import_format.is_some() {
11578 return Err(::serde::de::Error::duplicate_field("import_format"));
11579 }
11580 field_import_format = Some(map.next_value()?);
11581 }
11582 "doc_update_policy" => {
11583 if field_doc_update_policy.is_some() {
11584 return Err(::serde::de::Error::duplicate_field("doc_update_policy"));
11585 }
11586 field_doc_update_policy = Some(map.next_value()?);
11587 }
11588 "paper_revision" => {
11589 if field_paper_revision.is_some() {
11590 return Err(::serde::de::Error::duplicate_field("paper_revision"));
11591 }
11592 field_paper_revision = Some(map.next_value()?);
11593 }
11594 _ => {
11595 map.next_value::<::serde_json::Value>()?;
11597 }
11598 }
11599 }
11600 if optional && nothing {
11601 return Ok(None);
11602 }
11603 let result = PaperUpdateArg {
11604 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
11605 import_format: field_import_format.ok_or_else(|| ::serde::de::Error::missing_field("import_format"))?,
11606 doc_update_policy: field_doc_update_policy.ok_or_else(|| ::serde::de::Error::missing_field("doc_update_policy"))?,
11607 paper_revision: field_paper_revision.and_then(Option::flatten),
11608 };
11609 Ok(Some(result))
11610 }
11611
11612 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11613 &self,
11614 s: &mut S::SerializeStruct,
11615 ) -> Result<(), S::Error> {
11616 use serde::ser::SerializeStruct;
11617 s.serialize_field("path", &self.path)?;
11618 s.serialize_field("import_format", &self.import_format)?;
11619 s.serialize_field("doc_update_policy", &self.doc_update_policy)?;
11620 if let Some(val) = &self.paper_revision {
11621 s.serialize_field("paper_revision", val)?;
11622 }
11623 Ok(())
11624 }
11625}
11626
11627impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateArg {
11628 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11629 use serde::de::{MapAccess, Visitor};
11631 struct StructVisitor;
11632 impl<'de> Visitor<'de> for StructVisitor {
11633 type Value = PaperUpdateArg;
11634 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11635 f.write_str("a PaperUpdateArg struct")
11636 }
11637 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11638 PaperUpdateArg::internal_deserialize(map)
11639 }
11640 }
11641 deserializer.deserialize_struct("PaperUpdateArg", PAPER_UPDATE_ARG_FIELDS, StructVisitor)
11642 }
11643}
11644
11645impl ::serde::ser::Serialize for PaperUpdateArg {
11646 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11647 use serde::ser::SerializeStruct;
11649 let mut s = serializer.serialize_struct("PaperUpdateArg", 4)?;
11650 self.internal_serialize::<S>(&mut s)?;
11651 s.end()
11652 }
11653}
11654
11655#[derive(Debug, Clone, PartialEq, Eq)]
11656#[non_exhaustive] pub enum PaperUpdateError {
11658 InsufficientPermissions,
11660 ContentMalformed,
11662 DocLengthExceeded,
11664 ImageSizeExceeded,
11667 Path(LookupError),
11668 RevisionMismatch,
11670 DocArchived,
11672 DocDeleted,
11674 Other,
11677}
11678
11679impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateError {
11680 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11681 use serde::de::{self, MapAccess, Visitor};
11683 struct EnumVisitor;
11684 impl<'de> Visitor<'de> for EnumVisitor {
11685 type Value = PaperUpdateError;
11686 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11687 f.write_str("a PaperUpdateError structure")
11688 }
11689 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11690 let tag: &str = match map.next_key()? {
11691 Some(".tag") => map.next_value()?,
11692 _ => return Err(de::Error::missing_field(".tag"))
11693 };
11694 let value = match tag {
11695 "insufficient_permissions" => PaperUpdateError::InsufficientPermissions,
11696 "content_malformed" => PaperUpdateError::ContentMalformed,
11697 "doc_length_exceeded" => PaperUpdateError::DocLengthExceeded,
11698 "image_size_exceeded" => PaperUpdateError::ImageSizeExceeded,
11699 "path" => {
11700 match map.next_key()? {
11701 Some("path") => PaperUpdateError::Path(map.next_value()?),
11702 None => return Err(de::Error::missing_field("path")),
11703 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
11704 }
11705 }
11706 "revision_mismatch" => PaperUpdateError::RevisionMismatch,
11707 "doc_archived" => PaperUpdateError::DocArchived,
11708 "doc_deleted" => PaperUpdateError::DocDeleted,
11709 _ => PaperUpdateError::Other,
11710 };
11711 crate::eat_json_fields(&mut map)?;
11712 Ok(value)
11713 }
11714 }
11715 const VARIANTS: &[&str] = &["insufficient_permissions",
11716 "content_malformed",
11717 "doc_length_exceeded",
11718 "image_size_exceeded",
11719 "other",
11720 "path",
11721 "revision_mismatch",
11722 "doc_archived",
11723 "doc_deleted"];
11724 deserializer.deserialize_struct("PaperUpdateError", VARIANTS, EnumVisitor)
11725 }
11726}
11727
11728impl ::serde::ser::Serialize for PaperUpdateError {
11729 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11730 use serde::ser::SerializeStruct;
11732 match self {
11733 PaperUpdateError::InsufficientPermissions => {
11734 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11736 s.serialize_field(".tag", "insufficient_permissions")?;
11737 s.end()
11738 }
11739 PaperUpdateError::ContentMalformed => {
11740 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11742 s.serialize_field(".tag", "content_malformed")?;
11743 s.end()
11744 }
11745 PaperUpdateError::DocLengthExceeded => {
11746 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11748 s.serialize_field(".tag", "doc_length_exceeded")?;
11749 s.end()
11750 }
11751 PaperUpdateError::ImageSizeExceeded => {
11752 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11754 s.serialize_field(".tag", "image_size_exceeded")?;
11755 s.end()
11756 }
11757 PaperUpdateError::Path(x) => {
11758 let mut s = serializer.serialize_struct("PaperUpdateError", 2)?;
11760 s.serialize_field(".tag", "path")?;
11761 s.serialize_field("path", x)?;
11762 s.end()
11763 }
11764 PaperUpdateError::RevisionMismatch => {
11765 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11767 s.serialize_field(".tag", "revision_mismatch")?;
11768 s.end()
11769 }
11770 PaperUpdateError::DocArchived => {
11771 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11773 s.serialize_field(".tag", "doc_archived")?;
11774 s.end()
11775 }
11776 PaperUpdateError::DocDeleted => {
11777 let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
11779 s.serialize_field(".tag", "doc_deleted")?;
11780 s.end()
11781 }
11782 PaperUpdateError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11783 }
11784 }
11785}
11786
11787impl ::std::error::Error for PaperUpdateError {
11788 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
11789 match self {
11790 PaperUpdateError::Path(inner) => Some(inner),
11791 _ => None,
11792 }
11793 }
11794}
11795
11796impl ::std::fmt::Display for PaperUpdateError {
11797 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11798 match self {
11799 PaperUpdateError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
11800 PaperUpdateError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
11801 PaperUpdateError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
11802 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."),
11803 PaperUpdateError::Path(inner) => write!(f, "PaperUpdateError: {}", inner),
11804 PaperUpdateError::RevisionMismatch => f.write_str("The provided revision does not match the document head."),
11805 PaperUpdateError::DocArchived => f.write_str("This operation is not allowed on archived Paper docs."),
11806 PaperUpdateError::DocDeleted => f.write_str("This operation is not allowed on deleted Paper docs."),
11807 _ => write!(f, "{:?}", *self),
11808 }
11809 }
11810}
11811
11812impl From<PaperContentError> for PaperUpdateError {
11814 fn from(parent: PaperContentError) -> Self {
11815 match parent {
11816 PaperContentError::InsufficientPermissions => PaperUpdateError::InsufficientPermissions,
11817 PaperContentError::ContentMalformed => PaperUpdateError::ContentMalformed,
11818 PaperContentError::DocLengthExceeded => PaperUpdateError::DocLengthExceeded,
11819 PaperContentError::ImageSizeExceeded => PaperUpdateError::ImageSizeExceeded,
11820 PaperContentError::Other => PaperUpdateError::Other,
11821 }
11822 }
11823}
11824#[derive(Debug, Clone, PartialEq, Eq)]
11825#[non_exhaustive] pub struct PaperUpdateResult {
11827 pub paper_revision: i64,
11829}
11830
11831impl PaperUpdateResult {
11832 pub fn new(paper_revision: i64) -> Self {
11833 PaperUpdateResult {
11834 paper_revision,
11835 }
11836 }
11837}
11838
11839const PAPER_UPDATE_RESULT_FIELDS: &[&str] = &["paper_revision"];
11840impl PaperUpdateResult {
11841 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
11842 map: V,
11843 ) -> Result<PaperUpdateResult, V::Error> {
11844 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
11845 }
11846
11847 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
11848 mut map: V,
11849 optional: bool,
11850 ) -> Result<Option<PaperUpdateResult>, V::Error> {
11851 let mut field_paper_revision = None;
11852 let mut nothing = true;
11853 while let Some(key) = map.next_key::<&str>()? {
11854 nothing = false;
11855 match key {
11856 "paper_revision" => {
11857 if field_paper_revision.is_some() {
11858 return Err(::serde::de::Error::duplicate_field("paper_revision"));
11859 }
11860 field_paper_revision = Some(map.next_value()?);
11861 }
11862 _ => {
11863 map.next_value::<::serde_json::Value>()?;
11865 }
11866 }
11867 }
11868 if optional && nothing {
11869 return Ok(None);
11870 }
11871 let result = PaperUpdateResult {
11872 paper_revision: field_paper_revision.ok_or_else(|| ::serde::de::Error::missing_field("paper_revision"))?,
11873 };
11874 Ok(Some(result))
11875 }
11876
11877 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
11878 &self,
11879 s: &mut S::SerializeStruct,
11880 ) -> Result<(), S::Error> {
11881 use serde::ser::SerializeStruct;
11882 s.serialize_field("paper_revision", &self.paper_revision)?;
11883 Ok(())
11884 }
11885}
11886
11887impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateResult {
11888 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11889 use serde::de::{MapAccess, Visitor};
11891 struct StructVisitor;
11892 impl<'de> Visitor<'de> for StructVisitor {
11893 type Value = PaperUpdateResult;
11894 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11895 f.write_str("a PaperUpdateResult struct")
11896 }
11897 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
11898 PaperUpdateResult::internal_deserialize(map)
11899 }
11900 }
11901 deserializer.deserialize_struct("PaperUpdateResult", PAPER_UPDATE_RESULT_FIELDS, StructVisitor)
11902 }
11903}
11904
11905impl ::serde::ser::Serialize for PaperUpdateResult {
11906 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11907 use serde::ser::SerializeStruct;
11909 let mut s = serializer.serialize_struct("PaperUpdateResult", 1)?;
11910 self.internal_serialize::<S>(&mut s)?;
11911 s.end()
11912 }
11913}
11914
11915#[derive(Debug, Clone, PartialEq, Eq)]
11916#[non_exhaustive] pub enum PathOrLink {
11918 Path(ReadPath),
11919 Link(SharedLinkFileInfo),
11920 Other,
11923}
11924
11925impl<'de> ::serde::de::Deserialize<'de> for PathOrLink {
11926 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
11927 use serde::de::{self, MapAccess, Visitor};
11929 struct EnumVisitor;
11930 impl<'de> Visitor<'de> for EnumVisitor {
11931 type Value = PathOrLink;
11932 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
11933 f.write_str("a PathOrLink structure")
11934 }
11935 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
11936 let tag: &str = match map.next_key()? {
11937 Some(".tag") => map.next_value()?,
11938 _ => return Err(de::Error::missing_field(".tag"))
11939 };
11940 let value = match tag {
11941 "path" => {
11942 match map.next_key()? {
11943 Some("path") => PathOrLink::Path(map.next_value()?),
11944 None => return Err(de::Error::missing_field("path")),
11945 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
11946 }
11947 }
11948 "link" => PathOrLink::Link(SharedLinkFileInfo::internal_deserialize(&mut map)?),
11949 _ => PathOrLink::Other,
11950 };
11951 crate::eat_json_fields(&mut map)?;
11952 Ok(value)
11953 }
11954 }
11955 const VARIANTS: &[&str] = &["path",
11956 "link",
11957 "other"];
11958 deserializer.deserialize_struct("PathOrLink", VARIANTS, EnumVisitor)
11959 }
11960}
11961
11962impl ::serde::ser::Serialize for PathOrLink {
11963 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
11964 use serde::ser::SerializeStruct;
11966 match self {
11967 PathOrLink::Path(x) => {
11968 let mut s = serializer.serialize_struct("PathOrLink", 2)?;
11970 s.serialize_field(".tag", "path")?;
11971 s.serialize_field("path", x)?;
11972 s.end()
11973 }
11974 PathOrLink::Link(x) => {
11975 let mut s = serializer.serialize_struct("PathOrLink", 4)?;
11977 s.serialize_field(".tag", "link")?;
11978 x.internal_serialize::<S>(&mut s)?;
11979 s.end()
11980 }
11981 PathOrLink::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
11982 }
11983 }
11984}
11985
11986#[derive(Debug, Clone, PartialEq, Eq)]
11987#[non_exhaustive] pub struct PathToTags {
11989 pub path: Path,
11991 pub tags: Vec<Tag>,
11993}
11994
11995impl PathToTags {
11996 pub fn new(path: Path, tags: Vec<Tag>) -> Self {
11997 PathToTags {
11998 path,
11999 tags,
12000 }
12001 }
12002}
12003
12004const PATH_TO_TAGS_FIELDS: &[&str] = &["path",
12005 "tags"];
12006impl PathToTags {
12007 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12008 map: V,
12009 ) -> Result<PathToTags, V::Error> {
12010 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12011 }
12012
12013 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12014 mut map: V,
12015 optional: bool,
12016 ) -> Result<Option<PathToTags>, V::Error> {
12017 let mut field_path = None;
12018 let mut field_tags = None;
12019 let mut nothing = true;
12020 while let Some(key) = map.next_key::<&str>()? {
12021 nothing = false;
12022 match key {
12023 "path" => {
12024 if field_path.is_some() {
12025 return Err(::serde::de::Error::duplicate_field("path"));
12026 }
12027 field_path = Some(map.next_value()?);
12028 }
12029 "tags" => {
12030 if field_tags.is_some() {
12031 return Err(::serde::de::Error::duplicate_field("tags"));
12032 }
12033 field_tags = Some(map.next_value()?);
12034 }
12035 _ => {
12036 map.next_value::<::serde_json::Value>()?;
12038 }
12039 }
12040 }
12041 if optional && nothing {
12042 return Ok(None);
12043 }
12044 let result = PathToTags {
12045 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
12046 tags: field_tags.ok_or_else(|| ::serde::de::Error::missing_field("tags"))?,
12047 };
12048 Ok(Some(result))
12049 }
12050
12051 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12052 &self,
12053 s: &mut S::SerializeStruct,
12054 ) -> Result<(), S::Error> {
12055 use serde::ser::SerializeStruct;
12056 s.serialize_field("path", &self.path)?;
12057 s.serialize_field("tags", &self.tags)?;
12058 Ok(())
12059 }
12060}
12061
12062impl<'de> ::serde::de::Deserialize<'de> for PathToTags {
12063 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12064 use serde::de::{MapAccess, Visitor};
12066 struct StructVisitor;
12067 impl<'de> Visitor<'de> for StructVisitor {
12068 type Value = PathToTags;
12069 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12070 f.write_str("a PathToTags struct")
12071 }
12072 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12073 PathToTags::internal_deserialize(map)
12074 }
12075 }
12076 deserializer.deserialize_struct("PathToTags", PATH_TO_TAGS_FIELDS, StructVisitor)
12077 }
12078}
12079
12080impl ::serde::ser::Serialize for PathToTags {
12081 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12082 use serde::ser::SerializeStruct;
12084 let mut s = serializer.serialize_struct("PathToTags", 2)?;
12085 self.internal_serialize::<S>(&mut s)?;
12086 s.end()
12087 }
12088}
12089
12090#[derive(Debug, Clone, PartialEq, Default)]
12092#[non_exhaustive] pub struct PhotoMetadata {
12094 pub dimensions: Option<Dimensions>,
12096 pub location: Option<GpsCoordinates>,
12098 pub time_taken: Option<crate::types::common::DropboxTimestamp>,
12100}
12101
12102impl PhotoMetadata {
12103 pub fn with_dimensions(mut self, value: Dimensions) -> Self {
12104 self.dimensions = Some(value);
12105 self
12106 }
12107
12108 pub fn with_location(mut self, value: GpsCoordinates) -> Self {
12109 self.location = Some(value);
12110 self
12111 }
12112
12113 pub fn with_time_taken(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
12114 self.time_taken = Some(value);
12115 self
12116 }
12117}
12118
12119const PHOTO_METADATA_FIELDS: &[&str] = &["dimensions",
12120 "location",
12121 "time_taken"];
12122impl PhotoMetadata {
12123 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12125 mut map: V,
12126 ) -> Result<PhotoMetadata, V::Error> {
12127 let mut field_dimensions = None;
12128 let mut field_location = None;
12129 let mut field_time_taken = None;
12130 while let Some(key) = map.next_key::<&str>()? {
12131 match key {
12132 "dimensions" => {
12133 if field_dimensions.is_some() {
12134 return Err(::serde::de::Error::duplicate_field("dimensions"));
12135 }
12136 field_dimensions = Some(map.next_value()?);
12137 }
12138 "location" => {
12139 if field_location.is_some() {
12140 return Err(::serde::de::Error::duplicate_field("location"));
12141 }
12142 field_location = Some(map.next_value()?);
12143 }
12144 "time_taken" => {
12145 if field_time_taken.is_some() {
12146 return Err(::serde::de::Error::duplicate_field("time_taken"));
12147 }
12148 field_time_taken = Some(map.next_value()?);
12149 }
12150 _ => {
12151 map.next_value::<::serde_json::Value>()?;
12153 }
12154 }
12155 }
12156 let result = PhotoMetadata {
12157 dimensions: field_dimensions.and_then(Option::flatten),
12158 location: field_location.and_then(Option::flatten),
12159 time_taken: field_time_taken.and_then(Option::flatten),
12160 };
12161 Ok(result)
12162 }
12163
12164 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12165 &self,
12166 s: &mut S::SerializeStruct,
12167 ) -> Result<(), S::Error> {
12168 use serde::ser::SerializeStruct;
12169 if let Some(val) = &self.dimensions {
12170 s.serialize_field("dimensions", val)?;
12171 }
12172 if let Some(val) = &self.location {
12173 s.serialize_field("location", val)?;
12174 }
12175 if let Some(val) = &self.time_taken {
12176 s.serialize_field("time_taken", val)?;
12177 }
12178 Ok(())
12179 }
12180}
12181
12182impl<'de> ::serde::de::Deserialize<'de> for PhotoMetadata {
12183 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12184 use serde::de::{MapAccess, Visitor};
12186 struct StructVisitor;
12187 impl<'de> Visitor<'de> for StructVisitor {
12188 type Value = PhotoMetadata;
12189 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12190 f.write_str("a PhotoMetadata struct")
12191 }
12192 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12193 PhotoMetadata::internal_deserialize(map)
12194 }
12195 }
12196 deserializer.deserialize_struct("PhotoMetadata", PHOTO_METADATA_FIELDS, StructVisitor)
12197 }
12198}
12199
12200impl ::serde::ser::Serialize for PhotoMetadata {
12201 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12202 use serde::ser::SerializeStruct;
12204 let mut s = serializer.serialize_struct("PhotoMetadata", 3)?;
12205 self.internal_serialize::<S>(&mut s)?;
12206 s.end()
12207 }
12208}
12209
12210impl From<PhotoMetadata> for MediaMetadata {
12212 fn from(subtype: PhotoMetadata) -> Self {
12213 MediaMetadata::Photo(subtype)
12214 }
12215}
12216#[derive(Debug, Clone, PartialEq, Eq)]
12217#[non_exhaustive] pub struct PreviewArg {
12219 pub path: ReadPath,
12221 #[deprecated]
12223 pub rev: Option<Rev>,
12224}
12225
12226impl PreviewArg {
12227 pub fn new(path: ReadPath) -> Self {
12228 PreviewArg {
12229 path,
12230 #[allow(deprecated)] rev: None,
12231 }
12232 }
12233
12234 #[deprecated]
12235 #[allow(deprecated)]
12236 pub fn with_rev(mut self, value: Rev) -> Self {
12237 self.rev = Some(value);
12238 self
12239 }
12240}
12241
12242const PREVIEW_ARG_FIELDS: &[&str] = &["path",
12243 "rev"];
12244impl PreviewArg {
12245 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12246 map: V,
12247 ) -> Result<PreviewArg, V::Error> {
12248 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12249 }
12250
12251 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12252 mut map: V,
12253 optional: bool,
12254 ) -> Result<Option<PreviewArg>, V::Error> {
12255 let mut field_path = None;
12256 let mut field_rev = None;
12257 let mut nothing = true;
12258 while let Some(key) = map.next_key::<&str>()? {
12259 nothing = false;
12260 match key {
12261 "path" => {
12262 if field_path.is_some() {
12263 return Err(::serde::de::Error::duplicate_field("path"));
12264 }
12265 field_path = Some(map.next_value()?);
12266 }
12267 "rev" => {
12268 if field_rev.is_some() {
12269 return Err(::serde::de::Error::duplicate_field("rev"));
12270 }
12271 field_rev = Some(map.next_value()?);
12272 }
12273 _ => {
12274 map.next_value::<::serde_json::Value>()?;
12276 }
12277 }
12278 }
12279 if optional && nothing {
12280 return Ok(None);
12281 }
12282 let result = PreviewArg {
12283 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
12284 #[allow(deprecated)] rev: field_rev.and_then(Option::flatten),
12285 };
12286 Ok(Some(result))
12287 }
12288
12289 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12290 &self,
12291 s: &mut S::SerializeStruct,
12292 ) -> Result<(), S::Error> {
12293 use serde::ser::SerializeStruct;
12294 s.serialize_field("path", &self.path)?;
12295 #[allow(deprecated)]
12296 if let Some(val) = &self.rev {
12297 s.serialize_field("rev", val)?;
12298 }
12299 Ok(())
12300 }
12301}
12302
12303impl<'de> ::serde::de::Deserialize<'de> for PreviewArg {
12304 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12305 use serde::de::{MapAccess, Visitor};
12307 struct StructVisitor;
12308 impl<'de> Visitor<'de> for StructVisitor {
12309 type Value = PreviewArg;
12310 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12311 f.write_str("a PreviewArg struct")
12312 }
12313 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12314 PreviewArg::internal_deserialize(map)
12315 }
12316 }
12317 deserializer.deserialize_struct("PreviewArg", PREVIEW_ARG_FIELDS, StructVisitor)
12318 }
12319}
12320
12321impl ::serde::ser::Serialize for PreviewArg {
12322 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12323 use serde::ser::SerializeStruct;
12325 let mut s = serializer.serialize_struct("PreviewArg", 2)?;
12326 self.internal_serialize::<S>(&mut s)?;
12327 s.end()
12328 }
12329}
12330
12331#[derive(Debug, Clone, PartialEq, Eq)]
12332pub enum PreviewError {
12333 Path(LookupError),
12335 InProgress,
12337 UnsupportedExtension,
12339 UnsupportedContent,
12341}
12342
12343impl<'de> ::serde::de::Deserialize<'de> for PreviewError {
12344 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12345 use serde::de::{self, MapAccess, Visitor};
12347 struct EnumVisitor;
12348 impl<'de> Visitor<'de> for EnumVisitor {
12349 type Value = PreviewError;
12350 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12351 f.write_str("a PreviewError structure")
12352 }
12353 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
12354 let tag: &str = match map.next_key()? {
12355 Some(".tag") => map.next_value()?,
12356 _ => return Err(de::Error::missing_field(".tag"))
12357 };
12358 let value = match tag {
12359 "path" => {
12360 match map.next_key()? {
12361 Some("path") => PreviewError::Path(map.next_value()?),
12362 None => return Err(de::Error::missing_field("path")),
12363 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
12364 }
12365 }
12366 "in_progress" => PreviewError::InProgress,
12367 "unsupported_extension" => PreviewError::UnsupportedExtension,
12368 "unsupported_content" => PreviewError::UnsupportedContent,
12369 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
12370 };
12371 crate::eat_json_fields(&mut map)?;
12372 Ok(value)
12373 }
12374 }
12375 const VARIANTS: &[&str] = &["path",
12376 "in_progress",
12377 "unsupported_extension",
12378 "unsupported_content"];
12379 deserializer.deserialize_struct("PreviewError", VARIANTS, EnumVisitor)
12380 }
12381}
12382
12383impl ::serde::ser::Serialize for PreviewError {
12384 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12385 use serde::ser::SerializeStruct;
12387 match self {
12388 PreviewError::Path(x) => {
12389 let mut s = serializer.serialize_struct("PreviewError", 2)?;
12391 s.serialize_field(".tag", "path")?;
12392 s.serialize_field("path", x)?;
12393 s.end()
12394 }
12395 PreviewError::InProgress => {
12396 let mut s = serializer.serialize_struct("PreviewError", 1)?;
12398 s.serialize_field(".tag", "in_progress")?;
12399 s.end()
12400 }
12401 PreviewError::UnsupportedExtension => {
12402 let mut s = serializer.serialize_struct("PreviewError", 1)?;
12404 s.serialize_field(".tag", "unsupported_extension")?;
12405 s.end()
12406 }
12407 PreviewError::UnsupportedContent => {
12408 let mut s = serializer.serialize_struct("PreviewError", 1)?;
12410 s.serialize_field(".tag", "unsupported_content")?;
12411 s.end()
12412 }
12413 }
12414 }
12415}
12416
12417impl ::std::error::Error for PreviewError {
12418 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
12419 match self {
12420 PreviewError::Path(inner) => Some(inner),
12421 _ => None,
12422 }
12423 }
12424}
12425
12426impl ::std::fmt::Display for PreviewError {
12427 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12428 match self {
12429 PreviewError::Path(inner) => write!(f, "An error occurs when downloading metadata for the file: {}", inner),
12430 PreviewError::InProgress => f.write_str("This preview generation is still in progress and the file is not ready for preview yet."),
12431 PreviewError::UnsupportedExtension => f.write_str("The file extension is not supported preview generation."),
12432 PreviewError::UnsupportedContent => f.write_str("The file content is not supported for preview generation."),
12433 }
12434 }
12435}
12436
12437#[derive(Debug, Clone, PartialEq, Default)]
12438#[non_exhaustive] pub struct PreviewResult {
12440 pub file_metadata: Option<FileMetadata>,
12443 pub link_metadata: Option<MinimalFileLinkMetadata>,
12446}
12447
12448impl PreviewResult {
12449 pub fn with_file_metadata(mut self, value: FileMetadata) -> Self {
12450 self.file_metadata = Some(value);
12451 self
12452 }
12453
12454 pub fn with_link_metadata(mut self, value: MinimalFileLinkMetadata) -> Self {
12455 self.link_metadata = Some(value);
12456 self
12457 }
12458}
12459
12460const PREVIEW_RESULT_FIELDS: &[&str] = &["file_metadata",
12461 "link_metadata"];
12462impl PreviewResult {
12463 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12465 mut map: V,
12466 ) -> Result<PreviewResult, V::Error> {
12467 let mut field_file_metadata = None;
12468 let mut field_link_metadata = None;
12469 while let Some(key) = map.next_key::<&str>()? {
12470 match key {
12471 "file_metadata" => {
12472 if field_file_metadata.is_some() {
12473 return Err(::serde::de::Error::duplicate_field("file_metadata"));
12474 }
12475 field_file_metadata = Some(map.next_value()?);
12476 }
12477 "link_metadata" => {
12478 if field_link_metadata.is_some() {
12479 return Err(::serde::de::Error::duplicate_field("link_metadata"));
12480 }
12481 field_link_metadata = Some(map.next_value()?);
12482 }
12483 _ => {
12484 map.next_value::<::serde_json::Value>()?;
12486 }
12487 }
12488 }
12489 let result = PreviewResult {
12490 file_metadata: field_file_metadata.and_then(Option::flatten),
12491 link_metadata: field_link_metadata.and_then(Option::flatten),
12492 };
12493 Ok(result)
12494 }
12495
12496 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12497 &self,
12498 s: &mut S::SerializeStruct,
12499 ) -> Result<(), S::Error> {
12500 use serde::ser::SerializeStruct;
12501 if let Some(val) = &self.file_metadata {
12502 s.serialize_field("file_metadata", val)?;
12503 }
12504 if let Some(val) = &self.link_metadata {
12505 s.serialize_field("link_metadata", val)?;
12506 }
12507 Ok(())
12508 }
12509}
12510
12511impl<'de> ::serde::de::Deserialize<'de> for PreviewResult {
12512 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12513 use serde::de::{MapAccess, Visitor};
12515 struct StructVisitor;
12516 impl<'de> Visitor<'de> for StructVisitor {
12517 type Value = PreviewResult;
12518 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12519 f.write_str("a PreviewResult struct")
12520 }
12521 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12522 PreviewResult::internal_deserialize(map)
12523 }
12524 }
12525 deserializer.deserialize_struct("PreviewResult", PREVIEW_RESULT_FIELDS, StructVisitor)
12526 }
12527}
12528
12529impl ::serde::ser::Serialize for PreviewResult {
12530 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12531 use serde::ser::SerializeStruct;
12533 let mut s = serializer.serialize_struct("PreviewResult", 2)?;
12534 self.internal_serialize::<S>(&mut s)?;
12535 s.end()
12536 }
12537}
12538
12539#[derive(Debug, Clone, PartialEq, Eq)]
12540#[non_exhaustive] pub struct RelocationArg {
12542 pub from_path: WritePathOrId,
12544 pub to_path: WritePathOrId,
12546 #[deprecated]
12548 pub allow_shared_folder: bool,
12549 pub autorename: bool,
12552 pub allow_ownership_transfer: bool,
12555}
12556
12557impl RelocationArg {
12558 pub fn new(from_path: WritePathOrId, to_path: WritePathOrId) -> Self {
12559 RelocationArg {
12560 from_path,
12561 to_path,
12562 #[allow(deprecated)] allow_shared_folder: false,
12563 autorename: false,
12564 allow_ownership_transfer: false,
12565 }
12566 }
12567
12568 #[deprecated]
12569 #[allow(deprecated)]
12570 pub fn with_allow_shared_folder(mut self, value: bool) -> Self {
12571 self.allow_shared_folder = value;
12572 self
12573 }
12574
12575 pub fn with_autorename(mut self, value: bool) -> Self {
12576 self.autorename = value;
12577 self
12578 }
12579
12580 pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
12581 self.allow_ownership_transfer = value;
12582 self
12583 }
12584}
12585
12586const RELOCATION_ARG_FIELDS: &[&str] = &["from_path",
12587 "to_path",
12588 "allow_shared_folder",
12589 "autorename",
12590 "allow_ownership_transfer"];
12591impl RelocationArg {
12592 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12593 map: V,
12594 ) -> Result<RelocationArg, V::Error> {
12595 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12596 }
12597
12598 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12599 mut map: V,
12600 optional: bool,
12601 ) -> Result<Option<RelocationArg>, V::Error> {
12602 let mut field_from_path = None;
12603 let mut field_to_path = None;
12604 let mut field_allow_shared_folder = None;
12605 let mut field_autorename = None;
12606 let mut field_allow_ownership_transfer = None;
12607 let mut nothing = true;
12608 while let Some(key) = map.next_key::<&str>()? {
12609 nothing = false;
12610 match key {
12611 "from_path" => {
12612 if field_from_path.is_some() {
12613 return Err(::serde::de::Error::duplicate_field("from_path"));
12614 }
12615 field_from_path = Some(map.next_value()?);
12616 }
12617 "to_path" => {
12618 if field_to_path.is_some() {
12619 return Err(::serde::de::Error::duplicate_field("to_path"));
12620 }
12621 field_to_path = Some(map.next_value()?);
12622 }
12623 "allow_shared_folder" => {
12624 if field_allow_shared_folder.is_some() {
12625 return Err(::serde::de::Error::duplicate_field("allow_shared_folder"));
12626 }
12627 field_allow_shared_folder = Some(map.next_value()?);
12628 }
12629 "autorename" => {
12630 if field_autorename.is_some() {
12631 return Err(::serde::de::Error::duplicate_field("autorename"));
12632 }
12633 field_autorename = Some(map.next_value()?);
12634 }
12635 "allow_ownership_transfer" => {
12636 if field_allow_ownership_transfer.is_some() {
12637 return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
12638 }
12639 field_allow_ownership_transfer = Some(map.next_value()?);
12640 }
12641 _ => {
12642 map.next_value::<::serde_json::Value>()?;
12644 }
12645 }
12646 }
12647 if optional && nothing {
12648 return Ok(None);
12649 }
12650 let result = RelocationArg {
12651 from_path: field_from_path.ok_or_else(|| ::serde::de::Error::missing_field("from_path"))?,
12652 to_path: field_to_path.ok_or_else(|| ::serde::de::Error::missing_field("to_path"))?,
12653 #[allow(deprecated)] allow_shared_folder: field_allow_shared_folder.unwrap_or(false),
12654 autorename: field_autorename.unwrap_or(false),
12655 allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
12656 };
12657 Ok(Some(result))
12658 }
12659
12660 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12661 &self,
12662 s: &mut S::SerializeStruct,
12663 ) -> Result<(), S::Error> {
12664 use serde::ser::SerializeStruct;
12665 s.serialize_field("from_path", &self.from_path)?;
12666 s.serialize_field("to_path", &self.to_path)?;
12667 #[allow(deprecated)]
12668 if self.allow_shared_folder {
12669 s.serialize_field("allow_shared_folder", &self.allow_shared_folder)?;
12670 }
12671 if self.autorename {
12672 s.serialize_field("autorename", &self.autorename)?;
12673 }
12674 if self.allow_ownership_transfer {
12675 s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
12676 }
12677 Ok(())
12678 }
12679}
12680
12681impl<'de> ::serde::de::Deserialize<'de> for RelocationArg {
12682 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12683 use serde::de::{MapAccess, Visitor};
12685 struct StructVisitor;
12686 impl<'de> Visitor<'de> for StructVisitor {
12687 type Value = RelocationArg;
12688 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12689 f.write_str("a RelocationArg struct")
12690 }
12691 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12692 RelocationArg::internal_deserialize(map)
12693 }
12694 }
12695 deserializer.deserialize_struct("RelocationArg", RELOCATION_ARG_FIELDS, StructVisitor)
12696 }
12697}
12698
12699impl ::serde::ser::Serialize for RelocationArg {
12700 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12701 use serde::ser::SerializeStruct;
12703 let mut s = serializer.serialize_struct("RelocationArg", 5)?;
12704 self.internal_serialize::<S>(&mut s)?;
12705 s.end()
12706 }
12707}
12708
12709impl From<RelocationArg> for RelocationPath {
12711 fn from(subtype: RelocationArg) -> Self {
12712 Self {
12713 from_path: subtype.from_path,
12714 to_path: subtype.to_path,
12715 }
12716 }
12717}
12718#[derive(Debug, Clone, PartialEq, Eq)]
12719#[non_exhaustive] pub struct RelocationBatchArg {
12721 pub entries: Vec<RelocationPath>,
12723 pub autorename: bool,
12726 #[deprecated]
12728 pub allow_shared_folder: bool,
12729 pub allow_ownership_transfer: bool,
12732}
12733
12734impl RelocationBatchArg {
12735 pub fn new(entries: Vec<RelocationPath>) -> Self {
12736 RelocationBatchArg {
12737 entries,
12738 autorename: false,
12739 #[allow(deprecated)] allow_shared_folder: false,
12740 allow_ownership_transfer: false,
12741 }
12742 }
12743
12744 pub fn with_autorename(mut self, value: bool) -> Self {
12745 self.autorename = value;
12746 self
12747 }
12748
12749 #[deprecated]
12750 #[allow(deprecated)]
12751 pub fn with_allow_shared_folder(mut self, value: bool) -> Self {
12752 self.allow_shared_folder = value;
12753 self
12754 }
12755
12756 pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
12757 self.allow_ownership_transfer = value;
12758 self
12759 }
12760}
12761
12762const RELOCATION_BATCH_ARG_FIELDS: &[&str] = &["entries",
12763 "autorename",
12764 "allow_shared_folder",
12765 "allow_ownership_transfer"];
12766impl RelocationBatchArg {
12767 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12768 map: V,
12769 ) -> Result<RelocationBatchArg, V::Error> {
12770 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12771 }
12772
12773 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12774 mut map: V,
12775 optional: bool,
12776 ) -> Result<Option<RelocationBatchArg>, V::Error> {
12777 let mut field_entries = None;
12778 let mut field_autorename = None;
12779 let mut field_allow_shared_folder = None;
12780 let mut field_allow_ownership_transfer = None;
12781 let mut nothing = true;
12782 while let Some(key) = map.next_key::<&str>()? {
12783 nothing = false;
12784 match key {
12785 "entries" => {
12786 if field_entries.is_some() {
12787 return Err(::serde::de::Error::duplicate_field("entries"));
12788 }
12789 field_entries = Some(map.next_value()?);
12790 }
12791 "autorename" => {
12792 if field_autorename.is_some() {
12793 return Err(::serde::de::Error::duplicate_field("autorename"));
12794 }
12795 field_autorename = Some(map.next_value()?);
12796 }
12797 "allow_shared_folder" => {
12798 if field_allow_shared_folder.is_some() {
12799 return Err(::serde::de::Error::duplicate_field("allow_shared_folder"));
12800 }
12801 field_allow_shared_folder = Some(map.next_value()?);
12802 }
12803 "allow_ownership_transfer" => {
12804 if field_allow_ownership_transfer.is_some() {
12805 return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
12806 }
12807 field_allow_ownership_transfer = Some(map.next_value()?);
12808 }
12809 _ => {
12810 map.next_value::<::serde_json::Value>()?;
12812 }
12813 }
12814 }
12815 if optional && nothing {
12816 return Ok(None);
12817 }
12818 let result = RelocationBatchArg {
12819 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
12820 autorename: field_autorename.unwrap_or(false),
12821 #[allow(deprecated)] allow_shared_folder: field_allow_shared_folder.unwrap_or(false),
12822 allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
12823 };
12824 Ok(Some(result))
12825 }
12826
12827 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12828 &self,
12829 s: &mut S::SerializeStruct,
12830 ) -> Result<(), S::Error> {
12831 use serde::ser::SerializeStruct;
12832 s.serialize_field("entries", &self.entries)?;
12833 if self.autorename {
12834 s.serialize_field("autorename", &self.autorename)?;
12835 }
12836 #[allow(deprecated)]
12837 if self.allow_shared_folder {
12838 s.serialize_field("allow_shared_folder", &self.allow_shared_folder)?;
12839 }
12840 if self.allow_ownership_transfer {
12841 s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
12842 }
12843 Ok(())
12844 }
12845}
12846
12847impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchArg {
12848 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12849 use serde::de::{MapAccess, Visitor};
12851 struct StructVisitor;
12852 impl<'de> Visitor<'de> for StructVisitor {
12853 type Value = RelocationBatchArg;
12854 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12855 f.write_str("a RelocationBatchArg struct")
12856 }
12857 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12858 RelocationBatchArg::internal_deserialize(map)
12859 }
12860 }
12861 deserializer.deserialize_struct("RelocationBatchArg", RELOCATION_BATCH_ARG_FIELDS, StructVisitor)
12862 }
12863}
12864
12865impl ::serde::ser::Serialize for RelocationBatchArg {
12866 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12867 use serde::ser::SerializeStruct;
12869 let mut s = serializer.serialize_struct("RelocationBatchArg", 4)?;
12870 self.internal_serialize::<S>(&mut s)?;
12871 s.end()
12872 }
12873}
12874
12875impl From<RelocationBatchArg> for RelocationBatchArgBase {
12877 fn from(subtype: RelocationBatchArg) -> Self {
12878 Self {
12879 entries: subtype.entries,
12880 autorename: subtype.autorename,
12881 }
12882 }
12883}
12884#[derive(Debug, Clone, PartialEq, Eq)]
12885#[non_exhaustive] pub struct RelocationBatchArgBase {
12887 pub entries: Vec<RelocationPath>,
12889 pub autorename: bool,
12892}
12893
12894impl RelocationBatchArgBase {
12895 pub fn new(entries: Vec<RelocationPath>) -> Self {
12896 RelocationBatchArgBase {
12897 entries,
12898 autorename: false,
12899 }
12900 }
12901
12902 pub fn with_autorename(mut self, value: bool) -> Self {
12903 self.autorename = value;
12904 self
12905 }
12906}
12907
12908const RELOCATION_BATCH_ARG_BASE_FIELDS: &[&str] = &["entries",
12909 "autorename"];
12910impl RelocationBatchArgBase {
12911 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
12912 map: V,
12913 ) -> Result<RelocationBatchArgBase, V::Error> {
12914 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
12915 }
12916
12917 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
12918 mut map: V,
12919 optional: bool,
12920 ) -> Result<Option<RelocationBatchArgBase>, V::Error> {
12921 let mut field_entries = None;
12922 let mut field_autorename = None;
12923 let mut nothing = true;
12924 while let Some(key) = map.next_key::<&str>()? {
12925 nothing = false;
12926 match key {
12927 "entries" => {
12928 if field_entries.is_some() {
12929 return Err(::serde::de::Error::duplicate_field("entries"));
12930 }
12931 field_entries = Some(map.next_value()?);
12932 }
12933 "autorename" => {
12934 if field_autorename.is_some() {
12935 return Err(::serde::de::Error::duplicate_field("autorename"));
12936 }
12937 field_autorename = Some(map.next_value()?);
12938 }
12939 _ => {
12940 map.next_value::<::serde_json::Value>()?;
12942 }
12943 }
12944 }
12945 if optional && nothing {
12946 return Ok(None);
12947 }
12948 let result = RelocationBatchArgBase {
12949 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
12950 autorename: field_autorename.unwrap_or(false),
12951 };
12952 Ok(Some(result))
12953 }
12954
12955 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
12956 &self,
12957 s: &mut S::SerializeStruct,
12958 ) -> Result<(), S::Error> {
12959 use serde::ser::SerializeStruct;
12960 s.serialize_field("entries", &self.entries)?;
12961 if self.autorename {
12962 s.serialize_field("autorename", &self.autorename)?;
12963 }
12964 Ok(())
12965 }
12966}
12967
12968impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchArgBase {
12969 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
12970 use serde::de::{MapAccess, Visitor};
12972 struct StructVisitor;
12973 impl<'de> Visitor<'de> for StructVisitor {
12974 type Value = RelocationBatchArgBase;
12975 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
12976 f.write_str("a RelocationBatchArgBase struct")
12977 }
12978 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
12979 RelocationBatchArgBase::internal_deserialize(map)
12980 }
12981 }
12982 deserializer.deserialize_struct("RelocationBatchArgBase", RELOCATION_BATCH_ARG_BASE_FIELDS, StructVisitor)
12983 }
12984}
12985
12986impl ::serde::ser::Serialize for RelocationBatchArgBase {
12987 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
12988 use serde::ser::SerializeStruct;
12990 let mut s = serializer.serialize_struct("RelocationBatchArgBase", 2)?;
12991 self.internal_serialize::<S>(&mut s)?;
12992 s.end()
12993 }
12994}
12995
12996#[derive(Debug, Clone, PartialEq, Eq)]
12997#[non_exhaustive] pub enum RelocationBatchError {
12999 FromLookup(LookupError),
13000 FromWrite(WriteError),
13001 To(WriteError),
13002 CantCopySharedFolder,
13004 CantNestSharedFolder,
13006 CantMoveFolderIntoItself,
13008 TooManyFiles,
13010 DuplicatedOrNestedPaths,
13013 CantTransferOwnership,
13016 InsufficientQuota,
13018 InternalError,
13021 CantMoveSharedFolder,
13023 CantMoveIntoVault(MoveIntoVaultError),
13025 CantMoveIntoFamily(MoveIntoFamilyError),
13028 TooManyWriteOperations,
13030 Other,
13033}
13034
13035impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchError {
13036 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13037 use serde::de::{self, MapAccess, Visitor};
13039 struct EnumVisitor;
13040 impl<'de> Visitor<'de> for EnumVisitor {
13041 type Value = RelocationBatchError;
13042 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13043 f.write_str("a RelocationBatchError structure")
13044 }
13045 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13046 let tag: &str = match map.next_key()? {
13047 Some(".tag") => map.next_value()?,
13048 _ => return Err(de::Error::missing_field(".tag"))
13049 };
13050 let value = match tag {
13051 "from_lookup" => {
13052 match map.next_key()? {
13053 Some("from_lookup") => RelocationBatchError::FromLookup(map.next_value()?),
13054 None => return Err(de::Error::missing_field("from_lookup")),
13055 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13056 }
13057 }
13058 "from_write" => {
13059 match map.next_key()? {
13060 Some("from_write") => RelocationBatchError::FromWrite(map.next_value()?),
13061 None => return Err(de::Error::missing_field("from_write")),
13062 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13063 }
13064 }
13065 "to" => {
13066 match map.next_key()? {
13067 Some("to") => RelocationBatchError::To(map.next_value()?),
13068 None => return Err(de::Error::missing_field("to")),
13069 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13070 }
13071 }
13072 "cant_copy_shared_folder" => RelocationBatchError::CantCopySharedFolder,
13073 "cant_nest_shared_folder" => RelocationBatchError::CantNestSharedFolder,
13074 "cant_move_folder_into_itself" => RelocationBatchError::CantMoveFolderIntoItself,
13075 "too_many_files" => RelocationBatchError::TooManyFiles,
13076 "duplicated_or_nested_paths" => RelocationBatchError::DuplicatedOrNestedPaths,
13077 "cant_transfer_ownership" => RelocationBatchError::CantTransferOwnership,
13078 "insufficient_quota" => RelocationBatchError::InsufficientQuota,
13079 "internal_error" => RelocationBatchError::InternalError,
13080 "cant_move_shared_folder" => RelocationBatchError::CantMoveSharedFolder,
13081 "cant_move_into_vault" => {
13082 match map.next_key()? {
13083 Some("cant_move_into_vault") => RelocationBatchError::CantMoveIntoVault(map.next_value()?),
13084 None => return Err(de::Error::missing_field("cant_move_into_vault")),
13085 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13086 }
13087 }
13088 "cant_move_into_family" => {
13089 match map.next_key()? {
13090 Some("cant_move_into_family") => RelocationBatchError::CantMoveIntoFamily(map.next_value()?),
13091 None => return Err(de::Error::missing_field("cant_move_into_family")),
13092 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13093 }
13094 }
13095 "too_many_write_operations" => RelocationBatchError::TooManyWriteOperations,
13096 _ => RelocationBatchError::Other,
13097 };
13098 crate::eat_json_fields(&mut map)?;
13099 Ok(value)
13100 }
13101 }
13102 const VARIANTS: &[&str] = &["from_lookup",
13103 "from_write",
13104 "to",
13105 "cant_copy_shared_folder",
13106 "cant_nest_shared_folder",
13107 "cant_move_folder_into_itself",
13108 "too_many_files",
13109 "duplicated_or_nested_paths",
13110 "cant_transfer_ownership",
13111 "insufficient_quota",
13112 "internal_error",
13113 "cant_move_shared_folder",
13114 "cant_move_into_vault",
13115 "cant_move_into_family",
13116 "other",
13117 "too_many_write_operations"];
13118 deserializer.deserialize_struct("RelocationBatchError", VARIANTS, EnumVisitor)
13119 }
13120}
13121
13122impl ::serde::ser::Serialize for RelocationBatchError {
13123 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13124 use serde::ser::SerializeStruct;
13126 match self {
13127 RelocationBatchError::FromLookup(x) => {
13128 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13130 s.serialize_field(".tag", "from_lookup")?;
13131 s.serialize_field("from_lookup", x)?;
13132 s.end()
13133 }
13134 RelocationBatchError::FromWrite(x) => {
13135 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13137 s.serialize_field(".tag", "from_write")?;
13138 s.serialize_field("from_write", x)?;
13139 s.end()
13140 }
13141 RelocationBatchError::To(x) => {
13142 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13144 s.serialize_field(".tag", "to")?;
13145 s.serialize_field("to", x)?;
13146 s.end()
13147 }
13148 RelocationBatchError::CantCopySharedFolder => {
13149 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13151 s.serialize_field(".tag", "cant_copy_shared_folder")?;
13152 s.end()
13153 }
13154 RelocationBatchError::CantNestSharedFolder => {
13155 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13157 s.serialize_field(".tag", "cant_nest_shared_folder")?;
13158 s.end()
13159 }
13160 RelocationBatchError::CantMoveFolderIntoItself => {
13161 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13163 s.serialize_field(".tag", "cant_move_folder_into_itself")?;
13164 s.end()
13165 }
13166 RelocationBatchError::TooManyFiles => {
13167 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13169 s.serialize_field(".tag", "too_many_files")?;
13170 s.end()
13171 }
13172 RelocationBatchError::DuplicatedOrNestedPaths => {
13173 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13175 s.serialize_field(".tag", "duplicated_or_nested_paths")?;
13176 s.end()
13177 }
13178 RelocationBatchError::CantTransferOwnership => {
13179 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13181 s.serialize_field(".tag", "cant_transfer_ownership")?;
13182 s.end()
13183 }
13184 RelocationBatchError::InsufficientQuota => {
13185 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13187 s.serialize_field(".tag", "insufficient_quota")?;
13188 s.end()
13189 }
13190 RelocationBatchError::InternalError => {
13191 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13193 s.serialize_field(".tag", "internal_error")?;
13194 s.end()
13195 }
13196 RelocationBatchError::CantMoveSharedFolder => {
13197 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13199 s.serialize_field(".tag", "cant_move_shared_folder")?;
13200 s.end()
13201 }
13202 RelocationBatchError::CantMoveIntoVault(x) => {
13203 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13205 s.serialize_field(".tag", "cant_move_into_vault")?;
13206 s.serialize_field("cant_move_into_vault", x)?;
13207 s.end()
13208 }
13209 RelocationBatchError::CantMoveIntoFamily(x) => {
13210 let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
13212 s.serialize_field(".tag", "cant_move_into_family")?;
13213 s.serialize_field("cant_move_into_family", x)?;
13214 s.end()
13215 }
13216 RelocationBatchError::TooManyWriteOperations => {
13217 let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
13219 s.serialize_field(".tag", "too_many_write_operations")?;
13220 s.end()
13221 }
13222 RelocationBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13223 }
13224 }
13225}
13226
13227impl ::std::error::Error for RelocationBatchError {
13228 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
13229 match self {
13230 RelocationBatchError::FromLookup(inner) => Some(inner),
13231 RelocationBatchError::FromWrite(inner) => Some(inner),
13232 RelocationBatchError::To(inner) => Some(inner),
13233 RelocationBatchError::CantMoveIntoVault(inner) => Some(inner),
13234 RelocationBatchError::CantMoveIntoFamily(inner) => Some(inner),
13235 _ => None,
13236 }
13237 }
13238}
13239
13240impl ::std::fmt::Display for RelocationBatchError {
13241 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13242 match self {
13243 RelocationBatchError::FromLookup(inner) => write!(f, "RelocationBatchError: {}", inner),
13244 RelocationBatchError::FromWrite(inner) => write!(f, "RelocationBatchError: {}", inner),
13245 RelocationBatchError::To(inner) => write!(f, "RelocationBatchError: {}", inner),
13246 RelocationBatchError::CantCopySharedFolder => f.write_str("Shared folders can't be copied."),
13247 RelocationBatchError::CantNestSharedFolder => f.write_str("Your move operation would result in nested shared folders. This is not allowed."),
13248 RelocationBatchError::CantMoveFolderIntoItself => f.write_str("You cannot move a folder into itself."),
13249 RelocationBatchError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
13250 RelocationBatchError::InsufficientQuota => f.write_str("The current user does not have enough space to move or copy the files."),
13251 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."),
13252 RelocationBatchError::CantMoveSharedFolder => f.write_str("Can't move the shared folder to the given destination."),
13253 RelocationBatchError::CantMoveIntoVault(inner) => write!(f, "Some content cannot be moved into Vault under certain circumstances, see detailed error: {}", inner),
13254 RelocationBatchError::CantMoveIntoFamily(inner) => write!(f, "Some content cannot be moved into the Family Room folder under certain circumstances, see detailed error: {}", inner),
13255 RelocationBatchError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
13256 _ => write!(f, "{:?}", *self),
13257 }
13258 }
13259}
13260
13261impl From<RelocationError> for RelocationBatchError {
13263 fn from(parent: RelocationError) -> Self {
13264 match parent {
13265 RelocationError::FromLookup(x) => RelocationBatchError::FromLookup(x),
13266 RelocationError::FromWrite(x) => RelocationBatchError::FromWrite(x),
13267 RelocationError::To(x) => RelocationBatchError::To(x),
13268 RelocationError::CantCopySharedFolder => RelocationBatchError::CantCopySharedFolder,
13269 RelocationError::CantNestSharedFolder => RelocationBatchError::CantNestSharedFolder,
13270 RelocationError::CantMoveFolderIntoItself => RelocationBatchError::CantMoveFolderIntoItself,
13271 RelocationError::TooManyFiles => RelocationBatchError::TooManyFiles,
13272 RelocationError::DuplicatedOrNestedPaths => RelocationBatchError::DuplicatedOrNestedPaths,
13273 RelocationError::CantTransferOwnership => RelocationBatchError::CantTransferOwnership,
13274 RelocationError::InsufficientQuota => RelocationBatchError::InsufficientQuota,
13275 RelocationError::InternalError => RelocationBatchError::InternalError,
13276 RelocationError::CantMoveSharedFolder => RelocationBatchError::CantMoveSharedFolder,
13277 RelocationError::CantMoveIntoVault(x) => RelocationBatchError::CantMoveIntoVault(x),
13278 RelocationError::CantMoveIntoFamily(x) => RelocationBatchError::CantMoveIntoFamily(x),
13279 RelocationError::Other => RelocationBatchError::Other,
13280 }
13281 }
13282}
13283#[derive(Debug, Clone, PartialEq, Eq)]
13284#[non_exhaustive] pub enum RelocationBatchErrorEntry {
13286 RelocationError(RelocationError),
13288 InternalError,
13291 TooManyWriteOperations,
13293 Other,
13296}
13297
13298impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchErrorEntry {
13299 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13300 use serde::de::{self, MapAccess, Visitor};
13302 struct EnumVisitor;
13303 impl<'de> Visitor<'de> for EnumVisitor {
13304 type Value = RelocationBatchErrorEntry;
13305 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13306 f.write_str("a RelocationBatchErrorEntry structure")
13307 }
13308 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13309 let tag: &str = match map.next_key()? {
13310 Some(".tag") => map.next_value()?,
13311 _ => return Err(de::Error::missing_field(".tag"))
13312 };
13313 let value = match tag {
13314 "relocation_error" => {
13315 match map.next_key()? {
13316 Some("relocation_error") => RelocationBatchErrorEntry::RelocationError(map.next_value()?),
13317 None => return Err(de::Error::missing_field("relocation_error")),
13318 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13319 }
13320 }
13321 "internal_error" => RelocationBatchErrorEntry::InternalError,
13322 "too_many_write_operations" => RelocationBatchErrorEntry::TooManyWriteOperations,
13323 _ => RelocationBatchErrorEntry::Other,
13324 };
13325 crate::eat_json_fields(&mut map)?;
13326 Ok(value)
13327 }
13328 }
13329 const VARIANTS: &[&str] = &["relocation_error",
13330 "internal_error",
13331 "too_many_write_operations",
13332 "other"];
13333 deserializer.deserialize_struct("RelocationBatchErrorEntry", VARIANTS, EnumVisitor)
13334 }
13335}
13336
13337impl ::serde::ser::Serialize for RelocationBatchErrorEntry {
13338 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13339 use serde::ser::SerializeStruct;
13341 match self {
13342 RelocationBatchErrorEntry::RelocationError(x) => {
13343 let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 2)?;
13345 s.serialize_field(".tag", "relocation_error")?;
13346 s.serialize_field("relocation_error", x)?;
13347 s.end()
13348 }
13349 RelocationBatchErrorEntry::InternalError => {
13350 let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 1)?;
13352 s.serialize_field(".tag", "internal_error")?;
13353 s.end()
13354 }
13355 RelocationBatchErrorEntry::TooManyWriteOperations => {
13356 let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 1)?;
13358 s.serialize_field(".tag", "too_many_write_operations")?;
13359 s.end()
13360 }
13361 RelocationBatchErrorEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13362 }
13363 }
13364}
13365
13366#[derive(Debug, Clone, PartialEq)]
13367pub enum RelocationBatchJobStatus {
13368 InProgress,
13370 Complete(RelocationBatchResult),
13372 Failed(RelocationBatchError),
13374}
13375
13376impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchJobStatus {
13377 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13378 use serde::de::{self, MapAccess, Visitor};
13380 struct EnumVisitor;
13381 impl<'de> Visitor<'de> for EnumVisitor {
13382 type Value = RelocationBatchJobStatus;
13383 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13384 f.write_str("a RelocationBatchJobStatus structure")
13385 }
13386 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13387 let tag: &str = match map.next_key()? {
13388 Some(".tag") => map.next_value()?,
13389 _ => return Err(de::Error::missing_field(".tag"))
13390 };
13391 let value = match tag {
13392 "in_progress" => RelocationBatchJobStatus::InProgress,
13393 "complete" => RelocationBatchJobStatus::Complete(RelocationBatchResult::internal_deserialize(&mut map)?),
13394 "failed" => {
13395 match map.next_key()? {
13396 Some("failed") => RelocationBatchJobStatus::Failed(map.next_value()?),
13397 None => return Err(de::Error::missing_field("failed")),
13398 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13399 }
13400 }
13401 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
13402 };
13403 crate::eat_json_fields(&mut map)?;
13404 Ok(value)
13405 }
13406 }
13407 const VARIANTS: &[&str] = &["in_progress",
13408 "complete",
13409 "failed"];
13410 deserializer.deserialize_struct("RelocationBatchJobStatus", VARIANTS, EnumVisitor)
13411 }
13412}
13413
13414impl ::serde::ser::Serialize for RelocationBatchJobStatus {
13415 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13416 use serde::ser::SerializeStruct;
13418 match self {
13419 RelocationBatchJobStatus::InProgress => {
13420 let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 1)?;
13422 s.serialize_field(".tag", "in_progress")?;
13423 s.end()
13424 }
13425 RelocationBatchJobStatus::Complete(x) => {
13426 let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 2)?;
13428 s.serialize_field(".tag", "complete")?;
13429 x.internal_serialize::<S>(&mut s)?;
13430 s.end()
13431 }
13432 RelocationBatchJobStatus::Failed(x) => {
13433 let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 2)?;
13435 s.serialize_field(".tag", "failed")?;
13436 s.serialize_field("failed", x)?;
13437 s.end()
13438 }
13439 }
13440 }
13441}
13442
13443impl From<crate::types::dbx_async::PollResultBase> for RelocationBatchJobStatus {
13445 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
13446 match parent {
13447 crate::types::dbx_async::PollResultBase::InProgress => RelocationBatchJobStatus::InProgress,
13448 }
13449 }
13450}
13451#[derive(Debug, Clone, PartialEq)]
13455#[non_exhaustive] pub enum RelocationBatchLaunch {
13457 AsyncJobId(crate::types::dbx_async::AsyncJobId),
13460 Complete(RelocationBatchResult),
13461 Other,
13464}
13465
13466impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchLaunch {
13467 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13468 use serde::de::{self, MapAccess, Visitor};
13470 struct EnumVisitor;
13471 impl<'de> Visitor<'de> for EnumVisitor {
13472 type Value = RelocationBatchLaunch;
13473 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13474 f.write_str("a RelocationBatchLaunch structure")
13475 }
13476 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13477 let tag: &str = match map.next_key()? {
13478 Some(".tag") => map.next_value()?,
13479 _ => return Err(de::Error::missing_field(".tag"))
13480 };
13481 let value = match tag {
13482 "async_job_id" => {
13483 match map.next_key()? {
13484 Some("async_job_id") => RelocationBatchLaunch::AsyncJobId(map.next_value()?),
13485 None => return Err(de::Error::missing_field("async_job_id")),
13486 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13487 }
13488 }
13489 "complete" => RelocationBatchLaunch::Complete(RelocationBatchResult::internal_deserialize(&mut map)?),
13490 _ => RelocationBatchLaunch::Other,
13491 };
13492 crate::eat_json_fields(&mut map)?;
13493 Ok(value)
13494 }
13495 }
13496 const VARIANTS: &[&str] = &["async_job_id",
13497 "complete",
13498 "other"];
13499 deserializer.deserialize_struct("RelocationBatchLaunch", VARIANTS, EnumVisitor)
13500 }
13501}
13502
13503impl ::serde::ser::Serialize for RelocationBatchLaunch {
13504 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13505 use serde::ser::SerializeStruct;
13507 match self {
13508 RelocationBatchLaunch::AsyncJobId(x) => {
13509 let mut s = serializer.serialize_struct("RelocationBatchLaunch", 2)?;
13511 s.serialize_field(".tag", "async_job_id")?;
13512 s.serialize_field("async_job_id", x)?;
13513 s.end()
13514 }
13515 RelocationBatchLaunch::Complete(x) => {
13516 let mut s = serializer.serialize_struct("RelocationBatchLaunch", 2)?;
13518 s.serialize_field(".tag", "complete")?;
13519 x.internal_serialize::<S>(&mut s)?;
13520 s.end()
13521 }
13522 RelocationBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13523 }
13524 }
13525}
13526
13527impl From<crate::types::dbx_async::LaunchResultBase> for RelocationBatchLaunch {
13529 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
13530 match parent {
13531 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => RelocationBatchLaunch::AsyncJobId(x),
13532 }
13533 }
13534}
13535#[derive(Debug, Clone, PartialEq)]
13536#[non_exhaustive] pub struct RelocationBatchResult {
13538 pub entries: Vec<RelocationBatchResultData>,
13539}
13540
13541impl RelocationBatchResult {
13542 pub fn new(entries: Vec<RelocationBatchResultData>) -> Self {
13543 RelocationBatchResult {
13544 entries,
13545 }
13546 }
13547}
13548
13549const RELOCATION_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
13550impl RelocationBatchResult {
13551 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
13552 map: V,
13553 ) -> Result<RelocationBatchResult, V::Error> {
13554 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
13555 }
13556
13557 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
13558 mut map: V,
13559 optional: bool,
13560 ) -> Result<Option<RelocationBatchResult>, V::Error> {
13561 let mut field_entries = None;
13562 let mut nothing = true;
13563 while let Some(key) = map.next_key::<&str>()? {
13564 nothing = false;
13565 match key {
13566 "entries" => {
13567 if field_entries.is_some() {
13568 return Err(::serde::de::Error::duplicate_field("entries"));
13569 }
13570 field_entries = Some(map.next_value()?);
13571 }
13572 _ => {
13573 map.next_value::<::serde_json::Value>()?;
13575 }
13576 }
13577 }
13578 if optional && nothing {
13579 return Ok(None);
13580 }
13581 let result = RelocationBatchResult {
13582 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
13583 };
13584 Ok(Some(result))
13585 }
13586
13587 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
13588 &self,
13589 s: &mut S::SerializeStruct,
13590 ) -> Result<(), S::Error> {
13591 use serde::ser::SerializeStruct;
13592 s.serialize_field("entries", &self.entries)?;
13593 Ok(())
13594 }
13595}
13596
13597impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResult {
13598 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13599 use serde::de::{MapAccess, Visitor};
13601 struct StructVisitor;
13602 impl<'de> Visitor<'de> for StructVisitor {
13603 type Value = RelocationBatchResult;
13604 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13605 f.write_str("a RelocationBatchResult struct")
13606 }
13607 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
13608 RelocationBatchResult::internal_deserialize(map)
13609 }
13610 }
13611 deserializer.deserialize_struct("RelocationBatchResult", RELOCATION_BATCH_RESULT_FIELDS, StructVisitor)
13612 }
13613}
13614
13615impl ::serde::ser::Serialize for RelocationBatchResult {
13616 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13617 use serde::ser::SerializeStruct;
13619 let mut s = serializer.serialize_struct("RelocationBatchResult", 1)?;
13620 self.internal_serialize::<S>(&mut s)?;
13621 s.end()
13622 }
13623}
13624
13625impl From<RelocationBatchResult> for FileOpsResult {
13627 fn from(_: RelocationBatchResult) -> Self {
13628 Self {}
13629 }
13630}
13631#[derive(Debug, Clone, PartialEq)]
13632#[non_exhaustive] pub struct RelocationBatchResultData {
13634 pub metadata: Metadata,
13636}
13637
13638impl RelocationBatchResultData {
13639 pub fn new(metadata: Metadata) -> Self {
13640 RelocationBatchResultData {
13641 metadata,
13642 }
13643 }
13644}
13645
13646const RELOCATION_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata"];
13647impl RelocationBatchResultData {
13648 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
13649 map: V,
13650 ) -> Result<RelocationBatchResultData, V::Error> {
13651 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
13652 }
13653
13654 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
13655 mut map: V,
13656 optional: bool,
13657 ) -> Result<Option<RelocationBatchResultData>, V::Error> {
13658 let mut field_metadata = None;
13659 let mut nothing = true;
13660 while let Some(key) = map.next_key::<&str>()? {
13661 nothing = false;
13662 match key {
13663 "metadata" => {
13664 if field_metadata.is_some() {
13665 return Err(::serde::de::Error::duplicate_field("metadata"));
13666 }
13667 field_metadata = Some(map.next_value()?);
13668 }
13669 _ => {
13670 map.next_value::<::serde_json::Value>()?;
13672 }
13673 }
13674 }
13675 if optional && nothing {
13676 return Ok(None);
13677 }
13678 let result = RelocationBatchResultData {
13679 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
13680 };
13681 Ok(Some(result))
13682 }
13683
13684 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
13685 &self,
13686 s: &mut S::SerializeStruct,
13687 ) -> Result<(), S::Error> {
13688 use serde::ser::SerializeStruct;
13689 s.serialize_field("metadata", &self.metadata)?;
13690 Ok(())
13691 }
13692}
13693
13694impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResultData {
13695 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13696 use serde::de::{MapAccess, Visitor};
13698 struct StructVisitor;
13699 impl<'de> Visitor<'de> for StructVisitor {
13700 type Value = RelocationBatchResultData;
13701 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13702 f.write_str("a RelocationBatchResultData struct")
13703 }
13704 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
13705 RelocationBatchResultData::internal_deserialize(map)
13706 }
13707 }
13708 deserializer.deserialize_struct("RelocationBatchResultData", RELOCATION_BATCH_RESULT_DATA_FIELDS, StructVisitor)
13709 }
13710}
13711
13712impl ::serde::ser::Serialize for RelocationBatchResultData {
13713 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13714 use serde::ser::SerializeStruct;
13716 let mut s = serializer.serialize_struct("RelocationBatchResultData", 1)?;
13717 self.internal_serialize::<S>(&mut s)?;
13718 s.end()
13719 }
13720}
13721
13722#[derive(Debug, Clone, PartialEq)]
13723#[non_exhaustive] pub enum RelocationBatchResultEntry {
13725 Success(Metadata),
13726 Failure(RelocationBatchErrorEntry),
13727 Other,
13730}
13731
13732impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResultEntry {
13733 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13734 use serde::de::{self, MapAccess, Visitor};
13736 struct EnumVisitor;
13737 impl<'de> Visitor<'de> for EnumVisitor {
13738 type Value = RelocationBatchResultEntry;
13739 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13740 f.write_str("a RelocationBatchResultEntry structure")
13741 }
13742 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13743 let tag: &str = match map.next_key()? {
13744 Some(".tag") => map.next_value()?,
13745 _ => return Err(de::Error::missing_field(".tag"))
13746 };
13747 let value = match tag {
13748 "success" => {
13749 match map.next_key()? {
13750 Some("success") => RelocationBatchResultEntry::Success(map.next_value()?),
13751 None => return Err(de::Error::missing_field("success")),
13752 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13753 }
13754 }
13755 "failure" => {
13756 match map.next_key()? {
13757 Some("failure") => RelocationBatchResultEntry::Failure(map.next_value()?),
13758 None => return Err(de::Error::missing_field("failure")),
13759 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13760 }
13761 }
13762 _ => RelocationBatchResultEntry::Other,
13763 };
13764 crate::eat_json_fields(&mut map)?;
13765 Ok(value)
13766 }
13767 }
13768 const VARIANTS: &[&str] = &["success",
13769 "failure",
13770 "other"];
13771 deserializer.deserialize_struct("RelocationBatchResultEntry", VARIANTS, EnumVisitor)
13772 }
13773}
13774
13775impl ::serde::ser::Serialize for RelocationBatchResultEntry {
13776 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13777 use serde::ser::SerializeStruct;
13779 match self {
13780 RelocationBatchResultEntry::Success(x) => {
13781 let mut s = serializer.serialize_struct("RelocationBatchResultEntry", 2)?;
13783 s.serialize_field(".tag", "success")?;
13784 s.serialize_field("success", x)?;
13785 s.end()
13786 }
13787 RelocationBatchResultEntry::Failure(x) => {
13788 let mut s = serializer.serialize_struct("RelocationBatchResultEntry", 2)?;
13790 s.serialize_field(".tag", "failure")?;
13791 s.serialize_field("failure", x)?;
13792 s.end()
13793 }
13794 RelocationBatchResultEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
13795 }
13796 }
13797}
13798
13799#[derive(Debug, Clone, PartialEq)]
13803pub enum RelocationBatchV2JobStatus {
13804 InProgress,
13806 Complete(RelocationBatchV2Result),
13808}
13809
13810impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2JobStatus {
13811 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13812 use serde::de::{self, MapAccess, Visitor};
13814 struct EnumVisitor;
13815 impl<'de> Visitor<'de> for EnumVisitor {
13816 type Value = RelocationBatchV2JobStatus;
13817 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13818 f.write_str("a RelocationBatchV2JobStatus structure")
13819 }
13820 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13821 let tag: &str = match map.next_key()? {
13822 Some(".tag") => map.next_value()?,
13823 _ => return Err(de::Error::missing_field(".tag"))
13824 };
13825 let value = match tag {
13826 "in_progress" => RelocationBatchV2JobStatus::InProgress,
13827 "complete" => RelocationBatchV2JobStatus::Complete(RelocationBatchV2Result::internal_deserialize(&mut map)?),
13828 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
13829 };
13830 crate::eat_json_fields(&mut map)?;
13831 Ok(value)
13832 }
13833 }
13834 const VARIANTS: &[&str] = &["in_progress",
13835 "complete"];
13836 deserializer.deserialize_struct("RelocationBatchV2JobStatus", VARIANTS, EnumVisitor)
13837 }
13838}
13839
13840impl ::serde::ser::Serialize for RelocationBatchV2JobStatus {
13841 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13842 use serde::ser::SerializeStruct;
13844 match self {
13845 RelocationBatchV2JobStatus::InProgress => {
13846 let mut s = serializer.serialize_struct("RelocationBatchV2JobStatus", 1)?;
13848 s.serialize_field(".tag", "in_progress")?;
13849 s.end()
13850 }
13851 RelocationBatchV2JobStatus::Complete(x) => {
13852 let mut s = serializer.serialize_struct("RelocationBatchV2JobStatus", 2)?;
13854 s.serialize_field(".tag", "complete")?;
13855 x.internal_serialize::<S>(&mut s)?;
13856 s.end()
13857 }
13858 }
13859 }
13860}
13861
13862impl From<crate::types::dbx_async::PollResultBase> for RelocationBatchV2JobStatus {
13864 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
13865 match parent {
13866 crate::types::dbx_async::PollResultBase::InProgress => RelocationBatchV2JobStatus::InProgress,
13867 }
13868 }
13869}
13870#[derive(Debug, Clone, PartialEq)]
13874pub enum RelocationBatchV2Launch {
13875 AsyncJobId(crate::types::dbx_async::AsyncJobId),
13878 Complete(RelocationBatchV2Result),
13879}
13880
13881impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2Launch {
13882 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
13883 use serde::de::{self, MapAccess, Visitor};
13885 struct EnumVisitor;
13886 impl<'de> Visitor<'de> for EnumVisitor {
13887 type Value = RelocationBatchV2Launch;
13888 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
13889 f.write_str("a RelocationBatchV2Launch structure")
13890 }
13891 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
13892 let tag: &str = match map.next_key()? {
13893 Some(".tag") => map.next_value()?,
13894 _ => return Err(de::Error::missing_field(".tag"))
13895 };
13896 let value = match tag {
13897 "async_job_id" => {
13898 match map.next_key()? {
13899 Some("async_job_id") => RelocationBatchV2Launch::AsyncJobId(map.next_value()?),
13900 None => return Err(de::Error::missing_field("async_job_id")),
13901 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
13902 }
13903 }
13904 "complete" => RelocationBatchV2Launch::Complete(RelocationBatchV2Result::internal_deserialize(&mut map)?),
13905 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
13906 };
13907 crate::eat_json_fields(&mut map)?;
13908 Ok(value)
13909 }
13910 }
13911 const VARIANTS: &[&str] = &["async_job_id",
13912 "complete"];
13913 deserializer.deserialize_struct("RelocationBatchV2Launch", VARIANTS, EnumVisitor)
13914 }
13915}
13916
13917impl ::serde::ser::Serialize for RelocationBatchV2Launch {
13918 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
13919 use serde::ser::SerializeStruct;
13921 match self {
13922 RelocationBatchV2Launch::AsyncJobId(x) => {
13923 let mut s = serializer.serialize_struct("RelocationBatchV2Launch", 2)?;
13925 s.serialize_field(".tag", "async_job_id")?;
13926 s.serialize_field("async_job_id", x)?;
13927 s.end()
13928 }
13929 RelocationBatchV2Launch::Complete(x) => {
13930 let mut s = serializer.serialize_struct("RelocationBatchV2Launch", 2)?;
13932 s.serialize_field(".tag", "complete")?;
13933 x.internal_serialize::<S>(&mut s)?;
13934 s.end()
13935 }
13936 }
13937 }
13938}
13939
13940impl From<crate::types::dbx_async::LaunchResultBase> for RelocationBatchV2Launch {
13942 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
13943 match parent {
13944 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => RelocationBatchV2Launch::AsyncJobId(x),
13945 }
13946 }
13947}
13948#[derive(Debug, Clone, PartialEq)]
13949#[non_exhaustive] pub struct RelocationBatchV2Result {
13951 pub entries: Vec<RelocationBatchResultEntry>,
13954}
13955
13956impl RelocationBatchV2Result {
13957 pub fn new(entries: Vec<RelocationBatchResultEntry>) -> Self {
13958 RelocationBatchV2Result {
13959 entries,
13960 }
13961 }
13962}
13963
13964const RELOCATION_BATCH_V2_RESULT_FIELDS: &[&str] = &["entries"];
13965impl RelocationBatchV2Result {
13966 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
13967 map: V,
13968 ) -> Result<RelocationBatchV2Result, V::Error> {
13969 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
13970 }
13971
13972 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
13973 mut map: V,
13974 optional: bool,
13975 ) -> Result<Option<RelocationBatchV2Result>, V::Error> {
13976 let mut field_entries = None;
13977 let mut nothing = true;
13978 while let Some(key) = map.next_key::<&str>()? {
13979 nothing = false;
13980 match key {
13981 "entries" => {
13982 if field_entries.is_some() {
13983 return Err(::serde::de::Error::duplicate_field("entries"));
13984 }
13985 field_entries = Some(map.next_value()?);
13986 }
13987 _ => {
13988 map.next_value::<::serde_json::Value>()?;
13990 }
13991 }
13992 }
13993 if optional && nothing {
13994 return Ok(None);
13995 }
13996 let result = RelocationBatchV2Result {
13997 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
13998 };
13999 Ok(Some(result))
14000 }
14001
14002 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14003 &self,
14004 s: &mut S::SerializeStruct,
14005 ) -> Result<(), S::Error> {
14006 use serde::ser::SerializeStruct;
14007 s.serialize_field("entries", &self.entries)?;
14008 Ok(())
14009 }
14010}
14011
14012impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2Result {
14013 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14014 use serde::de::{MapAccess, Visitor};
14016 struct StructVisitor;
14017 impl<'de> Visitor<'de> for StructVisitor {
14018 type Value = RelocationBatchV2Result;
14019 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14020 f.write_str("a RelocationBatchV2Result struct")
14021 }
14022 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14023 RelocationBatchV2Result::internal_deserialize(map)
14024 }
14025 }
14026 deserializer.deserialize_struct("RelocationBatchV2Result", RELOCATION_BATCH_V2_RESULT_FIELDS, StructVisitor)
14027 }
14028}
14029
14030impl ::serde::ser::Serialize for RelocationBatchV2Result {
14031 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14032 use serde::ser::SerializeStruct;
14034 let mut s = serializer.serialize_struct("RelocationBatchV2Result", 1)?;
14035 self.internal_serialize::<S>(&mut s)?;
14036 s.end()
14037 }
14038}
14039
14040impl From<RelocationBatchV2Result> for FileOpsResult {
14042 fn from(_: RelocationBatchV2Result) -> Self {
14043 Self {}
14044 }
14045}
14046#[derive(Debug, Clone, PartialEq, Eq)]
14047#[non_exhaustive] pub enum RelocationError {
14049 FromLookup(LookupError),
14050 FromWrite(WriteError),
14051 To(WriteError),
14052 CantCopySharedFolder,
14054 CantNestSharedFolder,
14056 CantMoveFolderIntoItself,
14058 TooManyFiles,
14060 DuplicatedOrNestedPaths,
14063 CantTransferOwnership,
14066 InsufficientQuota,
14068 InternalError,
14071 CantMoveSharedFolder,
14073 CantMoveIntoVault(MoveIntoVaultError),
14075 CantMoveIntoFamily(MoveIntoFamilyError),
14078 Other,
14081}
14082
14083impl<'de> ::serde::de::Deserialize<'de> for RelocationError {
14084 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14085 use serde::de::{self, MapAccess, Visitor};
14087 struct EnumVisitor;
14088 impl<'de> Visitor<'de> for EnumVisitor {
14089 type Value = RelocationError;
14090 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14091 f.write_str("a RelocationError structure")
14092 }
14093 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
14094 let tag: &str = match map.next_key()? {
14095 Some(".tag") => map.next_value()?,
14096 _ => return Err(de::Error::missing_field(".tag"))
14097 };
14098 let value = match tag {
14099 "from_lookup" => {
14100 match map.next_key()? {
14101 Some("from_lookup") => RelocationError::FromLookup(map.next_value()?),
14102 None => return Err(de::Error::missing_field("from_lookup")),
14103 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14104 }
14105 }
14106 "from_write" => {
14107 match map.next_key()? {
14108 Some("from_write") => RelocationError::FromWrite(map.next_value()?),
14109 None => return Err(de::Error::missing_field("from_write")),
14110 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14111 }
14112 }
14113 "to" => {
14114 match map.next_key()? {
14115 Some("to") => RelocationError::To(map.next_value()?),
14116 None => return Err(de::Error::missing_field("to")),
14117 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14118 }
14119 }
14120 "cant_copy_shared_folder" => RelocationError::CantCopySharedFolder,
14121 "cant_nest_shared_folder" => RelocationError::CantNestSharedFolder,
14122 "cant_move_folder_into_itself" => RelocationError::CantMoveFolderIntoItself,
14123 "too_many_files" => RelocationError::TooManyFiles,
14124 "duplicated_or_nested_paths" => RelocationError::DuplicatedOrNestedPaths,
14125 "cant_transfer_ownership" => RelocationError::CantTransferOwnership,
14126 "insufficient_quota" => RelocationError::InsufficientQuota,
14127 "internal_error" => RelocationError::InternalError,
14128 "cant_move_shared_folder" => RelocationError::CantMoveSharedFolder,
14129 "cant_move_into_vault" => {
14130 match map.next_key()? {
14131 Some("cant_move_into_vault") => RelocationError::CantMoveIntoVault(map.next_value()?),
14132 None => return Err(de::Error::missing_field("cant_move_into_vault")),
14133 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14134 }
14135 }
14136 "cant_move_into_family" => {
14137 match map.next_key()? {
14138 Some("cant_move_into_family") => RelocationError::CantMoveIntoFamily(map.next_value()?),
14139 None => return Err(de::Error::missing_field("cant_move_into_family")),
14140 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14141 }
14142 }
14143 _ => RelocationError::Other,
14144 };
14145 crate::eat_json_fields(&mut map)?;
14146 Ok(value)
14147 }
14148 }
14149 const VARIANTS: &[&str] = &["from_lookup",
14150 "from_write",
14151 "to",
14152 "cant_copy_shared_folder",
14153 "cant_nest_shared_folder",
14154 "cant_move_folder_into_itself",
14155 "too_many_files",
14156 "duplicated_or_nested_paths",
14157 "cant_transfer_ownership",
14158 "insufficient_quota",
14159 "internal_error",
14160 "cant_move_shared_folder",
14161 "cant_move_into_vault",
14162 "cant_move_into_family",
14163 "other"];
14164 deserializer.deserialize_struct("RelocationError", VARIANTS, EnumVisitor)
14165 }
14166}
14167
14168impl ::serde::ser::Serialize for RelocationError {
14169 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14170 use serde::ser::SerializeStruct;
14172 match self {
14173 RelocationError::FromLookup(x) => {
14174 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14176 s.serialize_field(".tag", "from_lookup")?;
14177 s.serialize_field("from_lookup", x)?;
14178 s.end()
14179 }
14180 RelocationError::FromWrite(x) => {
14181 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14183 s.serialize_field(".tag", "from_write")?;
14184 s.serialize_field("from_write", x)?;
14185 s.end()
14186 }
14187 RelocationError::To(x) => {
14188 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14190 s.serialize_field(".tag", "to")?;
14191 s.serialize_field("to", x)?;
14192 s.end()
14193 }
14194 RelocationError::CantCopySharedFolder => {
14195 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14197 s.serialize_field(".tag", "cant_copy_shared_folder")?;
14198 s.end()
14199 }
14200 RelocationError::CantNestSharedFolder => {
14201 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14203 s.serialize_field(".tag", "cant_nest_shared_folder")?;
14204 s.end()
14205 }
14206 RelocationError::CantMoveFolderIntoItself => {
14207 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14209 s.serialize_field(".tag", "cant_move_folder_into_itself")?;
14210 s.end()
14211 }
14212 RelocationError::TooManyFiles => {
14213 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14215 s.serialize_field(".tag", "too_many_files")?;
14216 s.end()
14217 }
14218 RelocationError::DuplicatedOrNestedPaths => {
14219 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14221 s.serialize_field(".tag", "duplicated_or_nested_paths")?;
14222 s.end()
14223 }
14224 RelocationError::CantTransferOwnership => {
14225 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14227 s.serialize_field(".tag", "cant_transfer_ownership")?;
14228 s.end()
14229 }
14230 RelocationError::InsufficientQuota => {
14231 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14233 s.serialize_field(".tag", "insufficient_quota")?;
14234 s.end()
14235 }
14236 RelocationError::InternalError => {
14237 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14239 s.serialize_field(".tag", "internal_error")?;
14240 s.end()
14241 }
14242 RelocationError::CantMoveSharedFolder => {
14243 let mut s = serializer.serialize_struct("RelocationError", 1)?;
14245 s.serialize_field(".tag", "cant_move_shared_folder")?;
14246 s.end()
14247 }
14248 RelocationError::CantMoveIntoVault(x) => {
14249 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14251 s.serialize_field(".tag", "cant_move_into_vault")?;
14252 s.serialize_field("cant_move_into_vault", x)?;
14253 s.end()
14254 }
14255 RelocationError::CantMoveIntoFamily(x) => {
14256 let mut s = serializer.serialize_struct("RelocationError", 2)?;
14258 s.serialize_field(".tag", "cant_move_into_family")?;
14259 s.serialize_field("cant_move_into_family", x)?;
14260 s.end()
14261 }
14262 RelocationError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
14263 }
14264 }
14265}
14266
14267impl ::std::error::Error for RelocationError {
14268 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
14269 match self {
14270 RelocationError::FromLookup(inner) => Some(inner),
14271 RelocationError::FromWrite(inner) => Some(inner),
14272 RelocationError::To(inner) => Some(inner),
14273 RelocationError::CantMoveIntoVault(inner) => Some(inner),
14274 RelocationError::CantMoveIntoFamily(inner) => Some(inner),
14275 _ => None,
14276 }
14277 }
14278}
14279
14280impl ::std::fmt::Display for RelocationError {
14281 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14282 match self {
14283 RelocationError::FromLookup(inner) => write!(f, "RelocationError: {}", inner),
14284 RelocationError::FromWrite(inner) => write!(f, "RelocationError: {}", inner),
14285 RelocationError::To(inner) => write!(f, "RelocationError: {}", inner),
14286 RelocationError::CantCopySharedFolder => f.write_str("Shared folders can't be copied."),
14287 RelocationError::CantNestSharedFolder => f.write_str("Your move operation would result in nested shared folders. This is not allowed."),
14288 RelocationError::CantMoveFolderIntoItself => f.write_str("You cannot move a folder into itself."),
14289 RelocationError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
14290 RelocationError::InsufficientQuota => f.write_str("The current user does not have enough space to move or copy the files."),
14291 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."),
14292 RelocationError::CantMoveSharedFolder => f.write_str("Can't move the shared folder to the given destination."),
14293 RelocationError::CantMoveIntoVault(inner) => write!(f, "Some content cannot be moved into Vault under certain circumstances, see detailed error: {}", inner),
14294 RelocationError::CantMoveIntoFamily(inner) => write!(f, "Some content cannot be moved into the Family Room folder under certain circumstances, see detailed error: {}", inner),
14295 _ => write!(f, "{:?}", *self),
14296 }
14297 }
14298}
14299
14300#[derive(Debug, Clone, PartialEq, Eq)]
14301#[non_exhaustive] pub struct RelocationPath {
14303 pub from_path: WritePathOrId,
14305 pub to_path: WritePathOrId,
14307}
14308
14309impl RelocationPath {
14310 pub fn new(from_path: WritePathOrId, to_path: WritePathOrId) -> Self {
14311 RelocationPath {
14312 from_path,
14313 to_path,
14314 }
14315 }
14316}
14317
14318const RELOCATION_PATH_FIELDS: &[&str] = &["from_path",
14319 "to_path"];
14320impl RelocationPath {
14321 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14322 map: V,
14323 ) -> Result<RelocationPath, V::Error> {
14324 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14325 }
14326
14327 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14328 mut map: V,
14329 optional: bool,
14330 ) -> Result<Option<RelocationPath>, V::Error> {
14331 let mut field_from_path = None;
14332 let mut field_to_path = None;
14333 let mut nothing = true;
14334 while let Some(key) = map.next_key::<&str>()? {
14335 nothing = false;
14336 match key {
14337 "from_path" => {
14338 if field_from_path.is_some() {
14339 return Err(::serde::de::Error::duplicate_field("from_path"));
14340 }
14341 field_from_path = Some(map.next_value()?);
14342 }
14343 "to_path" => {
14344 if field_to_path.is_some() {
14345 return Err(::serde::de::Error::duplicate_field("to_path"));
14346 }
14347 field_to_path = Some(map.next_value()?);
14348 }
14349 _ => {
14350 map.next_value::<::serde_json::Value>()?;
14352 }
14353 }
14354 }
14355 if optional && nothing {
14356 return Ok(None);
14357 }
14358 let result = RelocationPath {
14359 from_path: field_from_path.ok_or_else(|| ::serde::de::Error::missing_field("from_path"))?,
14360 to_path: field_to_path.ok_or_else(|| ::serde::de::Error::missing_field("to_path"))?,
14361 };
14362 Ok(Some(result))
14363 }
14364
14365 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14366 &self,
14367 s: &mut S::SerializeStruct,
14368 ) -> Result<(), S::Error> {
14369 use serde::ser::SerializeStruct;
14370 s.serialize_field("from_path", &self.from_path)?;
14371 s.serialize_field("to_path", &self.to_path)?;
14372 Ok(())
14373 }
14374}
14375
14376impl<'de> ::serde::de::Deserialize<'de> for RelocationPath {
14377 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14378 use serde::de::{MapAccess, Visitor};
14380 struct StructVisitor;
14381 impl<'de> Visitor<'de> for StructVisitor {
14382 type Value = RelocationPath;
14383 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14384 f.write_str("a RelocationPath struct")
14385 }
14386 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14387 RelocationPath::internal_deserialize(map)
14388 }
14389 }
14390 deserializer.deserialize_struct("RelocationPath", RELOCATION_PATH_FIELDS, StructVisitor)
14391 }
14392}
14393
14394impl ::serde::ser::Serialize for RelocationPath {
14395 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14396 use serde::ser::SerializeStruct;
14398 let mut s = serializer.serialize_struct("RelocationPath", 2)?;
14399 self.internal_serialize::<S>(&mut s)?;
14400 s.end()
14401 }
14402}
14403
14404#[derive(Debug, Clone, PartialEq)]
14405#[non_exhaustive] pub struct RelocationResult {
14407 pub metadata: Metadata,
14409}
14410
14411impl RelocationResult {
14412 pub fn new(metadata: Metadata) -> Self {
14413 RelocationResult {
14414 metadata,
14415 }
14416 }
14417}
14418
14419const RELOCATION_RESULT_FIELDS: &[&str] = &["metadata"];
14420impl RelocationResult {
14421 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14422 map: V,
14423 ) -> Result<RelocationResult, V::Error> {
14424 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14425 }
14426
14427 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14428 mut map: V,
14429 optional: bool,
14430 ) -> Result<Option<RelocationResult>, V::Error> {
14431 let mut field_metadata = None;
14432 let mut nothing = true;
14433 while let Some(key) = map.next_key::<&str>()? {
14434 nothing = false;
14435 match key {
14436 "metadata" => {
14437 if field_metadata.is_some() {
14438 return Err(::serde::de::Error::duplicate_field("metadata"));
14439 }
14440 field_metadata = Some(map.next_value()?);
14441 }
14442 _ => {
14443 map.next_value::<::serde_json::Value>()?;
14445 }
14446 }
14447 }
14448 if optional && nothing {
14449 return Ok(None);
14450 }
14451 let result = RelocationResult {
14452 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
14453 };
14454 Ok(Some(result))
14455 }
14456
14457 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14458 &self,
14459 s: &mut S::SerializeStruct,
14460 ) -> Result<(), S::Error> {
14461 use serde::ser::SerializeStruct;
14462 s.serialize_field("metadata", &self.metadata)?;
14463 Ok(())
14464 }
14465}
14466
14467impl<'de> ::serde::de::Deserialize<'de> for RelocationResult {
14468 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14469 use serde::de::{MapAccess, Visitor};
14471 struct StructVisitor;
14472 impl<'de> Visitor<'de> for StructVisitor {
14473 type Value = RelocationResult;
14474 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14475 f.write_str("a RelocationResult struct")
14476 }
14477 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14478 RelocationResult::internal_deserialize(map)
14479 }
14480 }
14481 deserializer.deserialize_struct("RelocationResult", RELOCATION_RESULT_FIELDS, StructVisitor)
14482 }
14483}
14484
14485impl ::serde::ser::Serialize for RelocationResult {
14486 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14487 use serde::ser::SerializeStruct;
14489 let mut s = serializer.serialize_struct("RelocationResult", 1)?;
14490 self.internal_serialize::<S>(&mut s)?;
14491 s.end()
14492 }
14493}
14494
14495impl From<RelocationResult> for FileOpsResult {
14497 fn from(_: RelocationResult) -> Self {
14498 Self {}
14499 }
14500}
14501#[derive(Debug, Clone, PartialEq, Eq)]
14502#[non_exhaustive] pub struct RemoveTagArg {
14504 pub path: Path,
14506 pub tag_text: TagText,
14508}
14509
14510impl RemoveTagArg {
14511 pub fn new(path: Path, tag_text: TagText) -> Self {
14512 RemoveTagArg {
14513 path,
14514 tag_text,
14515 }
14516 }
14517}
14518
14519const REMOVE_TAG_ARG_FIELDS: &[&str] = &["path",
14520 "tag_text"];
14521impl RemoveTagArg {
14522 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14523 map: V,
14524 ) -> Result<RemoveTagArg, V::Error> {
14525 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14526 }
14527
14528 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14529 mut map: V,
14530 optional: bool,
14531 ) -> Result<Option<RemoveTagArg>, V::Error> {
14532 let mut field_path = None;
14533 let mut field_tag_text = None;
14534 let mut nothing = true;
14535 while let Some(key) = map.next_key::<&str>()? {
14536 nothing = false;
14537 match key {
14538 "path" => {
14539 if field_path.is_some() {
14540 return Err(::serde::de::Error::duplicate_field("path"));
14541 }
14542 field_path = Some(map.next_value()?);
14543 }
14544 "tag_text" => {
14545 if field_tag_text.is_some() {
14546 return Err(::serde::de::Error::duplicate_field("tag_text"));
14547 }
14548 field_tag_text = Some(map.next_value()?);
14549 }
14550 _ => {
14551 map.next_value::<::serde_json::Value>()?;
14553 }
14554 }
14555 }
14556 if optional && nothing {
14557 return Ok(None);
14558 }
14559 let result = RemoveTagArg {
14560 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
14561 tag_text: field_tag_text.ok_or_else(|| ::serde::de::Error::missing_field("tag_text"))?,
14562 };
14563 Ok(Some(result))
14564 }
14565
14566 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14567 &self,
14568 s: &mut S::SerializeStruct,
14569 ) -> Result<(), S::Error> {
14570 use serde::ser::SerializeStruct;
14571 s.serialize_field("path", &self.path)?;
14572 s.serialize_field("tag_text", &self.tag_text)?;
14573 Ok(())
14574 }
14575}
14576
14577impl<'de> ::serde::de::Deserialize<'de> for RemoveTagArg {
14578 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14579 use serde::de::{MapAccess, Visitor};
14581 struct StructVisitor;
14582 impl<'de> Visitor<'de> for StructVisitor {
14583 type Value = RemoveTagArg;
14584 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14585 f.write_str("a RemoveTagArg struct")
14586 }
14587 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14588 RemoveTagArg::internal_deserialize(map)
14589 }
14590 }
14591 deserializer.deserialize_struct("RemoveTagArg", REMOVE_TAG_ARG_FIELDS, StructVisitor)
14592 }
14593}
14594
14595impl ::serde::ser::Serialize for RemoveTagArg {
14596 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14597 use serde::ser::SerializeStruct;
14599 let mut s = serializer.serialize_struct("RemoveTagArg", 2)?;
14600 self.internal_serialize::<S>(&mut s)?;
14601 s.end()
14602 }
14603}
14604
14605#[derive(Debug, Clone, PartialEq, Eq)]
14606#[non_exhaustive] pub enum RemoveTagError {
14608 Path(LookupError),
14609 TagNotPresent,
14611 Other,
14614}
14615
14616impl<'de> ::serde::de::Deserialize<'de> for RemoveTagError {
14617 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14618 use serde::de::{self, MapAccess, Visitor};
14620 struct EnumVisitor;
14621 impl<'de> Visitor<'de> for EnumVisitor {
14622 type Value = RemoveTagError;
14623 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14624 f.write_str("a RemoveTagError structure")
14625 }
14626 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
14627 let tag: &str = match map.next_key()? {
14628 Some(".tag") => map.next_value()?,
14629 _ => return Err(de::Error::missing_field(".tag"))
14630 };
14631 let value = match tag {
14632 "path" => {
14633 match map.next_key()? {
14634 Some("path") => RemoveTagError::Path(map.next_value()?),
14635 None => return Err(de::Error::missing_field("path")),
14636 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14637 }
14638 }
14639 "tag_not_present" => RemoveTagError::TagNotPresent,
14640 _ => RemoveTagError::Other,
14641 };
14642 crate::eat_json_fields(&mut map)?;
14643 Ok(value)
14644 }
14645 }
14646 const VARIANTS: &[&str] = &["path",
14647 "other",
14648 "tag_not_present"];
14649 deserializer.deserialize_struct("RemoveTagError", VARIANTS, EnumVisitor)
14650 }
14651}
14652
14653impl ::serde::ser::Serialize for RemoveTagError {
14654 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14655 use serde::ser::SerializeStruct;
14657 match self {
14658 RemoveTagError::Path(x) => {
14659 let mut s = serializer.serialize_struct("RemoveTagError", 2)?;
14661 s.serialize_field(".tag", "path")?;
14662 s.serialize_field("path", x)?;
14663 s.end()
14664 }
14665 RemoveTagError::TagNotPresent => {
14666 let mut s = serializer.serialize_struct("RemoveTagError", 1)?;
14668 s.serialize_field(".tag", "tag_not_present")?;
14669 s.end()
14670 }
14671 RemoveTagError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
14672 }
14673 }
14674}
14675
14676impl ::std::error::Error for RemoveTagError {
14677 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
14678 match self {
14679 RemoveTagError::Path(inner) => Some(inner),
14680 _ => None,
14681 }
14682 }
14683}
14684
14685impl ::std::fmt::Display for RemoveTagError {
14686 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14687 match self {
14688 RemoveTagError::Path(inner) => write!(f, "RemoveTagError: {}", inner),
14689 RemoveTagError::TagNotPresent => f.write_str("That tag doesn't exist at this path."),
14690 _ => write!(f, "{:?}", *self),
14691 }
14692 }
14693}
14694
14695impl From<BaseTagError> for RemoveTagError {
14697 fn from(parent: BaseTagError) -> Self {
14698 match parent {
14699 BaseTagError::Path(x) => RemoveTagError::Path(x),
14700 BaseTagError::Other => RemoveTagError::Other,
14701 }
14702 }
14703}
14704#[derive(Debug, Clone, PartialEq, Eq)]
14705#[non_exhaustive] pub struct RestoreArg {
14707 pub path: WritePath,
14709 pub rev: Rev,
14711}
14712
14713impl RestoreArg {
14714 pub fn new(path: WritePath, rev: Rev) -> Self {
14715 RestoreArg {
14716 path,
14717 rev,
14718 }
14719 }
14720}
14721
14722const RESTORE_ARG_FIELDS: &[&str] = &["path",
14723 "rev"];
14724impl RestoreArg {
14725 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14726 map: V,
14727 ) -> Result<RestoreArg, V::Error> {
14728 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14729 }
14730
14731 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14732 mut map: V,
14733 optional: bool,
14734 ) -> Result<Option<RestoreArg>, V::Error> {
14735 let mut field_path = None;
14736 let mut field_rev = None;
14737 let mut nothing = true;
14738 while let Some(key) = map.next_key::<&str>()? {
14739 nothing = false;
14740 match key {
14741 "path" => {
14742 if field_path.is_some() {
14743 return Err(::serde::de::Error::duplicate_field("path"));
14744 }
14745 field_path = Some(map.next_value()?);
14746 }
14747 "rev" => {
14748 if field_rev.is_some() {
14749 return Err(::serde::de::Error::duplicate_field("rev"));
14750 }
14751 field_rev = Some(map.next_value()?);
14752 }
14753 _ => {
14754 map.next_value::<::serde_json::Value>()?;
14756 }
14757 }
14758 }
14759 if optional && nothing {
14760 return Ok(None);
14761 }
14762 let result = RestoreArg {
14763 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
14764 rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
14765 };
14766 Ok(Some(result))
14767 }
14768
14769 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14770 &self,
14771 s: &mut S::SerializeStruct,
14772 ) -> Result<(), S::Error> {
14773 use serde::ser::SerializeStruct;
14774 s.serialize_field("path", &self.path)?;
14775 s.serialize_field("rev", &self.rev)?;
14776 Ok(())
14777 }
14778}
14779
14780impl<'de> ::serde::de::Deserialize<'de> for RestoreArg {
14781 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14782 use serde::de::{MapAccess, Visitor};
14784 struct StructVisitor;
14785 impl<'de> Visitor<'de> for StructVisitor {
14786 type Value = RestoreArg;
14787 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14788 f.write_str("a RestoreArg struct")
14789 }
14790 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
14791 RestoreArg::internal_deserialize(map)
14792 }
14793 }
14794 deserializer.deserialize_struct("RestoreArg", RESTORE_ARG_FIELDS, StructVisitor)
14795 }
14796}
14797
14798impl ::serde::ser::Serialize for RestoreArg {
14799 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14800 use serde::ser::SerializeStruct;
14802 let mut s = serializer.serialize_struct("RestoreArg", 2)?;
14803 self.internal_serialize::<S>(&mut s)?;
14804 s.end()
14805 }
14806}
14807
14808#[derive(Debug, Clone, PartialEq, Eq)]
14809#[non_exhaustive] pub enum RestoreError {
14811 PathLookup(LookupError),
14813 PathWrite(WriteError),
14815 InvalidRevision,
14817 InProgress,
14819 Other,
14822}
14823
14824impl<'de> ::serde::de::Deserialize<'de> for RestoreError {
14825 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
14826 use serde::de::{self, MapAccess, Visitor};
14828 struct EnumVisitor;
14829 impl<'de> Visitor<'de> for EnumVisitor {
14830 type Value = RestoreError;
14831 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14832 f.write_str("a RestoreError structure")
14833 }
14834 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
14835 let tag: &str = match map.next_key()? {
14836 Some(".tag") => map.next_value()?,
14837 _ => return Err(de::Error::missing_field(".tag"))
14838 };
14839 let value = match tag {
14840 "path_lookup" => {
14841 match map.next_key()? {
14842 Some("path_lookup") => RestoreError::PathLookup(map.next_value()?),
14843 None => return Err(de::Error::missing_field("path_lookup")),
14844 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14845 }
14846 }
14847 "path_write" => {
14848 match map.next_key()? {
14849 Some("path_write") => RestoreError::PathWrite(map.next_value()?),
14850 None => return Err(de::Error::missing_field("path_write")),
14851 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
14852 }
14853 }
14854 "invalid_revision" => RestoreError::InvalidRevision,
14855 "in_progress" => RestoreError::InProgress,
14856 _ => RestoreError::Other,
14857 };
14858 crate::eat_json_fields(&mut map)?;
14859 Ok(value)
14860 }
14861 }
14862 const VARIANTS: &[&str] = &["path_lookup",
14863 "path_write",
14864 "invalid_revision",
14865 "in_progress",
14866 "other"];
14867 deserializer.deserialize_struct("RestoreError", VARIANTS, EnumVisitor)
14868 }
14869}
14870
14871impl ::serde::ser::Serialize for RestoreError {
14872 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
14873 use serde::ser::SerializeStruct;
14875 match self {
14876 RestoreError::PathLookup(x) => {
14877 let mut s = serializer.serialize_struct("RestoreError", 2)?;
14879 s.serialize_field(".tag", "path_lookup")?;
14880 s.serialize_field("path_lookup", x)?;
14881 s.end()
14882 }
14883 RestoreError::PathWrite(x) => {
14884 let mut s = serializer.serialize_struct("RestoreError", 2)?;
14886 s.serialize_field(".tag", "path_write")?;
14887 s.serialize_field("path_write", x)?;
14888 s.end()
14889 }
14890 RestoreError::InvalidRevision => {
14891 let mut s = serializer.serialize_struct("RestoreError", 1)?;
14893 s.serialize_field(".tag", "invalid_revision")?;
14894 s.end()
14895 }
14896 RestoreError::InProgress => {
14897 let mut s = serializer.serialize_struct("RestoreError", 1)?;
14899 s.serialize_field(".tag", "in_progress")?;
14900 s.end()
14901 }
14902 RestoreError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
14903 }
14904 }
14905}
14906
14907impl ::std::error::Error for RestoreError {
14908 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
14909 match self {
14910 RestoreError::PathLookup(inner) => Some(inner),
14911 RestoreError::PathWrite(inner) => Some(inner),
14912 _ => None,
14913 }
14914 }
14915}
14916
14917impl ::std::fmt::Display for RestoreError {
14918 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
14919 match self {
14920 RestoreError::PathLookup(inner) => write!(f, "An error occurs when downloading metadata for the file: {}", inner),
14921 RestoreError::PathWrite(inner) => write!(f, "An error occurs when trying to restore the file to that path: {}", inner),
14922 RestoreError::InvalidRevision => f.write_str("The revision is invalid. It may not exist or may point to a deleted file."),
14923 RestoreError::InProgress => f.write_str("The restore is currently executing, but has not yet completed."),
14924 _ => write!(f, "{:?}", *self),
14925 }
14926 }
14927}
14928
14929#[derive(Debug, Clone, PartialEq, Eq)]
14930#[non_exhaustive] pub struct SaveCopyReferenceArg {
14932 pub copy_reference: String,
14934 pub path: Path,
14936}
14937
14938impl SaveCopyReferenceArg {
14939 pub fn new(copy_reference: String, path: Path) -> Self {
14940 SaveCopyReferenceArg {
14941 copy_reference,
14942 path,
14943 }
14944 }
14945}
14946
14947const SAVE_COPY_REFERENCE_ARG_FIELDS: &[&str] = &["copy_reference",
14948 "path"];
14949impl SaveCopyReferenceArg {
14950 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
14951 map: V,
14952 ) -> Result<SaveCopyReferenceArg, V::Error> {
14953 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
14954 }
14955
14956 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
14957 mut map: V,
14958 optional: bool,
14959 ) -> Result<Option<SaveCopyReferenceArg>, V::Error> {
14960 let mut field_copy_reference = None;
14961 let mut field_path = None;
14962 let mut nothing = true;
14963 while let Some(key) = map.next_key::<&str>()? {
14964 nothing = false;
14965 match key {
14966 "copy_reference" => {
14967 if field_copy_reference.is_some() {
14968 return Err(::serde::de::Error::duplicate_field("copy_reference"));
14969 }
14970 field_copy_reference = Some(map.next_value()?);
14971 }
14972 "path" => {
14973 if field_path.is_some() {
14974 return Err(::serde::de::Error::duplicate_field("path"));
14975 }
14976 field_path = Some(map.next_value()?);
14977 }
14978 _ => {
14979 map.next_value::<::serde_json::Value>()?;
14981 }
14982 }
14983 }
14984 if optional && nothing {
14985 return Ok(None);
14986 }
14987 let result = SaveCopyReferenceArg {
14988 copy_reference: field_copy_reference.ok_or_else(|| ::serde::de::Error::missing_field("copy_reference"))?,
14989 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
14990 };
14991 Ok(Some(result))
14992 }
14993
14994 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
14995 &self,
14996 s: &mut S::SerializeStruct,
14997 ) -> Result<(), S::Error> {
14998 use serde::ser::SerializeStruct;
14999 s.serialize_field("copy_reference", &self.copy_reference)?;
15000 s.serialize_field("path", &self.path)?;
15001 Ok(())
15002 }
15003}
15004
15005impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceArg {
15006 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15007 use serde::de::{MapAccess, Visitor};
15009 struct StructVisitor;
15010 impl<'de> Visitor<'de> for StructVisitor {
15011 type Value = SaveCopyReferenceArg;
15012 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15013 f.write_str("a SaveCopyReferenceArg struct")
15014 }
15015 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15016 SaveCopyReferenceArg::internal_deserialize(map)
15017 }
15018 }
15019 deserializer.deserialize_struct("SaveCopyReferenceArg", SAVE_COPY_REFERENCE_ARG_FIELDS, StructVisitor)
15020 }
15021}
15022
15023impl ::serde::ser::Serialize for SaveCopyReferenceArg {
15024 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15025 use serde::ser::SerializeStruct;
15027 let mut s = serializer.serialize_struct("SaveCopyReferenceArg", 2)?;
15028 self.internal_serialize::<S>(&mut s)?;
15029 s.end()
15030 }
15031}
15032
15033#[derive(Debug, Clone, PartialEq, Eq)]
15034#[non_exhaustive] pub enum SaveCopyReferenceError {
15036 Path(WriteError),
15037 InvalidCopyReference,
15039 NoPermission,
15042 NotFound,
15044 TooManyFiles,
15046 Other,
15049}
15050
15051impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceError {
15052 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15053 use serde::de::{self, MapAccess, Visitor};
15055 struct EnumVisitor;
15056 impl<'de> Visitor<'de> for EnumVisitor {
15057 type Value = SaveCopyReferenceError;
15058 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15059 f.write_str("a SaveCopyReferenceError structure")
15060 }
15061 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15062 let tag: &str = match map.next_key()? {
15063 Some(".tag") => map.next_value()?,
15064 _ => return Err(de::Error::missing_field(".tag"))
15065 };
15066 let value = match tag {
15067 "path" => {
15068 match map.next_key()? {
15069 Some("path") => SaveCopyReferenceError::Path(map.next_value()?),
15070 None => return Err(de::Error::missing_field("path")),
15071 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15072 }
15073 }
15074 "invalid_copy_reference" => SaveCopyReferenceError::InvalidCopyReference,
15075 "no_permission" => SaveCopyReferenceError::NoPermission,
15076 "not_found" => SaveCopyReferenceError::NotFound,
15077 "too_many_files" => SaveCopyReferenceError::TooManyFiles,
15078 _ => SaveCopyReferenceError::Other,
15079 };
15080 crate::eat_json_fields(&mut map)?;
15081 Ok(value)
15082 }
15083 }
15084 const VARIANTS: &[&str] = &["path",
15085 "invalid_copy_reference",
15086 "no_permission",
15087 "not_found",
15088 "too_many_files",
15089 "other"];
15090 deserializer.deserialize_struct("SaveCopyReferenceError", VARIANTS, EnumVisitor)
15091 }
15092}
15093
15094impl ::serde::ser::Serialize for SaveCopyReferenceError {
15095 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15096 use serde::ser::SerializeStruct;
15098 match self {
15099 SaveCopyReferenceError::Path(x) => {
15100 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 2)?;
15102 s.serialize_field(".tag", "path")?;
15103 s.serialize_field("path", x)?;
15104 s.end()
15105 }
15106 SaveCopyReferenceError::InvalidCopyReference => {
15107 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15109 s.serialize_field(".tag", "invalid_copy_reference")?;
15110 s.end()
15111 }
15112 SaveCopyReferenceError::NoPermission => {
15113 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15115 s.serialize_field(".tag", "no_permission")?;
15116 s.end()
15117 }
15118 SaveCopyReferenceError::NotFound => {
15119 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15121 s.serialize_field(".tag", "not_found")?;
15122 s.end()
15123 }
15124 SaveCopyReferenceError::TooManyFiles => {
15125 let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
15127 s.serialize_field(".tag", "too_many_files")?;
15128 s.end()
15129 }
15130 SaveCopyReferenceError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
15131 }
15132 }
15133}
15134
15135impl ::std::error::Error for SaveCopyReferenceError {
15136 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
15137 match self {
15138 SaveCopyReferenceError::Path(inner) => Some(inner),
15139 _ => None,
15140 }
15141 }
15142}
15143
15144impl ::std::fmt::Display for SaveCopyReferenceError {
15145 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15146 match self {
15147 SaveCopyReferenceError::Path(inner) => write!(f, "SaveCopyReferenceError: {}", inner),
15148 SaveCopyReferenceError::InvalidCopyReference => f.write_str("The copy reference is invalid."),
15149 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."),
15150 SaveCopyReferenceError::NotFound => f.write_str("The file referenced by the copy reference cannot be found."),
15151 SaveCopyReferenceError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
15152 _ => write!(f, "{:?}", *self),
15153 }
15154 }
15155}
15156
15157#[derive(Debug, Clone, PartialEq)]
15158#[non_exhaustive] pub struct SaveCopyReferenceResult {
15160 pub metadata: Metadata,
15162}
15163
15164impl SaveCopyReferenceResult {
15165 pub fn new(metadata: Metadata) -> Self {
15166 SaveCopyReferenceResult {
15167 metadata,
15168 }
15169 }
15170}
15171
15172const SAVE_COPY_REFERENCE_RESULT_FIELDS: &[&str] = &["metadata"];
15173impl SaveCopyReferenceResult {
15174 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15175 map: V,
15176 ) -> Result<SaveCopyReferenceResult, V::Error> {
15177 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15178 }
15179
15180 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15181 mut map: V,
15182 optional: bool,
15183 ) -> Result<Option<SaveCopyReferenceResult>, V::Error> {
15184 let mut field_metadata = None;
15185 let mut nothing = true;
15186 while let Some(key) = map.next_key::<&str>()? {
15187 nothing = false;
15188 match key {
15189 "metadata" => {
15190 if field_metadata.is_some() {
15191 return Err(::serde::de::Error::duplicate_field("metadata"));
15192 }
15193 field_metadata = Some(map.next_value()?);
15194 }
15195 _ => {
15196 map.next_value::<::serde_json::Value>()?;
15198 }
15199 }
15200 }
15201 if optional && nothing {
15202 return Ok(None);
15203 }
15204 let result = SaveCopyReferenceResult {
15205 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
15206 };
15207 Ok(Some(result))
15208 }
15209
15210 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15211 &self,
15212 s: &mut S::SerializeStruct,
15213 ) -> Result<(), S::Error> {
15214 use serde::ser::SerializeStruct;
15215 s.serialize_field("metadata", &self.metadata)?;
15216 Ok(())
15217 }
15218}
15219
15220impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceResult {
15221 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15222 use serde::de::{MapAccess, Visitor};
15224 struct StructVisitor;
15225 impl<'de> Visitor<'de> for StructVisitor {
15226 type Value = SaveCopyReferenceResult;
15227 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15228 f.write_str("a SaveCopyReferenceResult struct")
15229 }
15230 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15231 SaveCopyReferenceResult::internal_deserialize(map)
15232 }
15233 }
15234 deserializer.deserialize_struct("SaveCopyReferenceResult", SAVE_COPY_REFERENCE_RESULT_FIELDS, StructVisitor)
15235 }
15236}
15237
15238impl ::serde::ser::Serialize for SaveCopyReferenceResult {
15239 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15240 use serde::ser::SerializeStruct;
15242 let mut s = serializer.serialize_struct("SaveCopyReferenceResult", 1)?;
15243 self.internal_serialize::<S>(&mut s)?;
15244 s.end()
15245 }
15246}
15247
15248#[derive(Debug, Clone, PartialEq, Eq)]
15249#[non_exhaustive] pub struct SaveUrlArg {
15251 pub path: Path,
15253 pub url: String,
15255}
15256
15257impl SaveUrlArg {
15258 pub fn new(path: Path, url: String) -> Self {
15259 SaveUrlArg {
15260 path,
15261 url,
15262 }
15263 }
15264}
15265
15266const SAVE_URL_ARG_FIELDS: &[&str] = &["path",
15267 "url"];
15268impl SaveUrlArg {
15269 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15270 map: V,
15271 ) -> Result<SaveUrlArg, V::Error> {
15272 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15273 }
15274
15275 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15276 mut map: V,
15277 optional: bool,
15278 ) -> Result<Option<SaveUrlArg>, V::Error> {
15279 let mut field_path = None;
15280 let mut field_url = None;
15281 let mut nothing = true;
15282 while let Some(key) = map.next_key::<&str>()? {
15283 nothing = false;
15284 match key {
15285 "path" => {
15286 if field_path.is_some() {
15287 return Err(::serde::de::Error::duplicate_field("path"));
15288 }
15289 field_path = Some(map.next_value()?);
15290 }
15291 "url" => {
15292 if field_url.is_some() {
15293 return Err(::serde::de::Error::duplicate_field("url"));
15294 }
15295 field_url = Some(map.next_value()?);
15296 }
15297 _ => {
15298 map.next_value::<::serde_json::Value>()?;
15300 }
15301 }
15302 }
15303 if optional && nothing {
15304 return Ok(None);
15305 }
15306 let result = SaveUrlArg {
15307 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
15308 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
15309 };
15310 Ok(Some(result))
15311 }
15312
15313 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15314 &self,
15315 s: &mut S::SerializeStruct,
15316 ) -> Result<(), S::Error> {
15317 use serde::ser::SerializeStruct;
15318 s.serialize_field("path", &self.path)?;
15319 s.serialize_field("url", &self.url)?;
15320 Ok(())
15321 }
15322}
15323
15324impl<'de> ::serde::de::Deserialize<'de> for SaveUrlArg {
15325 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15326 use serde::de::{MapAccess, Visitor};
15328 struct StructVisitor;
15329 impl<'de> Visitor<'de> for StructVisitor {
15330 type Value = SaveUrlArg;
15331 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15332 f.write_str("a SaveUrlArg struct")
15333 }
15334 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15335 SaveUrlArg::internal_deserialize(map)
15336 }
15337 }
15338 deserializer.deserialize_struct("SaveUrlArg", SAVE_URL_ARG_FIELDS, StructVisitor)
15339 }
15340}
15341
15342impl ::serde::ser::Serialize for SaveUrlArg {
15343 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15344 use serde::ser::SerializeStruct;
15346 let mut s = serializer.serialize_struct("SaveUrlArg", 2)?;
15347 self.internal_serialize::<S>(&mut s)?;
15348 s.end()
15349 }
15350}
15351
15352#[derive(Debug, Clone, PartialEq, Eq)]
15353#[non_exhaustive] pub enum SaveUrlError {
15355 Path(WriteError),
15356 DownloadFailed,
15359 InvalidUrl,
15361 NotFound,
15363 Other,
15366}
15367
15368impl<'de> ::serde::de::Deserialize<'de> for SaveUrlError {
15369 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15370 use serde::de::{self, MapAccess, Visitor};
15372 struct EnumVisitor;
15373 impl<'de> Visitor<'de> for EnumVisitor {
15374 type Value = SaveUrlError;
15375 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15376 f.write_str("a SaveUrlError structure")
15377 }
15378 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15379 let tag: &str = match map.next_key()? {
15380 Some(".tag") => map.next_value()?,
15381 _ => return Err(de::Error::missing_field(".tag"))
15382 };
15383 let value = match tag {
15384 "path" => {
15385 match map.next_key()? {
15386 Some("path") => SaveUrlError::Path(map.next_value()?),
15387 None => return Err(de::Error::missing_field("path")),
15388 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15389 }
15390 }
15391 "download_failed" => SaveUrlError::DownloadFailed,
15392 "invalid_url" => SaveUrlError::InvalidUrl,
15393 "not_found" => SaveUrlError::NotFound,
15394 _ => SaveUrlError::Other,
15395 };
15396 crate::eat_json_fields(&mut map)?;
15397 Ok(value)
15398 }
15399 }
15400 const VARIANTS: &[&str] = &["path",
15401 "download_failed",
15402 "invalid_url",
15403 "not_found",
15404 "other"];
15405 deserializer.deserialize_struct("SaveUrlError", VARIANTS, EnumVisitor)
15406 }
15407}
15408
15409impl ::serde::ser::Serialize for SaveUrlError {
15410 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15411 use serde::ser::SerializeStruct;
15413 match self {
15414 SaveUrlError::Path(x) => {
15415 let mut s = serializer.serialize_struct("SaveUrlError", 2)?;
15417 s.serialize_field(".tag", "path")?;
15418 s.serialize_field("path", x)?;
15419 s.end()
15420 }
15421 SaveUrlError::DownloadFailed => {
15422 let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
15424 s.serialize_field(".tag", "download_failed")?;
15425 s.end()
15426 }
15427 SaveUrlError::InvalidUrl => {
15428 let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
15430 s.serialize_field(".tag", "invalid_url")?;
15431 s.end()
15432 }
15433 SaveUrlError::NotFound => {
15434 let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
15436 s.serialize_field(".tag", "not_found")?;
15437 s.end()
15438 }
15439 SaveUrlError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
15440 }
15441 }
15442}
15443
15444impl ::std::error::Error for SaveUrlError {
15445 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
15446 match self {
15447 SaveUrlError::Path(inner) => Some(inner),
15448 _ => None,
15449 }
15450 }
15451}
15452
15453impl ::std::fmt::Display for SaveUrlError {
15454 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15455 match self {
15456 SaveUrlError::Path(inner) => write!(f, "SaveUrlError: {}", inner),
15457 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."),
15458 SaveUrlError::InvalidUrl => f.write_str("The given URL is invalid."),
15459 SaveUrlError::NotFound => f.write_str("The file where the URL is saved to no longer exists."),
15460 _ => write!(f, "{:?}", *self),
15461 }
15462 }
15463}
15464
15465#[derive(Debug, Clone, PartialEq)]
15466pub enum SaveUrlJobStatus {
15467 InProgress,
15469 Complete(FileMetadata),
15471 Failed(SaveUrlError),
15472}
15473
15474impl<'de> ::serde::de::Deserialize<'de> for SaveUrlJobStatus {
15475 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15476 use serde::de::{self, MapAccess, Visitor};
15478 struct EnumVisitor;
15479 impl<'de> Visitor<'de> for EnumVisitor {
15480 type Value = SaveUrlJobStatus;
15481 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15482 f.write_str("a SaveUrlJobStatus structure")
15483 }
15484 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15485 let tag: &str = match map.next_key()? {
15486 Some(".tag") => map.next_value()?,
15487 _ => return Err(de::Error::missing_field(".tag"))
15488 };
15489 let value = match tag {
15490 "in_progress" => SaveUrlJobStatus::InProgress,
15491 "complete" => SaveUrlJobStatus::Complete(FileMetadata::internal_deserialize(&mut map)?),
15492 "failed" => {
15493 match map.next_key()? {
15494 Some("failed") => SaveUrlJobStatus::Failed(map.next_value()?),
15495 None => return Err(de::Error::missing_field("failed")),
15496 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15497 }
15498 }
15499 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
15500 };
15501 crate::eat_json_fields(&mut map)?;
15502 Ok(value)
15503 }
15504 }
15505 const VARIANTS: &[&str] = &["in_progress",
15506 "complete",
15507 "failed"];
15508 deserializer.deserialize_struct("SaveUrlJobStatus", VARIANTS, EnumVisitor)
15509 }
15510}
15511
15512impl ::serde::ser::Serialize for SaveUrlJobStatus {
15513 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15514 use serde::ser::SerializeStruct;
15516 match self {
15517 SaveUrlJobStatus::InProgress => {
15518 let mut s = serializer.serialize_struct("SaveUrlJobStatus", 1)?;
15520 s.serialize_field(".tag", "in_progress")?;
15521 s.end()
15522 }
15523 SaveUrlJobStatus::Complete(x) => {
15524 let mut s = serializer.serialize_struct("SaveUrlJobStatus", 20)?;
15526 s.serialize_field(".tag", "complete")?;
15527 x.internal_serialize::<S>(&mut s)?;
15528 s.end()
15529 }
15530 SaveUrlJobStatus::Failed(x) => {
15531 let mut s = serializer.serialize_struct("SaveUrlJobStatus", 2)?;
15533 s.serialize_field(".tag", "failed")?;
15534 s.serialize_field("failed", x)?;
15535 s.end()
15536 }
15537 }
15538 }
15539}
15540
15541impl From<crate::types::dbx_async::PollResultBase> for SaveUrlJobStatus {
15543 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
15544 match parent {
15545 crate::types::dbx_async::PollResultBase::InProgress => SaveUrlJobStatus::InProgress,
15546 }
15547 }
15548}
15549#[derive(Debug, Clone, PartialEq)]
15550pub enum SaveUrlResult {
15551 AsyncJobId(crate::types::dbx_async::AsyncJobId),
15554 Complete(FileMetadata),
15556}
15557
15558impl<'de> ::serde::de::Deserialize<'de> for SaveUrlResult {
15559 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15560 use serde::de::{self, MapAccess, Visitor};
15562 struct EnumVisitor;
15563 impl<'de> Visitor<'de> for EnumVisitor {
15564 type Value = SaveUrlResult;
15565 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15566 f.write_str("a SaveUrlResult structure")
15567 }
15568 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15569 let tag: &str = match map.next_key()? {
15570 Some(".tag") => map.next_value()?,
15571 _ => return Err(de::Error::missing_field(".tag"))
15572 };
15573 let value = match tag {
15574 "async_job_id" => {
15575 match map.next_key()? {
15576 Some("async_job_id") => SaveUrlResult::AsyncJobId(map.next_value()?),
15577 None => return Err(de::Error::missing_field("async_job_id")),
15578 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15579 }
15580 }
15581 "complete" => SaveUrlResult::Complete(FileMetadata::internal_deserialize(&mut map)?),
15582 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
15583 };
15584 crate::eat_json_fields(&mut map)?;
15585 Ok(value)
15586 }
15587 }
15588 const VARIANTS: &[&str] = &["async_job_id",
15589 "complete"];
15590 deserializer.deserialize_struct("SaveUrlResult", VARIANTS, EnumVisitor)
15591 }
15592}
15593
15594impl ::serde::ser::Serialize for SaveUrlResult {
15595 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15596 use serde::ser::SerializeStruct;
15598 match self {
15599 SaveUrlResult::AsyncJobId(x) => {
15600 let mut s = serializer.serialize_struct("SaveUrlResult", 2)?;
15602 s.serialize_field(".tag", "async_job_id")?;
15603 s.serialize_field("async_job_id", x)?;
15604 s.end()
15605 }
15606 SaveUrlResult::Complete(x) => {
15607 let mut s = serializer.serialize_struct("SaveUrlResult", 20)?;
15609 s.serialize_field(".tag", "complete")?;
15610 x.internal_serialize::<S>(&mut s)?;
15611 s.end()
15612 }
15613 }
15614 }
15615}
15616
15617impl From<crate::types::dbx_async::LaunchResultBase> for SaveUrlResult {
15619 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
15620 match parent {
15621 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => SaveUrlResult::AsyncJobId(x),
15622 }
15623 }
15624}
15625#[derive(Debug, Clone, PartialEq, Eq)]
15626#[non_exhaustive] pub struct SearchArg {
15628 pub path: PathROrId,
15630 pub query: String,
15634 pub start: u64,
15636 pub max_results: u64,
15638 pub mode: SearchMode,
15641}
15642
15643impl SearchArg {
15644 pub fn new(path: PathROrId, query: String) -> Self {
15645 SearchArg {
15646 path,
15647 query,
15648 start: 0,
15649 max_results: 100,
15650 mode: SearchMode::Filename,
15651 }
15652 }
15653
15654 pub fn with_start(mut self, value: u64) -> Self {
15655 self.start = value;
15656 self
15657 }
15658
15659 pub fn with_max_results(mut self, value: u64) -> Self {
15660 self.max_results = value;
15661 self
15662 }
15663
15664 pub fn with_mode(mut self, value: SearchMode) -> Self {
15665 self.mode = value;
15666 self
15667 }
15668}
15669
15670const SEARCH_ARG_FIELDS: &[&str] = &["path",
15671 "query",
15672 "start",
15673 "max_results",
15674 "mode"];
15675impl SearchArg {
15676 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15677 map: V,
15678 ) -> Result<SearchArg, V::Error> {
15679 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15680 }
15681
15682 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15683 mut map: V,
15684 optional: bool,
15685 ) -> Result<Option<SearchArg>, V::Error> {
15686 let mut field_path = None;
15687 let mut field_query = None;
15688 let mut field_start = None;
15689 let mut field_max_results = None;
15690 let mut field_mode = None;
15691 let mut nothing = true;
15692 while let Some(key) = map.next_key::<&str>()? {
15693 nothing = false;
15694 match key {
15695 "path" => {
15696 if field_path.is_some() {
15697 return Err(::serde::de::Error::duplicate_field("path"));
15698 }
15699 field_path = Some(map.next_value()?);
15700 }
15701 "query" => {
15702 if field_query.is_some() {
15703 return Err(::serde::de::Error::duplicate_field("query"));
15704 }
15705 field_query = Some(map.next_value()?);
15706 }
15707 "start" => {
15708 if field_start.is_some() {
15709 return Err(::serde::de::Error::duplicate_field("start"));
15710 }
15711 field_start = Some(map.next_value()?);
15712 }
15713 "max_results" => {
15714 if field_max_results.is_some() {
15715 return Err(::serde::de::Error::duplicate_field("max_results"));
15716 }
15717 field_max_results = Some(map.next_value()?);
15718 }
15719 "mode" => {
15720 if field_mode.is_some() {
15721 return Err(::serde::de::Error::duplicate_field("mode"));
15722 }
15723 field_mode = Some(map.next_value()?);
15724 }
15725 _ => {
15726 map.next_value::<::serde_json::Value>()?;
15728 }
15729 }
15730 }
15731 if optional && nothing {
15732 return Ok(None);
15733 }
15734 let result = SearchArg {
15735 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
15736 query: field_query.ok_or_else(|| ::serde::de::Error::missing_field("query"))?,
15737 start: field_start.unwrap_or(0),
15738 max_results: field_max_results.unwrap_or(100),
15739 mode: field_mode.unwrap_or(SearchMode::Filename),
15740 };
15741 Ok(Some(result))
15742 }
15743
15744 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15745 &self,
15746 s: &mut S::SerializeStruct,
15747 ) -> Result<(), S::Error> {
15748 use serde::ser::SerializeStruct;
15749 s.serialize_field("path", &self.path)?;
15750 s.serialize_field("query", &self.query)?;
15751 if self.start != 0 {
15752 s.serialize_field("start", &self.start)?;
15753 }
15754 if self.max_results != 100 {
15755 s.serialize_field("max_results", &self.max_results)?;
15756 }
15757 if self.mode != SearchMode::Filename {
15758 s.serialize_field("mode", &self.mode)?;
15759 }
15760 Ok(())
15761 }
15762}
15763
15764impl<'de> ::serde::de::Deserialize<'de> for SearchArg {
15765 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15766 use serde::de::{MapAccess, Visitor};
15768 struct StructVisitor;
15769 impl<'de> Visitor<'de> for StructVisitor {
15770 type Value = SearchArg;
15771 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15772 f.write_str("a SearchArg struct")
15773 }
15774 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15775 SearchArg::internal_deserialize(map)
15776 }
15777 }
15778 deserializer.deserialize_struct("SearchArg", SEARCH_ARG_FIELDS, StructVisitor)
15779 }
15780}
15781
15782impl ::serde::ser::Serialize for SearchArg {
15783 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15784 use serde::ser::SerializeStruct;
15786 let mut s = serializer.serialize_struct("SearchArg", 5)?;
15787 self.internal_serialize::<S>(&mut s)?;
15788 s.end()
15789 }
15790}
15791
15792#[derive(Debug, Clone, PartialEq, Eq)]
15793#[non_exhaustive] pub enum SearchError {
15795 Path(LookupError),
15796 InvalidArgument(Option<String>),
15797 InternalError,
15799 Other,
15802}
15803
15804impl<'de> ::serde::de::Deserialize<'de> for SearchError {
15805 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15806 use serde::de::{self, MapAccess, Visitor};
15808 struct EnumVisitor;
15809 impl<'de> Visitor<'de> for EnumVisitor {
15810 type Value = SearchError;
15811 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15812 f.write_str("a SearchError structure")
15813 }
15814 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
15815 let tag: &str = match map.next_key()? {
15816 Some(".tag") => map.next_value()?,
15817 _ => return Err(de::Error::missing_field(".tag"))
15818 };
15819 let value = match tag {
15820 "path" => {
15821 match map.next_key()? {
15822 Some("path") => SearchError::Path(map.next_value()?),
15823 None => return Err(de::Error::missing_field("path")),
15824 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15825 }
15826 }
15827 "invalid_argument" => {
15828 match map.next_key()? {
15829 Some("invalid_argument") => SearchError::InvalidArgument(map.next_value()?),
15830 None => SearchError::InvalidArgument(None),
15831 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
15832 }
15833 }
15834 "internal_error" => SearchError::InternalError,
15835 _ => SearchError::Other,
15836 };
15837 crate::eat_json_fields(&mut map)?;
15838 Ok(value)
15839 }
15840 }
15841 const VARIANTS: &[&str] = &["path",
15842 "invalid_argument",
15843 "internal_error",
15844 "other"];
15845 deserializer.deserialize_struct("SearchError", VARIANTS, EnumVisitor)
15846 }
15847}
15848
15849impl ::serde::ser::Serialize for SearchError {
15850 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15851 use serde::ser::SerializeStruct;
15853 match self {
15854 SearchError::Path(x) => {
15855 let mut s = serializer.serialize_struct("SearchError", 2)?;
15857 s.serialize_field(".tag", "path")?;
15858 s.serialize_field("path", x)?;
15859 s.end()
15860 }
15861 SearchError::InvalidArgument(x) => {
15862 let n = if x.is_some() { 2 } else { 1 };
15864 let mut s = serializer.serialize_struct("SearchError", n)?;
15865 s.serialize_field(".tag", "invalid_argument")?;
15866 if let Some(x) = x {
15867 s.serialize_field("invalid_argument", &x)?;
15868 }
15869 s.end()
15870 }
15871 SearchError::InternalError => {
15872 let mut s = serializer.serialize_struct("SearchError", 1)?;
15874 s.serialize_field(".tag", "internal_error")?;
15875 s.end()
15876 }
15877 SearchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
15878 }
15879 }
15880}
15881
15882impl ::std::error::Error for SearchError {
15883 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
15884 match self {
15885 SearchError::Path(inner) => Some(inner),
15886 _ => None,
15887 }
15888 }
15889}
15890
15891impl ::std::fmt::Display for SearchError {
15892 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15893 match self {
15894 SearchError::Path(inner) => write!(f, "SearchError: {}", inner),
15895 SearchError::InvalidArgument(None) => f.write_str("invalid_argument"),
15896 SearchError::InvalidArgument(Some(inner)) => write!(f, "invalid_argument: {:?}", inner),
15897 SearchError::InternalError => f.write_str("Something went wrong, please try again."),
15898 _ => write!(f, "{:?}", *self),
15899 }
15900 }
15901}
15902
15903#[derive(Debug, Clone, PartialEq)]
15904#[non_exhaustive] pub struct SearchMatch {
15906 pub match_type: SearchMatchType,
15908 pub metadata: Metadata,
15910}
15911
15912impl SearchMatch {
15913 pub fn new(match_type: SearchMatchType, metadata: Metadata) -> Self {
15914 SearchMatch {
15915 match_type,
15916 metadata,
15917 }
15918 }
15919}
15920
15921const SEARCH_MATCH_FIELDS: &[&str] = &["match_type",
15922 "metadata"];
15923impl SearchMatch {
15924 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
15925 map: V,
15926 ) -> Result<SearchMatch, V::Error> {
15927 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
15928 }
15929
15930 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
15931 mut map: V,
15932 optional: bool,
15933 ) -> Result<Option<SearchMatch>, V::Error> {
15934 let mut field_match_type = None;
15935 let mut field_metadata = None;
15936 let mut nothing = true;
15937 while let Some(key) = map.next_key::<&str>()? {
15938 nothing = false;
15939 match key {
15940 "match_type" => {
15941 if field_match_type.is_some() {
15942 return Err(::serde::de::Error::duplicate_field("match_type"));
15943 }
15944 field_match_type = Some(map.next_value()?);
15945 }
15946 "metadata" => {
15947 if field_metadata.is_some() {
15948 return Err(::serde::de::Error::duplicate_field("metadata"));
15949 }
15950 field_metadata = Some(map.next_value()?);
15951 }
15952 _ => {
15953 map.next_value::<::serde_json::Value>()?;
15955 }
15956 }
15957 }
15958 if optional && nothing {
15959 return Ok(None);
15960 }
15961 let result = SearchMatch {
15962 match_type: field_match_type.ok_or_else(|| ::serde::de::Error::missing_field("match_type"))?,
15963 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
15964 };
15965 Ok(Some(result))
15966 }
15967
15968 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
15969 &self,
15970 s: &mut S::SerializeStruct,
15971 ) -> Result<(), S::Error> {
15972 use serde::ser::SerializeStruct;
15973 s.serialize_field("match_type", &self.match_type)?;
15974 s.serialize_field("metadata", &self.metadata)?;
15975 Ok(())
15976 }
15977}
15978
15979impl<'de> ::serde::de::Deserialize<'de> for SearchMatch {
15980 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
15981 use serde::de::{MapAccess, Visitor};
15983 struct StructVisitor;
15984 impl<'de> Visitor<'de> for StructVisitor {
15985 type Value = SearchMatch;
15986 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
15987 f.write_str("a SearchMatch struct")
15988 }
15989 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
15990 SearchMatch::internal_deserialize(map)
15991 }
15992 }
15993 deserializer.deserialize_struct("SearchMatch", SEARCH_MATCH_FIELDS, StructVisitor)
15994 }
15995}
15996
15997impl ::serde::ser::Serialize for SearchMatch {
15998 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
15999 use serde::ser::SerializeStruct;
16001 let mut s = serializer.serialize_struct("SearchMatch", 2)?;
16002 self.internal_serialize::<S>(&mut s)?;
16003 s.end()
16004 }
16005}
16006
16007#[derive(Debug, Clone, PartialEq, Eq, Default)]
16008#[non_exhaustive] pub struct SearchMatchFieldOptions {
16010 pub include_highlights: bool,
16012}
16013
16014impl SearchMatchFieldOptions {
16015 pub fn with_include_highlights(mut self, value: bool) -> Self {
16016 self.include_highlights = value;
16017 self
16018 }
16019}
16020
16021const SEARCH_MATCH_FIELD_OPTIONS_FIELDS: &[&str] = &["include_highlights"];
16022impl SearchMatchFieldOptions {
16023 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16025 mut map: V,
16026 ) -> Result<SearchMatchFieldOptions, V::Error> {
16027 let mut field_include_highlights = None;
16028 while let Some(key) = map.next_key::<&str>()? {
16029 match key {
16030 "include_highlights" => {
16031 if field_include_highlights.is_some() {
16032 return Err(::serde::de::Error::duplicate_field("include_highlights"));
16033 }
16034 field_include_highlights = Some(map.next_value()?);
16035 }
16036 _ => {
16037 map.next_value::<::serde_json::Value>()?;
16039 }
16040 }
16041 }
16042 let result = SearchMatchFieldOptions {
16043 include_highlights: field_include_highlights.unwrap_or(false),
16044 };
16045 Ok(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 if self.include_highlights {
16054 s.serialize_field("include_highlights", &self.include_highlights)?;
16055 }
16056 Ok(())
16057 }
16058}
16059
16060impl<'de> ::serde::de::Deserialize<'de> for SearchMatchFieldOptions {
16061 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16062 use serde::de::{MapAccess, Visitor};
16064 struct StructVisitor;
16065 impl<'de> Visitor<'de> for StructVisitor {
16066 type Value = SearchMatchFieldOptions;
16067 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16068 f.write_str("a SearchMatchFieldOptions struct")
16069 }
16070 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16071 SearchMatchFieldOptions::internal_deserialize(map)
16072 }
16073 }
16074 deserializer.deserialize_struct("SearchMatchFieldOptions", SEARCH_MATCH_FIELD_OPTIONS_FIELDS, StructVisitor)
16075 }
16076}
16077
16078impl ::serde::ser::Serialize for SearchMatchFieldOptions {
16079 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16080 use serde::ser::SerializeStruct;
16082 let mut s = serializer.serialize_struct("SearchMatchFieldOptions", 1)?;
16083 self.internal_serialize::<S>(&mut s)?;
16084 s.end()
16085 }
16086}
16087
16088#[derive(Debug, Clone, PartialEq, Eq)]
16090pub enum SearchMatchType {
16091 Filename,
16093 Content,
16095 Both,
16097}
16098
16099impl<'de> ::serde::de::Deserialize<'de> for SearchMatchType {
16100 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16101 use serde::de::{self, MapAccess, Visitor};
16103 struct EnumVisitor;
16104 impl<'de> Visitor<'de> for EnumVisitor {
16105 type Value = SearchMatchType;
16106 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16107 f.write_str("a SearchMatchType structure")
16108 }
16109 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16110 let tag: &str = match map.next_key()? {
16111 Some(".tag") => map.next_value()?,
16112 _ => return Err(de::Error::missing_field(".tag"))
16113 };
16114 let value = match tag {
16115 "filename" => SearchMatchType::Filename,
16116 "content" => SearchMatchType::Content,
16117 "both" => SearchMatchType::Both,
16118 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
16119 };
16120 crate::eat_json_fields(&mut map)?;
16121 Ok(value)
16122 }
16123 }
16124 const VARIANTS: &[&str] = &["filename",
16125 "content",
16126 "both"];
16127 deserializer.deserialize_struct("SearchMatchType", VARIANTS, EnumVisitor)
16128 }
16129}
16130
16131impl ::serde::ser::Serialize for SearchMatchType {
16132 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16133 use serde::ser::SerializeStruct;
16135 match self {
16136 SearchMatchType::Filename => {
16137 let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
16139 s.serialize_field(".tag", "filename")?;
16140 s.end()
16141 }
16142 SearchMatchType::Content => {
16143 let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
16145 s.serialize_field(".tag", "content")?;
16146 s.end()
16147 }
16148 SearchMatchType::Both => {
16149 let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
16151 s.serialize_field(".tag", "both")?;
16152 s.end()
16153 }
16154 }
16155 }
16156}
16157
16158#[derive(Debug, Clone, PartialEq, Eq)]
16160#[non_exhaustive] pub enum SearchMatchTypeV2 {
16162 Filename,
16164 FileContent,
16166 FilenameAndContent,
16168 ImageContent,
16170 Metadata,
16172 Other,
16175}
16176
16177impl<'de> ::serde::de::Deserialize<'de> for SearchMatchTypeV2 {
16178 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16179 use serde::de::{self, MapAccess, Visitor};
16181 struct EnumVisitor;
16182 impl<'de> Visitor<'de> for EnumVisitor {
16183 type Value = SearchMatchTypeV2;
16184 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16185 f.write_str("a SearchMatchTypeV2 structure")
16186 }
16187 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16188 let tag: &str = match map.next_key()? {
16189 Some(".tag") => map.next_value()?,
16190 _ => return Err(de::Error::missing_field(".tag"))
16191 };
16192 let value = match tag {
16193 "filename" => SearchMatchTypeV2::Filename,
16194 "file_content" => SearchMatchTypeV2::FileContent,
16195 "filename_and_content" => SearchMatchTypeV2::FilenameAndContent,
16196 "image_content" => SearchMatchTypeV2::ImageContent,
16197 "metadata" => SearchMatchTypeV2::Metadata,
16198 _ => SearchMatchTypeV2::Other,
16199 };
16200 crate::eat_json_fields(&mut map)?;
16201 Ok(value)
16202 }
16203 }
16204 const VARIANTS: &[&str] = &["filename",
16205 "file_content",
16206 "filename_and_content",
16207 "image_content",
16208 "metadata",
16209 "other"];
16210 deserializer.deserialize_struct("SearchMatchTypeV2", VARIANTS, EnumVisitor)
16211 }
16212}
16213
16214impl ::serde::ser::Serialize for SearchMatchTypeV2 {
16215 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16216 use serde::ser::SerializeStruct;
16218 match self {
16219 SearchMatchTypeV2::Filename => {
16220 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16222 s.serialize_field(".tag", "filename")?;
16223 s.end()
16224 }
16225 SearchMatchTypeV2::FileContent => {
16226 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16228 s.serialize_field(".tag", "file_content")?;
16229 s.end()
16230 }
16231 SearchMatchTypeV2::FilenameAndContent => {
16232 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16234 s.serialize_field(".tag", "filename_and_content")?;
16235 s.end()
16236 }
16237 SearchMatchTypeV2::ImageContent => {
16238 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16240 s.serialize_field(".tag", "image_content")?;
16241 s.end()
16242 }
16243 SearchMatchTypeV2::Metadata => {
16244 let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
16246 s.serialize_field(".tag", "metadata")?;
16247 s.end()
16248 }
16249 SearchMatchTypeV2::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
16250 }
16251 }
16252}
16253
16254#[derive(Debug, Clone, PartialEq)]
16255#[non_exhaustive] pub struct SearchMatchV2 {
16257 pub metadata: MetadataV2,
16259 pub match_type: Option<SearchMatchTypeV2>,
16261 pub highlight_spans: Option<Vec<HighlightSpan>>,
16263}
16264
16265impl SearchMatchV2 {
16266 pub fn new(metadata: MetadataV2) -> Self {
16267 SearchMatchV2 {
16268 metadata,
16269 match_type: None,
16270 highlight_spans: None,
16271 }
16272 }
16273
16274 pub fn with_match_type(mut self, value: SearchMatchTypeV2) -> Self {
16275 self.match_type = Some(value);
16276 self
16277 }
16278
16279 pub fn with_highlight_spans(mut self, value: Vec<HighlightSpan>) -> Self {
16280 self.highlight_spans = Some(value);
16281 self
16282 }
16283}
16284
16285const SEARCH_MATCH_V2_FIELDS: &[&str] = &["metadata",
16286 "match_type",
16287 "highlight_spans"];
16288impl SearchMatchV2 {
16289 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16290 map: V,
16291 ) -> Result<SearchMatchV2, V::Error> {
16292 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16293 }
16294
16295 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16296 mut map: V,
16297 optional: bool,
16298 ) -> Result<Option<SearchMatchV2>, V::Error> {
16299 let mut field_metadata = None;
16300 let mut field_match_type = None;
16301 let mut field_highlight_spans = None;
16302 let mut nothing = true;
16303 while let Some(key) = map.next_key::<&str>()? {
16304 nothing = false;
16305 match key {
16306 "metadata" => {
16307 if field_metadata.is_some() {
16308 return Err(::serde::de::Error::duplicate_field("metadata"));
16309 }
16310 field_metadata = Some(map.next_value()?);
16311 }
16312 "match_type" => {
16313 if field_match_type.is_some() {
16314 return Err(::serde::de::Error::duplicate_field("match_type"));
16315 }
16316 field_match_type = Some(map.next_value()?);
16317 }
16318 "highlight_spans" => {
16319 if field_highlight_spans.is_some() {
16320 return Err(::serde::de::Error::duplicate_field("highlight_spans"));
16321 }
16322 field_highlight_spans = Some(map.next_value()?);
16323 }
16324 _ => {
16325 map.next_value::<::serde_json::Value>()?;
16327 }
16328 }
16329 }
16330 if optional && nothing {
16331 return Ok(None);
16332 }
16333 let result = SearchMatchV2 {
16334 metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
16335 match_type: field_match_type.and_then(Option::flatten),
16336 highlight_spans: field_highlight_spans.and_then(Option::flatten),
16337 };
16338 Ok(Some(result))
16339 }
16340
16341 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16342 &self,
16343 s: &mut S::SerializeStruct,
16344 ) -> Result<(), S::Error> {
16345 use serde::ser::SerializeStruct;
16346 s.serialize_field("metadata", &self.metadata)?;
16347 if let Some(val) = &self.match_type {
16348 s.serialize_field("match_type", val)?;
16349 }
16350 if let Some(val) = &self.highlight_spans {
16351 s.serialize_field("highlight_spans", val)?;
16352 }
16353 Ok(())
16354 }
16355}
16356
16357impl<'de> ::serde::de::Deserialize<'de> for SearchMatchV2 {
16358 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16359 use serde::de::{MapAccess, Visitor};
16361 struct StructVisitor;
16362 impl<'de> Visitor<'de> for StructVisitor {
16363 type Value = SearchMatchV2;
16364 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16365 f.write_str("a SearchMatchV2 struct")
16366 }
16367 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16368 SearchMatchV2::internal_deserialize(map)
16369 }
16370 }
16371 deserializer.deserialize_struct("SearchMatchV2", SEARCH_MATCH_V2_FIELDS, StructVisitor)
16372 }
16373}
16374
16375impl ::serde::ser::Serialize for SearchMatchV2 {
16376 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16377 use serde::ser::SerializeStruct;
16379 let mut s = serializer.serialize_struct("SearchMatchV2", 3)?;
16380 self.internal_serialize::<S>(&mut s)?;
16381 s.end()
16382 }
16383}
16384
16385#[derive(Debug, Clone, PartialEq, Eq)]
16386pub enum SearchMode {
16387 Filename,
16389 FilenameAndContent,
16391 DeletedFilename,
16393}
16394
16395impl<'de> ::serde::de::Deserialize<'de> for SearchMode {
16396 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16397 use serde::de::{self, MapAccess, Visitor};
16399 struct EnumVisitor;
16400 impl<'de> Visitor<'de> for EnumVisitor {
16401 type Value = SearchMode;
16402 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16403 f.write_str("a SearchMode structure")
16404 }
16405 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16406 let tag: &str = match map.next_key()? {
16407 Some(".tag") => map.next_value()?,
16408 _ => return Err(de::Error::missing_field(".tag"))
16409 };
16410 let value = match tag {
16411 "filename" => SearchMode::Filename,
16412 "filename_and_content" => SearchMode::FilenameAndContent,
16413 "deleted_filename" => SearchMode::DeletedFilename,
16414 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
16415 };
16416 crate::eat_json_fields(&mut map)?;
16417 Ok(value)
16418 }
16419 }
16420 const VARIANTS: &[&str] = &["filename",
16421 "filename_and_content",
16422 "deleted_filename"];
16423 deserializer.deserialize_struct("SearchMode", VARIANTS, EnumVisitor)
16424 }
16425}
16426
16427impl ::serde::ser::Serialize for SearchMode {
16428 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16429 use serde::ser::SerializeStruct;
16431 match self {
16432 SearchMode::Filename => {
16433 let mut s = serializer.serialize_struct("SearchMode", 1)?;
16435 s.serialize_field(".tag", "filename")?;
16436 s.end()
16437 }
16438 SearchMode::FilenameAndContent => {
16439 let mut s = serializer.serialize_struct("SearchMode", 1)?;
16441 s.serialize_field(".tag", "filename_and_content")?;
16442 s.end()
16443 }
16444 SearchMode::DeletedFilename => {
16445 let mut s = serializer.serialize_struct("SearchMode", 1)?;
16447 s.serialize_field(".tag", "deleted_filename")?;
16448 s.end()
16449 }
16450 }
16451 }
16452}
16453
16454#[derive(Debug, Clone, PartialEq, Eq)]
16455#[non_exhaustive] pub struct SearchOptions {
16457 pub path: Option<PathROrId>,
16460 pub max_results: u64,
16462 pub order_by: Option<SearchOrderBy>,
16465 pub file_status: FileStatus,
16467 pub filename_only: bool,
16469 pub file_extensions: Option<Vec<String>>,
16471 pub file_categories: Option<Vec<FileCategory>>,
16474 pub account_id: Option<crate::types::users_common::AccountId>,
16476}
16477
16478impl Default for SearchOptions {
16479 fn default() -> Self {
16480 SearchOptions {
16481 path: None,
16482 max_results: 100,
16483 order_by: None,
16484 file_status: FileStatus::Active,
16485 filename_only: false,
16486 file_extensions: None,
16487 file_categories: None,
16488 account_id: None,
16489 }
16490 }
16491}
16492
16493impl SearchOptions {
16494 pub fn with_path(mut self, value: PathROrId) -> Self {
16495 self.path = Some(value);
16496 self
16497 }
16498
16499 pub fn with_max_results(mut self, value: u64) -> Self {
16500 self.max_results = value;
16501 self
16502 }
16503
16504 pub fn with_order_by(mut self, value: SearchOrderBy) -> Self {
16505 self.order_by = Some(value);
16506 self
16507 }
16508
16509 pub fn with_file_status(mut self, value: FileStatus) -> Self {
16510 self.file_status = value;
16511 self
16512 }
16513
16514 pub fn with_filename_only(mut self, value: bool) -> Self {
16515 self.filename_only = value;
16516 self
16517 }
16518
16519 pub fn with_file_extensions(mut self, value: Vec<String>) -> Self {
16520 self.file_extensions = Some(value);
16521 self
16522 }
16523
16524 pub fn with_file_categories(mut self, value: Vec<FileCategory>) -> Self {
16525 self.file_categories = Some(value);
16526 self
16527 }
16528
16529 pub fn with_account_id(mut self, value: crate::types::users_common::AccountId) -> Self {
16530 self.account_id = Some(value);
16531 self
16532 }
16533}
16534
16535const SEARCH_OPTIONS_FIELDS: &[&str] = &["path",
16536 "max_results",
16537 "order_by",
16538 "file_status",
16539 "filename_only",
16540 "file_extensions",
16541 "file_categories",
16542 "account_id"];
16543impl SearchOptions {
16544 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16546 mut map: V,
16547 ) -> Result<SearchOptions, V::Error> {
16548 let mut field_path = None;
16549 let mut field_max_results = None;
16550 let mut field_order_by = None;
16551 let mut field_file_status = None;
16552 let mut field_filename_only = None;
16553 let mut field_file_extensions = None;
16554 let mut field_file_categories = None;
16555 let mut field_account_id = None;
16556 while let Some(key) = map.next_key::<&str>()? {
16557 match key {
16558 "path" => {
16559 if field_path.is_some() {
16560 return Err(::serde::de::Error::duplicate_field("path"));
16561 }
16562 field_path = Some(map.next_value()?);
16563 }
16564 "max_results" => {
16565 if field_max_results.is_some() {
16566 return Err(::serde::de::Error::duplicate_field("max_results"));
16567 }
16568 field_max_results = Some(map.next_value()?);
16569 }
16570 "order_by" => {
16571 if field_order_by.is_some() {
16572 return Err(::serde::de::Error::duplicate_field("order_by"));
16573 }
16574 field_order_by = Some(map.next_value()?);
16575 }
16576 "file_status" => {
16577 if field_file_status.is_some() {
16578 return Err(::serde::de::Error::duplicate_field("file_status"));
16579 }
16580 field_file_status = Some(map.next_value()?);
16581 }
16582 "filename_only" => {
16583 if field_filename_only.is_some() {
16584 return Err(::serde::de::Error::duplicate_field("filename_only"));
16585 }
16586 field_filename_only = Some(map.next_value()?);
16587 }
16588 "file_extensions" => {
16589 if field_file_extensions.is_some() {
16590 return Err(::serde::de::Error::duplicate_field("file_extensions"));
16591 }
16592 field_file_extensions = Some(map.next_value()?);
16593 }
16594 "file_categories" => {
16595 if field_file_categories.is_some() {
16596 return Err(::serde::de::Error::duplicate_field("file_categories"));
16597 }
16598 field_file_categories = Some(map.next_value()?);
16599 }
16600 "account_id" => {
16601 if field_account_id.is_some() {
16602 return Err(::serde::de::Error::duplicate_field("account_id"));
16603 }
16604 field_account_id = Some(map.next_value()?);
16605 }
16606 _ => {
16607 map.next_value::<::serde_json::Value>()?;
16609 }
16610 }
16611 }
16612 let result = SearchOptions {
16613 path: field_path.and_then(Option::flatten),
16614 max_results: field_max_results.unwrap_or(100),
16615 order_by: field_order_by.and_then(Option::flatten),
16616 file_status: field_file_status.unwrap_or(FileStatus::Active),
16617 filename_only: field_filename_only.unwrap_or(false),
16618 file_extensions: field_file_extensions.and_then(Option::flatten),
16619 file_categories: field_file_categories.and_then(Option::flatten),
16620 account_id: field_account_id.and_then(Option::flatten),
16621 };
16622 Ok(result)
16623 }
16624
16625 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16626 &self,
16627 s: &mut S::SerializeStruct,
16628 ) -> Result<(), S::Error> {
16629 use serde::ser::SerializeStruct;
16630 if let Some(val) = &self.path {
16631 s.serialize_field("path", val)?;
16632 }
16633 if self.max_results != 100 {
16634 s.serialize_field("max_results", &self.max_results)?;
16635 }
16636 if let Some(val) = &self.order_by {
16637 s.serialize_field("order_by", val)?;
16638 }
16639 if self.file_status != FileStatus::Active {
16640 s.serialize_field("file_status", &self.file_status)?;
16641 }
16642 if self.filename_only {
16643 s.serialize_field("filename_only", &self.filename_only)?;
16644 }
16645 if let Some(val) = &self.file_extensions {
16646 s.serialize_field("file_extensions", val)?;
16647 }
16648 if let Some(val) = &self.file_categories {
16649 s.serialize_field("file_categories", val)?;
16650 }
16651 if let Some(val) = &self.account_id {
16652 s.serialize_field("account_id", val)?;
16653 }
16654 Ok(())
16655 }
16656}
16657
16658impl<'de> ::serde::de::Deserialize<'de> for SearchOptions {
16659 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16660 use serde::de::{MapAccess, Visitor};
16662 struct StructVisitor;
16663 impl<'de> Visitor<'de> for StructVisitor {
16664 type Value = SearchOptions;
16665 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16666 f.write_str("a SearchOptions struct")
16667 }
16668 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16669 SearchOptions::internal_deserialize(map)
16670 }
16671 }
16672 deserializer.deserialize_struct("SearchOptions", SEARCH_OPTIONS_FIELDS, StructVisitor)
16673 }
16674}
16675
16676impl ::serde::ser::Serialize for SearchOptions {
16677 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16678 use serde::ser::SerializeStruct;
16680 let mut s = serializer.serialize_struct("SearchOptions", 8)?;
16681 self.internal_serialize::<S>(&mut s)?;
16682 s.end()
16683 }
16684}
16685
16686#[derive(Debug, Clone, PartialEq, Eq)]
16687#[non_exhaustive] pub enum SearchOrderBy {
16689 Relevance,
16690 LastModifiedTime,
16691 Other,
16694}
16695
16696impl<'de> ::serde::de::Deserialize<'de> for SearchOrderBy {
16697 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16698 use serde::de::{self, MapAccess, Visitor};
16700 struct EnumVisitor;
16701 impl<'de> Visitor<'de> for EnumVisitor {
16702 type Value = SearchOrderBy;
16703 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16704 f.write_str("a SearchOrderBy structure")
16705 }
16706 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
16707 let tag: &str = match map.next_key()? {
16708 Some(".tag") => map.next_value()?,
16709 _ => return Err(de::Error::missing_field(".tag"))
16710 };
16711 let value = match tag {
16712 "relevance" => SearchOrderBy::Relevance,
16713 "last_modified_time" => SearchOrderBy::LastModifiedTime,
16714 _ => SearchOrderBy::Other,
16715 };
16716 crate::eat_json_fields(&mut map)?;
16717 Ok(value)
16718 }
16719 }
16720 const VARIANTS: &[&str] = &["relevance",
16721 "last_modified_time",
16722 "other"];
16723 deserializer.deserialize_struct("SearchOrderBy", VARIANTS, EnumVisitor)
16724 }
16725}
16726
16727impl ::serde::ser::Serialize for SearchOrderBy {
16728 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16729 use serde::ser::SerializeStruct;
16731 match self {
16732 SearchOrderBy::Relevance => {
16733 let mut s = serializer.serialize_struct("SearchOrderBy", 1)?;
16735 s.serialize_field(".tag", "relevance")?;
16736 s.end()
16737 }
16738 SearchOrderBy::LastModifiedTime => {
16739 let mut s = serializer.serialize_struct("SearchOrderBy", 1)?;
16741 s.serialize_field(".tag", "last_modified_time")?;
16742 s.end()
16743 }
16744 SearchOrderBy::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
16745 }
16746 }
16747}
16748
16749#[derive(Debug, Clone, PartialEq)]
16750#[non_exhaustive] pub struct SearchResult {
16752 pub matches: Vec<SearchMatch>,
16754 pub more: bool,
16757 pub start: u64,
16760}
16761
16762impl SearchResult {
16763 pub fn new(matches: Vec<SearchMatch>, more: bool, start: u64) -> Self {
16764 SearchResult {
16765 matches,
16766 more,
16767 start,
16768 }
16769 }
16770}
16771
16772const SEARCH_RESULT_FIELDS: &[&str] = &["matches",
16773 "more",
16774 "start"];
16775impl SearchResult {
16776 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16777 map: V,
16778 ) -> Result<SearchResult, V::Error> {
16779 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16780 }
16781
16782 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16783 mut map: V,
16784 optional: bool,
16785 ) -> Result<Option<SearchResult>, V::Error> {
16786 let mut field_matches = None;
16787 let mut field_more = None;
16788 let mut field_start = None;
16789 let mut nothing = true;
16790 while let Some(key) = map.next_key::<&str>()? {
16791 nothing = false;
16792 match key {
16793 "matches" => {
16794 if field_matches.is_some() {
16795 return Err(::serde::de::Error::duplicate_field("matches"));
16796 }
16797 field_matches = Some(map.next_value()?);
16798 }
16799 "more" => {
16800 if field_more.is_some() {
16801 return Err(::serde::de::Error::duplicate_field("more"));
16802 }
16803 field_more = Some(map.next_value()?);
16804 }
16805 "start" => {
16806 if field_start.is_some() {
16807 return Err(::serde::de::Error::duplicate_field("start"));
16808 }
16809 field_start = Some(map.next_value()?);
16810 }
16811 _ => {
16812 map.next_value::<::serde_json::Value>()?;
16814 }
16815 }
16816 }
16817 if optional && nothing {
16818 return Ok(None);
16819 }
16820 let result = SearchResult {
16821 matches: field_matches.ok_or_else(|| ::serde::de::Error::missing_field("matches"))?,
16822 more: field_more.ok_or_else(|| ::serde::de::Error::missing_field("more"))?,
16823 start: field_start.ok_or_else(|| ::serde::de::Error::missing_field("start"))?,
16824 };
16825 Ok(Some(result))
16826 }
16827
16828 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16829 &self,
16830 s: &mut S::SerializeStruct,
16831 ) -> Result<(), S::Error> {
16832 use serde::ser::SerializeStruct;
16833 s.serialize_field("matches", &self.matches)?;
16834 s.serialize_field("more", &self.more)?;
16835 s.serialize_field("start", &self.start)?;
16836 Ok(())
16837 }
16838}
16839
16840impl<'de> ::serde::de::Deserialize<'de> for SearchResult {
16841 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16842 use serde::de::{MapAccess, Visitor};
16844 struct StructVisitor;
16845 impl<'de> Visitor<'de> for StructVisitor {
16846 type Value = SearchResult;
16847 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
16848 f.write_str("a SearchResult struct")
16849 }
16850 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
16851 SearchResult::internal_deserialize(map)
16852 }
16853 }
16854 deserializer.deserialize_struct("SearchResult", SEARCH_RESULT_FIELDS, StructVisitor)
16855 }
16856}
16857
16858impl ::serde::ser::Serialize for SearchResult {
16859 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
16860 use serde::ser::SerializeStruct;
16862 let mut s = serializer.serialize_struct("SearchResult", 3)?;
16863 self.internal_serialize::<S>(&mut s)?;
16864 s.end()
16865 }
16866}
16867
16868#[derive(Debug, Clone, PartialEq, Eq)]
16869#[non_exhaustive] pub struct SearchV2Arg {
16871 pub query: String,
16873 pub options: Option<SearchOptions>,
16875 pub match_field_options: Option<SearchMatchFieldOptions>,
16877 #[deprecated]
16879 pub include_highlights: Option<bool>,
16880}
16881
16882impl SearchV2Arg {
16883 pub fn new(query: String) -> Self {
16884 SearchV2Arg {
16885 query,
16886 options: None,
16887 match_field_options: None,
16888 #[allow(deprecated)] include_highlights: None,
16889 }
16890 }
16891
16892 pub fn with_options(mut self, value: SearchOptions) -> Self {
16893 self.options = Some(value);
16894 self
16895 }
16896
16897 pub fn with_match_field_options(mut self, value: SearchMatchFieldOptions) -> Self {
16898 self.match_field_options = Some(value);
16899 self
16900 }
16901
16902 #[deprecated]
16903 #[allow(deprecated)]
16904 pub fn with_include_highlights(mut self, value: bool) -> Self {
16905 self.include_highlights = Some(value);
16906 self
16907 }
16908}
16909
16910const SEARCH_V2_ARG_FIELDS: &[&str] = &["query",
16911 "options",
16912 "match_field_options",
16913 "include_highlights"];
16914impl SearchV2Arg {
16915 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
16916 map: V,
16917 ) -> Result<SearchV2Arg, V::Error> {
16918 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
16919 }
16920
16921 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
16922 mut map: V,
16923 optional: bool,
16924 ) -> Result<Option<SearchV2Arg>, V::Error> {
16925 let mut field_query = None;
16926 let mut field_options = None;
16927 let mut field_match_field_options = None;
16928 let mut field_include_highlights = None;
16929 let mut nothing = true;
16930 while let Some(key) = map.next_key::<&str>()? {
16931 nothing = false;
16932 match key {
16933 "query" => {
16934 if field_query.is_some() {
16935 return Err(::serde::de::Error::duplicate_field("query"));
16936 }
16937 field_query = Some(map.next_value()?);
16938 }
16939 "options" => {
16940 if field_options.is_some() {
16941 return Err(::serde::de::Error::duplicate_field("options"));
16942 }
16943 field_options = Some(map.next_value()?);
16944 }
16945 "match_field_options" => {
16946 if field_match_field_options.is_some() {
16947 return Err(::serde::de::Error::duplicate_field("match_field_options"));
16948 }
16949 field_match_field_options = Some(map.next_value()?);
16950 }
16951 "include_highlights" => {
16952 if field_include_highlights.is_some() {
16953 return Err(::serde::de::Error::duplicate_field("include_highlights"));
16954 }
16955 field_include_highlights = Some(map.next_value()?);
16956 }
16957 _ => {
16958 map.next_value::<::serde_json::Value>()?;
16960 }
16961 }
16962 }
16963 if optional && nothing {
16964 return Ok(None);
16965 }
16966 let result = SearchV2Arg {
16967 query: field_query.ok_or_else(|| ::serde::de::Error::missing_field("query"))?,
16968 options: field_options.and_then(Option::flatten),
16969 match_field_options: field_match_field_options.and_then(Option::flatten),
16970 #[allow(deprecated)] include_highlights: field_include_highlights.and_then(Option::flatten),
16971 };
16972 Ok(Some(result))
16973 }
16974
16975 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
16976 &self,
16977 s: &mut S::SerializeStruct,
16978 ) -> Result<(), S::Error> {
16979 use serde::ser::SerializeStruct;
16980 s.serialize_field("query", &self.query)?;
16981 if let Some(val) = &self.options {
16982 s.serialize_field("options", val)?;
16983 }
16984 if let Some(val) = &self.match_field_options {
16985 s.serialize_field("match_field_options", val)?;
16986 }
16987 #[allow(deprecated)]
16988 if let Some(val) = &self.include_highlights {
16989 s.serialize_field("include_highlights", val)?;
16990 }
16991 Ok(())
16992 }
16993}
16994
16995impl<'de> ::serde::de::Deserialize<'de> for SearchV2Arg {
16996 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
16997 use serde::de::{MapAccess, Visitor};
16999 struct StructVisitor;
17000 impl<'de> Visitor<'de> for StructVisitor {
17001 type Value = SearchV2Arg;
17002 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17003 f.write_str("a SearchV2Arg struct")
17004 }
17005 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17006 SearchV2Arg::internal_deserialize(map)
17007 }
17008 }
17009 deserializer.deserialize_struct("SearchV2Arg", SEARCH_V2_ARG_FIELDS, StructVisitor)
17010 }
17011}
17012
17013impl ::serde::ser::Serialize for SearchV2Arg {
17014 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17015 use serde::ser::SerializeStruct;
17017 let mut s = serializer.serialize_struct("SearchV2Arg", 4)?;
17018 self.internal_serialize::<S>(&mut s)?;
17019 s.end()
17020 }
17021}
17022
17023#[derive(Debug, Clone, PartialEq, Eq)]
17024#[non_exhaustive] pub struct SearchV2ContinueArg {
17026 pub cursor: SearchV2Cursor,
17029}
17030
17031impl SearchV2ContinueArg {
17032 pub fn new(cursor: SearchV2Cursor) -> Self {
17033 SearchV2ContinueArg {
17034 cursor,
17035 }
17036 }
17037}
17038
17039const SEARCH_V2_CONTINUE_ARG_FIELDS: &[&str] = &["cursor"];
17040impl SearchV2ContinueArg {
17041 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17042 map: V,
17043 ) -> Result<SearchV2ContinueArg, V::Error> {
17044 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17045 }
17046
17047 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17048 mut map: V,
17049 optional: bool,
17050 ) -> Result<Option<SearchV2ContinueArg>, V::Error> {
17051 let mut field_cursor = None;
17052 let mut nothing = true;
17053 while let Some(key) = map.next_key::<&str>()? {
17054 nothing = false;
17055 match key {
17056 "cursor" => {
17057 if field_cursor.is_some() {
17058 return Err(::serde::de::Error::duplicate_field("cursor"));
17059 }
17060 field_cursor = Some(map.next_value()?);
17061 }
17062 _ => {
17063 map.next_value::<::serde_json::Value>()?;
17065 }
17066 }
17067 }
17068 if optional && nothing {
17069 return Ok(None);
17070 }
17071 let result = SearchV2ContinueArg {
17072 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
17073 };
17074 Ok(Some(result))
17075 }
17076
17077 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17078 &self,
17079 s: &mut S::SerializeStruct,
17080 ) -> Result<(), S::Error> {
17081 use serde::ser::SerializeStruct;
17082 s.serialize_field("cursor", &self.cursor)?;
17083 Ok(())
17084 }
17085}
17086
17087impl<'de> ::serde::de::Deserialize<'de> for SearchV2ContinueArg {
17088 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17089 use serde::de::{MapAccess, Visitor};
17091 struct StructVisitor;
17092 impl<'de> Visitor<'de> for StructVisitor {
17093 type Value = SearchV2ContinueArg;
17094 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17095 f.write_str("a SearchV2ContinueArg struct")
17096 }
17097 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17098 SearchV2ContinueArg::internal_deserialize(map)
17099 }
17100 }
17101 deserializer.deserialize_struct("SearchV2ContinueArg", SEARCH_V2_CONTINUE_ARG_FIELDS, StructVisitor)
17102 }
17103}
17104
17105impl ::serde::ser::Serialize for SearchV2ContinueArg {
17106 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17107 use serde::ser::SerializeStruct;
17109 let mut s = serializer.serialize_struct("SearchV2ContinueArg", 1)?;
17110 self.internal_serialize::<S>(&mut s)?;
17111 s.end()
17112 }
17113}
17114
17115#[derive(Debug, Clone, PartialEq)]
17116#[non_exhaustive] pub struct SearchV2Result {
17118 pub matches: Vec<SearchMatchV2>,
17120 pub has_more: bool,
17124 pub cursor: Option<SearchV2Cursor>,
17127}
17128
17129impl SearchV2Result {
17130 pub fn new(matches: Vec<SearchMatchV2>, has_more: bool) -> Self {
17131 SearchV2Result {
17132 matches,
17133 has_more,
17134 cursor: None,
17135 }
17136 }
17137
17138 pub fn with_cursor(mut self, value: SearchV2Cursor) -> Self {
17139 self.cursor = Some(value);
17140 self
17141 }
17142}
17143
17144const SEARCH_V2_RESULT_FIELDS: &[&str] = &["matches",
17145 "has_more",
17146 "cursor"];
17147impl SearchV2Result {
17148 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17149 map: V,
17150 ) -> Result<SearchV2Result, V::Error> {
17151 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17152 }
17153
17154 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17155 mut map: V,
17156 optional: bool,
17157 ) -> Result<Option<SearchV2Result>, V::Error> {
17158 let mut field_matches = None;
17159 let mut field_has_more = None;
17160 let mut field_cursor = None;
17161 let mut nothing = true;
17162 while let Some(key) = map.next_key::<&str>()? {
17163 nothing = false;
17164 match key {
17165 "matches" => {
17166 if field_matches.is_some() {
17167 return Err(::serde::de::Error::duplicate_field("matches"));
17168 }
17169 field_matches = Some(map.next_value()?);
17170 }
17171 "has_more" => {
17172 if field_has_more.is_some() {
17173 return Err(::serde::de::Error::duplicate_field("has_more"));
17174 }
17175 field_has_more = Some(map.next_value()?);
17176 }
17177 "cursor" => {
17178 if field_cursor.is_some() {
17179 return Err(::serde::de::Error::duplicate_field("cursor"));
17180 }
17181 field_cursor = Some(map.next_value()?);
17182 }
17183 _ => {
17184 map.next_value::<::serde_json::Value>()?;
17186 }
17187 }
17188 }
17189 if optional && nothing {
17190 return Ok(None);
17191 }
17192 let result = SearchV2Result {
17193 matches: field_matches.ok_or_else(|| ::serde::de::Error::missing_field("matches"))?,
17194 has_more: field_has_more.ok_or_else(|| ::serde::de::Error::missing_field("has_more"))?,
17195 cursor: field_cursor.and_then(Option::flatten),
17196 };
17197 Ok(Some(result))
17198 }
17199
17200 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17201 &self,
17202 s: &mut S::SerializeStruct,
17203 ) -> Result<(), S::Error> {
17204 use serde::ser::SerializeStruct;
17205 s.serialize_field("matches", &self.matches)?;
17206 s.serialize_field("has_more", &self.has_more)?;
17207 if let Some(val) = &self.cursor {
17208 s.serialize_field("cursor", val)?;
17209 }
17210 Ok(())
17211 }
17212}
17213
17214impl<'de> ::serde::de::Deserialize<'de> for SearchV2Result {
17215 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17216 use serde::de::{MapAccess, Visitor};
17218 struct StructVisitor;
17219 impl<'de> Visitor<'de> for StructVisitor {
17220 type Value = SearchV2Result;
17221 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17222 f.write_str("a SearchV2Result struct")
17223 }
17224 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17225 SearchV2Result::internal_deserialize(map)
17226 }
17227 }
17228 deserializer.deserialize_struct("SearchV2Result", SEARCH_V2_RESULT_FIELDS, StructVisitor)
17229 }
17230}
17231
17232impl ::serde::ser::Serialize for SearchV2Result {
17233 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17234 use serde::ser::SerializeStruct;
17236 let mut s = serializer.serialize_struct("SearchV2Result", 3)?;
17237 self.internal_serialize::<S>(&mut s)?;
17238 s.end()
17239 }
17240}
17241
17242#[derive(Debug, Clone, PartialEq, Eq)]
17243#[non_exhaustive] pub struct SharedLink {
17245 pub url: SharedLinkUrl,
17247 pub password: Option<String>,
17249}
17250
17251impl SharedLink {
17252 pub fn new(url: SharedLinkUrl) -> Self {
17253 SharedLink {
17254 url,
17255 password: None,
17256 }
17257 }
17258
17259 pub fn with_password(mut self, value: String) -> Self {
17260 self.password = Some(value);
17261 self
17262 }
17263}
17264
17265const SHARED_LINK_FIELDS: &[&str] = &["url",
17266 "password"];
17267impl SharedLink {
17268 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17269 map: V,
17270 ) -> Result<SharedLink, V::Error> {
17271 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17272 }
17273
17274 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17275 mut map: V,
17276 optional: bool,
17277 ) -> Result<Option<SharedLink>, V::Error> {
17278 let mut field_url = None;
17279 let mut field_password = None;
17280 let mut nothing = true;
17281 while let Some(key) = map.next_key::<&str>()? {
17282 nothing = false;
17283 match key {
17284 "url" => {
17285 if field_url.is_some() {
17286 return Err(::serde::de::Error::duplicate_field("url"));
17287 }
17288 field_url = Some(map.next_value()?);
17289 }
17290 "password" => {
17291 if field_password.is_some() {
17292 return Err(::serde::de::Error::duplicate_field("password"));
17293 }
17294 field_password = Some(map.next_value()?);
17295 }
17296 _ => {
17297 map.next_value::<::serde_json::Value>()?;
17299 }
17300 }
17301 }
17302 if optional && nothing {
17303 return Ok(None);
17304 }
17305 let result = SharedLink {
17306 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
17307 password: field_password.and_then(Option::flatten),
17308 };
17309 Ok(Some(result))
17310 }
17311
17312 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17313 &self,
17314 s: &mut S::SerializeStruct,
17315 ) -> Result<(), S::Error> {
17316 use serde::ser::SerializeStruct;
17317 s.serialize_field("url", &self.url)?;
17318 if let Some(val) = &self.password {
17319 s.serialize_field("password", val)?;
17320 }
17321 Ok(())
17322 }
17323}
17324
17325impl<'de> ::serde::de::Deserialize<'de> for SharedLink {
17326 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17327 use serde::de::{MapAccess, Visitor};
17329 struct StructVisitor;
17330 impl<'de> Visitor<'de> for StructVisitor {
17331 type Value = SharedLink;
17332 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17333 f.write_str("a SharedLink struct")
17334 }
17335 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17336 SharedLink::internal_deserialize(map)
17337 }
17338 }
17339 deserializer.deserialize_struct("SharedLink", SHARED_LINK_FIELDS, StructVisitor)
17340 }
17341}
17342
17343impl ::serde::ser::Serialize for SharedLink {
17344 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17345 use serde::ser::SerializeStruct;
17347 let mut s = serializer.serialize_struct("SharedLink", 2)?;
17348 self.internal_serialize::<S>(&mut s)?;
17349 s.end()
17350 }
17351}
17352
17353#[derive(Debug, Clone, PartialEq, Eq)]
17354#[non_exhaustive] pub struct SharedLinkFileInfo {
17356 pub url: String,
17360 pub path: Option<String>,
17363 pub password: Option<String>,
17366}
17367
17368impl SharedLinkFileInfo {
17369 pub fn new(url: String) -> Self {
17370 SharedLinkFileInfo {
17371 url,
17372 path: None,
17373 password: None,
17374 }
17375 }
17376
17377 pub fn with_path(mut self, value: String) -> Self {
17378 self.path = Some(value);
17379 self
17380 }
17381
17382 pub fn with_password(mut self, value: String) -> Self {
17383 self.password = Some(value);
17384 self
17385 }
17386}
17387
17388const SHARED_LINK_FILE_INFO_FIELDS: &[&str] = &["url",
17389 "path",
17390 "password"];
17391impl SharedLinkFileInfo {
17392 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17393 map: V,
17394 ) -> Result<SharedLinkFileInfo, V::Error> {
17395 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17396 }
17397
17398 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17399 mut map: V,
17400 optional: bool,
17401 ) -> Result<Option<SharedLinkFileInfo>, V::Error> {
17402 let mut field_url = None;
17403 let mut field_path = None;
17404 let mut field_password = None;
17405 let mut nothing = true;
17406 while let Some(key) = map.next_key::<&str>()? {
17407 nothing = false;
17408 match key {
17409 "url" => {
17410 if field_url.is_some() {
17411 return Err(::serde::de::Error::duplicate_field("url"));
17412 }
17413 field_url = Some(map.next_value()?);
17414 }
17415 "path" => {
17416 if field_path.is_some() {
17417 return Err(::serde::de::Error::duplicate_field("path"));
17418 }
17419 field_path = Some(map.next_value()?);
17420 }
17421 "password" => {
17422 if field_password.is_some() {
17423 return Err(::serde::de::Error::duplicate_field("password"));
17424 }
17425 field_password = Some(map.next_value()?);
17426 }
17427 _ => {
17428 map.next_value::<::serde_json::Value>()?;
17430 }
17431 }
17432 }
17433 if optional && nothing {
17434 return Ok(None);
17435 }
17436 let result = SharedLinkFileInfo {
17437 url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
17438 path: field_path.and_then(Option::flatten),
17439 password: field_password.and_then(Option::flatten),
17440 };
17441 Ok(Some(result))
17442 }
17443
17444 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17445 &self,
17446 s: &mut S::SerializeStruct,
17447 ) -> Result<(), S::Error> {
17448 use serde::ser::SerializeStruct;
17449 s.serialize_field("url", &self.url)?;
17450 if let Some(val) = &self.path {
17451 s.serialize_field("path", val)?;
17452 }
17453 if let Some(val) = &self.password {
17454 s.serialize_field("password", val)?;
17455 }
17456 Ok(())
17457 }
17458}
17459
17460impl<'de> ::serde::de::Deserialize<'de> for SharedLinkFileInfo {
17461 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17462 use serde::de::{MapAccess, Visitor};
17464 struct StructVisitor;
17465 impl<'de> Visitor<'de> for StructVisitor {
17466 type Value = SharedLinkFileInfo;
17467 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17468 f.write_str("a SharedLinkFileInfo struct")
17469 }
17470 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17471 SharedLinkFileInfo::internal_deserialize(map)
17472 }
17473 }
17474 deserializer.deserialize_struct("SharedLinkFileInfo", SHARED_LINK_FILE_INFO_FIELDS, StructVisitor)
17475 }
17476}
17477
17478impl ::serde::ser::Serialize for SharedLinkFileInfo {
17479 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17480 use serde::ser::SerializeStruct;
17482 let mut s = serializer.serialize_struct("SharedLinkFileInfo", 3)?;
17483 self.internal_serialize::<S>(&mut s)?;
17484 s.end()
17485 }
17486}
17487
17488#[derive(Debug, Clone, PartialEq, Eq)]
17490#[non_exhaustive] pub struct SharingInfo {
17492 pub read_only: bool,
17494}
17495
17496impl SharingInfo {
17497 pub fn new(read_only: bool) -> Self {
17498 SharingInfo {
17499 read_only,
17500 }
17501 }
17502}
17503
17504const SHARING_INFO_FIELDS: &[&str] = &["read_only"];
17505impl SharingInfo {
17506 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17507 map: V,
17508 ) -> Result<SharingInfo, V::Error> {
17509 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17510 }
17511
17512 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17513 mut map: V,
17514 optional: bool,
17515 ) -> Result<Option<SharingInfo>, V::Error> {
17516 let mut field_read_only = None;
17517 let mut nothing = true;
17518 while let Some(key) = map.next_key::<&str>()? {
17519 nothing = false;
17520 match key {
17521 "read_only" => {
17522 if field_read_only.is_some() {
17523 return Err(::serde::de::Error::duplicate_field("read_only"));
17524 }
17525 field_read_only = Some(map.next_value()?);
17526 }
17527 _ => {
17528 map.next_value::<::serde_json::Value>()?;
17530 }
17531 }
17532 }
17533 if optional && nothing {
17534 return Ok(None);
17535 }
17536 let result = SharingInfo {
17537 read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
17538 };
17539 Ok(Some(result))
17540 }
17541
17542 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17543 &self,
17544 s: &mut S::SerializeStruct,
17545 ) -> Result<(), S::Error> {
17546 use serde::ser::SerializeStruct;
17547 s.serialize_field("read_only", &self.read_only)?;
17548 Ok(())
17549 }
17550}
17551
17552impl<'de> ::serde::de::Deserialize<'de> for SharingInfo {
17553 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17554 use serde::de::{MapAccess, Visitor};
17556 struct StructVisitor;
17557 impl<'de> Visitor<'de> for StructVisitor {
17558 type Value = SharingInfo;
17559 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17560 f.write_str("a SharingInfo struct")
17561 }
17562 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17563 SharingInfo::internal_deserialize(map)
17564 }
17565 }
17566 deserializer.deserialize_struct("SharingInfo", SHARING_INFO_FIELDS, StructVisitor)
17567 }
17568}
17569
17570impl ::serde::ser::Serialize for SharingInfo {
17571 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17572 use serde::ser::SerializeStruct;
17574 let mut s = serializer.serialize_struct("SharingInfo", 1)?;
17575 self.internal_serialize::<S>(&mut s)?;
17576 s.end()
17577 }
17578}
17579
17580#[derive(Debug, Clone, PartialEq, Eq)]
17581#[non_exhaustive] pub struct SingleUserLock {
17583 pub created: crate::types::common::DropboxTimestamp,
17585 pub lock_holder_account_id: crate::types::users_common::AccountId,
17587 pub lock_holder_team_id: Option<String>,
17589}
17590
17591impl SingleUserLock {
17592 pub fn new(
17593 created: crate::types::common::DropboxTimestamp,
17594 lock_holder_account_id: crate::types::users_common::AccountId,
17595 ) -> Self {
17596 SingleUserLock {
17597 created,
17598 lock_holder_account_id,
17599 lock_holder_team_id: None,
17600 }
17601 }
17602
17603 pub fn with_lock_holder_team_id(mut self, value: String) -> Self {
17604 self.lock_holder_team_id = Some(value);
17605 self
17606 }
17607}
17608
17609const SINGLE_USER_LOCK_FIELDS: &[&str] = &["created",
17610 "lock_holder_account_id",
17611 "lock_holder_team_id"];
17612impl SingleUserLock {
17613 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17614 map: V,
17615 ) -> Result<SingleUserLock, V::Error> {
17616 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17617 }
17618
17619 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17620 mut map: V,
17621 optional: bool,
17622 ) -> Result<Option<SingleUserLock>, V::Error> {
17623 let mut field_created = None;
17624 let mut field_lock_holder_account_id = None;
17625 let mut field_lock_holder_team_id = None;
17626 let mut nothing = true;
17627 while let Some(key) = map.next_key::<&str>()? {
17628 nothing = false;
17629 match key {
17630 "created" => {
17631 if field_created.is_some() {
17632 return Err(::serde::de::Error::duplicate_field("created"));
17633 }
17634 field_created = Some(map.next_value()?);
17635 }
17636 "lock_holder_account_id" => {
17637 if field_lock_holder_account_id.is_some() {
17638 return Err(::serde::de::Error::duplicate_field("lock_holder_account_id"));
17639 }
17640 field_lock_holder_account_id = Some(map.next_value()?);
17641 }
17642 "lock_holder_team_id" => {
17643 if field_lock_holder_team_id.is_some() {
17644 return Err(::serde::de::Error::duplicate_field("lock_holder_team_id"));
17645 }
17646 field_lock_holder_team_id = Some(map.next_value()?);
17647 }
17648 _ => {
17649 map.next_value::<::serde_json::Value>()?;
17651 }
17652 }
17653 }
17654 if optional && nothing {
17655 return Ok(None);
17656 }
17657 let result = SingleUserLock {
17658 created: field_created.ok_or_else(|| ::serde::de::Error::missing_field("created"))?,
17659 lock_holder_account_id: field_lock_holder_account_id.ok_or_else(|| ::serde::de::Error::missing_field("lock_holder_account_id"))?,
17660 lock_holder_team_id: field_lock_holder_team_id.and_then(Option::flatten),
17661 };
17662 Ok(Some(result))
17663 }
17664
17665 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17666 &self,
17667 s: &mut S::SerializeStruct,
17668 ) -> Result<(), S::Error> {
17669 use serde::ser::SerializeStruct;
17670 s.serialize_field("created", &self.created)?;
17671 s.serialize_field("lock_holder_account_id", &self.lock_holder_account_id)?;
17672 if let Some(val) = &self.lock_holder_team_id {
17673 s.serialize_field("lock_holder_team_id", val)?;
17674 }
17675 Ok(())
17676 }
17677}
17678
17679impl<'de> ::serde::de::Deserialize<'de> for SingleUserLock {
17680 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17681 use serde::de::{MapAccess, Visitor};
17683 struct StructVisitor;
17684 impl<'de> Visitor<'de> for StructVisitor {
17685 type Value = SingleUserLock;
17686 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17687 f.write_str("a SingleUserLock struct")
17688 }
17689 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17690 SingleUserLock::internal_deserialize(map)
17691 }
17692 }
17693 deserializer.deserialize_struct("SingleUserLock", SINGLE_USER_LOCK_FIELDS, StructVisitor)
17694 }
17695}
17696
17697impl ::serde::ser::Serialize for SingleUserLock {
17698 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17699 use serde::ser::SerializeStruct;
17701 let mut s = serializer.serialize_struct("SingleUserLock", 3)?;
17702 self.internal_serialize::<S>(&mut s)?;
17703 s.end()
17704 }
17705}
17706
17707#[derive(Debug, Clone, PartialEq, Eq)]
17708#[non_exhaustive] pub struct SymlinkInfo {
17710 pub target: String,
17712}
17713
17714impl SymlinkInfo {
17715 pub fn new(target: String) -> Self {
17716 SymlinkInfo {
17717 target,
17718 }
17719 }
17720}
17721
17722const SYMLINK_INFO_FIELDS: &[&str] = &["target"];
17723impl SymlinkInfo {
17724 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
17725 map: V,
17726 ) -> Result<SymlinkInfo, V::Error> {
17727 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
17728 }
17729
17730 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
17731 mut map: V,
17732 optional: bool,
17733 ) -> Result<Option<SymlinkInfo>, V::Error> {
17734 let mut field_target = None;
17735 let mut nothing = true;
17736 while let Some(key) = map.next_key::<&str>()? {
17737 nothing = false;
17738 match key {
17739 "target" => {
17740 if field_target.is_some() {
17741 return Err(::serde::de::Error::duplicate_field("target"));
17742 }
17743 field_target = Some(map.next_value()?);
17744 }
17745 _ => {
17746 map.next_value::<::serde_json::Value>()?;
17748 }
17749 }
17750 }
17751 if optional && nothing {
17752 return Ok(None);
17753 }
17754 let result = SymlinkInfo {
17755 target: field_target.ok_or_else(|| ::serde::de::Error::missing_field("target"))?,
17756 };
17757 Ok(Some(result))
17758 }
17759
17760 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
17761 &self,
17762 s: &mut S::SerializeStruct,
17763 ) -> Result<(), S::Error> {
17764 use serde::ser::SerializeStruct;
17765 s.serialize_field("target", &self.target)?;
17766 Ok(())
17767 }
17768}
17769
17770impl<'de> ::serde::de::Deserialize<'de> for SymlinkInfo {
17771 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17772 use serde::de::{MapAccess, Visitor};
17774 struct StructVisitor;
17775 impl<'de> Visitor<'de> for StructVisitor {
17776 type Value = SymlinkInfo;
17777 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17778 f.write_str("a SymlinkInfo struct")
17779 }
17780 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
17781 SymlinkInfo::internal_deserialize(map)
17782 }
17783 }
17784 deserializer.deserialize_struct("SymlinkInfo", SYMLINK_INFO_FIELDS, StructVisitor)
17785 }
17786}
17787
17788impl ::serde::ser::Serialize for SymlinkInfo {
17789 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17790 use serde::ser::SerializeStruct;
17792 let mut s = serializer.serialize_struct("SymlinkInfo", 1)?;
17793 self.internal_serialize::<S>(&mut s)?;
17794 s.end()
17795 }
17796}
17797
17798#[derive(Debug, Clone, PartialEq, Eq)]
17799#[non_exhaustive] pub enum SyncSetting {
17801 Default,
17804 NotSynced,
17807 NotSyncedInactive,
17810 Other,
17813}
17814
17815impl<'de> ::serde::de::Deserialize<'de> for SyncSetting {
17816 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17817 use serde::de::{self, MapAccess, Visitor};
17819 struct EnumVisitor;
17820 impl<'de> Visitor<'de> for EnumVisitor {
17821 type Value = SyncSetting;
17822 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17823 f.write_str("a SyncSetting structure")
17824 }
17825 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
17826 let tag: &str = match map.next_key()? {
17827 Some(".tag") => map.next_value()?,
17828 _ => return Err(de::Error::missing_field(".tag"))
17829 };
17830 let value = match tag {
17831 "default" => SyncSetting::Default,
17832 "not_synced" => SyncSetting::NotSynced,
17833 "not_synced_inactive" => SyncSetting::NotSyncedInactive,
17834 _ => SyncSetting::Other,
17835 };
17836 crate::eat_json_fields(&mut map)?;
17837 Ok(value)
17838 }
17839 }
17840 const VARIANTS: &[&str] = &["default",
17841 "not_synced",
17842 "not_synced_inactive",
17843 "other"];
17844 deserializer.deserialize_struct("SyncSetting", VARIANTS, EnumVisitor)
17845 }
17846}
17847
17848impl ::serde::ser::Serialize for SyncSetting {
17849 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17850 use serde::ser::SerializeStruct;
17852 match self {
17853 SyncSetting::Default => {
17854 let mut s = serializer.serialize_struct("SyncSetting", 1)?;
17856 s.serialize_field(".tag", "default")?;
17857 s.end()
17858 }
17859 SyncSetting::NotSynced => {
17860 let mut s = serializer.serialize_struct("SyncSetting", 1)?;
17862 s.serialize_field(".tag", "not_synced")?;
17863 s.end()
17864 }
17865 SyncSetting::NotSyncedInactive => {
17866 let mut s = serializer.serialize_struct("SyncSetting", 1)?;
17868 s.serialize_field(".tag", "not_synced_inactive")?;
17869 s.end()
17870 }
17871 SyncSetting::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
17872 }
17873 }
17874}
17875
17876#[derive(Debug, Clone, PartialEq, Eq)]
17877#[non_exhaustive] pub enum SyncSettingArg {
17879 Default,
17882 NotSynced,
17885 Other,
17888}
17889
17890impl<'de> ::serde::de::Deserialize<'de> for SyncSettingArg {
17891 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17892 use serde::de::{self, MapAccess, Visitor};
17894 struct EnumVisitor;
17895 impl<'de> Visitor<'de> for EnumVisitor {
17896 type Value = SyncSettingArg;
17897 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17898 f.write_str("a SyncSettingArg structure")
17899 }
17900 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
17901 let tag: &str = match map.next_key()? {
17902 Some(".tag") => map.next_value()?,
17903 _ => return Err(de::Error::missing_field(".tag"))
17904 };
17905 let value = match tag {
17906 "default" => SyncSettingArg::Default,
17907 "not_synced" => SyncSettingArg::NotSynced,
17908 _ => SyncSettingArg::Other,
17909 };
17910 crate::eat_json_fields(&mut map)?;
17911 Ok(value)
17912 }
17913 }
17914 const VARIANTS: &[&str] = &["default",
17915 "not_synced",
17916 "other"];
17917 deserializer.deserialize_struct("SyncSettingArg", VARIANTS, EnumVisitor)
17918 }
17919}
17920
17921impl ::serde::ser::Serialize for SyncSettingArg {
17922 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17923 use serde::ser::SerializeStruct;
17925 match self {
17926 SyncSettingArg::Default => {
17927 let mut s = serializer.serialize_struct("SyncSettingArg", 1)?;
17929 s.serialize_field(".tag", "default")?;
17930 s.end()
17931 }
17932 SyncSettingArg::NotSynced => {
17933 let mut s = serializer.serialize_struct("SyncSettingArg", 1)?;
17935 s.serialize_field(".tag", "not_synced")?;
17936 s.end()
17937 }
17938 SyncSettingArg::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
17939 }
17940 }
17941}
17942
17943#[derive(Debug, Clone, PartialEq, Eq)]
17944#[non_exhaustive] pub enum SyncSettingsError {
17946 Path(LookupError),
17947 UnsupportedCombination,
17949 UnsupportedConfiguration,
17951 Other,
17954}
17955
17956impl<'de> ::serde::de::Deserialize<'de> for SyncSettingsError {
17957 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
17958 use serde::de::{self, MapAccess, Visitor};
17960 struct EnumVisitor;
17961 impl<'de> Visitor<'de> for EnumVisitor {
17962 type Value = SyncSettingsError;
17963 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
17964 f.write_str("a SyncSettingsError structure")
17965 }
17966 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
17967 let tag: &str = match map.next_key()? {
17968 Some(".tag") => map.next_value()?,
17969 _ => return Err(de::Error::missing_field(".tag"))
17970 };
17971 let value = match tag {
17972 "path" => {
17973 match map.next_key()? {
17974 Some("path") => SyncSettingsError::Path(map.next_value()?),
17975 None => return Err(de::Error::missing_field("path")),
17976 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
17977 }
17978 }
17979 "unsupported_combination" => SyncSettingsError::UnsupportedCombination,
17980 "unsupported_configuration" => SyncSettingsError::UnsupportedConfiguration,
17981 _ => SyncSettingsError::Other,
17982 };
17983 crate::eat_json_fields(&mut map)?;
17984 Ok(value)
17985 }
17986 }
17987 const VARIANTS: &[&str] = &["path",
17988 "unsupported_combination",
17989 "unsupported_configuration",
17990 "other"];
17991 deserializer.deserialize_struct("SyncSettingsError", VARIANTS, EnumVisitor)
17992 }
17993}
17994
17995impl ::serde::ser::Serialize for SyncSettingsError {
17996 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
17997 use serde::ser::SerializeStruct;
17999 match self {
18000 SyncSettingsError::Path(x) => {
18001 let mut s = serializer.serialize_struct("SyncSettingsError", 2)?;
18003 s.serialize_field(".tag", "path")?;
18004 s.serialize_field("path", x)?;
18005 s.end()
18006 }
18007 SyncSettingsError::UnsupportedCombination => {
18008 let mut s = serializer.serialize_struct("SyncSettingsError", 1)?;
18010 s.serialize_field(".tag", "unsupported_combination")?;
18011 s.end()
18012 }
18013 SyncSettingsError::UnsupportedConfiguration => {
18014 let mut s = serializer.serialize_struct("SyncSettingsError", 1)?;
18016 s.serialize_field(".tag", "unsupported_configuration")?;
18017 s.end()
18018 }
18019 SyncSettingsError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
18020 }
18021 }
18022}
18023
18024impl ::std::error::Error for SyncSettingsError {
18025 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
18026 match self {
18027 SyncSettingsError::Path(inner) => Some(inner),
18028 _ => None,
18029 }
18030 }
18031}
18032
18033impl ::std::fmt::Display for SyncSettingsError {
18034 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18035 match self {
18036 SyncSettingsError::Path(inner) => write!(f, "SyncSettingsError: {}", inner),
18037 SyncSettingsError::UnsupportedCombination => f.write_str("Setting this combination of sync settings simultaneously is not supported."),
18038 SyncSettingsError::UnsupportedConfiguration => f.write_str("The specified configuration is not supported."),
18039 _ => write!(f, "{:?}", *self),
18040 }
18041 }
18042}
18043
18044#[derive(Debug, Clone, PartialEq, Eq)]
18046#[non_exhaustive] pub enum Tag {
18048 UserGeneratedTag(UserGeneratedTag),
18050 Other,
18053}
18054
18055impl<'de> ::serde::de::Deserialize<'de> for Tag {
18056 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18057 use serde::de::{self, MapAccess, Visitor};
18059 struct EnumVisitor;
18060 impl<'de> Visitor<'de> for EnumVisitor {
18061 type Value = Tag;
18062 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18063 f.write_str("a Tag structure")
18064 }
18065 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18066 let tag: &str = match map.next_key()? {
18067 Some(".tag") => map.next_value()?,
18068 _ => return Err(de::Error::missing_field(".tag"))
18069 };
18070 let value = match tag {
18071 "user_generated_tag" => Tag::UserGeneratedTag(UserGeneratedTag::internal_deserialize(&mut map)?),
18072 _ => Tag::Other,
18073 };
18074 crate::eat_json_fields(&mut map)?;
18075 Ok(value)
18076 }
18077 }
18078 const VARIANTS: &[&str] = &["user_generated_tag",
18079 "other"];
18080 deserializer.deserialize_struct("Tag", VARIANTS, EnumVisitor)
18081 }
18082}
18083
18084impl ::serde::ser::Serialize for Tag {
18085 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18086 use serde::ser::SerializeStruct;
18088 match self {
18089 Tag::UserGeneratedTag(x) => {
18090 let mut s = serializer.serialize_struct("Tag", 2)?;
18092 s.serialize_field(".tag", "user_generated_tag")?;
18093 x.internal_serialize::<S>(&mut s)?;
18094 s.end()
18095 }
18096 Tag::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
18097 }
18098 }
18099}
18100
18101#[derive(Debug, Clone, PartialEq, Eq)]
18102#[non_exhaustive] pub struct ThumbnailArg {
18104 pub path: ReadPath,
18106 pub format: ThumbnailFormat,
18110 pub size: ThumbnailSize,
18112 pub mode: ThumbnailMode,
18114 pub quality: ThumbnailQuality,
18116 pub exclude_media_info: Option<bool>,
18120}
18121
18122impl ThumbnailArg {
18123 pub fn new(path: ReadPath) -> Self {
18124 ThumbnailArg {
18125 path,
18126 format: ThumbnailFormat::Jpeg,
18127 size: ThumbnailSize::W64h64,
18128 mode: ThumbnailMode::Strict,
18129 quality: ThumbnailQuality::Quality80,
18130 exclude_media_info: None,
18131 }
18132 }
18133
18134 pub fn with_format(mut self, value: ThumbnailFormat) -> Self {
18135 self.format = value;
18136 self
18137 }
18138
18139 pub fn with_size(mut self, value: ThumbnailSize) -> Self {
18140 self.size = value;
18141 self
18142 }
18143
18144 pub fn with_mode(mut self, value: ThumbnailMode) -> Self {
18145 self.mode = value;
18146 self
18147 }
18148
18149 pub fn with_quality(mut self, value: ThumbnailQuality) -> Self {
18150 self.quality = value;
18151 self
18152 }
18153
18154 pub fn with_exclude_media_info(mut self, value: bool) -> Self {
18155 self.exclude_media_info = Some(value);
18156 self
18157 }
18158}
18159
18160const THUMBNAIL_ARG_FIELDS: &[&str] = &["path",
18161 "format",
18162 "size",
18163 "mode",
18164 "quality",
18165 "exclude_media_info"];
18166impl ThumbnailArg {
18167 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
18168 map: V,
18169 ) -> Result<ThumbnailArg, V::Error> {
18170 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
18171 }
18172
18173 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
18174 mut map: V,
18175 optional: bool,
18176 ) -> Result<Option<ThumbnailArg>, V::Error> {
18177 let mut field_path = None;
18178 let mut field_format = None;
18179 let mut field_size = None;
18180 let mut field_mode = None;
18181 let mut field_quality = None;
18182 let mut field_exclude_media_info = None;
18183 let mut nothing = true;
18184 while let Some(key) = map.next_key::<&str>()? {
18185 nothing = false;
18186 match key {
18187 "path" => {
18188 if field_path.is_some() {
18189 return Err(::serde::de::Error::duplicate_field("path"));
18190 }
18191 field_path = Some(map.next_value()?);
18192 }
18193 "format" => {
18194 if field_format.is_some() {
18195 return Err(::serde::de::Error::duplicate_field("format"));
18196 }
18197 field_format = Some(map.next_value()?);
18198 }
18199 "size" => {
18200 if field_size.is_some() {
18201 return Err(::serde::de::Error::duplicate_field("size"));
18202 }
18203 field_size = Some(map.next_value()?);
18204 }
18205 "mode" => {
18206 if field_mode.is_some() {
18207 return Err(::serde::de::Error::duplicate_field("mode"));
18208 }
18209 field_mode = Some(map.next_value()?);
18210 }
18211 "quality" => {
18212 if field_quality.is_some() {
18213 return Err(::serde::de::Error::duplicate_field("quality"));
18214 }
18215 field_quality = Some(map.next_value()?);
18216 }
18217 "exclude_media_info" => {
18218 if field_exclude_media_info.is_some() {
18219 return Err(::serde::de::Error::duplicate_field("exclude_media_info"));
18220 }
18221 field_exclude_media_info = Some(map.next_value()?);
18222 }
18223 _ => {
18224 map.next_value::<::serde_json::Value>()?;
18226 }
18227 }
18228 }
18229 if optional && nothing {
18230 return Ok(None);
18231 }
18232 let result = ThumbnailArg {
18233 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
18234 format: field_format.unwrap_or(ThumbnailFormat::Jpeg),
18235 size: field_size.unwrap_or(ThumbnailSize::W64h64),
18236 mode: field_mode.unwrap_or(ThumbnailMode::Strict),
18237 quality: field_quality.unwrap_or(ThumbnailQuality::Quality80),
18238 exclude_media_info: field_exclude_media_info.and_then(Option::flatten),
18239 };
18240 Ok(Some(result))
18241 }
18242
18243 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
18244 &self,
18245 s: &mut S::SerializeStruct,
18246 ) -> Result<(), S::Error> {
18247 use serde::ser::SerializeStruct;
18248 s.serialize_field("path", &self.path)?;
18249 if self.format != ThumbnailFormat::Jpeg {
18250 s.serialize_field("format", &self.format)?;
18251 }
18252 if self.size != ThumbnailSize::W64h64 {
18253 s.serialize_field("size", &self.size)?;
18254 }
18255 if self.mode != ThumbnailMode::Strict {
18256 s.serialize_field("mode", &self.mode)?;
18257 }
18258 if self.quality != ThumbnailQuality::Quality80 {
18259 s.serialize_field("quality", &self.quality)?;
18260 }
18261 if let Some(val) = &self.exclude_media_info {
18262 s.serialize_field("exclude_media_info", val)?;
18263 }
18264 Ok(())
18265 }
18266}
18267
18268impl<'de> ::serde::de::Deserialize<'de> for ThumbnailArg {
18269 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18270 use serde::de::{MapAccess, Visitor};
18272 struct StructVisitor;
18273 impl<'de> Visitor<'de> for StructVisitor {
18274 type Value = ThumbnailArg;
18275 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18276 f.write_str("a ThumbnailArg struct")
18277 }
18278 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
18279 ThumbnailArg::internal_deserialize(map)
18280 }
18281 }
18282 deserializer.deserialize_struct("ThumbnailArg", THUMBNAIL_ARG_FIELDS, StructVisitor)
18283 }
18284}
18285
18286impl ::serde::ser::Serialize for ThumbnailArg {
18287 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18288 use serde::ser::SerializeStruct;
18290 let mut s = serializer.serialize_struct("ThumbnailArg", 6)?;
18291 self.internal_serialize::<S>(&mut s)?;
18292 s.end()
18293 }
18294}
18295
18296#[derive(Debug, Clone, PartialEq, Eq)]
18297pub enum ThumbnailError {
18298 Path(LookupError),
18300 UnsupportedExtension,
18302 UnsupportedImage,
18304 EncryptedContent,
18306 ConversionError,
18308}
18309
18310impl<'de> ::serde::de::Deserialize<'de> for ThumbnailError {
18311 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18312 use serde::de::{self, MapAccess, Visitor};
18314 struct EnumVisitor;
18315 impl<'de> Visitor<'de> for EnumVisitor {
18316 type Value = ThumbnailError;
18317 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18318 f.write_str("a ThumbnailError structure")
18319 }
18320 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18321 let tag: &str = match map.next_key()? {
18322 Some(".tag") => map.next_value()?,
18323 _ => return Err(de::Error::missing_field(".tag"))
18324 };
18325 let value = match tag {
18326 "path" => {
18327 match map.next_key()? {
18328 Some("path") => ThumbnailError::Path(map.next_value()?),
18329 None => return Err(de::Error::missing_field("path")),
18330 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
18331 }
18332 }
18333 "unsupported_extension" => ThumbnailError::UnsupportedExtension,
18334 "unsupported_image" => ThumbnailError::UnsupportedImage,
18335 "encrypted_content" => ThumbnailError::EncryptedContent,
18336 "conversion_error" => ThumbnailError::ConversionError,
18337 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18338 };
18339 crate::eat_json_fields(&mut map)?;
18340 Ok(value)
18341 }
18342 }
18343 const VARIANTS: &[&str] = &["path",
18344 "unsupported_extension",
18345 "unsupported_image",
18346 "encrypted_content",
18347 "conversion_error"];
18348 deserializer.deserialize_struct("ThumbnailError", VARIANTS, EnumVisitor)
18349 }
18350}
18351
18352impl ::serde::ser::Serialize for ThumbnailError {
18353 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18354 use serde::ser::SerializeStruct;
18356 match self {
18357 ThumbnailError::Path(x) => {
18358 let mut s = serializer.serialize_struct("ThumbnailError", 2)?;
18360 s.serialize_field(".tag", "path")?;
18361 s.serialize_field("path", x)?;
18362 s.end()
18363 }
18364 ThumbnailError::UnsupportedExtension => {
18365 let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18367 s.serialize_field(".tag", "unsupported_extension")?;
18368 s.end()
18369 }
18370 ThumbnailError::UnsupportedImage => {
18371 let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18373 s.serialize_field(".tag", "unsupported_image")?;
18374 s.end()
18375 }
18376 ThumbnailError::EncryptedContent => {
18377 let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18379 s.serialize_field(".tag", "encrypted_content")?;
18380 s.end()
18381 }
18382 ThumbnailError::ConversionError => {
18383 let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
18385 s.serialize_field(".tag", "conversion_error")?;
18386 s.end()
18387 }
18388 }
18389 }
18390}
18391
18392impl ::std::error::Error for ThumbnailError {
18393 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
18394 match self {
18395 ThumbnailError::Path(inner) => Some(inner),
18396 _ => None,
18397 }
18398 }
18399}
18400
18401impl ::std::fmt::Display for ThumbnailError {
18402 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18403 match self {
18404 ThumbnailError::Path(inner) => write!(f, "An error occurs when downloading metadata for the image: {}", inner),
18405 ThumbnailError::UnsupportedExtension => f.write_str("The file extension doesn't allow conversion to a thumbnail."),
18406 ThumbnailError::UnsupportedImage => f.write_str("The image cannot be converted to a thumbnail."),
18407 ThumbnailError::EncryptedContent => f.write_str("Encrypted content cannot be converted to a thumbnail."),
18408 ThumbnailError::ConversionError => f.write_str("An error occurs during thumbnail conversion."),
18409 }
18410 }
18411}
18412
18413#[derive(Debug, Clone, PartialEq, Eq)]
18414pub enum ThumbnailFormat {
18415 Jpeg,
18416 Png,
18417 Webp,
18418}
18419
18420impl<'de> ::serde::de::Deserialize<'de> for ThumbnailFormat {
18421 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18422 use serde::de::{self, MapAccess, Visitor};
18424 struct EnumVisitor;
18425 impl<'de> Visitor<'de> for EnumVisitor {
18426 type Value = ThumbnailFormat;
18427 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18428 f.write_str("a ThumbnailFormat structure")
18429 }
18430 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18431 let tag: &str = match map.next_key()? {
18432 Some(".tag") => map.next_value()?,
18433 _ => return Err(de::Error::missing_field(".tag"))
18434 };
18435 let value = match tag {
18436 "jpeg" => ThumbnailFormat::Jpeg,
18437 "png" => ThumbnailFormat::Png,
18438 "webp" => ThumbnailFormat::Webp,
18439 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18440 };
18441 crate::eat_json_fields(&mut map)?;
18442 Ok(value)
18443 }
18444 }
18445 const VARIANTS: &[&str] = &["jpeg",
18446 "png",
18447 "webp"];
18448 deserializer.deserialize_struct("ThumbnailFormat", VARIANTS, EnumVisitor)
18449 }
18450}
18451
18452impl ::serde::ser::Serialize for ThumbnailFormat {
18453 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18454 use serde::ser::SerializeStruct;
18456 match self {
18457 ThumbnailFormat::Jpeg => {
18458 let mut s = serializer.serialize_struct("ThumbnailFormat", 1)?;
18460 s.serialize_field(".tag", "jpeg")?;
18461 s.end()
18462 }
18463 ThumbnailFormat::Png => {
18464 let mut s = serializer.serialize_struct("ThumbnailFormat", 1)?;
18466 s.serialize_field(".tag", "png")?;
18467 s.end()
18468 }
18469 ThumbnailFormat::Webp => {
18470 let mut s = serializer.serialize_struct("ThumbnailFormat", 1)?;
18472 s.serialize_field(".tag", "webp")?;
18473 s.end()
18474 }
18475 }
18476 }
18477}
18478
18479#[derive(Debug, Clone, PartialEq, Eq)]
18480pub enum ThumbnailMode {
18481 Strict,
18483 Bestfit,
18485 FitoneBestfit,
18487 Original,
18489}
18490
18491impl<'de> ::serde::de::Deserialize<'de> for ThumbnailMode {
18492 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18493 use serde::de::{self, MapAccess, Visitor};
18495 struct EnumVisitor;
18496 impl<'de> Visitor<'de> for EnumVisitor {
18497 type Value = ThumbnailMode;
18498 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18499 f.write_str("a ThumbnailMode structure")
18500 }
18501 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18502 let tag: &str = match map.next_key()? {
18503 Some(".tag") => map.next_value()?,
18504 _ => return Err(de::Error::missing_field(".tag"))
18505 };
18506 let value = match tag {
18507 "strict" => ThumbnailMode::Strict,
18508 "bestfit" => ThumbnailMode::Bestfit,
18509 "fitone_bestfit" => ThumbnailMode::FitoneBestfit,
18510 "original" => ThumbnailMode::Original,
18511 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18512 };
18513 crate::eat_json_fields(&mut map)?;
18514 Ok(value)
18515 }
18516 }
18517 const VARIANTS: &[&str] = &["strict",
18518 "bestfit",
18519 "fitone_bestfit",
18520 "original"];
18521 deserializer.deserialize_struct("ThumbnailMode", VARIANTS, EnumVisitor)
18522 }
18523}
18524
18525impl ::serde::ser::Serialize for ThumbnailMode {
18526 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18527 use serde::ser::SerializeStruct;
18529 match self {
18530 ThumbnailMode::Strict => {
18531 let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18533 s.serialize_field(".tag", "strict")?;
18534 s.end()
18535 }
18536 ThumbnailMode::Bestfit => {
18537 let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18539 s.serialize_field(".tag", "bestfit")?;
18540 s.end()
18541 }
18542 ThumbnailMode::FitoneBestfit => {
18543 let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18545 s.serialize_field(".tag", "fitone_bestfit")?;
18546 s.end()
18547 }
18548 ThumbnailMode::Original => {
18549 let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
18551 s.serialize_field(".tag", "original")?;
18552 s.end()
18553 }
18554 }
18555 }
18556}
18557
18558#[derive(Debug, Clone, PartialEq, Eq)]
18559pub enum ThumbnailQuality {
18560 Quality80,
18562 Quality90,
18564}
18565
18566impl<'de> ::serde::de::Deserialize<'de> for ThumbnailQuality {
18567 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18568 use serde::de::{self, MapAccess, Visitor};
18570 struct EnumVisitor;
18571 impl<'de> Visitor<'de> for EnumVisitor {
18572 type Value = ThumbnailQuality;
18573 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18574 f.write_str("a ThumbnailQuality structure")
18575 }
18576 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18577 let tag: &str = match map.next_key()? {
18578 Some(".tag") => map.next_value()?,
18579 _ => return Err(de::Error::missing_field(".tag"))
18580 };
18581 let value = match tag {
18582 "quality_80" => ThumbnailQuality::Quality80,
18583 "quality_90" => ThumbnailQuality::Quality90,
18584 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18585 };
18586 crate::eat_json_fields(&mut map)?;
18587 Ok(value)
18588 }
18589 }
18590 const VARIANTS: &[&str] = &["quality_80",
18591 "quality_90"];
18592 deserializer.deserialize_struct("ThumbnailQuality", VARIANTS, EnumVisitor)
18593 }
18594}
18595
18596impl ::serde::ser::Serialize for ThumbnailQuality {
18597 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18598 use serde::ser::SerializeStruct;
18600 match self {
18601 ThumbnailQuality::Quality80 => {
18602 let mut s = serializer.serialize_struct("ThumbnailQuality", 1)?;
18604 s.serialize_field(".tag", "quality_80")?;
18605 s.end()
18606 }
18607 ThumbnailQuality::Quality90 => {
18608 let mut s = serializer.serialize_struct("ThumbnailQuality", 1)?;
18610 s.serialize_field(".tag", "quality_90")?;
18611 s.end()
18612 }
18613 }
18614 }
18615}
18616
18617#[derive(Debug, Clone, PartialEq, Eq)]
18618pub enum ThumbnailSize {
18619 W32h32,
18621 W64h64,
18623 W128h128,
18625 W256h256,
18627 W480h320,
18629 W640h480,
18631 W960h640,
18633 W1024h768,
18635 W2048h1536,
18637 W3200h2400,
18639}
18640
18641impl<'de> ::serde::de::Deserialize<'de> for ThumbnailSize {
18642 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18643 use serde::de::{self, MapAccess, Visitor};
18645 struct EnumVisitor;
18646 impl<'de> Visitor<'de> for EnumVisitor {
18647 type Value = ThumbnailSize;
18648 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18649 f.write_str("a ThumbnailSize structure")
18650 }
18651 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18652 let tag: &str = match map.next_key()? {
18653 Some(".tag") => map.next_value()?,
18654 _ => return Err(de::Error::missing_field(".tag"))
18655 };
18656 let value = match tag {
18657 "w32h32" => ThumbnailSize::W32h32,
18658 "w64h64" => ThumbnailSize::W64h64,
18659 "w128h128" => ThumbnailSize::W128h128,
18660 "w256h256" => ThumbnailSize::W256h256,
18661 "w480h320" => ThumbnailSize::W480h320,
18662 "w640h480" => ThumbnailSize::W640h480,
18663 "w960h640" => ThumbnailSize::W960h640,
18664 "w1024h768" => ThumbnailSize::W1024h768,
18665 "w2048h1536" => ThumbnailSize::W2048h1536,
18666 "w3200h2400" => ThumbnailSize::W3200h2400,
18667 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
18668 };
18669 crate::eat_json_fields(&mut map)?;
18670 Ok(value)
18671 }
18672 }
18673 const VARIANTS: &[&str] = &["w32h32",
18674 "w64h64",
18675 "w128h128",
18676 "w256h256",
18677 "w480h320",
18678 "w640h480",
18679 "w960h640",
18680 "w1024h768",
18681 "w2048h1536",
18682 "w3200h2400"];
18683 deserializer.deserialize_struct("ThumbnailSize", VARIANTS, EnumVisitor)
18684 }
18685}
18686
18687impl ::serde::ser::Serialize for ThumbnailSize {
18688 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18689 use serde::ser::SerializeStruct;
18691 match self {
18692 ThumbnailSize::W32h32 => {
18693 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18695 s.serialize_field(".tag", "w32h32")?;
18696 s.end()
18697 }
18698 ThumbnailSize::W64h64 => {
18699 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18701 s.serialize_field(".tag", "w64h64")?;
18702 s.end()
18703 }
18704 ThumbnailSize::W128h128 => {
18705 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18707 s.serialize_field(".tag", "w128h128")?;
18708 s.end()
18709 }
18710 ThumbnailSize::W256h256 => {
18711 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18713 s.serialize_field(".tag", "w256h256")?;
18714 s.end()
18715 }
18716 ThumbnailSize::W480h320 => {
18717 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18719 s.serialize_field(".tag", "w480h320")?;
18720 s.end()
18721 }
18722 ThumbnailSize::W640h480 => {
18723 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18725 s.serialize_field(".tag", "w640h480")?;
18726 s.end()
18727 }
18728 ThumbnailSize::W960h640 => {
18729 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18731 s.serialize_field(".tag", "w960h640")?;
18732 s.end()
18733 }
18734 ThumbnailSize::W1024h768 => {
18735 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18737 s.serialize_field(".tag", "w1024h768")?;
18738 s.end()
18739 }
18740 ThumbnailSize::W2048h1536 => {
18741 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18743 s.serialize_field(".tag", "w2048h1536")?;
18744 s.end()
18745 }
18746 ThumbnailSize::W3200h2400 => {
18747 let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
18749 s.serialize_field(".tag", "w3200h2400")?;
18750 s.end()
18751 }
18752 }
18753 }
18754}
18755
18756#[derive(Debug, Clone, PartialEq, Eq)]
18757#[non_exhaustive] pub struct ThumbnailV2Arg {
18759 pub resource: PathOrLink,
18762 pub format: ThumbnailFormat,
18766 pub size: ThumbnailSize,
18768 pub mode: ThumbnailMode,
18770 pub quality: ThumbnailQuality,
18772 pub exclude_media_info: Option<bool>,
18776}
18777
18778impl ThumbnailV2Arg {
18779 pub fn new(resource: PathOrLink) -> Self {
18780 ThumbnailV2Arg {
18781 resource,
18782 format: ThumbnailFormat::Jpeg,
18783 size: ThumbnailSize::W64h64,
18784 mode: ThumbnailMode::Strict,
18785 quality: ThumbnailQuality::Quality80,
18786 exclude_media_info: None,
18787 }
18788 }
18789
18790 pub fn with_format(mut self, value: ThumbnailFormat) -> Self {
18791 self.format = value;
18792 self
18793 }
18794
18795 pub fn with_size(mut self, value: ThumbnailSize) -> Self {
18796 self.size = value;
18797 self
18798 }
18799
18800 pub fn with_mode(mut self, value: ThumbnailMode) -> Self {
18801 self.mode = value;
18802 self
18803 }
18804
18805 pub fn with_quality(mut self, value: ThumbnailQuality) -> Self {
18806 self.quality = value;
18807 self
18808 }
18809
18810 pub fn with_exclude_media_info(mut self, value: bool) -> Self {
18811 self.exclude_media_info = Some(value);
18812 self
18813 }
18814}
18815
18816const THUMBNAIL_V2_ARG_FIELDS: &[&str] = &["resource",
18817 "format",
18818 "size",
18819 "mode",
18820 "quality",
18821 "exclude_media_info"];
18822impl ThumbnailV2Arg {
18823 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
18824 map: V,
18825 ) -> Result<ThumbnailV2Arg, V::Error> {
18826 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
18827 }
18828
18829 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
18830 mut map: V,
18831 optional: bool,
18832 ) -> Result<Option<ThumbnailV2Arg>, V::Error> {
18833 let mut field_resource = None;
18834 let mut field_format = None;
18835 let mut field_size = None;
18836 let mut field_mode = None;
18837 let mut field_quality = None;
18838 let mut field_exclude_media_info = None;
18839 let mut nothing = true;
18840 while let Some(key) = map.next_key::<&str>()? {
18841 nothing = false;
18842 match key {
18843 "resource" => {
18844 if field_resource.is_some() {
18845 return Err(::serde::de::Error::duplicate_field("resource"));
18846 }
18847 field_resource = Some(map.next_value()?);
18848 }
18849 "format" => {
18850 if field_format.is_some() {
18851 return Err(::serde::de::Error::duplicate_field("format"));
18852 }
18853 field_format = Some(map.next_value()?);
18854 }
18855 "size" => {
18856 if field_size.is_some() {
18857 return Err(::serde::de::Error::duplicate_field("size"));
18858 }
18859 field_size = Some(map.next_value()?);
18860 }
18861 "mode" => {
18862 if field_mode.is_some() {
18863 return Err(::serde::de::Error::duplicate_field("mode"));
18864 }
18865 field_mode = Some(map.next_value()?);
18866 }
18867 "quality" => {
18868 if field_quality.is_some() {
18869 return Err(::serde::de::Error::duplicate_field("quality"));
18870 }
18871 field_quality = Some(map.next_value()?);
18872 }
18873 "exclude_media_info" => {
18874 if field_exclude_media_info.is_some() {
18875 return Err(::serde::de::Error::duplicate_field("exclude_media_info"));
18876 }
18877 field_exclude_media_info = Some(map.next_value()?);
18878 }
18879 _ => {
18880 map.next_value::<::serde_json::Value>()?;
18882 }
18883 }
18884 }
18885 if optional && nothing {
18886 return Ok(None);
18887 }
18888 let result = ThumbnailV2Arg {
18889 resource: field_resource.ok_or_else(|| ::serde::de::Error::missing_field("resource"))?,
18890 format: field_format.unwrap_or(ThumbnailFormat::Jpeg),
18891 size: field_size.unwrap_or(ThumbnailSize::W64h64),
18892 mode: field_mode.unwrap_or(ThumbnailMode::Strict),
18893 quality: field_quality.unwrap_or(ThumbnailQuality::Quality80),
18894 exclude_media_info: field_exclude_media_info.and_then(Option::flatten),
18895 };
18896 Ok(Some(result))
18897 }
18898
18899 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
18900 &self,
18901 s: &mut S::SerializeStruct,
18902 ) -> Result<(), S::Error> {
18903 use serde::ser::SerializeStruct;
18904 s.serialize_field("resource", &self.resource)?;
18905 if self.format != ThumbnailFormat::Jpeg {
18906 s.serialize_field("format", &self.format)?;
18907 }
18908 if self.size != ThumbnailSize::W64h64 {
18909 s.serialize_field("size", &self.size)?;
18910 }
18911 if self.mode != ThumbnailMode::Strict {
18912 s.serialize_field("mode", &self.mode)?;
18913 }
18914 if self.quality != ThumbnailQuality::Quality80 {
18915 s.serialize_field("quality", &self.quality)?;
18916 }
18917 if let Some(val) = &self.exclude_media_info {
18918 s.serialize_field("exclude_media_info", val)?;
18919 }
18920 Ok(())
18921 }
18922}
18923
18924impl<'de> ::serde::de::Deserialize<'de> for ThumbnailV2Arg {
18925 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18926 use serde::de::{MapAccess, Visitor};
18928 struct StructVisitor;
18929 impl<'de> Visitor<'de> for StructVisitor {
18930 type Value = ThumbnailV2Arg;
18931 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18932 f.write_str("a ThumbnailV2Arg struct")
18933 }
18934 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
18935 ThumbnailV2Arg::internal_deserialize(map)
18936 }
18937 }
18938 deserializer.deserialize_struct("ThumbnailV2Arg", THUMBNAIL_V2_ARG_FIELDS, StructVisitor)
18939 }
18940}
18941
18942impl ::serde::ser::Serialize for ThumbnailV2Arg {
18943 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
18944 use serde::ser::SerializeStruct;
18946 let mut s = serializer.serialize_struct("ThumbnailV2Arg", 6)?;
18947 self.internal_serialize::<S>(&mut s)?;
18948 s.end()
18949 }
18950}
18951
18952#[derive(Debug, Clone, PartialEq, Eq)]
18953#[non_exhaustive] pub enum ThumbnailV2Error {
18955 Path(LookupError),
18957 UnsupportedExtension,
18959 UnsupportedImage,
18961 EncryptedContent,
18963 ConversionError,
18965 AccessDenied,
18967 NotFound,
18969 Other,
18972}
18973
18974impl<'de> ::serde::de::Deserialize<'de> for ThumbnailV2Error {
18975 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
18976 use serde::de::{self, MapAccess, Visitor};
18978 struct EnumVisitor;
18979 impl<'de> Visitor<'de> for EnumVisitor {
18980 type Value = ThumbnailV2Error;
18981 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
18982 f.write_str("a ThumbnailV2Error structure")
18983 }
18984 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
18985 let tag: &str = match map.next_key()? {
18986 Some(".tag") => map.next_value()?,
18987 _ => return Err(de::Error::missing_field(".tag"))
18988 };
18989 let value = match tag {
18990 "path" => {
18991 match map.next_key()? {
18992 Some("path") => ThumbnailV2Error::Path(map.next_value()?),
18993 None => return Err(de::Error::missing_field("path")),
18994 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
18995 }
18996 }
18997 "unsupported_extension" => ThumbnailV2Error::UnsupportedExtension,
18998 "unsupported_image" => ThumbnailV2Error::UnsupportedImage,
18999 "encrypted_content" => ThumbnailV2Error::EncryptedContent,
19000 "conversion_error" => ThumbnailV2Error::ConversionError,
19001 "access_denied" => ThumbnailV2Error::AccessDenied,
19002 "not_found" => ThumbnailV2Error::NotFound,
19003 _ => ThumbnailV2Error::Other,
19004 };
19005 crate::eat_json_fields(&mut map)?;
19006 Ok(value)
19007 }
19008 }
19009 const VARIANTS: &[&str] = &["path",
19010 "unsupported_extension",
19011 "unsupported_image",
19012 "encrypted_content",
19013 "conversion_error",
19014 "access_denied",
19015 "not_found",
19016 "other"];
19017 deserializer.deserialize_struct("ThumbnailV2Error", VARIANTS, EnumVisitor)
19018 }
19019}
19020
19021impl ::serde::ser::Serialize for ThumbnailV2Error {
19022 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19023 use serde::ser::SerializeStruct;
19025 match self {
19026 ThumbnailV2Error::Path(x) => {
19027 let mut s = serializer.serialize_struct("ThumbnailV2Error", 2)?;
19029 s.serialize_field(".tag", "path")?;
19030 s.serialize_field("path", x)?;
19031 s.end()
19032 }
19033 ThumbnailV2Error::UnsupportedExtension => {
19034 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19036 s.serialize_field(".tag", "unsupported_extension")?;
19037 s.end()
19038 }
19039 ThumbnailV2Error::UnsupportedImage => {
19040 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19042 s.serialize_field(".tag", "unsupported_image")?;
19043 s.end()
19044 }
19045 ThumbnailV2Error::EncryptedContent => {
19046 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19048 s.serialize_field(".tag", "encrypted_content")?;
19049 s.end()
19050 }
19051 ThumbnailV2Error::ConversionError => {
19052 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19054 s.serialize_field(".tag", "conversion_error")?;
19055 s.end()
19056 }
19057 ThumbnailV2Error::AccessDenied => {
19058 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19060 s.serialize_field(".tag", "access_denied")?;
19061 s.end()
19062 }
19063 ThumbnailV2Error::NotFound => {
19064 let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
19066 s.serialize_field(".tag", "not_found")?;
19067 s.end()
19068 }
19069 ThumbnailV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
19070 }
19071 }
19072}
19073
19074impl ::std::error::Error for ThumbnailV2Error {
19075 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
19076 match self {
19077 ThumbnailV2Error::Path(inner) => Some(inner),
19078 _ => None,
19079 }
19080 }
19081}
19082
19083impl ::std::fmt::Display for ThumbnailV2Error {
19084 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19085 match self {
19086 ThumbnailV2Error::Path(inner) => write!(f, "An error occurred when downloading metadata for the image: {}", inner),
19087 ThumbnailV2Error::UnsupportedExtension => f.write_str("The file extension doesn't allow conversion to a thumbnail."),
19088 ThumbnailV2Error::UnsupportedImage => f.write_str("The image cannot be converted to a thumbnail."),
19089 ThumbnailV2Error::EncryptedContent => f.write_str("Encrypted content cannot be converted to a thumbnail."),
19090 ThumbnailV2Error::ConversionError => f.write_str("An error occurred during thumbnail conversion."),
19091 ThumbnailV2Error::AccessDenied => f.write_str("Access to this shared link is forbidden."),
19092 ThumbnailV2Error::NotFound => f.write_str("The shared link does not exist."),
19093 _ => write!(f, "{:?}", *self),
19094 }
19095 }
19096}
19097
19098#[derive(Debug, Clone, PartialEq, Eq)]
19099#[non_exhaustive] pub struct UnlockFileArg {
19101 pub path: WritePathOrId,
19103}
19104
19105impl UnlockFileArg {
19106 pub fn new(path: WritePathOrId) -> Self {
19107 UnlockFileArg {
19108 path,
19109 }
19110 }
19111}
19112
19113const UNLOCK_FILE_ARG_FIELDS: &[&str] = &["path"];
19114impl UnlockFileArg {
19115 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19116 map: V,
19117 ) -> Result<UnlockFileArg, V::Error> {
19118 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19119 }
19120
19121 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19122 mut map: V,
19123 optional: bool,
19124 ) -> Result<Option<UnlockFileArg>, V::Error> {
19125 let mut field_path = None;
19126 let mut nothing = true;
19127 while let Some(key) = map.next_key::<&str>()? {
19128 nothing = false;
19129 match key {
19130 "path" => {
19131 if field_path.is_some() {
19132 return Err(::serde::de::Error::duplicate_field("path"));
19133 }
19134 field_path = Some(map.next_value()?);
19135 }
19136 _ => {
19137 map.next_value::<::serde_json::Value>()?;
19139 }
19140 }
19141 }
19142 if optional && nothing {
19143 return Ok(None);
19144 }
19145 let result = UnlockFileArg {
19146 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
19147 };
19148 Ok(Some(result))
19149 }
19150
19151 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19152 &self,
19153 s: &mut S::SerializeStruct,
19154 ) -> Result<(), S::Error> {
19155 use serde::ser::SerializeStruct;
19156 s.serialize_field("path", &self.path)?;
19157 Ok(())
19158 }
19159}
19160
19161impl<'de> ::serde::de::Deserialize<'de> for UnlockFileArg {
19162 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19163 use serde::de::{MapAccess, Visitor};
19165 struct StructVisitor;
19166 impl<'de> Visitor<'de> for StructVisitor {
19167 type Value = UnlockFileArg;
19168 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19169 f.write_str("a UnlockFileArg struct")
19170 }
19171 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19172 UnlockFileArg::internal_deserialize(map)
19173 }
19174 }
19175 deserializer.deserialize_struct("UnlockFileArg", UNLOCK_FILE_ARG_FIELDS, StructVisitor)
19176 }
19177}
19178
19179impl ::serde::ser::Serialize for UnlockFileArg {
19180 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19181 use serde::ser::SerializeStruct;
19183 let mut s = serializer.serialize_struct("UnlockFileArg", 1)?;
19184 self.internal_serialize::<S>(&mut s)?;
19185 s.end()
19186 }
19187}
19188
19189#[derive(Debug, Clone, PartialEq, Eq)]
19190#[non_exhaustive] pub struct UnlockFileBatchArg {
19192 pub entries: Vec<UnlockFileArg>,
19195}
19196
19197impl UnlockFileBatchArg {
19198 pub fn new(entries: Vec<UnlockFileArg>) -> Self {
19199 UnlockFileBatchArg {
19200 entries,
19201 }
19202 }
19203}
19204
19205const UNLOCK_FILE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
19206impl UnlockFileBatchArg {
19207 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19208 map: V,
19209 ) -> Result<UnlockFileBatchArg, V::Error> {
19210 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19211 }
19212
19213 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19214 mut map: V,
19215 optional: bool,
19216 ) -> Result<Option<UnlockFileBatchArg>, V::Error> {
19217 let mut field_entries = None;
19218 let mut nothing = true;
19219 while let Some(key) = map.next_key::<&str>()? {
19220 nothing = false;
19221 match key {
19222 "entries" => {
19223 if field_entries.is_some() {
19224 return Err(::serde::de::Error::duplicate_field("entries"));
19225 }
19226 field_entries = Some(map.next_value()?);
19227 }
19228 _ => {
19229 map.next_value::<::serde_json::Value>()?;
19231 }
19232 }
19233 }
19234 if optional && nothing {
19235 return Ok(None);
19236 }
19237 let result = UnlockFileBatchArg {
19238 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
19239 };
19240 Ok(Some(result))
19241 }
19242
19243 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19244 &self,
19245 s: &mut S::SerializeStruct,
19246 ) -> Result<(), S::Error> {
19247 use serde::ser::SerializeStruct;
19248 s.serialize_field("entries", &self.entries)?;
19249 Ok(())
19250 }
19251}
19252
19253impl<'de> ::serde::de::Deserialize<'de> for UnlockFileBatchArg {
19254 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19255 use serde::de::{MapAccess, Visitor};
19257 struct StructVisitor;
19258 impl<'de> Visitor<'de> for StructVisitor {
19259 type Value = UnlockFileBatchArg;
19260 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19261 f.write_str("a UnlockFileBatchArg struct")
19262 }
19263 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19264 UnlockFileBatchArg::internal_deserialize(map)
19265 }
19266 }
19267 deserializer.deserialize_struct("UnlockFileBatchArg", UNLOCK_FILE_BATCH_ARG_FIELDS, StructVisitor)
19268 }
19269}
19270
19271impl ::serde::ser::Serialize for UnlockFileBatchArg {
19272 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19273 use serde::ser::SerializeStruct;
19275 let mut s = serializer.serialize_struct("UnlockFileBatchArg", 1)?;
19276 self.internal_serialize::<S>(&mut s)?;
19277 s.end()
19278 }
19279}
19280
19281#[derive(Debug, Clone, PartialEq, Eq)]
19282#[non_exhaustive] pub struct UploadArg {
19284 pub path: WritePathOrId,
19286 pub mode: WriteMode,
19288 pub autorename: bool,
19291 pub client_modified: Option<crate::types::common::DropboxTimestamp>,
19296 pub mute: bool,
19300 pub property_groups: Option<Vec<crate::types::file_properties::PropertyGroup>>,
19302 pub strict_conflict: bool,
19307 pub content_hash: Option<Sha256HexHash>,
19311}
19312
19313impl UploadArg {
19314 pub fn new(path: WritePathOrId) -> Self {
19315 UploadArg {
19316 path,
19317 mode: WriteMode::Add,
19318 autorename: false,
19319 client_modified: None,
19320 mute: false,
19321 property_groups: None,
19322 strict_conflict: false,
19323 content_hash: None,
19324 }
19325 }
19326
19327 pub fn with_mode(mut self, value: WriteMode) -> Self {
19328 self.mode = value;
19329 self
19330 }
19331
19332 pub fn with_autorename(mut self, value: bool) -> Self {
19333 self.autorename = value;
19334 self
19335 }
19336
19337 pub fn with_client_modified(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
19338 self.client_modified = Some(value);
19339 self
19340 }
19341
19342 pub fn with_mute(mut self, value: bool) -> Self {
19343 self.mute = value;
19344 self
19345 }
19346
19347 pub fn with_property_groups(
19348 mut self,
19349 value: Vec<crate::types::file_properties::PropertyGroup>,
19350 ) -> Self {
19351 self.property_groups = Some(value);
19352 self
19353 }
19354
19355 pub fn with_strict_conflict(mut self, value: bool) -> Self {
19356 self.strict_conflict = value;
19357 self
19358 }
19359
19360 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
19361 self.content_hash = Some(value);
19362 self
19363 }
19364}
19365
19366const UPLOAD_ARG_FIELDS: &[&str] = &["path",
19367 "mode",
19368 "autorename",
19369 "client_modified",
19370 "mute",
19371 "property_groups",
19372 "strict_conflict",
19373 "content_hash"];
19374impl UploadArg {
19375 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19376 map: V,
19377 ) -> Result<UploadArg, V::Error> {
19378 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19379 }
19380
19381 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19382 mut map: V,
19383 optional: bool,
19384 ) -> Result<Option<UploadArg>, V::Error> {
19385 let mut field_path = None;
19386 let mut field_mode = None;
19387 let mut field_autorename = None;
19388 let mut field_client_modified = None;
19389 let mut field_mute = None;
19390 let mut field_property_groups = None;
19391 let mut field_strict_conflict = None;
19392 let mut field_content_hash = None;
19393 let mut nothing = true;
19394 while let Some(key) = map.next_key::<&str>()? {
19395 nothing = false;
19396 match key {
19397 "path" => {
19398 if field_path.is_some() {
19399 return Err(::serde::de::Error::duplicate_field("path"));
19400 }
19401 field_path = Some(map.next_value()?);
19402 }
19403 "mode" => {
19404 if field_mode.is_some() {
19405 return Err(::serde::de::Error::duplicate_field("mode"));
19406 }
19407 field_mode = Some(map.next_value()?);
19408 }
19409 "autorename" => {
19410 if field_autorename.is_some() {
19411 return Err(::serde::de::Error::duplicate_field("autorename"));
19412 }
19413 field_autorename = Some(map.next_value()?);
19414 }
19415 "client_modified" => {
19416 if field_client_modified.is_some() {
19417 return Err(::serde::de::Error::duplicate_field("client_modified"));
19418 }
19419 field_client_modified = Some(map.next_value()?);
19420 }
19421 "mute" => {
19422 if field_mute.is_some() {
19423 return Err(::serde::de::Error::duplicate_field("mute"));
19424 }
19425 field_mute = Some(map.next_value()?);
19426 }
19427 "property_groups" => {
19428 if field_property_groups.is_some() {
19429 return Err(::serde::de::Error::duplicate_field("property_groups"));
19430 }
19431 field_property_groups = Some(map.next_value()?);
19432 }
19433 "strict_conflict" => {
19434 if field_strict_conflict.is_some() {
19435 return Err(::serde::de::Error::duplicate_field("strict_conflict"));
19436 }
19437 field_strict_conflict = Some(map.next_value()?);
19438 }
19439 "content_hash" => {
19440 if field_content_hash.is_some() {
19441 return Err(::serde::de::Error::duplicate_field("content_hash"));
19442 }
19443 field_content_hash = Some(map.next_value()?);
19444 }
19445 _ => {
19446 map.next_value::<::serde_json::Value>()?;
19448 }
19449 }
19450 }
19451 if optional && nothing {
19452 return Ok(None);
19453 }
19454 let result = UploadArg {
19455 path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
19456 mode: field_mode.unwrap_or(WriteMode::Add),
19457 autorename: field_autorename.unwrap_or(false),
19458 client_modified: field_client_modified.and_then(Option::flatten),
19459 mute: field_mute.unwrap_or(false),
19460 property_groups: field_property_groups.and_then(Option::flatten),
19461 strict_conflict: field_strict_conflict.unwrap_or(false),
19462 content_hash: field_content_hash.and_then(Option::flatten),
19463 };
19464 Ok(Some(result))
19465 }
19466
19467 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19468 &self,
19469 s: &mut S::SerializeStruct,
19470 ) -> Result<(), S::Error> {
19471 use serde::ser::SerializeStruct;
19472 s.serialize_field("path", &self.path)?;
19473 if self.mode != WriteMode::Add {
19474 s.serialize_field("mode", &self.mode)?;
19475 }
19476 if self.autorename {
19477 s.serialize_field("autorename", &self.autorename)?;
19478 }
19479 if let Some(val) = &self.client_modified {
19480 s.serialize_field("client_modified", val)?;
19481 }
19482 if self.mute {
19483 s.serialize_field("mute", &self.mute)?;
19484 }
19485 if let Some(val) = &self.property_groups {
19486 s.serialize_field("property_groups", val)?;
19487 }
19488 if self.strict_conflict {
19489 s.serialize_field("strict_conflict", &self.strict_conflict)?;
19490 }
19491 if let Some(val) = &self.content_hash {
19492 s.serialize_field("content_hash", val)?;
19493 }
19494 Ok(())
19495 }
19496}
19497
19498impl<'de> ::serde::de::Deserialize<'de> for UploadArg {
19499 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19500 use serde::de::{MapAccess, Visitor};
19502 struct StructVisitor;
19503 impl<'de> Visitor<'de> for StructVisitor {
19504 type Value = UploadArg;
19505 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19506 f.write_str("a UploadArg struct")
19507 }
19508 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19509 UploadArg::internal_deserialize(map)
19510 }
19511 }
19512 deserializer.deserialize_struct("UploadArg", UPLOAD_ARG_FIELDS, StructVisitor)
19513 }
19514}
19515
19516impl ::serde::ser::Serialize for UploadArg {
19517 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19518 use serde::ser::SerializeStruct;
19520 let mut s = serializer.serialize_struct("UploadArg", 8)?;
19521 self.internal_serialize::<S>(&mut s)?;
19522 s.end()
19523 }
19524}
19525
19526impl From<UploadArg> for CommitInfo {
19528 fn from(subtype: UploadArg) -> Self {
19529 Self {
19530 path: subtype.path,
19531 mode: subtype.mode,
19532 autorename: subtype.autorename,
19533 client_modified: subtype.client_modified,
19534 mute: subtype.mute,
19535 property_groups: subtype.property_groups,
19536 strict_conflict: subtype.strict_conflict,
19537 }
19538 }
19539}
19540#[derive(Debug, Clone, PartialEq, Eq)]
19541#[non_exhaustive] pub enum UploadError {
19543 Path(UploadWriteFailed),
19545 PropertiesError(crate::types::file_properties::InvalidPropertyGroupError),
19547 PayloadTooLarge,
19549 ContentHashMismatch,
19552 EncryptionNotSupported,
19554 Other,
19557}
19558
19559impl<'de> ::serde::de::Deserialize<'de> for UploadError {
19560 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19561 use serde::de::{self, MapAccess, Visitor};
19563 struct EnumVisitor;
19564 impl<'de> Visitor<'de> for EnumVisitor {
19565 type Value = UploadError;
19566 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19567 f.write_str("a UploadError structure")
19568 }
19569 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
19570 let tag: &str = match map.next_key()? {
19571 Some(".tag") => map.next_value()?,
19572 _ => return Err(de::Error::missing_field(".tag"))
19573 };
19574 let value = match tag {
19575 "path" => UploadError::Path(UploadWriteFailed::internal_deserialize(&mut map)?),
19576 "properties_error" => {
19577 match map.next_key()? {
19578 Some("properties_error") => UploadError::PropertiesError(map.next_value()?),
19579 None => return Err(de::Error::missing_field("properties_error")),
19580 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
19581 }
19582 }
19583 "payload_too_large" => UploadError::PayloadTooLarge,
19584 "content_hash_mismatch" => UploadError::ContentHashMismatch,
19585 "encryption_not_supported" => UploadError::EncryptionNotSupported,
19586 _ => UploadError::Other,
19587 };
19588 crate::eat_json_fields(&mut map)?;
19589 Ok(value)
19590 }
19591 }
19592 const VARIANTS: &[&str] = &["path",
19593 "properties_error",
19594 "payload_too_large",
19595 "content_hash_mismatch",
19596 "encryption_not_supported",
19597 "other"];
19598 deserializer.deserialize_struct("UploadError", VARIANTS, EnumVisitor)
19599 }
19600}
19601
19602impl ::serde::ser::Serialize for UploadError {
19603 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19604 use serde::ser::SerializeStruct;
19606 match self {
19607 UploadError::Path(x) => {
19608 let mut s = serializer.serialize_struct("UploadError", 3)?;
19610 s.serialize_field(".tag", "path")?;
19611 x.internal_serialize::<S>(&mut s)?;
19612 s.end()
19613 }
19614 UploadError::PropertiesError(x) => {
19615 let mut s = serializer.serialize_struct("UploadError", 2)?;
19617 s.serialize_field(".tag", "properties_error")?;
19618 s.serialize_field("properties_error", x)?;
19619 s.end()
19620 }
19621 UploadError::PayloadTooLarge => {
19622 let mut s = serializer.serialize_struct("UploadError", 1)?;
19624 s.serialize_field(".tag", "payload_too_large")?;
19625 s.end()
19626 }
19627 UploadError::ContentHashMismatch => {
19628 let mut s = serializer.serialize_struct("UploadError", 1)?;
19630 s.serialize_field(".tag", "content_hash_mismatch")?;
19631 s.end()
19632 }
19633 UploadError::EncryptionNotSupported => {
19634 let mut s = serializer.serialize_struct("UploadError", 1)?;
19636 s.serialize_field(".tag", "encryption_not_supported")?;
19637 s.end()
19638 }
19639 UploadError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
19640 }
19641 }
19642}
19643
19644impl ::std::error::Error for UploadError {
19645 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
19646 match self {
19647 UploadError::PropertiesError(inner) => Some(inner),
19648 _ => None,
19649 }
19650 }
19651}
19652
19653impl ::std::fmt::Display for UploadError {
19654 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19655 match self {
19656 UploadError::Path(inner) => write!(f, "Unable to save the uploaded contents to a file: {:?}", inner),
19657 UploadError::PropertiesError(inner) => write!(f, "The supplied property group is invalid. The file has uploaded without property groups: {}", inner),
19658 UploadError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
19659 UploadError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
19660 UploadError::EncryptionNotSupported => f.write_str("The file is required to be encrypted, which is not supported in our public API."),
19661 _ => write!(f, "{:?}", *self),
19662 }
19663 }
19664}
19665
19666#[derive(Debug, Clone, PartialEq, Eq)]
19667#[non_exhaustive] pub struct UploadSessionAppendArg {
19669 pub cursor: UploadSessionCursor,
19671 pub close: bool,
19675 pub content_hash: Option<Sha256HexHash>,
19679}
19680
19681impl UploadSessionAppendArg {
19682 pub fn new(cursor: UploadSessionCursor) -> Self {
19683 UploadSessionAppendArg {
19684 cursor,
19685 close: false,
19686 content_hash: None,
19687 }
19688 }
19689
19690 pub fn with_close(mut self, value: bool) -> Self {
19691 self.close = value;
19692 self
19693 }
19694
19695 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
19696 self.content_hash = Some(value);
19697 self
19698 }
19699}
19700
19701const UPLOAD_SESSION_APPEND_ARG_FIELDS: &[&str] = &["cursor",
19702 "close",
19703 "content_hash"];
19704impl UploadSessionAppendArg {
19705 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19706 map: V,
19707 ) -> Result<UploadSessionAppendArg, V::Error> {
19708 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19709 }
19710
19711 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19712 mut map: V,
19713 optional: bool,
19714 ) -> Result<Option<UploadSessionAppendArg>, V::Error> {
19715 let mut field_cursor = None;
19716 let mut field_close = None;
19717 let mut field_content_hash = None;
19718 let mut nothing = true;
19719 while let Some(key) = map.next_key::<&str>()? {
19720 nothing = false;
19721 match key {
19722 "cursor" => {
19723 if field_cursor.is_some() {
19724 return Err(::serde::de::Error::duplicate_field("cursor"));
19725 }
19726 field_cursor = Some(map.next_value()?);
19727 }
19728 "close" => {
19729 if field_close.is_some() {
19730 return Err(::serde::de::Error::duplicate_field("close"));
19731 }
19732 field_close = Some(map.next_value()?);
19733 }
19734 "content_hash" => {
19735 if field_content_hash.is_some() {
19736 return Err(::serde::de::Error::duplicate_field("content_hash"));
19737 }
19738 field_content_hash = Some(map.next_value()?);
19739 }
19740 _ => {
19741 map.next_value::<::serde_json::Value>()?;
19743 }
19744 }
19745 }
19746 if optional && nothing {
19747 return Ok(None);
19748 }
19749 let result = UploadSessionAppendArg {
19750 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
19751 close: field_close.unwrap_or(false),
19752 content_hash: field_content_hash.and_then(Option::flatten),
19753 };
19754 Ok(Some(result))
19755 }
19756
19757 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19758 &self,
19759 s: &mut S::SerializeStruct,
19760 ) -> Result<(), S::Error> {
19761 use serde::ser::SerializeStruct;
19762 s.serialize_field("cursor", &self.cursor)?;
19763 if self.close {
19764 s.serialize_field("close", &self.close)?;
19765 }
19766 if let Some(val) = &self.content_hash {
19767 s.serialize_field("content_hash", val)?;
19768 }
19769 Ok(())
19770 }
19771}
19772
19773impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendArg {
19774 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19775 use serde::de::{MapAccess, Visitor};
19777 struct StructVisitor;
19778 impl<'de> Visitor<'de> for StructVisitor {
19779 type Value = UploadSessionAppendArg;
19780 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19781 f.write_str("a UploadSessionAppendArg struct")
19782 }
19783 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19784 UploadSessionAppendArg::internal_deserialize(map)
19785 }
19786 }
19787 deserializer.deserialize_struct("UploadSessionAppendArg", UPLOAD_SESSION_APPEND_ARG_FIELDS, StructVisitor)
19788 }
19789}
19790
19791impl ::serde::ser::Serialize for UploadSessionAppendArg {
19792 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19793 use serde::ser::SerializeStruct;
19795 let mut s = serializer.serialize_struct("UploadSessionAppendArg", 3)?;
19796 self.internal_serialize::<S>(&mut s)?;
19797 s.end()
19798 }
19799}
19800
19801#[derive(Debug, Clone, PartialEq, Eq)]
19802#[non_exhaustive] pub struct UploadSessionAppendBatchArg {
19804 pub entries: Vec<UploadSessionAppendBatchArgEntry>,
19806 pub content_hash: Option<Sha256HexHash>,
19811}
19812
19813impl UploadSessionAppendBatchArg {
19814 pub fn new(entries: Vec<UploadSessionAppendBatchArgEntry>) -> Self {
19815 UploadSessionAppendBatchArg {
19816 entries,
19817 content_hash: None,
19818 }
19819 }
19820
19821 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
19822 self.content_hash = Some(value);
19823 self
19824 }
19825}
19826
19827const UPLOAD_SESSION_APPEND_BATCH_ARG_FIELDS: &[&str] = &["entries",
19828 "content_hash"];
19829impl UploadSessionAppendBatchArg {
19830 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19831 map: V,
19832 ) -> Result<UploadSessionAppendBatchArg, V::Error> {
19833 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19834 }
19835
19836 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19837 mut map: V,
19838 optional: bool,
19839 ) -> Result<Option<UploadSessionAppendBatchArg>, V::Error> {
19840 let mut field_entries = None;
19841 let mut field_content_hash = None;
19842 let mut nothing = true;
19843 while let Some(key) = map.next_key::<&str>()? {
19844 nothing = false;
19845 match key {
19846 "entries" => {
19847 if field_entries.is_some() {
19848 return Err(::serde::de::Error::duplicate_field("entries"));
19849 }
19850 field_entries = Some(map.next_value()?);
19851 }
19852 "content_hash" => {
19853 if field_content_hash.is_some() {
19854 return Err(::serde::de::Error::duplicate_field("content_hash"));
19855 }
19856 field_content_hash = Some(map.next_value()?);
19857 }
19858 _ => {
19859 map.next_value::<::serde_json::Value>()?;
19861 }
19862 }
19863 }
19864 if optional && nothing {
19865 return Ok(None);
19866 }
19867 let result = UploadSessionAppendBatchArg {
19868 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
19869 content_hash: field_content_hash.and_then(Option::flatten),
19870 };
19871 Ok(Some(result))
19872 }
19873
19874 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
19875 &self,
19876 s: &mut S::SerializeStruct,
19877 ) -> Result<(), S::Error> {
19878 use serde::ser::SerializeStruct;
19879 s.serialize_field("entries", &self.entries)?;
19880 if let Some(val) = &self.content_hash {
19881 s.serialize_field("content_hash", val)?;
19882 }
19883 Ok(())
19884 }
19885}
19886
19887impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchArg {
19888 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
19889 use serde::de::{MapAccess, Visitor};
19891 struct StructVisitor;
19892 impl<'de> Visitor<'de> for StructVisitor {
19893 type Value = UploadSessionAppendBatchArg;
19894 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
19895 f.write_str("a UploadSessionAppendBatchArg struct")
19896 }
19897 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
19898 UploadSessionAppendBatchArg::internal_deserialize(map)
19899 }
19900 }
19901 deserializer.deserialize_struct("UploadSessionAppendBatchArg", UPLOAD_SESSION_APPEND_BATCH_ARG_FIELDS, StructVisitor)
19902 }
19903}
19904
19905impl ::serde::ser::Serialize for UploadSessionAppendBatchArg {
19906 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
19907 use serde::ser::SerializeStruct;
19909 let mut s = serializer.serialize_struct("UploadSessionAppendBatchArg", 2)?;
19910 self.internal_serialize::<S>(&mut s)?;
19911 s.end()
19912 }
19913}
19914
19915#[derive(Debug, Clone, PartialEq, Eq)]
19916#[non_exhaustive] pub struct UploadSessionAppendBatchArgEntry {
19918 pub cursor: UploadSessionCursor,
19920 pub length: u64,
19923 pub close: bool,
19927}
19928
19929impl UploadSessionAppendBatchArgEntry {
19930 pub fn new(cursor: UploadSessionCursor, length: u64) -> Self {
19931 UploadSessionAppendBatchArgEntry {
19932 cursor,
19933 length,
19934 close: false,
19935 }
19936 }
19937
19938 pub fn with_close(mut self, value: bool) -> Self {
19939 self.close = value;
19940 self
19941 }
19942}
19943
19944const UPLOAD_SESSION_APPEND_BATCH_ARG_ENTRY_FIELDS: &[&str] = &["cursor",
19945 "length",
19946 "close"];
19947impl UploadSessionAppendBatchArgEntry {
19948 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
19949 map: V,
19950 ) -> Result<UploadSessionAppendBatchArgEntry, V::Error> {
19951 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
19952 }
19953
19954 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
19955 mut map: V,
19956 optional: bool,
19957 ) -> Result<Option<UploadSessionAppendBatchArgEntry>, V::Error> {
19958 let mut field_cursor = None;
19959 let mut field_length = None;
19960 let mut field_close = None;
19961 let mut nothing = true;
19962 while let Some(key) = map.next_key::<&str>()? {
19963 nothing = false;
19964 match key {
19965 "cursor" => {
19966 if field_cursor.is_some() {
19967 return Err(::serde::de::Error::duplicate_field("cursor"));
19968 }
19969 field_cursor = Some(map.next_value()?);
19970 }
19971 "length" => {
19972 if field_length.is_some() {
19973 return Err(::serde::de::Error::duplicate_field("length"));
19974 }
19975 field_length = Some(map.next_value()?);
19976 }
19977 "close" => {
19978 if field_close.is_some() {
19979 return Err(::serde::de::Error::duplicate_field("close"));
19980 }
19981 field_close = Some(map.next_value()?);
19982 }
19983 _ => {
19984 map.next_value::<::serde_json::Value>()?;
19986 }
19987 }
19988 }
19989 if optional && nothing {
19990 return Ok(None);
19991 }
19992 let result = UploadSessionAppendBatchArgEntry {
19993 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
19994 length: field_length.ok_or_else(|| ::serde::de::Error::missing_field("length"))?,
19995 close: field_close.unwrap_or(false),
19996 };
19997 Ok(Some(result))
19998 }
19999
20000 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20001 &self,
20002 s: &mut S::SerializeStruct,
20003 ) -> Result<(), S::Error> {
20004 use serde::ser::SerializeStruct;
20005 s.serialize_field("cursor", &self.cursor)?;
20006 s.serialize_field("length", &self.length)?;
20007 if self.close {
20008 s.serialize_field("close", &self.close)?;
20009 }
20010 Ok(())
20011 }
20012}
20013
20014impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchArgEntry {
20015 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20016 use serde::de::{MapAccess, Visitor};
20018 struct StructVisitor;
20019 impl<'de> Visitor<'de> for StructVisitor {
20020 type Value = UploadSessionAppendBatchArgEntry;
20021 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20022 f.write_str("a UploadSessionAppendBatchArgEntry struct")
20023 }
20024 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20025 UploadSessionAppendBatchArgEntry::internal_deserialize(map)
20026 }
20027 }
20028 deserializer.deserialize_struct("UploadSessionAppendBatchArgEntry", UPLOAD_SESSION_APPEND_BATCH_ARG_ENTRY_FIELDS, StructVisitor)
20029 }
20030}
20031
20032impl ::serde::ser::Serialize for UploadSessionAppendBatchArgEntry {
20033 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20034 use serde::ser::SerializeStruct;
20036 let mut s = serializer.serialize_struct("UploadSessionAppendBatchArgEntry", 3)?;
20037 self.internal_serialize::<S>(&mut s)?;
20038 s.end()
20039 }
20040}
20041
20042#[derive(Debug, Clone, PartialEq, Eq)]
20043#[non_exhaustive] pub enum UploadSessionAppendBatchEntryError {
20045 NotFound,
20047 IncorrectOffset(UploadSessionOffsetError),
20051 Closed,
20054 TooLarge,
20057 ConcurrentSessionInvalidOffset,
20059 ConcurrentSessionInvalidDataSize,
20062 Other,
20065}
20066
20067impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchEntryError {
20068 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20069 use serde::de::{self, MapAccess, Visitor};
20071 struct EnumVisitor;
20072 impl<'de> Visitor<'de> for EnumVisitor {
20073 type Value = UploadSessionAppendBatchEntryError;
20074 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20075 f.write_str("a UploadSessionAppendBatchEntryError structure")
20076 }
20077 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20078 let tag: &str = match map.next_key()? {
20079 Some(".tag") => map.next_value()?,
20080 _ => return Err(de::Error::missing_field(".tag"))
20081 };
20082 let value = match tag {
20083 "not_found" => UploadSessionAppendBatchEntryError::NotFound,
20084 "incorrect_offset" => UploadSessionAppendBatchEntryError::IncorrectOffset(UploadSessionOffsetError::internal_deserialize(&mut map)?),
20085 "closed" => UploadSessionAppendBatchEntryError::Closed,
20086 "too_large" => UploadSessionAppendBatchEntryError::TooLarge,
20087 "concurrent_session_invalid_offset" => UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidOffset,
20088 "concurrent_session_invalid_data_size" => UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidDataSize,
20089 _ => UploadSessionAppendBatchEntryError::Other,
20090 };
20091 crate::eat_json_fields(&mut map)?;
20092 Ok(value)
20093 }
20094 }
20095 const VARIANTS: &[&str] = &["not_found",
20096 "incorrect_offset",
20097 "closed",
20098 "too_large",
20099 "concurrent_session_invalid_offset",
20100 "concurrent_session_invalid_data_size",
20101 "other"];
20102 deserializer.deserialize_struct("UploadSessionAppendBatchEntryError", VARIANTS, EnumVisitor)
20103 }
20104}
20105
20106impl ::serde::ser::Serialize for UploadSessionAppendBatchEntryError {
20107 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20108 use serde::ser::SerializeStruct;
20110 match self {
20111 UploadSessionAppendBatchEntryError::NotFound => {
20112 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20114 s.serialize_field(".tag", "not_found")?;
20115 s.end()
20116 }
20117 UploadSessionAppendBatchEntryError::IncorrectOffset(x) => {
20118 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 2)?;
20120 s.serialize_field(".tag", "incorrect_offset")?;
20121 x.internal_serialize::<S>(&mut s)?;
20122 s.end()
20123 }
20124 UploadSessionAppendBatchEntryError::Closed => {
20125 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20127 s.serialize_field(".tag", "closed")?;
20128 s.end()
20129 }
20130 UploadSessionAppendBatchEntryError::TooLarge => {
20131 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20133 s.serialize_field(".tag", "too_large")?;
20134 s.end()
20135 }
20136 UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidOffset => {
20137 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20139 s.serialize_field(".tag", "concurrent_session_invalid_offset")?;
20140 s.end()
20141 }
20142 UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidDataSize => {
20143 let mut s = serializer.serialize_struct("UploadSessionAppendBatchEntryError", 1)?;
20145 s.serialize_field(".tag", "concurrent_session_invalid_data_size")?;
20146 s.end()
20147 }
20148 UploadSessionAppendBatchEntryError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
20149 }
20150 }
20151}
20152
20153impl ::std::error::Error for UploadSessionAppendBatchEntryError {
20154}
20155
20156impl ::std::fmt::Display for UploadSessionAppendBatchEntryError {
20157 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20158 match self {
20159 UploadSessionAppendBatchEntryError::NotFound => f.write_str("The upload session ID was not found or has expired. Upload sessions are valid for 7 days."),
20160 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),
20161 UploadSessionAppendBatchEntryError::Closed => f.write_str("You are attempting to append data to an upload session that has already been closed (i.e. committed)."),
20162 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)."),
20163 UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidOffset => f.write_str("For concurrent upload sessions, offset needs to be multiple of 2^22 (4,194,304) bytes."),
20164 UploadSessionAppendBatchEntryError::ConcurrentSessionInvalidDataSize => f.write_str("For concurrent upload sessions, only chunks with size multiple of 2^22 (4,194,304) bytes can be uploaded."),
20165 _ => write!(f, "{:?}", *self),
20166 }
20167 }
20168}
20169
20170#[derive(Debug, Clone, PartialEq, Eq)]
20171#[non_exhaustive] pub enum UploadSessionAppendBatchError {
20173 PayloadTooLarge,
20175 ContentHashMismatch,
20178 LengthMismatch,
20181 Other,
20184}
20185
20186impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchError {
20187 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20188 use serde::de::{self, MapAccess, Visitor};
20190 struct EnumVisitor;
20191 impl<'de> Visitor<'de> for EnumVisitor {
20192 type Value = UploadSessionAppendBatchError;
20193 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20194 f.write_str("a UploadSessionAppendBatchError structure")
20195 }
20196 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20197 let tag: &str = match map.next_key()? {
20198 Some(".tag") => map.next_value()?,
20199 _ => return Err(de::Error::missing_field(".tag"))
20200 };
20201 let value = match tag {
20202 "payload_too_large" => UploadSessionAppendBatchError::PayloadTooLarge,
20203 "content_hash_mismatch" => UploadSessionAppendBatchError::ContentHashMismatch,
20204 "length_mismatch" => UploadSessionAppendBatchError::LengthMismatch,
20205 _ => UploadSessionAppendBatchError::Other,
20206 };
20207 crate::eat_json_fields(&mut map)?;
20208 Ok(value)
20209 }
20210 }
20211 const VARIANTS: &[&str] = &["payload_too_large",
20212 "content_hash_mismatch",
20213 "length_mismatch",
20214 "other"];
20215 deserializer.deserialize_struct("UploadSessionAppendBatchError", VARIANTS, EnumVisitor)
20216 }
20217}
20218
20219impl ::serde::ser::Serialize for UploadSessionAppendBatchError {
20220 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20221 use serde::ser::SerializeStruct;
20223 match self {
20224 UploadSessionAppendBatchError::PayloadTooLarge => {
20225 let mut s = serializer.serialize_struct("UploadSessionAppendBatchError", 1)?;
20227 s.serialize_field(".tag", "payload_too_large")?;
20228 s.end()
20229 }
20230 UploadSessionAppendBatchError::ContentHashMismatch => {
20231 let mut s = serializer.serialize_struct("UploadSessionAppendBatchError", 1)?;
20233 s.serialize_field(".tag", "content_hash_mismatch")?;
20234 s.end()
20235 }
20236 UploadSessionAppendBatchError::LengthMismatch => {
20237 let mut s = serializer.serialize_struct("UploadSessionAppendBatchError", 1)?;
20239 s.serialize_field(".tag", "length_mismatch")?;
20240 s.end()
20241 }
20242 UploadSessionAppendBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
20243 }
20244 }
20245}
20246
20247impl ::std::error::Error for UploadSessionAppendBatchError {
20248}
20249
20250impl ::std::fmt::Display for UploadSessionAppendBatchError {
20251 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20252 match self {
20253 UploadSessionAppendBatchError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
20254 UploadSessionAppendBatchError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
20255 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."),
20256 _ => write!(f, "{:?}", *self),
20257 }
20258 }
20259}
20260
20261#[derive(Debug, Clone, PartialEq, Eq)]
20262#[non_exhaustive] pub struct UploadSessionAppendBatchResult {
20264 pub entries: Vec<UploadSessionAppendBatchResultEntry>,
20268}
20269
20270impl UploadSessionAppendBatchResult {
20271 pub fn new(entries: Vec<UploadSessionAppendBatchResultEntry>) -> Self {
20272 UploadSessionAppendBatchResult {
20273 entries,
20274 }
20275 }
20276}
20277
20278const UPLOAD_SESSION_APPEND_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
20279impl UploadSessionAppendBatchResult {
20280 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20281 map: V,
20282 ) -> Result<UploadSessionAppendBatchResult, V::Error> {
20283 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20284 }
20285
20286 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20287 mut map: V,
20288 optional: bool,
20289 ) -> Result<Option<UploadSessionAppendBatchResult>, V::Error> {
20290 let mut field_entries = None;
20291 let mut nothing = true;
20292 while let Some(key) = map.next_key::<&str>()? {
20293 nothing = false;
20294 match key {
20295 "entries" => {
20296 if field_entries.is_some() {
20297 return Err(::serde::de::Error::duplicate_field("entries"));
20298 }
20299 field_entries = Some(map.next_value()?);
20300 }
20301 _ => {
20302 map.next_value::<::serde_json::Value>()?;
20304 }
20305 }
20306 }
20307 if optional && nothing {
20308 return Ok(None);
20309 }
20310 let result = UploadSessionAppendBatchResult {
20311 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
20312 };
20313 Ok(Some(result))
20314 }
20315
20316 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20317 &self,
20318 s: &mut S::SerializeStruct,
20319 ) -> Result<(), S::Error> {
20320 use serde::ser::SerializeStruct;
20321 s.serialize_field("entries", &self.entries)?;
20322 Ok(())
20323 }
20324}
20325
20326impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchResult {
20327 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20328 use serde::de::{MapAccess, Visitor};
20330 struct StructVisitor;
20331 impl<'de> Visitor<'de> for StructVisitor {
20332 type Value = UploadSessionAppendBatchResult;
20333 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20334 f.write_str("a UploadSessionAppendBatchResult struct")
20335 }
20336 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20337 UploadSessionAppendBatchResult::internal_deserialize(map)
20338 }
20339 }
20340 deserializer.deserialize_struct("UploadSessionAppendBatchResult", UPLOAD_SESSION_APPEND_BATCH_RESULT_FIELDS, StructVisitor)
20341 }
20342}
20343
20344impl ::serde::ser::Serialize for UploadSessionAppendBatchResult {
20345 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20346 use serde::ser::SerializeStruct;
20348 let mut s = serializer.serialize_struct("UploadSessionAppendBatchResult", 1)?;
20349 self.internal_serialize::<S>(&mut s)?;
20350 s.end()
20351 }
20352}
20353
20354#[derive(Debug, Clone, PartialEq, Eq)]
20355pub enum UploadSessionAppendBatchResultEntry {
20356 Success,
20357 Failure(UploadSessionAppendBatchEntryError),
20358}
20359
20360impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendBatchResultEntry {
20361 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20362 use serde::de::{self, MapAccess, Visitor};
20364 struct EnumVisitor;
20365 impl<'de> Visitor<'de> for EnumVisitor {
20366 type Value = UploadSessionAppendBatchResultEntry;
20367 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20368 f.write_str("a UploadSessionAppendBatchResultEntry structure")
20369 }
20370 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20371 let tag: &str = match map.next_key()? {
20372 Some(".tag") => map.next_value()?,
20373 _ => return Err(de::Error::missing_field(".tag"))
20374 };
20375 let value = match tag {
20376 "success" => UploadSessionAppendBatchResultEntry::Success,
20377 "failure" => {
20378 match map.next_key()? {
20379 Some("failure") => UploadSessionAppendBatchResultEntry::Failure(map.next_value()?),
20380 None => return Err(de::Error::missing_field("failure")),
20381 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
20382 }
20383 }
20384 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
20385 };
20386 crate::eat_json_fields(&mut map)?;
20387 Ok(value)
20388 }
20389 }
20390 const VARIANTS: &[&str] = &["success",
20391 "failure"];
20392 deserializer.deserialize_struct("UploadSessionAppendBatchResultEntry", VARIANTS, EnumVisitor)
20393 }
20394}
20395
20396impl ::serde::ser::Serialize for UploadSessionAppendBatchResultEntry {
20397 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20398 use serde::ser::SerializeStruct;
20400 match self {
20401 UploadSessionAppendBatchResultEntry::Success => {
20402 let mut s = serializer.serialize_struct("UploadSessionAppendBatchResultEntry", 1)?;
20404 s.serialize_field(".tag", "success")?;
20405 s.end()
20406 }
20407 UploadSessionAppendBatchResultEntry::Failure(x) => {
20408 let mut s = serializer.serialize_struct("UploadSessionAppendBatchResultEntry", 2)?;
20410 s.serialize_field(".tag", "failure")?;
20411 s.serialize_field("failure", x)?;
20412 s.end()
20413 }
20414 }
20415 }
20416}
20417
20418#[derive(Debug, Clone, PartialEq, Eq)]
20419#[non_exhaustive] pub enum UploadSessionAppendError {
20421 NotFound,
20423 IncorrectOffset(UploadSessionOffsetError),
20427 Closed,
20430 TooLarge,
20433 ConcurrentSessionInvalidOffset,
20435 ConcurrentSessionInvalidDataSize,
20438 PayloadTooLarge,
20440 ContentHashMismatch,
20443 Other,
20446}
20447
20448impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendError {
20449 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20450 use serde::de::{self, MapAccess, Visitor};
20452 struct EnumVisitor;
20453 impl<'de> Visitor<'de> for EnumVisitor {
20454 type Value = UploadSessionAppendError;
20455 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20456 f.write_str("a UploadSessionAppendError structure")
20457 }
20458 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20459 let tag: &str = match map.next_key()? {
20460 Some(".tag") => map.next_value()?,
20461 _ => return Err(de::Error::missing_field(".tag"))
20462 };
20463 let value = match tag {
20464 "not_found" => UploadSessionAppendError::NotFound,
20465 "incorrect_offset" => UploadSessionAppendError::IncorrectOffset(UploadSessionOffsetError::internal_deserialize(&mut map)?),
20466 "closed" => UploadSessionAppendError::Closed,
20467 "too_large" => UploadSessionAppendError::TooLarge,
20468 "concurrent_session_invalid_offset" => UploadSessionAppendError::ConcurrentSessionInvalidOffset,
20469 "concurrent_session_invalid_data_size" => UploadSessionAppendError::ConcurrentSessionInvalidDataSize,
20470 "payload_too_large" => UploadSessionAppendError::PayloadTooLarge,
20471 "content_hash_mismatch" => UploadSessionAppendError::ContentHashMismatch,
20472 _ => UploadSessionAppendError::Other,
20473 };
20474 crate::eat_json_fields(&mut map)?;
20475 Ok(value)
20476 }
20477 }
20478 const VARIANTS: &[&str] = &["not_found",
20479 "incorrect_offset",
20480 "closed",
20481 "too_large",
20482 "concurrent_session_invalid_offset",
20483 "concurrent_session_invalid_data_size",
20484 "payload_too_large",
20485 "content_hash_mismatch",
20486 "other"];
20487 deserializer.deserialize_struct("UploadSessionAppendError", VARIANTS, EnumVisitor)
20488 }
20489}
20490
20491impl ::serde::ser::Serialize for UploadSessionAppendError {
20492 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20493 use serde::ser::SerializeStruct;
20495 match self {
20496 UploadSessionAppendError::NotFound => {
20497 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20499 s.serialize_field(".tag", "not_found")?;
20500 s.end()
20501 }
20502 UploadSessionAppendError::IncorrectOffset(x) => {
20503 let mut s = serializer.serialize_struct("UploadSessionAppendError", 2)?;
20505 s.serialize_field(".tag", "incorrect_offset")?;
20506 x.internal_serialize::<S>(&mut s)?;
20507 s.end()
20508 }
20509 UploadSessionAppendError::Closed => {
20510 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20512 s.serialize_field(".tag", "closed")?;
20513 s.end()
20514 }
20515 UploadSessionAppendError::TooLarge => {
20516 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20518 s.serialize_field(".tag", "too_large")?;
20519 s.end()
20520 }
20521 UploadSessionAppendError::ConcurrentSessionInvalidOffset => {
20522 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20524 s.serialize_field(".tag", "concurrent_session_invalid_offset")?;
20525 s.end()
20526 }
20527 UploadSessionAppendError::ConcurrentSessionInvalidDataSize => {
20528 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20530 s.serialize_field(".tag", "concurrent_session_invalid_data_size")?;
20531 s.end()
20532 }
20533 UploadSessionAppendError::PayloadTooLarge => {
20534 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20536 s.serialize_field(".tag", "payload_too_large")?;
20537 s.end()
20538 }
20539 UploadSessionAppendError::ContentHashMismatch => {
20540 let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
20542 s.serialize_field(".tag", "content_hash_mismatch")?;
20543 s.end()
20544 }
20545 UploadSessionAppendError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
20546 }
20547 }
20548}
20549
20550impl ::std::error::Error for UploadSessionAppendError {
20551}
20552
20553impl ::std::fmt::Display for UploadSessionAppendError {
20554 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20555 match self {
20556 UploadSessionAppendError::NotFound => f.write_str("The upload session ID was not found or has expired. Upload sessions are valid for 7 days."),
20557 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),
20558 UploadSessionAppendError::Closed => f.write_str("You are attempting to append data to an upload session that has already been closed (i.e. committed)."),
20559 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)."),
20560 UploadSessionAppendError::ConcurrentSessionInvalidOffset => f.write_str("For concurrent upload sessions, offset needs to be multiple of 2^22 (4,194,304) bytes."),
20561 UploadSessionAppendError::ConcurrentSessionInvalidDataSize => f.write_str("For concurrent upload sessions, only chunks with size multiple of 2^22 (4,194,304) bytes can be uploaded."),
20562 UploadSessionAppendError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
20563 UploadSessionAppendError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
20564 _ => write!(f, "{:?}", *self),
20565 }
20566 }
20567}
20568
20569#[derive(Debug, Clone, PartialEq, Eq)]
20570#[non_exhaustive] pub struct UploadSessionCursor {
20572 pub session_id: String,
20575 pub offset: u64,
20578}
20579
20580impl UploadSessionCursor {
20581 pub fn new(session_id: String, offset: u64) -> Self {
20582 UploadSessionCursor {
20583 session_id,
20584 offset,
20585 }
20586 }
20587}
20588
20589const UPLOAD_SESSION_CURSOR_FIELDS: &[&str] = &["session_id",
20590 "offset"];
20591impl UploadSessionCursor {
20592 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20593 map: V,
20594 ) -> Result<UploadSessionCursor, V::Error> {
20595 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20596 }
20597
20598 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20599 mut map: V,
20600 optional: bool,
20601 ) -> Result<Option<UploadSessionCursor>, V::Error> {
20602 let mut field_session_id = None;
20603 let mut field_offset = None;
20604 let mut nothing = true;
20605 while let Some(key) = map.next_key::<&str>()? {
20606 nothing = false;
20607 match key {
20608 "session_id" => {
20609 if field_session_id.is_some() {
20610 return Err(::serde::de::Error::duplicate_field("session_id"));
20611 }
20612 field_session_id = Some(map.next_value()?);
20613 }
20614 "offset" => {
20615 if field_offset.is_some() {
20616 return Err(::serde::de::Error::duplicate_field("offset"));
20617 }
20618 field_offset = Some(map.next_value()?);
20619 }
20620 _ => {
20621 map.next_value::<::serde_json::Value>()?;
20623 }
20624 }
20625 }
20626 if optional && nothing {
20627 return Ok(None);
20628 }
20629 let result = UploadSessionCursor {
20630 session_id: field_session_id.ok_or_else(|| ::serde::de::Error::missing_field("session_id"))?,
20631 offset: field_offset.ok_or_else(|| ::serde::de::Error::missing_field("offset"))?,
20632 };
20633 Ok(Some(result))
20634 }
20635
20636 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20637 &self,
20638 s: &mut S::SerializeStruct,
20639 ) -> Result<(), S::Error> {
20640 use serde::ser::SerializeStruct;
20641 s.serialize_field("session_id", &self.session_id)?;
20642 s.serialize_field("offset", &self.offset)?;
20643 Ok(())
20644 }
20645}
20646
20647impl<'de> ::serde::de::Deserialize<'de> for UploadSessionCursor {
20648 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20649 use serde::de::{MapAccess, Visitor};
20651 struct StructVisitor;
20652 impl<'de> Visitor<'de> for StructVisitor {
20653 type Value = UploadSessionCursor;
20654 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20655 f.write_str("a UploadSessionCursor struct")
20656 }
20657 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20658 UploadSessionCursor::internal_deserialize(map)
20659 }
20660 }
20661 deserializer.deserialize_struct("UploadSessionCursor", UPLOAD_SESSION_CURSOR_FIELDS, StructVisitor)
20662 }
20663}
20664
20665impl ::serde::ser::Serialize for UploadSessionCursor {
20666 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20667 use serde::ser::SerializeStruct;
20669 let mut s = serializer.serialize_struct("UploadSessionCursor", 2)?;
20670 self.internal_serialize::<S>(&mut s)?;
20671 s.end()
20672 }
20673}
20674
20675#[derive(Debug, Clone, PartialEq, Eq)]
20676#[non_exhaustive] pub struct UploadSessionFinishArg {
20678 pub cursor: UploadSessionCursor,
20680 pub commit: CommitInfo,
20682 pub content_hash: Option<Sha256HexHash>,
20686}
20687
20688impl UploadSessionFinishArg {
20689 pub fn new(cursor: UploadSessionCursor, commit: CommitInfo) -> Self {
20690 UploadSessionFinishArg {
20691 cursor,
20692 commit,
20693 content_hash: None,
20694 }
20695 }
20696
20697 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
20698 self.content_hash = Some(value);
20699 self
20700 }
20701}
20702
20703const UPLOAD_SESSION_FINISH_ARG_FIELDS: &[&str] = &["cursor",
20704 "commit",
20705 "content_hash"];
20706impl UploadSessionFinishArg {
20707 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20708 map: V,
20709 ) -> Result<UploadSessionFinishArg, V::Error> {
20710 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20711 }
20712
20713 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20714 mut map: V,
20715 optional: bool,
20716 ) -> Result<Option<UploadSessionFinishArg>, V::Error> {
20717 let mut field_cursor = None;
20718 let mut field_commit = None;
20719 let mut field_content_hash = None;
20720 let mut nothing = true;
20721 while let Some(key) = map.next_key::<&str>()? {
20722 nothing = false;
20723 match key {
20724 "cursor" => {
20725 if field_cursor.is_some() {
20726 return Err(::serde::de::Error::duplicate_field("cursor"));
20727 }
20728 field_cursor = Some(map.next_value()?);
20729 }
20730 "commit" => {
20731 if field_commit.is_some() {
20732 return Err(::serde::de::Error::duplicate_field("commit"));
20733 }
20734 field_commit = Some(map.next_value()?);
20735 }
20736 "content_hash" => {
20737 if field_content_hash.is_some() {
20738 return Err(::serde::de::Error::duplicate_field("content_hash"));
20739 }
20740 field_content_hash = Some(map.next_value()?);
20741 }
20742 _ => {
20743 map.next_value::<::serde_json::Value>()?;
20745 }
20746 }
20747 }
20748 if optional && nothing {
20749 return Ok(None);
20750 }
20751 let result = UploadSessionFinishArg {
20752 cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
20753 commit: field_commit.ok_or_else(|| ::serde::de::Error::missing_field("commit"))?,
20754 content_hash: field_content_hash.and_then(Option::flatten),
20755 };
20756 Ok(Some(result))
20757 }
20758
20759 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20760 &self,
20761 s: &mut S::SerializeStruct,
20762 ) -> Result<(), S::Error> {
20763 use serde::ser::SerializeStruct;
20764 s.serialize_field("cursor", &self.cursor)?;
20765 s.serialize_field("commit", &self.commit)?;
20766 if let Some(val) = &self.content_hash {
20767 s.serialize_field("content_hash", val)?;
20768 }
20769 Ok(())
20770 }
20771}
20772
20773impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishArg {
20774 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20775 use serde::de::{MapAccess, Visitor};
20777 struct StructVisitor;
20778 impl<'de> Visitor<'de> for StructVisitor {
20779 type Value = UploadSessionFinishArg;
20780 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20781 f.write_str("a UploadSessionFinishArg struct")
20782 }
20783 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20784 UploadSessionFinishArg::internal_deserialize(map)
20785 }
20786 }
20787 deserializer.deserialize_struct("UploadSessionFinishArg", UPLOAD_SESSION_FINISH_ARG_FIELDS, StructVisitor)
20788 }
20789}
20790
20791impl ::serde::ser::Serialize for UploadSessionFinishArg {
20792 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20793 use serde::ser::SerializeStruct;
20795 let mut s = serializer.serialize_struct("UploadSessionFinishArg", 3)?;
20796 self.internal_serialize::<S>(&mut s)?;
20797 s.end()
20798 }
20799}
20800
20801#[derive(Debug, Clone, PartialEq, Eq)]
20802#[non_exhaustive] pub struct UploadSessionFinishBatchArg {
20804 pub entries: Vec<UploadSessionFinishArg>,
20806}
20807
20808impl UploadSessionFinishBatchArg {
20809 pub fn new(entries: Vec<UploadSessionFinishArg>) -> Self {
20810 UploadSessionFinishBatchArg {
20811 entries,
20812 }
20813 }
20814}
20815
20816const UPLOAD_SESSION_FINISH_BATCH_ARG_FIELDS: &[&str] = &["entries"];
20817impl UploadSessionFinishBatchArg {
20818 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
20819 map: V,
20820 ) -> Result<UploadSessionFinishBatchArg, V::Error> {
20821 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
20822 }
20823
20824 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
20825 mut map: V,
20826 optional: bool,
20827 ) -> Result<Option<UploadSessionFinishBatchArg>, V::Error> {
20828 let mut field_entries = None;
20829 let mut nothing = true;
20830 while let Some(key) = map.next_key::<&str>()? {
20831 nothing = false;
20832 match key {
20833 "entries" => {
20834 if field_entries.is_some() {
20835 return Err(::serde::de::Error::duplicate_field("entries"));
20836 }
20837 field_entries = Some(map.next_value()?);
20838 }
20839 _ => {
20840 map.next_value::<::serde_json::Value>()?;
20842 }
20843 }
20844 }
20845 if optional && nothing {
20846 return Ok(None);
20847 }
20848 let result = UploadSessionFinishBatchArg {
20849 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
20850 };
20851 Ok(Some(result))
20852 }
20853
20854 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
20855 &self,
20856 s: &mut S::SerializeStruct,
20857 ) -> Result<(), S::Error> {
20858 use serde::ser::SerializeStruct;
20859 s.serialize_field("entries", &self.entries)?;
20860 Ok(())
20861 }
20862}
20863
20864impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchArg {
20865 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20866 use serde::de::{MapAccess, Visitor};
20868 struct StructVisitor;
20869 impl<'de> Visitor<'de> for StructVisitor {
20870 type Value = UploadSessionFinishBatchArg;
20871 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20872 f.write_str("a UploadSessionFinishBatchArg struct")
20873 }
20874 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
20875 UploadSessionFinishBatchArg::internal_deserialize(map)
20876 }
20877 }
20878 deserializer.deserialize_struct("UploadSessionFinishBatchArg", UPLOAD_SESSION_FINISH_BATCH_ARG_FIELDS, StructVisitor)
20879 }
20880}
20881
20882impl ::serde::ser::Serialize for UploadSessionFinishBatchArg {
20883 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20884 use serde::ser::SerializeStruct;
20886 let mut s = serializer.serialize_struct("UploadSessionFinishBatchArg", 1)?;
20887 self.internal_serialize::<S>(&mut s)?;
20888 s.end()
20889 }
20890}
20891
20892#[derive(Debug, Clone, PartialEq)]
20893pub enum UploadSessionFinishBatchJobStatus {
20894 InProgress,
20896 Complete(UploadSessionFinishBatchResult),
20899}
20900
20901impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchJobStatus {
20902 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20903 use serde::de::{self, MapAccess, Visitor};
20905 struct EnumVisitor;
20906 impl<'de> Visitor<'de> for EnumVisitor {
20907 type Value = UploadSessionFinishBatchJobStatus;
20908 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20909 f.write_str("a UploadSessionFinishBatchJobStatus structure")
20910 }
20911 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20912 let tag: &str = match map.next_key()? {
20913 Some(".tag") => map.next_value()?,
20914 _ => return Err(de::Error::missing_field(".tag"))
20915 };
20916 let value = match tag {
20917 "in_progress" => UploadSessionFinishBatchJobStatus::InProgress,
20918 "complete" => UploadSessionFinishBatchJobStatus::Complete(UploadSessionFinishBatchResult::internal_deserialize(&mut map)?),
20919 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
20920 };
20921 crate::eat_json_fields(&mut map)?;
20922 Ok(value)
20923 }
20924 }
20925 const VARIANTS: &[&str] = &["in_progress",
20926 "complete"];
20927 deserializer.deserialize_struct("UploadSessionFinishBatchJobStatus", VARIANTS, EnumVisitor)
20928 }
20929}
20930
20931impl ::serde::ser::Serialize for UploadSessionFinishBatchJobStatus {
20932 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
20933 use serde::ser::SerializeStruct;
20935 match self {
20936 UploadSessionFinishBatchJobStatus::InProgress => {
20937 let mut s = serializer.serialize_struct("UploadSessionFinishBatchJobStatus", 1)?;
20939 s.serialize_field(".tag", "in_progress")?;
20940 s.end()
20941 }
20942 UploadSessionFinishBatchJobStatus::Complete(x) => {
20943 let mut s = serializer.serialize_struct("UploadSessionFinishBatchJobStatus", 2)?;
20945 s.serialize_field(".tag", "complete")?;
20946 x.internal_serialize::<S>(&mut s)?;
20947 s.end()
20948 }
20949 }
20950 }
20951}
20952
20953impl From<crate::types::dbx_async::PollResultBase> for UploadSessionFinishBatchJobStatus {
20955 fn from(parent: crate::types::dbx_async::PollResultBase) -> Self {
20956 match parent {
20957 crate::types::dbx_async::PollResultBase::InProgress => UploadSessionFinishBatchJobStatus::InProgress,
20958 }
20959 }
20960}
20961#[derive(Debug, Clone, PartialEq)]
20964#[non_exhaustive] pub enum UploadSessionFinishBatchLaunch {
20966 AsyncJobId(crate::types::dbx_async::AsyncJobId),
20969 Complete(UploadSessionFinishBatchResult),
20970 Other,
20973}
20974
20975impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchLaunch {
20976 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
20977 use serde::de::{self, MapAccess, Visitor};
20979 struct EnumVisitor;
20980 impl<'de> Visitor<'de> for EnumVisitor {
20981 type Value = UploadSessionFinishBatchLaunch;
20982 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
20983 f.write_str("a UploadSessionFinishBatchLaunch structure")
20984 }
20985 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
20986 let tag: &str = match map.next_key()? {
20987 Some(".tag") => map.next_value()?,
20988 _ => return Err(de::Error::missing_field(".tag"))
20989 };
20990 let value = match tag {
20991 "async_job_id" => {
20992 match map.next_key()? {
20993 Some("async_job_id") => UploadSessionFinishBatchLaunch::AsyncJobId(map.next_value()?),
20994 None => return Err(de::Error::missing_field("async_job_id")),
20995 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
20996 }
20997 }
20998 "complete" => UploadSessionFinishBatchLaunch::Complete(UploadSessionFinishBatchResult::internal_deserialize(&mut map)?),
20999 _ => UploadSessionFinishBatchLaunch::Other,
21000 };
21001 crate::eat_json_fields(&mut map)?;
21002 Ok(value)
21003 }
21004 }
21005 const VARIANTS: &[&str] = &["async_job_id",
21006 "complete",
21007 "other"];
21008 deserializer.deserialize_struct("UploadSessionFinishBatchLaunch", VARIANTS, EnumVisitor)
21009 }
21010}
21011
21012impl ::serde::ser::Serialize for UploadSessionFinishBatchLaunch {
21013 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21014 use serde::ser::SerializeStruct;
21016 match self {
21017 UploadSessionFinishBatchLaunch::AsyncJobId(x) => {
21018 let mut s = serializer.serialize_struct("UploadSessionFinishBatchLaunch", 2)?;
21020 s.serialize_field(".tag", "async_job_id")?;
21021 s.serialize_field("async_job_id", x)?;
21022 s.end()
21023 }
21024 UploadSessionFinishBatchLaunch::Complete(x) => {
21025 let mut s = serializer.serialize_struct("UploadSessionFinishBatchLaunch", 2)?;
21027 s.serialize_field(".tag", "complete")?;
21028 x.internal_serialize::<S>(&mut s)?;
21029 s.end()
21030 }
21031 UploadSessionFinishBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
21032 }
21033 }
21034}
21035
21036impl From<crate::types::dbx_async::LaunchResultBase> for UploadSessionFinishBatchLaunch {
21038 fn from(parent: crate::types::dbx_async::LaunchResultBase) -> Self {
21039 match parent {
21040 crate::types::dbx_async::LaunchResultBase::AsyncJobId(x) => UploadSessionFinishBatchLaunch::AsyncJobId(x),
21041 }
21042 }
21043}
21044#[derive(Debug, Clone, PartialEq)]
21045#[non_exhaustive] pub struct UploadSessionFinishBatchResult {
21047 pub entries: Vec<UploadSessionFinishBatchResultEntry>,
21051}
21052
21053impl UploadSessionFinishBatchResult {
21054 pub fn new(entries: Vec<UploadSessionFinishBatchResultEntry>) -> Self {
21055 UploadSessionFinishBatchResult {
21056 entries,
21057 }
21058 }
21059}
21060
21061const UPLOAD_SESSION_FINISH_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
21062impl UploadSessionFinishBatchResult {
21063 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21064 map: V,
21065 ) -> Result<UploadSessionFinishBatchResult, V::Error> {
21066 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21067 }
21068
21069 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21070 mut map: V,
21071 optional: bool,
21072 ) -> Result<Option<UploadSessionFinishBatchResult>, V::Error> {
21073 let mut field_entries = None;
21074 let mut nothing = true;
21075 while let Some(key) = map.next_key::<&str>()? {
21076 nothing = false;
21077 match key {
21078 "entries" => {
21079 if field_entries.is_some() {
21080 return Err(::serde::de::Error::duplicate_field("entries"));
21081 }
21082 field_entries = Some(map.next_value()?);
21083 }
21084 _ => {
21085 map.next_value::<::serde_json::Value>()?;
21087 }
21088 }
21089 }
21090 if optional && nothing {
21091 return Ok(None);
21092 }
21093 let result = UploadSessionFinishBatchResult {
21094 entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
21095 };
21096 Ok(Some(result))
21097 }
21098
21099 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21100 &self,
21101 s: &mut S::SerializeStruct,
21102 ) -> Result<(), S::Error> {
21103 use serde::ser::SerializeStruct;
21104 s.serialize_field("entries", &self.entries)?;
21105 Ok(())
21106 }
21107}
21108
21109impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchResult {
21110 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21111 use serde::de::{MapAccess, Visitor};
21113 struct StructVisitor;
21114 impl<'de> Visitor<'de> for StructVisitor {
21115 type Value = UploadSessionFinishBatchResult;
21116 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21117 f.write_str("a UploadSessionFinishBatchResult struct")
21118 }
21119 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21120 UploadSessionFinishBatchResult::internal_deserialize(map)
21121 }
21122 }
21123 deserializer.deserialize_struct("UploadSessionFinishBatchResult", UPLOAD_SESSION_FINISH_BATCH_RESULT_FIELDS, StructVisitor)
21124 }
21125}
21126
21127impl ::serde::ser::Serialize for UploadSessionFinishBatchResult {
21128 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21129 use serde::ser::SerializeStruct;
21131 let mut s = serializer.serialize_struct("UploadSessionFinishBatchResult", 1)?;
21132 self.internal_serialize::<S>(&mut s)?;
21133 s.end()
21134 }
21135}
21136
21137#[derive(Debug, Clone, PartialEq)]
21138pub enum UploadSessionFinishBatchResultEntry {
21139 Success(FileMetadata),
21140 Failure(UploadSessionFinishError),
21141}
21142
21143impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchResultEntry {
21144 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21145 use serde::de::{self, MapAccess, Visitor};
21147 struct EnumVisitor;
21148 impl<'de> Visitor<'de> for EnumVisitor {
21149 type Value = UploadSessionFinishBatchResultEntry;
21150 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21151 f.write_str("a UploadSessionFinishBatchResultEntry structure")
21152 }
21153 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21154 let tag: &str = match map.next_key()? {
21155 Some(".tag") => map.next_value()?,
21156 _ => return Err(de::Error::missing_field(".tag"))
21157 };
21158 let value = match tag {
21159 "success" => UploadSessionFinishBatchResultEntry::Success(FileMetadata::internal_deserialize(&mut map)?),
21160 "failure" => {
21161 match map.next_key()? {
21162 Some("failure") => UploadSessionFinishBatchResultEntry::Failure(map.next_value()?),
21163 None => return Err(de::Error::missing_field("failure")),
21164 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21165 }
21166 }
21167 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
21168 };
21169 crate::eat_json_fields(&mut map)?;
21170 Ok(value)
21171 }
21172 }
21173 const VARIANTS: &[&str] = &["success",
21174 "failure"];
21175 deserializer.deserialize_struct("UploadSessionFinishBatchResultEntry", VARIANTS, EnumVisitor)
21176 }
21177}
21178
21179impl ::serde::ser::Serialize for UploadSessionFinishBatchResultEntry {
21180 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21181 use serde::ser::SerializeStruct;
21183 match self {
21184 UploadSessionFinishBatchResultEntry::Success(x) => {
21185 let mut s = serializer.serialize_struct("UploadSessionFinishBatchResultEntry", 20)?;
21187 s.serialize_field(".tag", "success")?;
21188 x.internal_serialize::<S>(&mut s)?;
21189 s.end()
21190 }
21191 UploadSessionFinishBatchResultEntry::Failure(x) => {
21192 let mut s = serializer.serialize_struct("UploadSessionFinishBatchResultEntry", 2)?;
21194 s.serialize_field(".tag", "failure")?;
21195 s.serialize_field("failure", x)?;
21196 s.end()
21197 }
21198 }
21199 }
21200}
21201
21202#[derive(Debug, Clone, PartialEq, Eq)]
21203#[non_exhaustive] pub enum UploadSessionFinishError {
21205 LookupFailed(UploadSessionLookupError),
21207 Path(WriteError),
21210 PropertiesError(crate::types::file_properties::InvalidPropertyGroupError),
21212 #[deprecated]
21215 TooManySharedFolderTargets,
21216 TooManyWriteOperations,
21219 ConcurrentSessionDataNotAllowed,
21221 ConcurrentSessionNotClosed,
21223 ConcurrentSessionMissingData,
21225 PayloadTooLarge,
21227 ContentHashMismatch,
21230 EncryptionNotSupported,
21232 Other,
21235}
21236
21237impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishError {
21238 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21239 use serde::de::{self, MapAccess, Visitor};
21241 struct EnumVisitor;
21242 impl<'de> Visitor<'de> for EnumVisitor {
21243 type Value = UploadSessionFinishError;
21244 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21245 f.write_str("a UploadSessionFinishError structure")
21246 }
21247 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21248 let tag: &str = match map.next_key()? {
21249 Some(".tag") => map.next_value()?,
21250 _ => return Err(de::Error::missing_field(".tag"))
21251 };
21252 let value = match tag {
21253 "lookup_failed" => {
21254 match map.next_key()? {
21255 Some("lookup_failed") => UploadSessionFinishError::LookupFailed(map.next_value()?),
21256 None => return Err(de::Error::missing_field("lookup_failed")),
21257 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21258 }
21259 }
21260 "path" => {
21261 match map.next_key()? {
21262 Some("path") => UploadSessionFinishError::Path(map.next_value()?),
21263 None => return Err(de::Error::missing_field("path")),
21264 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21265 }
21266 }
21267 "properties_error" => {
21268 match map.next_key()? {
21269 Some("properties_error") => UploadSessionFinishError::PropertiesError(map.next_value()?),
21270 None => return Err(de::Error::missing_field("properties_error")),
21271 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
21272 }
21273 }
21274 #[allow(deprecated)]
21275 "too_many_shared_folder_targets" => UploadSessionFinishError::TooManySharedFolderTargets,
21276 "too_many_write_operations" => UploadSessionFinishError::TooManyWriteOperations,
21277 "concurrent_session_data_not_allowed" => UploadSessionFinishError::ConcurrentSessionDataNotAllowed,
21278 "concurrent_session_not_closed" => UploadSessionFinishError::ConcurrentSessionNotClosed,
21279 "concurrent_session_missing_data" => UploadSessionFinishError::ConcurrentSessionMissingData,
21280 "payload_too_large" => UploadSessionFinishError::PayloadTooLarge,
21281 "content_hash_mismatch" => UploadSessionFinishError::ContentHashMismatch,
21282 "encryption_not_supported" => UploadSessionFinishError::EncryptionNotSupported,
21283 _ => UploadSessionFinishError::Other,
21284 };
21285 crate::eat_json_fields(&mut map)?;
21286 Ok(value)
21287 }
21288 }
21289 const VARIANTS: &[&str] = &["lookup_failed",
21290 "path",
21291 "properties_error",
21292 "too_many_shared_folder_targets",
21293 "too_many_write_operations",
21294 "concurrent_session_data_not_allowed",
21295 "concurrent_session_not_closed",
21296 "concurrent_session_missing_data",
21297 "payload_too_large",
21298 "content_hash_mismatch",
21299 "encryption_not_supported",
21300 "other"];
21301 deserializer.deserialize_struct("UploadSessionFinishError", VARIANTS, EnumVisitor)
21302 }
21303}
21304
21305impl ::serde::ser::Serialize for UploadSessionFinishError {
21306 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21307 use serde::ser::SerializeStruct;
21309 match self {
21310 UploadSessionFinishError::LookupFailed(x) => {
21311 let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
21313 s.serialize_field(".tag", "lookup_failed")?;
21314 s.serialize_field("lookup_failed", x)?;
21315 s.end()
21316 }
21317 UploadSessionFinishError::Path(x) => {
21318 let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
21320 s.serialize_field(".tag", "path")?;
21321 s.serialize_field("path", x)?;
21322 s.end()
21323 }
21324 UploadSessionFinishError::PropertiesError(x) => {
21325 let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
21327 s.serialize_field(".tag", "properties_error")?;
21328 s.serialize_field("properties_error", x)?;
21329 s.end()
21330 }
21331 #[allow(deprecated)]
21332 UploadSessionFinishError::TooManySharedFolderTargets => {
21333 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21335 s.serialize_field(".tag", "too_many_shared_folder_targets")?;
21336 s.end()
21337 }
21338 UploadSessionFinishError::TooManyWriteOperations => {
21339 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21341 s.serialize_field(".tag", "too_many_write_operations")?;
21342 s.end()
21343 }
21344 UploadSessionFinishError::ConcurrentSessionDataNotAllowed => {
21345 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21347 s.serialize_field(".tag", "concurrent_session_data_not_allowed")?;
21348 s.end()
21349 }
21350 UploadSessionFinishError::ConcurrentSessionNotClosed => {
21351 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21353 s.serialize_field(".tag", "concurrent_session_not_closed")?;
21354 s.end()
21355 }
21356 UploadSessionFinishError::ConcurrentSessionMissingData => {
21357 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21359 s.serialize_field(".tag", "concurrent_session_missing_data")?;
21360 s.end()
21361 }
21362 UploadSessionFinishError::PayloadTooLarge => {
21363 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21365 s.serialize_field(".tag", "payload_too_large")?;
21366 s.end()
21367 }
21368 UploadSessionFinishError::ContentHashMismatch => {
21369 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21371 s.serialize_field(".tag", "content_hash_mismatch")?;
21372 s.end()
21373 }
21374 UploadSessionFinishError::EncryptionNotSupported => {
21375 let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
21377 s.serialize_field(".tag", "encryption_not_supported")?;
21378 s.end()
21379 }
21380 UploadSessionFinishError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
21381 }
21382 }
21383}
21384
21385impl ::std::error::Error for UploadSessionFinishError {
21386 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
21387 match self {
21388 UploadSessionFinishError::LookupFailed(inner) => Some(inner),
21389 UploadSessionFinishError::Path(inner) => Some(inner),
21390 UploadSessionFinishError::PropertiesError(inner) => Some(inner),
21391 _ => None,
21392 }
21393 }
21394}
21395
21396impl ::std::fmt::Display for UploadSessionFinishError {
21397 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21398 match self {
21399 UploadSessionFinishError::LookupFailed(inner) => write!(f, "The session arguments are incorrect; the value explains the reason: {}", inner),
21400 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),
21401 UploadSessionFinishError::PropertiesError(inner) => write!(f, "The supplied property group is invalid. The file has uploaded without property groups: {}", inner),
21402 #[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."),
21403 UploadSessionFinishError::TooManyWriteOperations => f.write_str("There are too many write operations happening in the user's Dropbox. You should retry uploading this file."),
21404 UploadSessionFinishError::ConcurrentSessionDataNotAllowed => f.write_str("Uploading data not allowed when finishing concurrent upload session."),
21405 UploadSessionFinishError::ConcurrentSessionNotClosed => f.write_str("Concurrent upload sessions need to be closed before finishing."),
21406 UploadSessionFinishError::ConcurrentSessionMissingData => f.write_str("Not all pieces of data were uploaded before trying to finish the session."),
21407 UploadSessionFinishError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
21408 UploadSessionFinishError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
21409 UploadSessionFinishError::EncryptionNotSupported => f.write_str("The file is required to be encrypted, which is not supported in our public API."),
21410 _ => write!(f, "{:?}", *self),
21411 }
21412 }
21413}
21414
21415#[derive(Debug, Clone, PartialEq, Eq)]
21416#[non_exhaustive] pub enum UploadSessionLookupError {
21418 NotFound,
21420 IncorrectOffset(UploadSessionOffsetError),
21424 Closed,
21427 NotClosed,
21429 TooLarge,
21432 ConcurrentSessionInvalidOffset,
21434 ConcurrentSessionInvalidDataSize,
21437 PayloadTooLarge,
21439 Other,
21442}
21443
21444impl<'de> ::serde::de::Deserialize<'de> for UploadSessionLookupError {
21445 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21446 use serde::de::{self, MapAccess, Visitor};
21448 struct EnumVisitor;
21449 impl<'de> Visitor<'de> for EnumVisitor {
21450 type Value = UploadSessionLookupError;
21451 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21452 f.write_str("a UploadSessionLookupError structure")
21453 }
21454 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
21455 let tag: &str = match map.next_key()? {
21456 Some(".tag") => map.next_value()?,
21457 _ => return Err(de::Error::missing_field(".tag"))
21458 };
21459 let value = match tag {
21460 "not_found" => UploadSessionLookupError::NotFound,
21461 "incorrect_offset" => UploadSessionLookupError::IncorrectOffset(UploadSessionOffsetError::internal_deserialize(&mut map)?),
21462 "closed" => UploadSessionLookupError::Closed,
21463 "not_closed" => UploadSessionLookupError::NotClosed,
21464 "too_large" => UploadSessionLookupError::TooLarge,
21465 "concurrent_session_invalid_offset" => UploadSessionLookupError::ConcurrentSessionInvalidOffset,
21466 "concurrent_session_invalid_data_size" => UploadSessionLookupError::ConcurrentSessionInvalidDataSize,
21467 "payload_too_large" => UploadSessionLookupError::PayloadTooLarge,
21468 _ => UploadSessionLookupError::Other,
21469 };
21470 crate::eat_json_fields(&mut map)?;
21471 Ok(value)
21472 }
21473 }
21474 const VARIANTS: &[&str] = &["not_found",
21475 "incorrect_offset",
21476 "closed",
21477 "not_closed",
21478 "too_large",
21479 "concurrent_session_invalid_offset",
21480 "concurrent_session_invalid_data_size",
21481 "payload_too_large",
21482 "other"];
21483 deserializer.deserialize_struct("UploadSessionLookupError", VARIANTS, EnumVisitor)
21484 }
21485}
21486
21487impl ::serde::ser::Serialize for UploadSessionLookupError {
21488 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21489 use serde::ser::SerializeStruct;
21491 match self {
21492 UploadSessionLookupError::NotFound => {
21493 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21495 s.serialize_field(".tag", "not_found")?;
21496 s.end()
21497 }
21498 UploadSessionLookupError::IncorrectOffset(x) => {
21499 let mut s = serializer.serialize_struct("UploadSessionLookupError", 2)?;
21501 s.serialize_field(".tag", "incorrect_offset")?;
21502 x.internal_serialize::<S>(&mut s)?;
21503 s.end()
21504 }
21505 UploadSessionLookupError::Closed => {
21506 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21508 s.serialize_field(".tag", "closed")?;
21509 s.end()
21510 }
21511 UploadSessionLookupError::NotClosed => {
21512 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21514 s.serialize_field(".tag", "not_closed")?;
21515 s.end()
21516 }
21517 UploadSessionLookupError::TooLarge => {
21518 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21520 s.serialize_field(".tag", "too_large")?;
21521 s.end()
21522 }
21523 UploadSessionLookupError::ConcurrentSessionInvalidOffset => {
21524 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21526 s.serialize_field(".tag", "concurrent_session_invalid_offset")?;
21527 s.end()
21528 }
21529 UploadSessionLookupError::ConcurrentSessionInvalidDataSize => {
21530 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21532 s.serialize_field(".tag", "concurrent_session_invalid_data_size")?;
21533 s.end()
21534 }
21535 UploadSessionLookupError::PayloadTooLarge => {
21536 let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
21538 s.serialize_field(".tag", "payload_too_large")?;
21539 s.end()
21540 }
21541 UploadSessionLookupError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
21542 }
21543 }
21544}
21545
21546impl ::std::error::Error for UploadSessionLookupError {
21547}
21548
21549impl ::std::fmt::Display for UploadSessionLookupError {
21550 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21551 match self {
21552 UploadSessionLookupError::NotFound => f.write_str("The upload session ID was not found or has expired. Upload sessions are valid for 7 days."),
21553 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),
21554 UploadSessionLookupError::Closed => f.write_str("You are attempting to append data to an upload session that has already been closed (i.e. committed)."),
21555 UploadSessionLookupError::NotClosed => f.write_str("The session must be closed before calling upload_session/finish_batch."),
21556 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)."),
21557 UploadSessionLookupError::ConcurrentSessionInvalidOffset => f.write_str("For concurrent upload sessions, offset needs to be multiple of 2^22 (4,194,304) bytes."),
21558 UploadSessionLookupError::ConcurrentSessionInvalidDataSize => f.write_str("For concurrent upload sessions, only chunks with size multiple of 2^22 (4,194,304) bytes can be uploaded."),
21559 UploadSessionLookupError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
21560 _ => write!(f, "{:?}", *self),
21561 }
21562 }
21563}
21564
21565#[derive(Debug, Clone, PartialEq, Eq)]
21566#[non_exhaustive] pub struct UploadSessionOffsetError {
21568 pub correct_offset: u64,
21570}
21571
21572impl UploadSessionOffsetError {
21573 pub fn new(correct_offset: u64) -> Self {
21574 UploadSessionOffsetError {
21575 correct_offset,
21576 }
21577 }
21578}
21579
21580const UPLOAD_SESSION_OFFSET_ERROR_FIELDS: &[&str] = &["correct_offset"];
21581impl UploadSessionOffsetError {
21582 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21583 map: V,
21584 ) -> Result<UploadSessionOffsetError, V::Error> {
21585 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21586 }
21587
21588 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21589 mut map: V,
21590 optional: bool,
21591 ) -> Result<Option<UploadSessionOffsetError>, V::Error> {
21592 let mut field_correct_offset = None;
21593 let mut nothing = true;
21594 while let Some(key) = map.next_key::<&str>()? {
21595 nothing = false;
21596 match key {
21597 "correct_offset" => {
21598 if field_correct_offset.is_some() {
21599 return Err(::serde::de::Error::duplicate_field("correct_offset"));
21600 }
21601 field_correct_offset = Some(map.next_value()?);
21602 }
21603 _ => {
21604 map.next_value::<::serde_json::Value>()?;
21606 }
21607 }
21608 }
21609 if optional && nothing {
21610 return Ok(None);
21611 }
21612 let result = UploadSessionOffsetError {
21613 correct_offset: field_correct_offset.ok_or_else(|| ::serde::de::Error::missing_field("correct_offset"))?,
21614 };
21615 Ok(Some(result))
21616 }
21617
21618 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21619 &self,
21620 s: &mut S::SerializeStruct,
21621 ) -> Result<(), S::Error> {
21622 use serde::ser::SerializeStruct;
21623 s.serialize_field("correct_offset", &self.correct_offset)?;
21624 Ok(())
21625 }
21626}
21627
21628impl<'de> ::serde::de::Deserialize<'de> for UploadSessionOffsetError {
21629 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21630 use serde::de::{MapAccess, Visitor};
21632 struct StructVisitor;
21633 impl<'de> Visitor<'de> for StructVisitor {
21634 type Value = UploadSessionOffsetError;
21635 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21636 f.write_str("a UploadSessionOffsetError struct")
21637 }
21638 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21639 UploadSessionOffsetError::internal_deserialize(map)
21640 }
21641 }
21642 deserializer.deserialize_struct("UploadSessionOffsetError", UPLOAD_SESSION_OFFSET_ERROR_FIELDS, StructVisitor)
21643 }
21644}
21645
21646impl ::serde::ser::Serialize for UploadSessionOffsetError {
21647 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21648 use serde::ser::SerializeStruct;
21650 let mut s = serializer.serialize_struct("UploadSessionOffsetError", 1)?;
21651 self.internal_serialize::<S>(&mut s)?;
21652 s.end()
21653 }
21654}
21655
21656#[derive(Debug, Clone, PartialEq, Eq, Default)]
21657#[non_exhaustive] pub struct UploadSessionStartArg {
21659 pub close: bool,
21663 pub session_type: Option<UploadSessionType>,
21666 pub content_hash: Option<Sha256HexHash>,
21670}
21671
21672impl UploadSessionStartArg {
21673 pub fn with_close(mut self, value: bool) -> Self {
21674 self.close = value;
21675 self
21676 }
21677
21678 pub fn with_session_type(mut self, value: UploadSessionType) -> Self {
21679 self.session_type = Some(value);
21680 self
21681 }
21682
21683 pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
21684 self.content_hash = Some(value);
21685 self
21686 }
21687}
21688
21689const UPLOAD_SESSION_START_ARG_FIELDS: &[&str] = &["close",
21690 "session_type",
21691 "content_hash"];
21692impl UploadSessionStartArg {
21693 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21695 mut map: V,
21696 ) -> Result<UploadSessionStartArg, V::Error> {
21697 let mut field_close = None;
21698 let mut field_session_type = None;
21699 let mut field_content_hash = None;
21700 while let Some(key) = map.next_key::<&str>()? {
21701 match key {
21702 "close" => {
21703 if field_close.is_some() {
21704 return Err(::serde::de::Error::duplicate_field("close"));
21705 }
21706 field_close = Some(map.next_value()?);
21707 }
21708 "session_type" => {
21709 if field_session_type.is_some() {
21710 return Err(::serde::de::Error::duplicate_field("session_type"));
21711 }
21712 field_session_type = Some(map.next_value()?);
21713 }
21714 "content_hash" => {
21715 if field_content_hash.is_some() {
21716 return Err(::serde::de::Error::duplicate_field("content_hash"));
21717 }
21718 field_content_hash = Some(map.next_value()?);
21719 }
21720 _ => {
21721 map.next_value::<::serde_json::Value>()?;
21723 }
21724 }
21725 }
21726 let result = UploadSessionStartArg {
21727 close: field_close.unwrap_or(false),
21728 session_type: field_session_type.and_then(Option::flatten),
21729 content_hash: field_content_hash.and_then(Option::flatten),
21730 };
21731 Ok(result)
21732 }
21733
21734 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21735 &self,
21736 s: &mut S::SerializeStruct,
21737 ) -> Result<(), S::Error> {
21738 use serde::ser::SerializeStruct;
21739 if self.close {
21740 s.serialize_field("close", &self.close)?;
21741 }
21742 if let Some(val) = &self.session_type {
21743 s.serialize_field("session_type", val)?;
21744 }
21745 if let Some(val) = &self.content_hash {
21746 s.serialize_field("content_hash", val)?;
21747 }
21748 Ok(())
21749 }
21750}
21751
21752impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartArg {
21753 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21754 use serde::de::{MapAccess, Visitor};
21756 struct StructVisitor;
21757 impl<'de> Visitor<'de> for StructVisitor {
21758 type Value = UploadSessionStartArg;
21759 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21760 f.write_str("a UploadSessionStartArg struct")
21761 }
21762 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21763 UploadSessionStartArg::internal_deserialize(map)
21764 }
21765 }
21766 deserializer.deserialize_struct("UploadSessionStartArg", UPLOAD_SESSION_START_ARG_FIELDS, StructVisitor)
21767 }
21768}
21769
21770impl ::serde::ser::Serialize for UploadSessionStartArg {
21771 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21772 use serde::ser::SerializeStruct;
21774 let mut s = serializer.serialize_struct("UploadSessionStartArg", 3)?;
21775 self.internal_serialize::<S>(&mut s)?;
21776 s.end()
21777 }
21778}
21779
21780#[derive(Debug, Clone, PartialEq, Eq)]
21781#[non_exhaustive] pub struct UploadSessionStartBatchArg {
21783 pub num_sessions: u64,
21785 pub session_type: Option<UploadSessionType>,
21788}
21789
21790impl UploadSessionStartBatchArg {
21791 pub fn new(num_sessions: u64) -> Self {
21792 UploadSessionStartBatchArg {
21793 num_sessions,
21794 session_type: None,
21795 }
21796 }
21797
21798 pub fn with_session_type(mut self, value: UploadSessionType) -> Self {
21799 self.session_type = Some(value);
21800 self
21801 }
21802}
21803
21804const UPLOAD_SESSION_START_BATCH_ARG_FIELDS: &[&str] = &["num_sessions",
21805 "session_type"];
21806impl UploadSessionStartBatchArg {
21807 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21808 map: V,
21809 ) -> Result<UploadSessionStartBatchArg, V::Error> {
21810 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21811 }
21812
21813 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21814 mut map: V,
21815 optional: bool,
21816 ) -> Result<Option<UploadSessionStartBatchArg>, V::Error> {
21817 let mut field_num_sessions = None;
21818 let mut field_session_type = None;
21819 let mut nothing = true;
21820 while let Some(key) = map.next_key::<&str>()? {
21821 nothing = false;
21822 match key {
21823 "num_sessions" => {
21824 if field_num_sessions.is_some() {
21825 return Err(::serde::de::Error::duplicate_field("num_sessions"));
21826 }
21827 field_num_sessions = Some(map.next_value()?);
21828 }
21829 "session_type" => {
21830 if field_session_type.is_some() {
21831 return Err(::serde::de::Error::duplicate_field("session_type"));
21832 }
21833 field_session_type = Some(map.next_value()?);
21834 }
21835 _ => {
21836 map.next_value::<::serde_json::Value>()?;
21838 }
21839 }
21840 }
21841 if optional && nothing {
21842 return Ok(None);
21843 }
21844 let result = UploadSessionStartBatchArg {
21845 num_sessions: field_num_sessions.ok_or_else(|| ::serde::de::Error::missing_field("num_sessions"))?,
21846 session_type: field_session_type.and_then(Option::flatten),
21847 };
21848 Ok(Some(result))
21849 }
21850
21851 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21852 &self,
21853 s: &mut S::SerializeStruct,
21854 ) -> Result<(), S::Error> {
21855 use serde::ser::SerializeStruct;
21856 s.serialize_field("num_sessions", &self.num_sessions)?;
21857 if let Some(val) = &self.session_type {
21858 s.serialize_field("session_type", val)?;
21859 }
21860 Ok(())
21861 }
21862}
21863
21864impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartBatchArg {
21865 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21866 use serde::de::{MapAccess, Visitor};
21868 struct StructVisitor;
21869 impl<'de> Visitor<'de> for StructVisitor {
21870 type Value = UploadSessionStartBatchArg;
21871 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21872 f.write_str("a UploadSessionStartBatchArg struct")
21873 }
21874 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21875 UploadSessionStartBatchArg::internal_deserialize(map)
21876 }
21877 }
21878 deserializer.deserialize_struct("UploadSessionStartBatchArg", UPLOAD_SESSION_START_BATCH_ARG_FIELDS, StructVisitor)
21879 }
21880}
21881
21882impl ::serde::ser::Serialize for UploadSessionStartBatchArg {
21883 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21884 use serde::ser::SerializeStruct;
21886 let mut s = serializer.serialize_struct("UploadSessionStartBatchArg", 2)?;
21887 self.internal_serialize::<S>(&mut s)?;
21888 s.end()
21889 }
21890}
21891
21892#[derive(Debug, Clone, PartialEq, Eq)]
21893#[non_exhaustive] pub struct UploadSessionStartBatchResult {
21895 pub session_ids: Vec<String>,
21899}
21900
21901impl UploadSessionStartBatchResult {
21902 pub fn new(session_ids: Vec<String>) -> Self {
21903 UploadSessionStartBatchResult {
21904 session_ids,
21905 }
21906 }
21907}
21908
21909const UPLOAD_SESSION_START_BATCH_RESULT_FIELDS: &[&str] = &["session_ids"];
21910impl UploadSessionStartBatchResult {
21911 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
21912 map: V,
21913 ) -> Result<UploadSessionStartBatchResult, V::Error> {
21914 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
21915 }
21916
21917 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
21918 mut map: V,
21919 optional: bool,
21920 ) -> Result<Option<UploadSessionStartBatchResult>, V::Error> {
21921 let mut field_session_ids = None;
21922 let mut nothing = true;
21923 while let Some(key) = map.next_key::<&str>()? {
21924 nothing = false;
21925 match key {
21926 "session_ids" => {
21927 if field_session_ids.is_some() {
21928 return Err(::serde::de::Error::duplicate_field("session_ids"));
21929 }
21930 field_session_ids = Some(map.next_value()?);
21931 }
21932 _ => {
21933 map.next_value::<::serde_json::Value>()?;
21935 }
21936 }
21937 }
21938 if optional && nothing {
21939 return Ok(None);
21940 }
21941 let result = UploadSessionStartBatchResult {
21942 session_ids: field_session_ids.ok_or_else(|| ::serde::de::Error::missing_field("session_ids"))?,
21943 };
21944 Ok(Some(result))
21945 }
21946
21947 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
21948 &self,
21949 s: &mut S::SerializeStruct,
21950 ) -> Result<(), S::Error> {
21951 use serde::ser::SerializeStruct;
21952 s.serialize_field("session_ids", &self.session_ids)?;
21953 Ok(())
21954 }
21955}
21956
21957impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartBatchResult {
21958 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
21959 use serde::de::{MapAccess, Visitor};
21961 struct StructVisitor;
21962 impl<'de> Visitor<'de> for StructVisitor {
21963 type Value = UploadSessionStartBatchResult;
21964 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
21965 f.write_str("a UploadSessionStartBatchResult struct")
21966 }
21967 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
21968 UploadSessionStartBatchResult::internal_deserialize(map)
21969 }
21970 }
21971 deserializer.deserialize_struct("UploadSessionStartBatchResult", UPLOAD_SESSION_START_BATCH_RESULT_FIELDS, StructVisitor)
21972 }
21973}
21974
21975impl ::serde::ser::Serialize for UploadSessionStartBatchResult {
21976 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
21977 use serde::ser::SerializeStruct;
21979 let mut s = serializer.serialize_struct("UploadSessionStartBatchResult", 1)?;
21980 self.internal_serialize::<S>(&mut s)?;
21981 s.end()
21982 }
21983}
21984
21985#[derive(Debug, Clone, PartialEq, Eq)]
21986#[non_exhaustive] pub enum UploadSessionStartError {
21988 ConcurrentSessionDataNotAllowed,
21990 ConcurrentSessionCloseNotAllowed,
21992 PayloadTooLarge,
21994 ContentHashMismatch,
21997 Other,
22000}
22001
22002impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartError {
22003 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22004 use serde::de::{self, MapAccess, Visitor};
22006 struct EnumVisitor;
22007 impl<'de> Visitor<'de> for EnumVisitor {
22008 type Value = UploadSessionStartError;
22009 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22010 f.write_str("a UploadSessionStartError structure")
22011 }
22012 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22013 let tag: &str = match map.next_key()? {
22014 Some(".tag") => map.next_value()?,
22015 _ => return Err(de::Error::missing_field(".tag"))
22016 };
22017 let value = match tag {
22018 "concurrent_session_data_not_allowed" => UploadSessionStartError::ConcurrentSessionDataNotAllowed,
22019 "concurrent_session_close_not_allowed" => UploadSessionStartError::ConcurrentSessionCloseNotAllowed,
22020 "payload_too_large" => UploadSessionStartError::PayloadTooLarge,
22021 "content_hash_mismatch" => UploadSessionStartError::ContentHashMismatch,
22022 _ => UploadSessionStartError::Other,
22023 };
22024 crate::eat_json_fields(&mut map)?;
22025 Ok(value)
22026 }
22027 }
22028 const VARIANTS: &[&str] = &["concurrent_session_data_not_allowed",
22029 "concurrent_session_close_not_allowed",
22030 "payload_too_large",
22031 "content_hash_mismatch",
22032 "other"];
22033 deserializer.deserialize_struct("UploadSessionStartError", VARIANTS, EnumVisitor)
22034 }
22035}
22036
22037impl ::serde::ser::Serialize for UploadSessionStartError {
22038 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22039 use serde::ser::SerializeStruct;
22041 match self {
22042 UploadSessionStartError::ConcurrentSessionDataNotAllowed => {
22043 let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
22045 s.serialize_field(".tag", "concurrent_session_data_not_allowed")?;
22046 s.end()
22047 }
22048 UploadSessionStartError::ConcurrentSessionCloseNotAllowed => {
22049 let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
22051 s.serialize_field(".tag", "concurrent_session_close_not_allowed")?;
22052 s.end()
22053 }
22054 UploadSessionStartError::PayloadTooLarge => {
22055 let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
22057 s.serialize_field(".tag", "payload_too_large")?;
22058 s.end()
22059 }
22060 UploadSessionStartError::ContentHashMismatch => {
22061 let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
22063 s.serialize_field(".tag", "content_hash_mismatch")?;
22064 s.end()
22065 }
22066 UploadSessionStartError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
22067 }
22068 }
22069}
22070
22071impl ::std::error::Error for UploadSessionStartError {
22072}
22073
22074impl ::std::fmt::Display for UploadSessionStartError {
22075 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22076 match self {
22077 UploadSessionStartError::ConcurrentSessionDataNotAllowed => f.write_str("Uploading data not allowed when starting concurrent upload session."),
22078 UploadSessionStartError::ConcurrentSessionCloseNotAllowed => f.write_str("Can not start a closed concurrent upload session."),
22079 UploadSessionStartError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MiB."),
22080 UploadSessionStartError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
22081 _ => write!(f, "{:?}", *self),
22082 }
22083 }
22084}
22085
22086#[derive(Debug, Clone, PartialEq, Eq)]
22087#[non_exhaustive] pub struct UploadSessionStartResult {
22089 pub session_id: String,
22093}
22094
22095impl UploadSessionStartResult {
22096 pub fn new(session_id: String) -> Self {
22097 UploadSessionStartResult {
22098 session_id,
22099 }
22100 }
22101}
22102
22103const UPLOAD_SESSION_START_RESULT_FIELDS: &[&str] = &["session_id"];
22104impl UploadSessionStartResult {
22105 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
22106 map: V,
22107 ) -> Result<UploadSessionStartResult, V::Error> {
22108 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
22109 }
22110
22111 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
22112 mut map: V,
22113 optional: bool,
22114 ) -> Result<Option<UploadSessionStartResult>, V::Error> {
22115 let mut field_session_id = None;
22116 let mut nothing = true;
22117 while let Some(key) = map.next_key::<&str>()? {
22118 nothing = false;
22119 match key {
22120 "session_id" => {
22121 if field_session_id.is_some() {
22122 return Err(::serde::de::Error::duplicate_field("session_id"));
22123 }
22124 field_session_id = Some(map.next_value()?);
22125 }
22126 _ => {
22127 map.next_value::<::serde_json::Value>()?;
22129 }
22130 }
22131 }
22132 if optional && nothing {
22133 return Ok(None);
22134 }
22135 let result = UploadSessionStartResult {
22136 session_id: field_session_id.ok_or_else(|| ::serde::de::Error::missing_field("session_id"))?,
22137 };
22138 Ok(Some(result))
22139 }
22140
22141 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
22142 &self,
22143 s: &mut S::SerializeStruct,
22144 ) -> Result<(), S::Error> {
22145 use serde::ser::SerializeStruct;
22146 s.serialize_field("session_id", &self.session_id)?;
22147 Ok(())
22148 }
22149}
22150
22151impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartResult {
22152 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22153 use serde::de::{MapAccess, Visitor};
22155 struct StructVisitor;
22156 impl<'de> Visitor<'de> for StructVisitor {
22157 type Value = UploadSessionStartResult;
22158 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22159 f.write_str("a UploadSessionStartResult struct")
22160 }
22161 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
22162 UploadSessionStartResult::internal_deserialize(map)
22163 }
22164 }
22165 deserializer.deserialize_struct("UploadSessionStartResult", UPLOAD_SESSION_START_RESULT_FIELDS, StructVisitor)
22166 }
22167}
22168
22169impl ::serde::ser::Serialize for UploadSessionStartResult {
22170 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22171 use serde::ser::SerializeStruct;
22173 let mut s = serializer.serialize_struct("UploadSessionStartResult", 1)?;
22174 self.internal_serialize::<S>(&mut s)?;
22175 s.end()
22176 }
22177}
22178
22179#[derive(Debug, Clone, PartialEq, Eq)]
22180#[non_exhaustive] pub enum UploadSessionType {
22182 Sequential,
22184 Concurrent,
22186 Other,
22189}
22190
22191impl<'de> ::serde::de::Deserialize<'de> for UploadSessionType {
22192 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22193 use serde::de::{self, MapAccess, Visitor};
22195 struct EnumVisitor;
22196 impl<'de> Visitor<'de> for EnumVisitor {
22197 type Value = UploadSessionType;
22198 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22199 f.write_str("a UploadSessionType structure")
22200 }
22201 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22202 let tag: &str = match map.next_key()? {
22203 Some(".tag") => map.next_value()?,
22204 _ => return Err(de::Error::missing_field(".tag"))
22205 };
22206 let value = match tag {
22207 "sequential" => UploadSessionType::Sequential,
22208 "concurrent" => UploadSessionType::Concurrent,
22209 _ => UploadSessionType::Other,
22210 };
22211 crate::eat_json_fields(&mut map)?;
22212 Ok(value)
22213 }
22214 }
22215 const VARIANTS: &[&str] = &["sequential",
22216 "concurrent",
22217 "other"];
22218 deserializer.deserialize_struct("UploadSessionType", VARIANTS, EnumVisitor)
22219 }
22220}
22221
22222impl ::serde::ser::Serialize for UploadSessionType {
22223 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22224 use serde::ser::SerializeStruct;
22226 match self {
22227 UploadSessionType::Sequential => {
22228 let mut s = serializer.serialize_struct("UploadSessionType", 1)?;
22230 s.serialize_field(".tag", "sequential")?;
22231 s.end()
22232 }
22233 UploadSessionType::Concurrent => {
22234 let mut s = serializer.serialize_struct("UploadSessionType", 1)?;
22236 s.serialize_field(".tag", "concurrent")?;
22237 s.end()
22238 }
22239 UploadSessionType::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
22240 }
22241 }
22242}
22243
22244#[derive(Debug, Clone, PartialEq, Eq)]
22245#[non_exhaustive] pub struct UploadWriteFailed {
22247 pub reason: WriteError,
22249 pub upload_session_id: String,
22253}
22254
22255impl UploadWriteFailed {
22256 pub fn new(reason: WriteError, upload_session_id: String) -> Self {
22257 UploadWriteFailed {
22258 reason,
22259 upload_session_id,
22260 }
22261 }
22262}
22263
22264const UPLOAD_WRITE_FAILED_FIELDS: &[&str] = &["reason",
22265 "upload_session_id"];
22266impl UploadWriteFailed {
22267 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
22268 map: V,
22269 ) -> Result<UploadWriteFailed, V::Error> {
22270 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
22271 }
22272
22273 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
22274 mut map: V,
22275 optional: bool,
22276 ) -> Result<Option<UploadWriteFailed>, V::Error> {
22277 let mut field_reason = None;
22278 let mut field_upload_session_id = None;
22279 let mut nothing = true;
22280 while let Some(key) = map.next_key::<&str>()? {
22281 nothing = false;
22282 match key {
22283 "reason" => {
22284 if field_reason.is_some() {
22285 return Err(::serde::de::Error::duplicate_field("reason"));
22286 }
22287 field_reason = Some(map.next_value()?);
22288 }
22289 "upload_session_id" => {
22290 if field_upload_session_id.is_some() {
22291 return Err(::serde::de::Error::duplicate_field("upload_session_id"));
22292 }
22293 field_upload_session_id = Some(map.next_value()?);
22294 }
22295 _ => {
22296 map.next_value::<::serde_json::Value>()?;
22298 }
22299 }
22300 }
22301 if optional && nothing {
22302 return Ok(None);
22303 }
22304 let result = UploadWriteFailed {
22305 reason: field_reason.ok_or_else(|| ::serde::de::Error::missing_field("reason"))?,
22306 upload_session_id: field_upload_session_id.ok_or_else(|| ::serde::de::Error::missing_field("upload_session_id"))?,
22307 };
22308 Ok(Some(result))
22309 }
22310
22311 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
22312 &self,
22313 s: &mut S::SerializeStruct,
22314 ) -> Result<(), S::Error> {
22315 use serde::ser::SerializeStruct;
22316 s.serialize_field("reason", &self.reason)?;
22317 s.serialize_field("upload_session_id", &self.upload_session_id)?;
22318 Ok(())
22319 }
22320}
22321
22322impl<'de> ::serde::de::Deserialize<'de> for UploadWriteFailed {
22323 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22324 use serde::de::{MapAccess, Visitor};
22326 struct StructVisitor;
22327 impl<'de> Visitor<'de> for StructVisitor {
22328 type Value = UploadWriteFailed;
22329 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22330 f.write_str("a UploadWriteFailed struct")
22331 }
22332 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
22333 UploadWriteFailed::internal_deserialize(map)
22334 }
22335 }
22336 deserializer.deserialize_struct("UploadWriteFailed", UPLOAD_WRITE_FAILED_FIELDS, StructVisitor)
22337 }
22338}
22339
22340impl ::serde::ser::Serialize for UploadWriteFailed {
22341 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22342 use serde::ser::SerializeStruct;
22344 let mut s = serializer.serialize_struct("UploadWriteFailed", 2)?;
22345 self.internal_serialize::<S>(&mut s)?;
22346 s.end()
22347 }
22348}
22349
22350#[derive(Debug, Clone, PartialEq, Eq)]
22351#[non_exhaustive] pub struct UserGeneratedTag {
22353 pub tag_text: TagText,
22354}
22355
22356impl UserGeneratedTag {
22357 pub fn new(tag_text: TagText) -> Self {
22358 UserGeneratedTag {
22359 tag_text,
22360 }
22361 }
22362}
22363
22364const USER_GENERATED_TAG_FIELDS: &[&str] = &["tag_text"];
22365impl UserGeneratedTag {
22366 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
22367 map: V,
22368 ) -> Result<UserGeneratedTag, V::Error> {
22369 Self::internal_deserialize_opt(map, false).map(Option::unwrap)
22370 }
22371
22372 pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
22373 mut map: V,
22374 optional: bool,
22375 ) -> Result<Option<UserGeneratedTag>, V::Error> {
22376 let mut field_tag_text = None;
22377 let mut nothing = true;
22378 while let Some(key) = map.next_key::<&str>()? {
22379 nothing = false;
22380 match key {
22381 "tag_text" => {
22382 if field_tag_text.is_some() {
22383 return Err(::serde::de::Error::duplicate_field("tag_text"));
22384 }
22385 field_tag_text = Some(map.next_value()?);
22386 }
22387 _ => {
22388 map.next_value::<::serde_json::Value>()?;
22390 }
22391 }
22392 }
22393 if optional && nothing {
22394 return Ok(None);
22395 }
22396 let result = UserGeneratedTag {
22397 tag_text: field_tag_text.ok_or_else(|| ::serde::de::Error::missing_field("tag_text"))?,
22398 };
22399 Ok(Some(result))
22400 }
22401
22402 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
22403 &self,
22404 s: &mut S::SerializeStruct,
22405 ) -> Result<(), S::Error> {
22406 use serde::ser::SerializeStruct;
22407 s.serialize_field("tag_text", &self.tag_text)?;
22408 Ok(())
22409 }
22410}
22411
22412impl<'de> ::serde::de::Deserialize<'de> for UserGeneratedTag {
22413 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22414 use serde::de::{MapAccess, Visitor};
22416 struct StructVisitor;
22417 impl<'de> Visitor<'de> for StructVisitor {
22418 type Value = UserGeneratedTag;
22419 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22420 f.write_str("a UserGeneratedTag struct")
22421 }
22422 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
22423 UserGeneratedTag::internal_deserialize(map)
22424 }
22425 }
22426 deserializer.deserialize_struct("UserGeneratedTag", USER_GENERATED_TAG_FIELDS, StructVisitor)
22427 }
22428}
22429
22430impl ::serde::ser::Serialize for UserGeneratedTag {
22431 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22432 use serde::ser::SerializeStruct;
22434 let mut s = serializer.serialize_struct("UserGeneratedTag", 1)?;
22435 self.internal_serialize::<S>(&mut s)?;
22436 s.end()
22437 }
22438}
22439
22440#[derive(Debug, Clone, PartialEq, Default)]
22442#[non_exhaustive] pub struct VideoMetadata {
22444 pub dimensions: Option<Dimensions>,
22446 pub location: Option<GpsCoordinates>,
22448 pub time_taken: Option<crate::types::common::DropboxTimestamp>,
22450 pub duration: Option<u64>,
22452}
22453
22454impl VideoMetadata {
22455 pub fn with_dimensions(mut self, value: Dimensions) -> Self {
22456 self.dimensions = Some(value);
22457 self
22458 }
22459
22460 pub fn with_location(mut self, value: GpsCoordinates) -> Self {
22461 self.location = Some(value);
22462 self
22463 }
22464
22465 pub fn with_time_taken(mut self, value: crate::types::common::DropboxTimestamp) -> Self {
22466 self.time_taken = Some(value);
22467 self
22468 }
22469
22470 pub fn with_duration(mut self, value: u64) -> Self {
22471 self.duration = Some(value);
22472 self
22473 }
22474}
22475
22476const VIDEO_METADATA_FIELDS: &[&str] = &["dimensions",
22477 "location",
22478 "time_taken",
22479 "duration"];
22480impl VideoMetadata {
22481 pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
22483 mut map: V,
22484 ) -> Result<VideoMetadata, V::Error> {
22485 let mut field_dimensions = None;
22486 let mut field_location = None;
22487 let mut field_time_taken = None;
22488 let mut field_duration = None;
22489 while let Some(key) = map.next_key::<&str>()? {
22490 match key {
22491 "dimensions" => {
22492 if field_dimensions.is_some() {
22493 return Err(::serde::de::Error::duplicate_field("dimensions"));
22494 }
22495 field_dimensions = Some(map.next_value()?);
22496 }
22497 "location" => {
22498 if field_location.is_some() {
22499 return Err(::serde::de::Error::duplicate_field("location"));
22500 }
22501 field_location = Some(map.next_value()?);
22502 }
22503 "time_taken" => {
22504 if field_time_taken.is_some() {
22505 return Err(::serde::de::Error::duplicate_field("time_taken"));
22506 }
22507 field_time_taken = Some(map.next_value()?);
22508 }
22509 "duration" => {
22510 if field_duration.is_some() {
22511 return Err(::serde::de::Error::duplicate_field("duration"));
22512 }
22513 field_duration = Some(map.next_value()?);
22514 }
22515 _ => {
22516 map.next_value::<::serde_json::Value>()?;
22518 }
22519 }
22520 }
22521 let result = VideoMetadata {
22522 dimensions: field_dimensions.and_then(Option::flatten),
22523 location: field_location.and_then(Option::flatten),
22524 time_taken: field_time_taken.and_then(Option::flatten),
22525 duration: field_duration.and_then(Option::flatten),
22526 };
22527 Ok(result)
22528 }
22529
22530 pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
22531 &self,
22532 s: &mut S::SerializeStruct,
22533 ) -> Result<(), S::Error> {
22534 use serde::ser::SerializeStruct;
22535 if let Some(val) = &self.dimensions {
22536 s.serialize_field("dimensions", val)?;
22537 }
22538 if let Some(val) = &self.location {
22539 s.serialize_field("location", val)?;
22540 }
22541 if let Some(val) = &self.time_taken {
22542 s.serialize_field("time_taken", val)?;
22543 }
22544 if let Some(val) = &self.duration {
22545 s.serialize_field("duration", val)?;
22546 }
22547 Ok(())
22548 }
22549}
22550
22551impl<'de> ::serde::de::Deserialize<'de> for VideoMetadata {
22552 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22553 use serde::de::{MapAccess, Visitor};
22555 struct StructVisitor;
22556 impl<'de> Visitor<'de> for StructVisitor {
22557 type Value = VideoMetadata;
22558 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22559 f.write_str("a VideoMetadata struct")
22560 }
22561 fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
22562 VideoMetadata::internal_deserialize(map)
22563 }
22564 }
22565 deserializer.deserialize_struct("VideoMetadata", VIDEO_METADATA_FIELDS, StructVisitor)
22566 }
22567}
22568
22569impl ::serde::ser::Serialize for VideoMetadata {
22570 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22571 use serde::ser::SerializeStruct;
22573 let mut s = serializer.serialize_struct("VideoMetadata", 4)?;
22574 self.internal_serialize::<S>(&mut s)?;
22575 s.end()
22576 }
22577}
22578
22579impl From<VideoMetadata> for MediaMetadata {
22581 fn from(subtype: VideoMetadata) -> Self {
22582 MediaMetadata::Video(subtype)
22583 }
22584}
22585#[derive(Debug, Clone, PartialEq, Eq)]
22586#[non_exhaustive] pub enum WriteConflictError {
22588 File,
22590 Folder,
22592 FileAncestor,
22594 Other,
22597}
22598
22599impl<'de> ::serde::de::Deserialize<'de> for WriteConflictError {
22600 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22601 use serde::de::{self, MapAccess, Visitor};
22603 struct EnumVisitor;
22604 impl<'de> Visitor<'de> for EnumVisitor {
22605 type Value = WriteConflictError;
22606 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22607 f.write_str("a WriteConflictError structure")
22608 }
22609 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22610 let tag: &str = match map.next_key()? {
22611 Some(".tag") => map.next_value()?,
22612 _ => return Err(de::Error::missing_field(".tag"))
22613 };
22614 let value = match tag {
22615 "file" => WriteConflictError::File,
22616 "folder" => WriteConflictError::Folder,
22617 "file_ancestor" => WriteConflictError::FileAncestor,
22618 _ => WriteConflictError::Other,
22619 };
22620 crate::eat_json_fields(&mut map)?;
22621 Ok(value)
22622 }
22623 }
22624 const VARIANTS: &[&str] = &["file",
22625 "folder",
22626 "file_ancestor",
22627 "other"];
22628 deserializer.deserialize_struct("WriteConflictError", VARIANTS, EnumVisitor)
22629 }
22630}
22631
22632impl ::serde::ser::Serialize for WriteConflictError {
22633 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22634 use serde::ser::SerializeStruct;
22636 match self {
22637 WriteConflictError::File => {
22638 let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
22640 s.serialize_field(".tag", "file")?;
22641 s.end()
22642 }
22643 WriteConflictError::Folder => {
22644 let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
22646 s.serialize_field(".tag", "folder")?;
22647 s.end()
22648 }
22649 WriteConflictError::FileAncestor => {
22650 let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
22652 s.serialize_field(".tag", "file_ancestor")?;
22653 s.end()
22654 }
22655 WriteConflictError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
22656 }
22657 }
22658}
22659
22660impl ::std::error::Error for WriteConflictError {
22661}
22662
22663impl ::std::fmt::Display for WriteConflictError {
22664 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22665 match self {
22666 WriteConflictError::File => f.write_str("There's a file in the way."),
22667 WriteConflictError::Folder => f.write_str("There's a folder in the way."),
22668 WriteConflictError::FileAncestor => f.write_str("There's a file at an ancestor path, so we couldn't create the required parent folders."),
22669 _ => write!(f, "{:?}", *self),
22670 }
22671 }
22672}
22673
22674#[derive(Debug, Clone, PartialEq, Eq)]
22675#[non_exhaustive] pub enum WriteError {
22677 MalformedPath(MalformedPathError),
22681 Conflict(WriteConflictError),
22683 NoWritePermission,
22685 InsufficientSpace,
22687 DisallowedName,
22689 TeamFolder,
22691 OperationSuppressed,
22693 TooManyWriteOperations,
22695 AccessRestricted,
22698 Other,
22701}
22702
22703impl<'de> ::serde::de::Deserialize<'de> for WriteError {
22704 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22705 use serde::de::{self, MapAccess, Visitor};
22707 struct EnumVisitor;
22708 impl<'de> Visitor<'de> for EnumVisitor {
22709 type Value = WriteError;
22710 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22711 f.write_str("a WriteError structure")
22712 }
22713 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22714 let tag: &str = match map.next_key()? {
22715 Some(".tag") => map.next_value()?,
22716 _ => return Err(de::Error::missing_field(".tag"))
22717 };
22718 let value = match tag {
22719 "malformed_path" => {
22720 match map.next_key()? {
22721 Some("malformed_path") => WriteError::MalformedPath(map.next_value()?),
22722 None => WriteError::MalformedPath(None),
22723 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
22724 }
22725 }
22726 "conflict" => {
22727 match map.next_key()? {
22728 Some("conflict") => WriteError::Conflict(map.next_value()?),
22729 None => return Err(de::Error::missing_field("conflict")),
22730 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
22731 }
22732 }
22733 "no_write_permission" => WriteError::NoWritePermission,
22734 "insufficient_space" => WriteError::InsufficientSpace,
22735 "disallowed_name" => WriteError::DisallowedName,
22736 "team_folder" => WriteError::TeamFolder,
22737 "operation_suppressed" => WriteError::OperationSuppressed,
22738 "too_many_write_operations" => WriteError::TooManyWriteOperations,
22739 "access_restricted" => WriteError::AccessRestricted,
22740 _ => WriteError::Other,
22741 };
22742 crate::eat_json_fields(&mut map)?;
22743 Ok(value)
22744 }
22745 }
22746 const VARIANTS: &[&str] = &["malformed_path",
22747 "conflict",
22748 "no_write_permission",
22749 "insufficient_space",
22750 "disallowed_name",
22751 "team_folder",
22752 "operation_suppressed",
22753 "too_many_write_operations",
22754 "access_restricted",
22755 "other"];
22756 deserializer.deserialize_struct("WriteError", VARIANTS, EnumVisitor)
22757 }
22758}
22759
22760impl ::serde::ser::Serialize for WriteError {
22761 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22762 use serde::ser::SerializeStruct;
22764 match self {
22765 WriteError::MalformedPath(x) => {
22766 let n = if x.is_some() { 2 } else { 1 };
22768 let mut s = serializer.serialize_struct("WriteError", n)?;
22769 s.serialize_field(".tag", "malformed_path")?;
22770 if let Some(x) = x {
22771 s.serialize_field("malformed_path", &x)?;
22772 }
22773 s.end()
22774 }
22775 WriteError::Conflict(x) => {
22776 let mut s = serializer.serialize_struct("WriteError", 2)?;
22778 s.serialize_field(".tag", "conflict")?;
22779 s.serialize_field("conflict", x)?;
22780 s.end()
22781 }
22782 WriteError::NoWritePermission => {
22783 let mut s = serializer.serialize_struct("WriteError", 1)?;
22785 s.serialize_field(".tag", "no_write_permission")?;
22786 s.end()
22787 }
22788 WriteError::InsufficientSpace => {
22789 let mut s = serializer.serialize_struct("WriteError", 1)?;
22791 s.serialize_field(".tag", "insufficient_space")?;
22792 s.end()
22793 }
22794 WriteError::DisallowedName => {
22795 let mut s = serializer.serialize_struct("WriteError", 1)?;
22797 s.serialize_field(".tag", "disallowed_name")?;
22798 s.end()
22799 }
22800 WriteError::TeamFolder => {
22801 let mut s = serializer.serialize_struct("WriteError", 1)?;
22803 s.serialize_field(".tag", "team_folder")?;
22804 s.end()
22805 }
22806 WriteError::OperationSuppressed => {
22807 let mut s = serializer.serialize_struct("WriteError", 1)?;
22809 s.serialize_field(".tag", "operation_suppressed")?;
22810 s.end()
22811 }
22812 WriteError::TooManyWriteOperations => {
22813 let mut s = serializer.serialize_struct("WriteError", 1)?;
22815 s.serialize_field(".tag", "too_many_write_operations")?;
22816 s.end()
22817 }
22818 WriteError::AccessRestricted => {
22819 let mut s = serializer.serialize_struct("WriteError", 1)?;
22821 s.serialize_field(".tag", "access_restricted")?;
22822 s.end()
22823 }
22824 WriteError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
22825 }
22826 }
22827}
22828
22829impl ::std::error::Error for WriteError {
22830 fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
22831 match self {
22832 WriteError::Conflict(inner) => Some(inner),
22833 _ => None,
22834 }
22835 }
22836}
22837
22838impl ::std::fmt::Display for WriteError {
22839 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22840 match self {
22841 WriteError::MalformedPath(inner) => write!(f, "malformed_path: {:?}", inner),
22842 WriteError::Conflict(inner) => write!(f, "Couldn't write to the target path because there was something in the way: {}", inner),
22843 WriteError::NoWritePermission => f.write_str("The user doesn't have permissions to write to the target location."),
22844 WriteError::InsufficientSpace => f.write_str("The user doesn't have enough available space (bytes) to write more data."),
22845 WriteError::DisallowedName => f.write_str("Dropbox will not save the file or folder because of its name."),
22846 WriteError::TeamFolder => f.write_str("This endpoint cannot move or delete team folders."),
22847 WriteError::OperationSuppressed => f.write_str("This file operation is not allowed at this path."),
22848 WriteError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
22849 WriteError::AccessRestricted => f.write_str("The user doesn't have permission to perform the action due to restrictions set by a team administrator"),
22850 _ => write!(f, "{:?}", *self),
22851 }
22852 }
22853}
22854
22855#[derive(Debug, Clone, PartialEq, Eq)]
22863pub enum WriteMode {
22864 Add,
22868 Overwrite,
22871 Update(Rev),
22879}
22880
22881impl<'de> ::serde::de::Deserialize<'de> for WriteMode {
22882 fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
22883 use serde::de::{self, MapAccess, Visitor};
22885 struct EnumVisitor;
22886 impl<'de> Visitor<'de> for EnumVisitor {
22887 type Value = WriteMode;
22888 fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
22889 f.write_str("a WriteMode structure")
22890 }
22891 fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
22892 let tag: &str = match map.next_key()? {
22893 Some(".tag") => map.next_value()?,
22894 _ => return Err(de::Error::missing_field(".tag"))
22895 };
22896 let value = match tag {
22897 "add" => WriteMode::Add,
22898 "overwrite" => WriteMode::Overwrite,
22899 "update" => {
22900 match map.next_key()? {
22901 Some("update") => WriteMode::Update(map.next_value()?),
22902 None => return Err(de::Error::missing_field("update")),
22903 _ => return Err(de::Error::unknown_field(tag, VARIANTS))
22904 }
22905 }
22906 _ => return Err(de::Error::unknown_variant(tag, VARIANTS))
22907 };
22908 crate::eat_json_fields(&mut map)?;
22909 Ok(value)
22910 }
22911 }
22912 const VARIANTS: &[&str] = &["add",
22913 "overwrite",
22914 "update"];
22915 deserializer.deserialize_struct("WriteMode", VARIANTS, EnumVisitor)
22916 }
22917}
22918
22919impl ::serde::ser::Serialize for WriteMode {
22920 fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
22921 use serde::ser::SerializeStruct;
22923 match self {
22924 WriteMode::Add => {
22925 let mut s = serializer.serialize_struct("WriteMode", 1)?;
22927 s.serialize_field(".tag", "add")?;
22928 s.end()
22929 }
22930 WriteMode::Overwrite => {
22931 let mut s = serializer.serialize_struct("WriteMode", 1)?;
22933 s.serialize_field(".tag", "overwrite")?;
22934 s.end()
22935 }
22936 WriteMode::Update(x) => {
22937 let mut s = serializer.serialize_struct("WriteMode", 2)?;
22939 s.serialize_field(".tag", "update")?;
22940 s.serialize_field("update", x)?;
22941 s.end()
22942 }
22943 }
22944 }
22945}
22946