#![allow(
clippy::too_many_arguments,
clippy::large_enum_variant,
clippy::doc_markdown,
)]
pub type CopyBatchArg = RelocationBatchArgBase;
pub type FileId = String;
pub type Id = String;
pub type ListFolderCursor = String;
pub type MalformedPathError = Option<String>;
pub type Path = String;
pub type PathOrId = String;
pub type PathR = String;
pub type PathROrId = String;
pub type ReadPath = String;
pub type Rev = String;
pub type SearchV2Cursor = String;
pub type Sha256HexHash = String;
pub type SharedLinkUrl = String;
pub type TagText = String;
pub type WritePath = String;
pub type WritePathOrId = String;
#[cfg(feature = "unstable")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[deprecated(note = "replaced by get_metadata")]
pub fn alpha_get_metadata(
client: &impl crate::client_trait::UserAuthClient,
arg: &AlphaGetMetadataArg,
) -> crate::Result<Result<Metadata, AlphaGetMetadataError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/alpha/get_metadata",
arg,
None)
}
#[cfg(feature = "unstable")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
#[deprecated(note = "replaced by upload")]
pub fn alpha_upload(
client: &impl crate::client_trait::UserAuthClient,
arg: &UploadArg,
body: &[u8],
) -> crate::Result<Result<FileMetadata, UploadError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Upload,
"files/alpha/upload",
arg,
Some(body))
}
pub fn copy_v2(
client: &impl crate::client_trait::UserAuthClient,
arg: &RelocationArg,
) -> crate::Result<Result<RelocationResult, RelocationError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/copy_v2",
arg,
None)
}
#[deprecated(note = "replaced by copy_v2")]
pub fn copy(
client: &impl crate::client_trait::UserAuthClient,
arg: &RelocationArg,
) -> crate::Result<Result<Metadata, RelocationError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/copy",
arg,
None)
}
pub fn copy_batch_v2(
client: &impl crate::client_trait::UserAuthClient,
arg: &CopyBatchArg,
) -> crate::Result<Result<RelocationBatchV2Launch, crate::NoError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/copy_batch_v2",
arg,
None)
}
#[deprecated(note = "replaced by copy_batch_v2")]
pub fn copy_batch(
client: &impl crate::client_trait::UserAuthClient,
arg: &RelocationBatchArg,
) -> crate::Result<Result<RelocationBatchLaunch, crate::NoError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/copy_batch",
arg,
None)
}
pub fn copy_batch_check_v2(
client: &impl crate::client_trait::UserAuthClient,
arg: &crate::dbx_async::PollArg,
) -> crate::Result<Result<RelocationBatchV2JobStatus, crate::dbx_async::PollError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/copy_batch/check_v2",
arg,
None)
}
#[deprecated(note = "replaced by copy_batch_check_v2")]
pub fn copy_batch_check(
client: &impl crate::client_trait::UserAuthClient,
arg: &crate::dbx_async::PollArg,
) -> crate::Result<Result<RelocationBatchJobStatus, crate::dbx_async::PollError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/copy_batch/check",
arg,
None)
}
pub fn copy_reference_get(
client: &impl crate::client_trait::UserAuthClient,
arg: &GetCopyReferenceArg,
) -> crate::Result<Result<GetCopyReferenceResult, GetCopyReferenceError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/copy_reference/get",
arg,
None)
}
pub fn copy_reference_save(
client: &impl crate::client_trait::UserAuthClient,
arg: &SaveCopyReferenceArg,
) -> crate::Result<Result<SaveCopyReferenceResult, SaveCopyReferenceError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/copy_reference/save",
arg,
None)
}
pub fn create_folder_v2(
client: &impl crate::client_trait::UserAuthClient,
arg: &CreateFolderArg,
) -> crate::Result<Result<CreateFolderResult, CreateFolderError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/create_folder_v2",
arg,
None)
}
#[deprecated(note = "replaced by create_folder_v2")]
pub fn create_folder(
client: &impl crate::client_trait::UserAuthClient,
arg: &CreateFolderArg,
) -> crate::Result<Result<FolderMetadata, CreateFolderError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/create_folder",
arg,
None)
}
pub fn create_folder_batch(
client: &impl crate::client_trait::UserAuthClient,
arg: &CreateFolderBatchArg,
) -> crate::Result<Result<CreateFolderBatchLaunch, crate::NoError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/create_folder_batch",
arg,
None)
}
pub fn create_folder_batch_check(
client: &impl crate::client_trait::UserAuthClient,
arg: &crate::dbx_async::PollArg,
) -> crate::Result<Result<CreateFolderBatchJobStatus, crate::dbx_async::PollError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/create_folder_batch/check",
arg,
None)
}
pub fn delete_v2(
client: &impl crate::client_trait::UserAuthClient,
arg: &DeleteArg,
) -> crate::Result<Result<DeleteResult, DeleteError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/delete_v2",
arg,
None)
}
#[deprecated(note = "replaced by delete_v2")]
pub fn delete(
client: &impl crate::client_trait::UserAuthClient,
arg: &DeleteArg,
) -> crate::Result<Result<Metadata, DeleteError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/delete",
arg,
None)
}
pub fn delete_batch(
client: &impl crate::client_trait::UserAuthClient,
arg: &DeleteBatchArg,
) -> crate::Result<Result<DeleteBatchLaunch, crate::NoError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/delete_batch",
arg,
None)
}
pub fn delete_batch_check(
client: &impl crate::client_trait::UserAuthClient,
arg: &crate::dbx_async::PollArg,
) -> crate::Result<Result<DeleteBatchJobStatus, crate::dbx_async::PollError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/delete_batch/check",
arg,
None)
}
pub fn download(
client: &impl crate::client_trait::UserAuthClient,
arg: &DownloadArg,
range_start: Option<u64>,
range_end: Option<u64>,
) -> crate::Result<Result<crate::client_trait::HttpRequestResult<FileMetadata>, DownloadError>> {
crate::client_helpers::request_with_body(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Download,
"files/download",
arg,
None,
range_start,
range_end)
}
pub fn download_zip(
client: &impl crate::client_trait::UserAuthClient,
arg: &DownloadZipArg,
range_start: Option<u64>,
range_end: Option<u64>,
) -> crate::Result<Result<crate::client_trait::HttpRequestResult<DownloadZipResult>, DownloadZipError>> {
crate::client_helpers::request_with_body(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Download,
"files/download_zip",
arg,
None,
range_start,
range_end)
}
#[cfg(feature = "unstable")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
pub fn export(
client: &impl crate::client_trait::UserAuthClient,
arg: &ExportArg,
range_start: Option<u64>,
range_end: Option<u64>,
) -> crate::Result<Result<crate::client_trait::HttpRequestResult<ExportResult>, ExportError>> {
crate::client_helpers::request_with_body(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Download,
"files/export",
arg,
None,
range_start,
range_end)
}
pub fn get_file_lock_batch(
client: &impl crate::client_trait::UserAuthClient,
arg: &LockFileBatchArg,
) -> crate::Result<Result<LockFileBatchResult, LockFileError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/get_file_lock_batch",
arg,
None)
}
pub fn get_metadata(
client: &impl crate::client_trait::UserAuthClient,
arg: &GetMetadataArg,
) -> crate::Result<Result<Metadata, GetMetadataError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/get_metadata",
arg,
None)
}
pub fn get_preview(
client: &impl crate::client_trait::UserAuthClient,
arg: &PreviewArg,
range_start: Option<u64>,
range_end: Option<u64>,
) -> crate::Result<Result<crate::client_trait::HttpRequestResult<FileMetadata>, PreviewError>> {
crate::client_helpers::request_with_body(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Download,
"files/get_preview",
arg,
None,
range_start,
range_end)
}
pub fn get_temporary_link(
client: &impl crate::client_trait::UserAuthClient,
arg: &GetTemporaryLinkArg,
) -> crate::Result<Result<GetTemporaryLinkResult, GetTemporaryLinkError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/get_temporary_link",
arg,
None)
}
pub fn get_temporary_upload_link(
client: &impl crate::client_trait::UserAuthClient,
arg: &GetTemporaryUploadLinkArg,
) -> crate::Result<Result<GetTemporaryUploadLinkResult, crate::NoError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/get_temporary_upload_link",
arg,
None)
}
pub fn get_thumbnail(
client: &impl crate::client_trait::UserAuthClient,
arg: &ThumbnailArg,
range_start: Option<u64>,
range_end: Option<u64>,
) -> crate::Result<Result<crate::client_trait::HttpRequestResult<FileMetadata>, ThumbnailError>> {
crate::client_helpers::request_with_body(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Download,
"files/get_thumbnail",
arg,
None,
range_start,
range_end)
}
pub fn get_thumbnail_v2(
client: &impl crate::client_trait::UserAuthClient,
arg: &ThumbnailV2Arg,
range_start: Option<u64>,
range_end: Option<u64>,
) -> crate::Result<Result<crate::client_trait::HttpRequestResult<PreviewResult>, ThumbnailV2Error>> {
crate::client_helpers::request_with_body(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Download,
"files/get_thumbnail_v2",
arg,
None,
range_start,
range_end)
}
pub fn get_thumbnail_v2_app_auth(
client: &impl crate::client_trait::AppAuthClient,
arg: &ThumbnailV2Arg,
range_start: Option<u64>,
range_end: Option<u64>,
) -> crate::Result<Result<crate::client_trait::HttpRequestResult<PreviewResult>, ThumbnailV2Error>> {
crate::client_helpers::request_with_body(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Download,
"files/get_thumbnail_v2",
arg,
None,
range_start,
range_end)
}
pub fn get_thumbnail_batch(
client: &impl crate::client_trait::UserAuthClient,
arg: &GetThumbnailBatchArg,
) -> crate::Result<Result<GetThumbnailBatchResult, GetThumbnailBatchError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Rpc,
"files/get_thumbnail_batch",
arg,
None)
}
pub fn list_folder(
client: &impl crate::client_trait::UserAuthClient,
arg: &ListFolderArg,
) -> crate::Result<Result<ListFolderResult, ListFolderError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/list_folder",
arg,
None)
}
pub fn list_folder_app_auth(
client: &impl crate::client_trait::AppAuthClient,
arg: &ListFolderArg,
) -> crate::Result<Result<ListFolderResult, ListFolderError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/list_folder",
arg,
None)
}
pub fn list_folder_continue(
client: &impl crate::client_trait::UserAuthClient,
arg: &ListFolderContinueArg,
) -> crate::Result<Result<ListFolderResult, ListFolderContinueError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/list_folder/continue",
arg,
None)
}
pub fn list_folder_continue_app_auth(
client: &impl crate::client_trait::AppAuthClient,
arg: &ListFolderContinueArg,
) -> crate::Result<Result<ListFolderResult, ListFolderContinueError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/list_folder/continue",
arg,
None)
}
pub fn list_folder_get_latest_cursor(
client: &impl crate::client_trait::UserAuthClient,
arg: &ListFolderArg,
) -> crate::Result<Result<ListFolderGetLatestCursorResult, ListFolderError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/list_folder/get_latest_cursor",
arg,
None)
}
pub fn list_folder_longpoll(
client: &impl crate::client_trait::NoauthClient,
arg: &ListFolderLongpollArg,
) -> crate::Result<Result<ListFolderLongpollResult, ListFolderLongpollError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Notify,
crate::client_trait::Style::Rpc,
"files/list_folder/longpoll",
arg,
None)
}
pub fn list_revisions(
client: &impl crate::client_trait::UserAuthClient,
arg: &ListRevisionsArg,
) -> crate::Result<Result<ListRevisionsResult, ListRevisionsError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/list_revisions",
arg,
None)
}
pub fn lock_file_batch(
client: &impl crate::client_trait::UserAuthClient,
arg: &LockFileBatchArg,
) -> crate::Result<Result<LockFileBatchResult, LockFileError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/lock_file_batch",
arg,
None)
}
pub fn move_v2(
client: &impl crate::client_trait::UserAuthClient,
arg: &RelocationArg,
) -> crate::Result<Result<RelocationResult, RelocationError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/move_v2",
arg,
None)
}
#[deprecated(note = "replaced by move_v2")]
pub fn do_move(
client: &impl crate::client_trait::UserAuthClient,
arg: &RelocationArg,
) -> crate::Result<Result<Metadata, RelocationError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/move",
arg,
None)
}
pub fn move_batch_v2(
client: &impl crate::client_trait::UserAuthClient,
arg: &MoveBatchArg,
) -> crate::Result<Result<RelocationBatchV2Launch, crate::NoError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/move_batch_v2",
arg,
None)
}
#[deprecated(note = "replaced by move_batch_v2")]
pub fn move_batch(
client: &impl crate::client_trait::UserAuthClient,
arg: &RelocationBatchArg,
) -> crate::Result<Result<RelocationBatchLaunch, crate::NoError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/move_batch",
arg,
None)
}
pub fn move_batch_check_v2(
client: &impl crate::client_trait::UserAuthClient,
arg: &crate::dbx_async::PollArg,
) -> crate::Result<Result<RelocationBatchV2JobStatus, crate::dbx_async::PollError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/move_batch/check_v2",
arg,
None)
}
#[deprecated(note = "replaced by move_batch_check_v2")]
pub fn move_batch_check(
client: &impl crate::client_trait::UserAuthClient,
arg: &crate::dbx_async::PollArg,
) -> crate::Result<Result<RelocationBatchJobStatus, crate::dbx_async::PollError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/move_batch/check",
arg,
None)
}
#[cfg(feature = "unstable")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
pub fn paper_create(
client: &impl crate::client_trait::UserAuthClient,
arg: &PaperCreateArg,
body: &[u8],
) -> crate::Result<Result<PaperCreateResult, PaperCreateError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Upload,
"files/paper/create",
arg,
Some(body))
}
#[cfg(feature = "unstable")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
pub fn paper_update(
client: &impl crate::client_trait::UserAuthClient,
arg: &PaperUpdateArg,
body: &[u8],
) -> crate::Result<Result<PaperUpdateResult, PaperUpdateError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Upload,
"files/paper/update",
arg,
Some(body))
}
pub fn permanently_delete(
client: &impl crate::client_trait::UserAuthClient,
arg: &DeleteArg,
) -> crate::Result<Result<(), DeleteError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/permanently_delete",
arg,
None)
}
#[deprecated]
pub fn properties_add(
client: &impl crate::client_trait::UserAuthClient,
arg: &crate::file_properties::AddPropertiesArg,
) -> crate::Result<Result<(), crate::file_properties::AddPropertiesError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/properties/add",
arg,
None)
}
#[deprecated]
pub fn properties_overwrite(
client: &impl crate::client_trait::UserAuthClient,
arg: &crate::file_properties::OverwritePropertyGroupArg,
) -> crate::Result<Result<(), crate::file_properties::InvalidPropertyGroupError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/properties/overwrite",
arg,
None)
}
#[deprecated]
pub fn properties_remove(
client: &impl crate::client_trait::UserAuthClient,
arg: &crate::file_properties::RemovePropertiesArg,
) -> crate::Result<Result<(), crate::file_properties::RemovePropertiesError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/properties/remove",
arg,
None)
}
#[deprecated]
pub fn properties_template_get(
client: &impl crate::client_trait::UserAuthClient,
arg: &crate::file_properties::GetTemplateArg,
) -> crate::Result<Result<crate::file_properties::GetTemplateResult, crate::file_properties::TemplateError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/properties/template/get",
arg,
None)
}
#[deprecated]
pub fn properties_template_list(
client: &impl crate::client_trait::UserAuthClient,
) -> crate::Result<Result<crate::file_properties::ListTemplateResult, crate::file_properties::TemplateError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/properties/template/list",
&(),
None)
}
#[deprecated]
pub fn properties_update(
client: &impl crate::client_trait::UserAuthClient,
arg: &crate::file_properties::UpdatePropertiesArg,
) -> crate::Result<Result<(), crate::file_properties::UpdatePropertiesError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/properties/update",
arg,
None)
}
pub fn restore(
client: &impl crate::client_trait::UserAuthClient,
arg: &RestoreArg,
) -> crate::Result<Result<FileMetadata, RestoreError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/restore",
arg,
None)
}
pub fn save_url(
client: &impl crate::client_trait::UserAuthClient,
arg: &SaveUrlArg,
) -> crate::Result<Result<SaveUrlResult, SaveUrlError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/save_url",
arg,
None)
}
pub fn save_url_check_job_status(
client: &impl crate::client_trait::UserAuthClient,
arg: &crate::dbx_async::PollArg,
) -> crate::Result<Result<SaveUrlJobStatus, crate::dbx_async::PollError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/save_url/check_job_status",
arg,
None)
}
#[deprecated(note = "replaced by search_v2")]
pub fn search(
client: &impl crate::client_trait::UserAuthClient,
arg: &SearchArg,
) -> crate::Result<Result<SearchResult, SearchError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/search",
arg,
None)
}
pub fn search_v2(
client: &impl crate::client_trait::UserAuthClient,
arg: &SearchV2Arg,
) -> crate::Result<Result<SearchV2Result, SearchError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/search_v2",
arg,
None)
}
pub fn search_continue_v2(
client: &impl crate::client_trait::UserAuthClient,
arg: &SearchV2ContinueArg,
) -> crate::Result<Result<SearchV2Result, SearchError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/search/continue_v2",
arg,
None)
}
#[cfg(feature = "unstable")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
pub fn tags_add(
client: &impl crate::client_trait::UserAuthClient,
arg: &AddTagArg,
) -> crate::Result<Result<(), AddTagError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/tags/add",
arg,
None)
}
#[cfg(feature = "unstable")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
pub fn tags_get(
client: &impl crate::client_trait::UserAuthClient,
arg: &GetTagsArg,
) -> crate::Result<Result<GetTagsResult, BaseTagError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/tags/get",
arg,
None)
}
#[cfg(feature = "unstable")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable")))]
pub fn tags_remove(
client: &impl crate::client_trait::UserAuthClient,
arg: &RemoveTagArg,
) -> crate::Result<Result<(), RemoveTagError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/tags/remove",
arg,
None)
}
pub fn unlock_file_batch(
client: &impl crate::client_trait::UserAuthClient,
arg: &UnlockFileBatchArg,
) -> crate::Result<Result<LockFileBatchResult, LockFileError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/unlock_file_batch",
arg,
None)
}
pub fn upload(
client: &impl crate::client_trait::UserAuthClient,
arg: &UploadArg,
body: &[u8],
) -> crate::Result<Result<FileMetadata, UploadError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Upload,
"files/upload",
arg,
Some(body))
}
pub fn upload_session_append_v2(
client: &impl crate::client_trait::UserAuthClient,
arg: &UploadSessionAppendArg,
body: &[u8],
) -> crate::Result<Result<(), UploadSessionAppendError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Upload,
"files/upload_session/append_v2",
arg,
Some(body))
}
#[deprecated(note = "replaced by upload_session_append_v2")]
pub fn upload_session_append(
client: &impl crate::client_trait::UserAuthClient,
arg: &UploadSessionCursor,
body: &[u8],
) -> crate::Result<Result<(), UploadSessionAppendError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Upload,
"files/upload_session/append",
arg,
Some(body))
}
pub fn upload_session_finish(
client: &impl crate::client_trait::UserAuthClient,
arg: &UploadSessionFinishArg,
body: &[u8],
) -> crate::Result<Result<FileMetadata, UploadSessionFinishError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Upload,
"files/upload_session/finish",
arg,
Some(body))
}
#[deprecated(note = "replaced by upload_session_finish_batch_v2")]
pub fn upload_session_finish_batch(
client: &impl crate::client_trait::UserAuthClient,
arg: &UploadSessionFinishBatchArg,
) -> crate::Result<Result<UploadSessionFinishBatchLaunch, crate::NoError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/upload_session/finish_batch",
arg,
None)
}
pub fn upload_session_finish_batch_v2(
client: &impl crate::client_trait::UserAuthClient,
arg: &UploadSessionFinishBatchArg,
) -> crate::Result<Result<UploadSessionFinishBatchResult, crate::NoError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/upload_session/finish_batch_v2",
arg,
None)
}
pub fn upload_session_finish_batch_check(
client: &impl crate::client_trait::UserAuthClient,
arg: &crate::dbx_async::PollArg,
) -> crate::Result<Result<UploadSessionFinishBatchJobStatus, crate::dbx_async::PollError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/upload_session/finish_batch/check",
arg,
None)
}
pub fn upload_session_start(
client: &impl crate::client_trait::UserAuthClient,
arg: &UploadSessionStartArg,
body: &[u8],
) -> crate::Result<Result<UploadSessionStartResult, UploadSessionStartError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Content,
crate::client_trait::Style::Upload,
"files/upload_session/start",
arg,
Some(body))
}
pub fn upload_session_start_batch(
client: &impl crate::client_trait::UserAuthClient,
arg: &UploadSessionStartBatchArg,
) -> crate::Result<Result<UploadSessionStartBatchResult, crate::NoError>> {
crate::client_helpers::request(
client,
crate::client_trait::Endpoint::Api,
crate::client_trait::Style::Rpc,
"files/upload_session/start_batch",
arg,
None)
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct AddTagArg {
pub path: Path,
pub tag_text: TagText,
}
impl AddTagArg {
pub fn new(path: Path, tag_text: TagText) -> Self {
AddTagArg {
path,
tag_text,
}
}
}
const ADD_TAG_ARG_FIELDS: &[&str] = &["path",
"tag_text"];
impl AddTagArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<AddTagArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<AddTagArg>, V::Error> {
let mut field_path = None;
let mut field_tag_text = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"tag_text" => {
if field_tag_text.is_some() {
return Err(::serde::de::Error::duplicate_field("tag_text"));
}
field_tag_text = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = AddTagArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
tag_text: field_tag_text.ok_or_else(|| ::serde::de::Error::missing_field("tag_text"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("tag_text", &self.tag_text)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for AddTagArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = AddTagArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a AddTagArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
AddTagArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("AddTagArg", ADD_TAG_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for AddTagArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("AddTagArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum AddTagError {
Path(LookupError),
TooManyTags,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for AddTagError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = AddTagError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a AddTagError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => AddTagError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"too_many_tags" => AddTagError::TooManyTags,
_ => AddTagError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"other",
"too_many_tags"];
deserializer.deserialize_struct("AddTagError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for AddTagError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
AddTagError::Path(ref x) => {
let mut s = serializer.serialize_struct("AddTagError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
AddTagError::TooManyTags => {
let mut s = serializer.serialize_struct("AddTagError", 1)?;
s.serialize_field(".tag", "too_many_tags")?;
s.end()
}
AddTagError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for AddTagError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
AddTagError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for AddTagError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
AddTagError::Path(inner) => write!(f, "{}", inner),
AddTagError::TooManyTags => f.write_str("The item already has the maximum supported number of tags."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct AlphaGetMetadataArg {
pub path: ReadPath,
pub include_media_info: bool,
pub include_deleted: bool,
pub include_has_explicit_shared_members: bool,
pub include_property_groups: Option<crate::file_properties::TemplateFilterBase>,
pub include_property_templates: Option<Vec<crate::file_properties::TemplateId>>,
}
impl AlphaGetMetadataArg {
pub fn new(path: ReadPath) -> Self {
AlphaGetMetadataArg {
path,
include_media_info: false,
include_deleted: false,
include_has_explicit_shared_members: false,
include_property_groups: None,
include_property_templates: None,
}
}
pub fn with_include_media_info(mut self, value: bool) -> Self {
self.include_media_info = value;
self
}
pub fn with_include_deleted(mut self, value: bool) -> Self {
self.include_deleted = value;
self
}
pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
self.include_has_explicit_shared_members = value;
self
}
pub fn with_include_property_groups(
mut self,
value: crate::file_properties::TemplateFilterBase,
) -> Self {
self.include_property_groups = Some(value);
self
}
pub fn with_include_property_templates(
mut self,
value: Vec<crate::file_properties::TemplateId>,
) -> Self {
self.include_property_templates = Some(value);
self
}
}
const ALPHA_GET_METADATA_ARG_FIELDS: &[&str] = &["path",
"include_media_info",
"include_deleted",
"include_has_explicit_shared_members",
"include_property_groups",
"include_property_templates"];
impl AlphaGetMetadataArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<AlphaGetMetadataArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<AlphaGetMetadataArg>, V::Error> {
let mut field_path = None;
let mut field_include_media_info = None;
let mut field_include_deleted = None;
let mut field_include_has_explicit_shared_members = None;
let mut field_include_property_groups = None;
let mut field_include_property_templates = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"include_media_info" => {
if field_include_media_info.is_some() {
return Err(::serde::de::Error::duplicate_field("include_media_info"));
}
field_include_media_info = Some(map.next_value()?);
}
"include_deleted" => {
if field_include_deleted.is_some() {
return Err(::serde::de::Error::duplicate_field("include_deleted"));
}
field_include_deleted = Some(map.next_value()?);
}
"include_has_explicit_shared_members" => {
if field_include_has_explicit_shared_members.is_some() {
return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
}
field_include_has_explicit_shared_members = Some(map.next_value()?);
}
"include_property_groups" => {
if field_include_property_groups.is_some() {
return Err(::serde::de::Error::duplicate_field("include_property_groups"));
}
field_include_property_groups = Some(map.next_value()?);
}
"include_property_templates" => {
if field_include_property_templates.is_some() {
return Err(::serde::de::Error::duplicate_field("include_property_templates"));
}
field_include_property_templates = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = AlphaGetMetadataArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
include_media_info: field_include_media_info.unwrap_or(false),
include_deleted: field_include_deleted.unwrap_or(false),
include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
include_property_groups: field_include_property_groups,
include_property_templates: field_include_property_templates,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("include_media_info", &self.include_media_info)?;
s.serialize_field("include_deleted", &self.include_deleted)?;
s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
if let Some(val) = &self.include_property_groups {
s.serialize_field("include_property_groups", val)?;
}
if let Some(val) = &self.include_property_templates {
s.serialize_field("include_property_templates", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for AlphaGetMetadataArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = AlphaGetMetadataArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a AlphaGetMetadataArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
AlphaGetMetadataArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("AlphaGetMetadataArg", ALPHA_GET_METADATA_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for AlphaGetMetadataArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("AlphaGetMetadataArg", 6)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AlphaGetMetadataError {
Path(LookupError),
PropertiesError(crate::file_properties::LookUpPropertiesError),
}
impl<'de> ::serde::de::Deserialize<'de> for AlphaGetMetadataError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = AlphaGetMetadataError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a AlphaGetMetadataError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => AlphaGetMetadataError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"properties_error" => {
match map.next_key()? {
Some("properties_error") => AlphaGetMetadataError::PropertiesError(map.next_value()?),
None => return Err(de::Error::missing_field("properties_error")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"properties_error"];
deserializer.deserialize_struct("AlphaGetMetadataError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for AlphaGetMetadataError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
AlphaGetMetadataError::Path(ref x) => {
let mut s = serializer.serialize_struct("AlphaGetMetadataError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
AlphaGetMetadataError::PropertiesError(ref x) => {
let mut s = serializer.serialize_struct("AlphaGetMetadataError", 2)?;
s.serialize_field(".tag", "properties_error")?;
s.serialize_field("properties_error", x)?;
s.end()
}
}
}
}
impl ::std::error::Error for AlphaGetMetadataError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
AlphaGetMetadataError::Path(inner) => Some(inner),
AlphaGetMetadataError::PropertiesError(inner) => Some(inner),
}
}
}
impl ::std::fmt::Display for AlphaGetMetadataError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
AlphaGetMetadataError::Path(inner) => write!(f, "{}", inner),
AlphaGetMetadataError::PropertiesError(inner) => write!(f, "{}", inner),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum BaseTagError {
Path(LookupError),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for BaseTagError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = BaseTagError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a BaseTagError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => BaseTagError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => BaseTagError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"other"];
deserializer.deserialize_struct("BaseTagError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for BaseTagError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
BaseTagError::Path(ref x) => {
let mut s = serializer.serialize_struct("BaseTagError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
BaseTagError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for BaseTagError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
BaseTagError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for BaseTagError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
BaseTagError::Path(inner) => write!(f, "{}", inner),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct CommitInfo {
pub path: WritePathOrId,
pub mode: WriteMode,
pub autorename: bool,
pub client_modified: Option<crate::common::DropboxTimestamp>,
pub mute: bool,
pub property_groups: Option<Vec<crate::file_properties::PropertyGroup>>,
pub strict_conflict: bool,
}
impl CommitInfo {
pub fn new(path: WritePathOrId) -> Self {
CommitInfo {
path,
mode: WriteMode::Add,
autorename: false,
client_modified: None,
mute: false,
property_groups: None,
strict_conflict: false,
}
}
pub fn with_mode(mut self, value: WriteMode) -> Self {
self.mode = value;
self
}
pub fn with_autorename(mut self, value: bool) -> Self {
self.autorename = value;
self
}
pub fn with_client_modified(mut self, value: crate::common::DropboxTimestamp) -> Self {
self.client_modified = Some(value);
self
}
pub fn with_mute(mut self, value: bool) -> Self {
self.mute = value;
self
}
pub fn with_property_groups(
mut self,
value: Vec<crate::file_properties::PropertyGroup>,
) -> Self {
self.property_groups = Some(value);
self
}
pub fn with_strict_conflict(mut self, value: bool) -> Self {
self.strict_conflict = value;
self
}
}
const COMMIT_INFO_FIELDS: &[&str] = &["path",
"mode",
"autorename",
"client_modified",
"mute",
"property_groups",
"strict_conflict"];
impl CommitInfo {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<CommitInfo, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<CommitInfo>, V::Error> {
let mut field_path = None;
let mut field_mode = None;
let mut field_autorename = None;
let mut field_client_modified = None;
let mut field_mute = None;
let mut field_property_groups = None;
let mut field_strict_conflict = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"mode" => {
if field_mode.is_some() {
return Err(::serde::de::Error::duplicate_field("mode"));
}
field_mode = Some(map.next_value()?);
}
"autorename" => {
if field_autorename.is_some() {
return Err(::serde::de::Error::duplicate_field("autorename"));
}
field_autorename = Some(map.next_value()?);
}
"client_modified" => {
if field_client_modified.is_some() {
return Err(::serde::de::Error::duplicate_field("client_modified"));
}
field_client_modified = Some(map.next_value()?);
}
"mute" => {
if field_mute.is_some() {
return Err(::serde::de::Error::duplicate_field("mute"));
}
field_mute = Some(map.next_value()?);
}
"property_groups" => {
if field_property_groups.is_some() {
return Err(::serde::de::Error::duplicate_field("property_groups"));
}
field_property_groups = Some(map.next_value()?);
}
"strict_conflict" => {
if field_strict_conflict.is_some() {
return Err(::serde::de::Error::duplicate_field("strict_conflict"));
}
field_strict_conflict = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = CommitInfo {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
mode: field_mode.unwrap_or(WriteMode::Add),
autorename: field_autorename.unwrap_or(false),
client_modified: field_client_modified,
mute: field_mute.unwrap_or(false),
property_groups: field_property_groups,
strict_conflict: field_strict_conflict.unwrap_or(false),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("mode", &self.mode)?;
s.serialize_field("autorename", &self.autorename)?;
if let Some(val) = &self.client_modified {
s.serialize_field("client_modified", val)?;
}
s.serialize_field("mute", &self.mute)?;
if let Some(val) = &self.property_groups {
s.serialize_field("property_groups", val)?;
}
s.serialize_field("strict_conflict", &self.strict_conflict)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for CommitInfo {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = CommitInfo;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a CommitInfo struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
CommitInfo::internal_deserialize(map)
}
}
deserializer.deserialize_struct("CommitInfo", COMMIT_INFO_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for CommitInfo {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("CommitInfo", 7)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct ContentSyncSetting {
pub id: FileId,
pub sync_setting: SyncSetting,
}
impl ContentSyncSetting {
pub fn new(id: FileId, sync_setting: SyncSetting) -> Self {
ContentSyncSetting {
id,
sync_setting,
}
}
}
const CONTENT_SYNC_SETTING_FIELDS: &[&str] = &["id",
"sync_setting"];
impl ContentSyncSetting {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ContentSyncSetting, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ContentSyncSetting>, V::Error> {
let mut field_id = None;
let mut field_sync_setting = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"id" => {
if field_id.is_some() {
return Err(::serde::de::Error::duplicate_field("id"));
}
field_id = Some(map.next_value()?);
}
"sync_setting" => {
if field_sync_setting.is_some() {
return Err(::serde::de::Error::duplicate_field("sync_setting"));
}
field_sync_setting = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ContentSyncSetting {
id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
sync_setting: field_sync_setting.ok_or_else(|| ::serde::de::Error::missing_field("sync_setting"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("id", &self.id)?;
s.serialize_field("sync_setting", &self.sync_setting)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ContentSyncSetting {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ContentSyncSetting;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ContentSyncSetting struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ContentSyncSetting::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ContentSyncSetting", CONTENT_SYNC_SETTING_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ContentSyncSetting {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ContentSyncSetting", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct ContentSyncSettingArg {
pub id: FileId,
pub sync_setting: SyncSettingArg,
}
impl ContentSyncSettingArg {
pub fn new(id: FileId, sync_setting: SyncSettingArg) -> Self {
ContentSyncSettingArg {
id,
sync_setting,
}
}
}
const CONTENT_SYNC_SETTING_ARG_FIELDS: &[&str] = &["id",
"sync_setting"];
impl ContentSyncSettingArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ContentSyncSettingArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ContentSyncSettingArg>, V::Error> {
let mut field_id = None;
let mut field_sync_setting = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"id" => {
if field_id.is_some() {
return Err(::serde::de::Error::duplicate_field("id"));
}
field_id = Some(map.next_value()?);
}
"sync_setting" => {
if field_sync_setting.is_some() {
return Err(::serde::de::Error::duplicate_field("sync_setting"));
}
field_sync_setting = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ContentSyncSettingArg {
id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
sync_setting: field_sync_setting.ok_or_else(|| ::serde::de::Error::missing_field("sync_setting"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("id", &self.id)?;
s.serialize_field("sync_setting", &self.sync_setting)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ContentSyncSettingArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ContentSyncSettingArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ContentSyncSettingArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ContentSyncSettingArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ContentSyncSettingArg", CONTENT_SYNC_SETTING_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ContentSyncSettingArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ContentSyncSettingArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct CreateFolderArg {
pub path: WritePath,
pub autorename: bool,
}
impl CreateFolderArg {
pub fn new(path: WritePath) -> Self {
CreateFolderArg {
path,
autorename: false,
}
}
pub fn with_autorename(mut self, value: bool) -> Self {
self.autorename = value;
self
}
}
const CREATE_FOLDER_ARG_FIELDS: &[&str] = &["path",
"autorename"];
impl CreateFolderArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<CreateFolderArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<CreateFolderArg>, V::Error> {
let mut field_path = None;
let mut field_autorename = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"autorename" => {
if field_autorename.is_some() {
return Err(::serde::de::Error::duplicate_field("autorename"));
}
field_autorename = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = CreateFolderArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
autorename: field_autorename.unwrap_or(false),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("autorename", &self.autorename)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for CreateFolderArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = CreateFolderArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a CreateFolderArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
CreateFolderArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("CreateFolderArg", CREATE_FOLDER_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for CreateFolderArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("CreateFolderArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct CreateFolderBatchArg {
pub paths: Vec<WritePath>,
pub autorename: bool,
pub force_async: bool,
}
impl CreateFolderBatchArg {
pub fn new(paths: Vec<WritePath>) -> Self {
CreateFolderBatchArg {
paths,
autorename: false,
force_async: false,
}
}
pub fn with_autorename(mut self, value: bool) -> Self {
self.autorename = value;
self
}
pub fn with_force_async(mut self, value: bool) -> Self {
self.force_async = value;
self
}
}
const CREATE_FOLDER_BATCH_ARG_FIELDS: &[&str] = &["paths",
"autorename",
"force_async"];
impl CreateFolderBatchArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<CreateFolderBatchArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<CreateFolderBatchArg>, V::Error> {
let mut field_paths = None;
let mut field_autorename = None;
let mut field_force_async = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"paths" => {
if field_paths.is_some() {
return Err(::serde::de::Error::duplicate_field("paths"));
}
field_paths = Some(map.next_value()?);
}
"autorename" => {
if field_autorename.is_some() {
return Err(::serde::de::Error::duplicate_field("autorename"));
}
field_autorename = Some(map.next_value()?);
}
"force_async" => {
if field_force_async.is_some() {
return Err(::serde::de::Error::duplicate_field("force_async"));
}
field_force_async = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = CreateFolderBatchArg {
paths: field_paths.ok_or_else(|| ::serde::de::Error::missing_field("paths"))?,
autorename: field_autorename.unwrap_or(false),
force_async: field_force_async.unwrap_or(false),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("paths", &self.paths)?;
s.serialize_field("autorename", &self.autorename)?;
s.serialize_field("force_async", &self.force_async)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = CreateFolderBatchArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a CreateFolderBatchArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
CreateFolderBatchArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("CreateFolderBatchArg", CREATE_FOLDER_BATCH_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for CreateFolderBatchArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("CreateFolderBatchArg", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum CreateFolderBatchError {
TooManyFiles,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = CreateFolderBatchError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a CreateFolderBatchError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"too_many_files" => CreateFolderBatchError::TooManyFiles,
_ => CreateFolderBatchError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["too_many_files",
"other"];
deserializer.deserialize_struct("CreateFolderBatchError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for CreateFolderBatchError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
CreateFolderBatchError::TooManyFiles => {
let mut s = serializer.serialize_struct("CreateFolderBatchError", 1)?;
s.serialize_field(".tag", "too_many_files")?;
s.end()
}
CreateFolderBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for CreateFolderBatchError {
}
impl ::std::fmt::Display for CreateFolderBatchError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
CreateFolderBatchError::TooManyFiles => f.write_str("The operation would involve too many files or folders."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum CreateFolderBatchJobStatus {
InProgress,
Complete(CreateFolderBatchResult),
Failed(CreateFolderBatchError),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchJobStatus {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = CreateFolderBatchJobStatus;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a CreateFolderBatchJobStatus structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"in_progress" => CreateFolderBatchJobStatus::InProgress,
"complete" => CreateFolderBatchJobStatus::Complete(CreateFolderBatchResult::internal_deserialize(&mut map)?),
"failed" => {
match map.next_key()? {
Some("failed") => CreateFolderBatchJobStatus::Failed(map.next_value()?),
None => return Err(de::Error::missing_field("failed")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => CreateFolderBatchJobStatus::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["in_progress",
"complete",
"failed",
"other"];
deserializer.deserialize_struct("CreateFolderBatchJobStatus", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for CreateFolderBatchJobStatus {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
CreateFolderBatchJobStatus::InProgress => {
let mut s = serializer.serialize_struct("CreateFolderBatchJobStatus", 1)?;
s.serialize_field(".tag", "in_progress")?;
s.end()
}
CreateFolderBatchJobStatus::Complete(ref x) => {
let mut s = serializer.serialize_struct("CreateFolderBatchJobStatus", 2)?;
s.serialize_field(".tag", "complete")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
CreateFolderBatchJobStatus::Failed(ref x) => {
let mut s = serializer.serialize_struct("CreateFolderBatchJobStatus", 2)?;
s.serialize_field(".tag", "failed")?;
s.serialize_field("failed", x)?;
s.end()
}
CreateFolderBatchJobStatus::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum CreateFolderBatchLaunch {
AsyncJobId(crate::dbx_async::AsyncJobId),
Complete(CreateFolderBatchResult),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchLaunch {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = CreateFolderBatchLaunch;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a CreateFolderBatchLaunch structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"async_job_id" => {
match map.next_key()? {
Some("async_job_id") => CreateFolderBatchLaunch::AsyncJobId(map.next_value()?),
None => return Err(de::Error::missing_field("async_job_id")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"complete" => CreateFolderBatchLaunch::Complete(CreateFolderBatchResult::internal_deserialize(&mut map)?),
_ => CreateFolderBatchLaunch::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["async_job_id",
"complete",
"other"];
deserializer.deserialize_struct("CreateFolderBatchLaunch", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for CreateFolderBatchLaunch {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
CreateFolderBatchLaunch::AsyncJobId(ref x) => {
let mut s = serializer.serialize_struct("CreateFolderBatchLaunch", 2)?;
s.serialize_field(".tag", "async_job_id")?;
s.serialize_field("async_job_id", x)?;
s.end()
}
CreateFolderBatchLaunch::Complete(ref x) => {
let mut s = serializer.serialize_struct("CreateFolderBatchLaunch", 2)?;
s.serialize_field(".tag", "complete")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
CreateFolderBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct CreateFolderBatchResult {
pub entries: Vec<CreateFolderBatchResultEntry>,
}
impl CreateFolderBatchResult {
pub fn new(entries: Vec<CreateFolderBatchResultEntry>) -> Self {
CreateFolderBatchResult {
entries,
}
}
}
const CREATE_FOLDER_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
impl CreateFolderBatchResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<CreateFolderBatchResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<CreateFolderBatchResult>, V::Error> {
let mut field_entries = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = CreateFolderBatchResult {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = CreateFolderBatchResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a CreateFolderBatchResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
CreateFolderBatchResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("CreateFolderBatchResult", CREATE_FOLDER_BATCH_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for CreateFolderBatchResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("CreateFolderBatchResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CreateFolderBatchResultEntry {
Success(CreateFolderEntryResult),
Failure(CreateFolderEntryError),
}
impl<'de> ::serde::de::Deserialize<'de> for CreateFolderBatchResultEntry {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = CreateFolderBatchResultEntry;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a CreateFolderBatchResultEntry structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"success" => CreateFolderBatchResultEntry::Success(CreateFolderEntryResult::internal_deserialize(&mut map)?),
"failure" => {
match map.next_key()? {
Some("failure") => CreateFolderBatchResultEntry::Failure(map.next_value()?),
None => return Err(de::Error::missing_field("failure")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["success",
"failure"];
deserializer.deserialize_struct("CreateFolderBatchResultEntry", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for CreateFolderBatchResultEntry {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
CreateFolderBatchResultEntry::Success(ref x) => {
let mut s = serializer.serialize_struct("CreateFolderBatchResultEntry", 2)?;
s.serialize_field(".tag", "success")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
CreateFolderBatchResultEntry::Failure(ref x) => {
let mut s = serializer.serialize_struct("CreateFolderBatchResultEntry", 2)?;
s.serialize_field(".tag", "failure")?;
s.serialize_field("failure", x)?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum CreateFolderEntryError {
Path(WriteError),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for CreateFolderEntryError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = CreateFolderEntryError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a CreateFolderEntryError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => CreateFolderEntryError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => CreateFolderEntryError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"other"];
deserializer.deserialize_struct("CreateFolderEntryError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for CreateFolderEntryError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
CreateFolderEntryError::Path(ref x) => {
let mut s = serializer.serialize_struct("CreateFolderEntryError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
CreateFolderEntryError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for CreateFolderEntryError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
CreateFolderEntryError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for CreateFolderEntryError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
CreateFolderEntryError::Path(inner) => write!(f, "{}", inner),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct CreateFolderEntryResult {
pub metadata: FolderMetadata,
}
impl CreateFolderEntryResult {
pub fn new(metadata: FolderMetadata) -> Self {
CreateFolderEntryResult {
metadata,
}
}
}
const CREATE_FOLDER_ENTRY_RESULT_FIELDS: &[&str] = &["metadata"];
impl CreateFolderEntryResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<CreateFolderEntryResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<CreateFolderEntryResult>, V::Error> {
let mut field_metadata = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = CreateFolderEntryResult {
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("metadata", &self.metadata)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for CreateFolderEntryResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = CreateFolderEntryResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a CreateFolderEntryResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
CreateFolderEntryResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("CreateFolderEntryResult", CREATE_FOLDER_ENTRY_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for CreateFolderEntryResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("CreateFolderEntryResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CreateFolderError {
Path(WriteError),
}
impl<'de> ::serde::de::Deserialize<'de> for CreateFolderError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = CreateFolderError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a CreateFolderError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => CreateFolderError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path"];
deserializer.deserialize_struct("CreateFolderError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for CreateFolderError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
CreateFolderError::Path(ref x) => {
let mut s = serializer.serialize_struct("CreateFolderError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
}
}
}
impl ::std::error::Error for CreateFolderError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
CreateFolderError::Path(inner) => Some(inner),
}
}
}
impl ::std::fmt::Display for CreateFolderError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
CreateFolderError::Path(inner) => write!(f, "{}", inner),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct CreateFolderResult {
pub metadata: FolderMetadata,
}
impl CreateFolderResult {
pub fn new(metadata: FolderMetadata) -> Self {
CreateFolderResult {
metadata,
}
}
}
const CREATE_FOLDER_RESULT_FIELDS: &[&str] = &["metadata"];
impl CreateFolderResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<CreateFolderResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<CreateFolderResult>, V::Error> {
let mut field_metadata = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = CreateFolderResult {
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("metadata", &self.metadata)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for CreateFolderResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = CreateFolderResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a CreateFolderResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
CreateFolderResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("CreateFolderResult", CREATE_FOLDER_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for CreateFolderResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("CreateFolderResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct DeleteArg {
pub path: WritePathOrId,
pub parent_rev: Option<Rev>,
}
impl DeleteArg {
pub fn new(path: WritePathOrId) -> Self {
DeleteArg {
path,
parent_rev: None,
}
}
pub fn with_parent_rev(mut self, value: Rev) -> Self {
self.parent_rev = Some(value);
self
}
}
const DELETE_ARG_FIELDS: &[&str] = &["path",
"parent_rev"];
impl DeleteArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<DeleteArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<DeleteArg>, V::Error> {
let mut field_path = None;
let mut field_parent_rev = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"parent_rev" => {
if field_parent_rev.is_some() {
return Err(::serde::de::Error::duplicate_field("parent_rev"));
}
field_parent_rev = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = DeleteArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
parent_rev: field_parent_rev,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
if let Some(val) = &self.parent_rev {
s.serialize_field("parent_rev", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for DeleteArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = DeleteArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DeleteArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
DeleteArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("DeleteArg", DELETE_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for DeleteArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("DeleteArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct DeleteBatchArg {
pub entries: Vec<DeleteArg>,
}
impl DeleteBatchArg {
pub fn new(entries: Vec<DeleteArg>) -> Self {
DeleteBatchArg {
entries,
}
}
}
const DELETE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
impl DeleteBatchArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<DeleteBatchArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<DeleteBatchArg>, V::Error> {
let mut field_entries = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = DeleteBatchArg {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = DeleteBatchArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DeleteBatchArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
DeleteBatchArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("DeleteBatchArg", DELETE_BATCH_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for DeleteBatchArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("DeleteBatchArg", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum DeleteBatchError {
TooManyWriteOperations,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = DeleteBatchError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DeleteBatchError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"too_many_write_operations" => DeleteBatchError::TooManyWriteOperations,
_ => DeleteBatchError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["too_many_write_operations",
"other"];
deserializer.deserialize_struct("DeleteBatchError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for DeleteBatchError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
DeleteBatchError::TooManyWriteOperations => {
let mut s = serializer.serialize_struct("DeleteBatchError", 1)?;
s.serialize_field(".tag", "too_many_write_operations")?;
s.end()
}
DeleteBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for DeleteBatchError {
}
impl ::std::fmt::Display for DeleteBatchError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(f, "{:?}", *self)
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub enum DeleteBatchJobStatus {
InProgress,
Complete(DeleteBatchResult),
Failed(DeleteBatchError),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchJobStatus {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = DeleteBatchJobStatus;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DeleteBatchJobStatus structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"in_progress" => DeleteBatchJobStatus::InProgress,
"complete" => DeleteBatchJobStatus::Complete(DeleteBatchResult::internal_deserialize(&mut map)?),
"failed" => {
match map.next_key()? {
Some("failed") => DeleteBatchJobStatus::Failed(map.next_value()?),
None => return Err(de::Error::missing_field("failed")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => DeleteBatchJobStatus::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["in_progress",
"complete",
"failed",
"other"];
deserializer.deserialize_struct("DeleteBatchJobStatus", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for DeleteBatchJobStatus {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
DeleteBatchJobStatus::InProgress => {
let mut s = serializer.serialize_struct("DeleteBatchJobStatus", 1)?;
s.serialize_field(".tag", "in_progress")?;
s.end()
}
DeleteBatchJobStatus::Complete(ref x) => {
let mut s = serializer.serialize_struct("DeleteBatchJobStatus", 2)?;
s.serialize_field(".tag", "complete")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
DeleteBatchJobStatus::Failed(ref x) => {
let mut s = serializer.serialize_struct("DeleteBatchJobStatus", 2)?;
s.serialize_field(".tag", "failed")?;
s.serialize_field("failed", x)?;
s.end()
}
DeleteBatchJobStatus::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub enum DeleteBatchLaunch {
AsyncJobId(crate::dbx_async::AsyncJobId),
Complete(DeleteBatchResult),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchLaunch {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = DeleteBatchLaunch;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DeleteBatchLaunch structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"async_job_id" => {
match map.next_key()? {
Some("async_job_id") => DeleteBatchLaunch::AsyncJobId(map.next_value()?),
None => return Err(de::Error::missing_field("async_job_id")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"complete" => DeleteBatchLaunch::Complete(DeleteBatchResult::internal_deserialize(&mut map)?),
_ => DeleteBatchLaunch::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["async_job_id",
"complete",
"other"];
deserializer.deserialize_struct("DeleteBatchLaunch", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for DeleteBatchLaunch {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
DeleteBatchLaunch::AsyncJobId(ref x) => {
let mut s = serializer.serialize_struct("DeleteBatchLaunch", 2)?;
s.serialize_field(".tag", "async_job_id")?;
s.serialize_field("async_job_id", x)?;
s.end()
}
DeleteBatchLaunch::Complete(ref x) => {
let mut s = serializer.serialize_struct("DeleteBatchLaunch", 2)?;
s.serialize_field(".tag", "complete")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
DeleteBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct DeleteBatchResult {
pub entries: Vec<DeleteBatchResultEntry>,
}
impl DeleteBatchResult {
pub fn new(entries: Vec<DeleteBatchResultEntry>) -> Self {
DeleteBatchResult {
entries,
}
}
}
const DELETE_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
impl DeleteBatchResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<DeleteBatchResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<DeleteBatchResult>, V::Error> {
let mut field_entries = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = DeleteBatchResult {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = DeleteBatchResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DeleteBatchResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
DeleteBatchResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("DeleteBatchResult", DELETE_BATCH_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for DeleteBatchResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("DeleteBatchResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct DeleteBatchResultData {
pub metadata: Metadata,
}
impl DeleteBatchResultData {
pub fn new(metadata: Metadata) -> Self {
DeleteBatchResultData {
metadata,
}
}
}
const DELETE_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata"];
impl DeleteBatchResultData {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<DeleteBatchResultData, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<DeleteBatchResultData>, V::Error> {
let mut field_metadata = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = DeleteBatchResultData {
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("metadata", &self.metadata)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchResultData {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = DeleteBatchResultData;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DeleteBatchResultData struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
DeleteBatchResultData::internal_deserialize(map)
}
}
deserializer.deserialize_struct("DeleteBatchResultData", DELETE_BATCH_RESULT_DATA_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for DeleteBatchResultData {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("DeleteBatchResultData", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum DeleteBatchResultEntry {
Success(DeleteBatchResultData),
Failure(DeleteError),
}
impl<'de> ::serde::de::Deserialize<'de> for DeleteBatchResultEntry {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = DeleteBatchResultEntry;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DeleteBatchResultEntry structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"success" => DeleteBatchResultEntry::Success(DeleteBatchResultData::internal_deserialize(&mut map)?),
"failure" => {
match map.next_key()? {
Some("failure") => DeleteBatchResultEntry::Failure(map.next_value()?),
None => return Err(de::Error::missing_field("failure")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["success",
"failure"];
deserializer.deserialize_struct("DeleteBatchResultEntry", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for DeleteBatchResultEntry {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
DeleteBatchResultEntry::Success(ref x) => {
let mut s = serializer.serialize_struct("DeleteBatchResultEntry", 2)?;
s.serialize_field(".tag", "success")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
DeleteBatchResultEntry::Failure(ref x) => {
let mut s = serializer.serialize_struct("DeleteBatchResultEntry", 2)?;
s.serialize_field(".tag", "failure")?;
s.serialize_field("failure", x)?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum DeleteError {
PathLookup(LookupError),
PathWrite(WriteError),
TooManyWriteOperations,
TooManyFiles,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for DeleteError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = DeleteError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DeleteError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path_lookup" => {
match map.next_key()? {
Some("path_lookup") => DeleteError::PathLookup(map.next_value()?),
None => return Err(de::Error::missing_field("path_lookup")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"path_write" => {
match map.next_key()? {
Some("path_write") => DeleteError::PathWrite(map.next_value()?),
None => return Err(de::Error::missing_field("path_write")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"too_many_write_operations" => DeleteError::TooManyWriteOperations,
"too_many_files" => DeleteError::TooManyFiles,
_ => DeleteError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path_lookup",
"path_write",
"too_many_write_operations",
"too_many_files",
"other"];
deserializer.deserialize_struct("DeleteError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for DeleteError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
DeleteError::PathLookup(ref x) => {
let mut s = serializer.serialize_struct("DeleteError", 2)?;
s.serialize_field(".tag", "path_lookup")?;
s.serialize_field("path_lookup", x)?;
s.end()
}
DeleteError::PathWrite(ref x) => {
let mut s = serializer.serialize_struct("DeleteError", 2)?;
s.serialize_field(".tag", "path_write")?;
s.serialize_field("path_write", x)?;
s.end()
}
DeleteError::TooManyWriteOperations => {
let mut s = serializer.serialize_struct("DeleteError", 1)?;
s.serialize_field(".tag", "too_many_write_operations")?;
s.end()
}
DeleteError::TooManyFiles => {
let mut s = serializer.serialize_struct("DeleteError", 1)?;
s.serialize_field(".tag", "too_many_files")?;
s.end()
}
DeleteError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for DeleteError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
DeleteError::PathLookup(inner) => Some(inner),
DeleteError::PathWrite(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for DeleteError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
DeleteError::PathLookup(inner) => write!(f, "{}", inner),
DeleteError::PathWrite(inner) => write!(f, "{}", inner),
DeleteError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
DeleteError::TooManyFiles => f.write_str("There are too many files in one request. Please retry with fewer files."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct DeleteResult {
pub metadata: Metadata,
}
impl DeleteResult {
pub fn new(metadata: Metadata) -> Self {
DeleteResult {
metadata,
}
}
}
const DELETE_RESULT_FIELDS: &[&str] = &["metadata"];
impl DeleteResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<DeleteResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<DeleteResult>, V::Error> {
let mut field_metadata = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = DeleteResult {
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("metadata", &self.metadata)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for DeleteResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = DeleteResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DeleteResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
DeleteResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("DeleteResult", DELETE_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for DeleteResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("DeleteResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct DeletedMetadata {
pub name: String,
pub path_lower: Option<String>,
pub path_display: Option<String>,
pub parent_shared_folder_id: Option<crate::common::SharedFolderId>,
pub preview_url: Option<String>,
}
impl DeletedMetadata {
pub fn new(name: String) -> Self {
DeletedMetadata {
name,
path_lower: None,
path_display: None,
parent_shared_folder_id: None,
preview_url: None,
}
}
pub fn with_path_lower(mut self, value: String) -> Self {
self.path_lower = Some(value);
self
}
pub fn with_path_display(mut self, value: String) -> Self {
self.path_display = Some(value);
self
}
pub fn with_parent_shared_folder_id(mut self, value: crate::common::SharedFolderId) -> Self {
self.parent_shared_folder_id = Some(value);
self
}
pub fn with_preview_url(mut self, value: String) -> Self {
self.preview_url = Some(value);
self
}
}
const DELETED_METADATA_FIELDS: &[&str] = &["name",
"path_lower",
"path_display",
"parent_shared_folder_id",
"preview_url"];
impl DeletedMetadata {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<DeletedMetadata, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<DeletedMetadata>, V::Error> {
let mut field_name = None;
let mut field_path_lower = None;
let mut field_path_display = None;
let mut field_parent_shared_folder_id = None;
let mut field_preview_url = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"name" => {
if field_name.is_some() {
return Err(::serde::de::Error::duplicate_field("name"));
}
field_name = Some(map.next_value()?);
}
"path_lower" => {
if field_path_lower.is_some() {
return Err(::serde::de::Error::duplicate_field("path_lower"));
}
field_path_lower = Some(map.next_value()?);
}
"path_display" => {
if field_path_display.is_some() {
return Err(::serde::de::Error::duplicate_field("path_display"));
}
field_path_display = Some(map.next_value()?);
}
"parent_shared_folder_id" => {
if field_parent_shared_folder_id.is_some() {
return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
}
field_parent_shared_folder_id = Some(map.next_value()?);
}
"preview_url" => {
if field_preview_url.is_some() {
return Err(::serde::de::Error::duplicate_field("preview_url"));
}
field_preview_url = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = DeletedMetadata {
name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
path_lower: field_path_lower,
path_display: field_path_display,
parent_shared_folder_id: field_parent_shared_folder_id,
preview_url: field_preview_url,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("name", &self.name)?;
if let Some(val) = &self.path_lower {
s.serialize_field("path_lower", val)?;
}
if let Some(val) = &self.path_display {
s.serialize_field("path_display", val)?;
}
if let Some(val) = &self.parent_shared_folder_id {
s.serialize_field("parent_shared_folder_id", val)?;
}
if let Some(val) = &self.preview_url {
s.serialize_field("preview_url", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for DeletedMetadata {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = DeletedMetadata;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DeletedMetadata struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
DeletedMetadata::internal_deserialize(map)
}
}
deserializer.deserialize_struct("DeletedMetadata", DELETED_METADATA_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for DeletedMetadata {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("DeletedMetadata", 5)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct Dimensions {
pub height: u64,
pub width: u64,
}
impl Dimensions {
pub fn new(height: u64, width: u64) -> Self {
Dimensions {
height,
width,
}
}
}
const DIMENSIONS_FIELDS: &[&str] = &["height",
"width"];
impl Dimensions {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<Dimensions, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<Dimensions>, V::Error> {
let mut field_height = None;
let mut field_width = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"height" => {
if field_height.is_some() {
return Err(::serde::de::Error::duplicate_field("height"));
}
field_height = Some(map.next_value()?);
}
"width" => {
if field_width.is_some() {
return Err(::serde::de::Error::duplicate_field("width"));
}
field_width = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = Dimensions {
height: field_height.ok_or_else(|| ::serde::de::Error::missing_field("height"))?,
width: field_width.ok_or_else(|| ::serde::de::Error::missing_field("width"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("height", &self.height)?;
s.serialize_field("width", &self.width)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for Dimensions {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = Dimensions;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a Dimensions struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
Dimensions::internal_deserialize(map)
}
}
deserializer.deserialize_struct("Dimensions", DIMENSIONS_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for Dimensions {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("Dimensions", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct DownloadArg {
pub path: ReadPath,
pub rev: Option<Rev>,
}
impl DownloadArg {
pub fn new(path: ReadPath) -> Self {
DownloadArg {
path,
rev: None,
}
}
pub fn with_rev(mut self, value: Rev) -> Self {
self.rev = Some(value);
self
}
}
const DOWNLOAD_ARG_FIELDS: &[&str] = &["path",
"rev"];
impl DownloadArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<DownloadArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<DownloadArg>, V::Error> {
let mut field_path = None;
let mut field_rev = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"rev" => {
if field_rev.is_some() {
return Err(::serde::de::Error::duplicate_field("rev"));
}
field_rev = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = DownloadArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
rev: field_rev,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
if let Some(val) = &self.rev {
s.serialize_field("rev", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for DownloadArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = DownloadArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DownloadArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
DownloadArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("DownloadArg", DOWNLOAD_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for DownloadArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("DownloadArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum DownloadError {
Path(LookupError),
UnsupportedFile,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for DownloadError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = DownloadError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DownloadError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => DownloadError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"unsupported_file" => DownloadError::UnsupportedFile,
_ => DownloadError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"unsupported_file",
"other"];
deserializer.deserialize_struct("DownloadError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for DownloadError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
DownloadError::Path(ref x) => {
let mut s = serializer.serialize_struct("DownloadError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
DownloadError::UnsupportedFile => {
let mut s = serializer.serialize_struct("DownloadError", 1)?;
s.serialize_field(".tag", "unsupported_file")?;
s.end()
}
DownloadError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for DownloadError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
DownloadError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for DownloadError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
DownloadError::Path(inner) => write!(f, "{}", inner),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct DownloadZipArg {
pub path: ReadPath,
}
impl DownloadZipArg {
pub fn new(path: ReadPath) -> Self {
DownloadZipArg {
path,
}
}
}
const DOWNLOAD_ZIP_ARG_FIELDS: &[&str] = &["path"];
impl DownloadZipArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<DownloadZipArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<DownloadZipArg>, V::Error> {
let mut field_path = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = DownloadZipArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for DownloadZipArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = DownloadZipArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DownloadZipArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
DownloadZipArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("DownloadZipArg", DOWNLOAD_ZIP_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for DownloadZipArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("DownloadZipArg", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum DownloadZipError {
Path(LookupError),
TooLarge,
TooManyFiles,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for DownloadZipError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = DownloadZipError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DownloadZipError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => DownloadZipError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"too_large" => DownloadZipError::TooLarge,
"too_many_files" => DownloadZipError::TooManyFiles,
_ => DownloadZipError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"too_large",
"too_many_files",
"other"];
deserializer.deserialize_struct("DownloadZipError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for DownloadZipError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
DownloadZipError::Path(ref x) => {
let mut s = serializer.serialize_struct("DownloadZipError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
DownloadZipError::TooLarge => {
let mut s = serializer.serialize_struct("DownloadZipError", 1)?;
s.serialize_field(".tag", "too_large")?;
s.end()
}
DownloadZipError::TooManyFiles => {
let mut s = serializer.serialize_struct("DownloadZipError", 1)?;
s.serialize_field(".tag", "too_many_files")?;
s.end()
}
DownloadZipError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for DownloadZipError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
DownloadZipError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for DownloadZipError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
DownloadZipError::Path(inner) => write!(f, "{}", inner),
DownloadZipError::TooLarge => f.write_str("The folder or a file is too large to download."),
DownloadZipError::TooManyFiles => f.write_str("The folder has too many files to download."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct DownloadZipResult {
pub metadata: FolderMetadata,
}
impl DownloadZipResult {
pub fn new(metadata: FolderMetadata) -> Self {
DownloadZipResult {
metadata,
}
}
}
const DOWNLOAD_ZIP_RESULT_FIELDS: &[&str] = &["metadata"];
impl DownloadZipResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<DownloadZipResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<DownloadZipResult>, V::Error> {
let mut field_metadata = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = DownloadZipResult {
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("metadata", &self.metadata)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for DownloadZipResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = DownloadZipResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a DownloadZipResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
DownloadZipResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("DownloadZipResult", DOWNLOAD_ZIP_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for DownloadZipResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("DownloadZipResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct ExportArg {
pub path: ReadPath,
pub export_format: Option<String>,
}
impl ExportArg {
pub fn new(path: ReadPath) -> Self {
ExportArg {
path,
export_format: None,
}
}
pub fn with_export_format(mut self, value: String) -> Self {
self.export_format = Some(value);
self
}
}
const EXPORT_ARG_FIELDS: &[&str] = &["path",
"export_format"];
impl ExportArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ExportArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ExportArg>, V::Error> {
let mut field_path = None;
let mut field_export_format = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"export_format" => {
if field_export_format.is_some() {
return Err(::serde::de::Error::duplicate_field("export_format"));
}
field_export_format = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ExportArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
export_format: field_export_format,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
if let Some(val) = &self.export_format {
s.serialize_field("export_format", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ExportArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ExportArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ExportArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ExportArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ExportArg", EXPORT_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ExportArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ExportArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum ExportError {
Path(LookupError),
NonExportable,
InvalidExportFormat,
RetryError,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for ExportError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ExportError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ExportError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => ExportError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"non_exportable" => ExportError::NonExportable,
"invalid_export_format" => ExportError::InvalidExportFormat,
"retry_error" => ExportError::RetryError,
_ => ExportError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"non_exportable",
"invalid_export_format",
"retry_error",
"other"];
deserializer.deserialize_struct("ExportError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ExportError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
ExportError::Path(ref x) => {
let mut s = serializer.serialize_struct("ExportError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
ExportError::NonExportable => {
let mut s = serializer.serialize_struct("ExportError", 1)?;
s.serialize_field(".tag", "non_exportable")?;
s.end()
}
ExportError::InvalidExportFormat => {
let mut s = serializer.serialize_struct("ExportError", 1)?;
s.serialize_field(".tag", "invalid_export_format")?;
s.end()
}
ExportError::RetryError => {
let mut s = serializer.serialize_struct("ExportError", 1)?;
s.serialize_field(".tag", "retry_error")?;
s.end()
}
ExportError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for ExportError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
ExportError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for ExportError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
ExportError::Path(inner) => write!(f, "{}", inner),
ExportError::InvalidExportFormat => f.write_str("The specified export format is not a valid option for this file type."),
ExportError::RetryError => f.write_str("The exportable content is not yet available. Please retry later."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[non_exhaustive] pub struct ExportInfo {
pub export_as: Option<String>,
pub export_options: Option<Vec<String>>,
}
impl ExportInfo {
pub fn with_export_as(mut self, value: String) -> Self {
self.export_as = Some(value);
self
}
pub fn with_export_options(mut self, value: Vec<String>) -> Self {
self.export_options = Some(value);
self
}
}
const EXPORT_INFO_FIELDS: &[&str] = &["export_as",
"export_options"];
impl ExportInfo {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<ExportInfo, V::Error> {
let mut field_export_as = None;
let mut field_export_options = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"export_as" => {
if field_export_as.is_some() {
return Err(::serde::de::Error::duplicate_field("export_as"));
}
field_export_as = Some(map.next_value()?);
}
"export_options" => {
if field_export_options.is_some() {
return Err(::serde::de::Error::duplicate_field("export_options"));
}
field_export_options = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = ExportInfo {
export_as: field_export_as,
export_options: field_export_options,
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
if let Some(val) = &self.export_as {
s.serialize_field("export_as", val)?;
}
if let Some(val) = &self.export_options {
s.serialize_field("export_options", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ExportInfo {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ExportInfo;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ExportInfo struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ExportInfo::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ExportInfo", EXPORT_INFO_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ExportInfo {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ExportInfo", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct ExportMetadata {
pub name: String,
pub size: u64,
pub export_hash: Option<Sha256HexHash>,
pub paper_revision: Option<i64>,
}
impl ExportMetadata {
pub fn new(name: String, size: u64) -> Self {
ExportMetadata {
name,
size,
export_hash: None,
paper_revision: None,
}
}
pub fn with_export_hash(mut self, value: Sha256HexHash) -> Self {
self.export_hash = Some(value);
self
}
pub fn with_paper_revision(mut self, value: i64) -> Self {
self.paper_revision = Some(value);
self
}
}
const EXPORT_METADATA_FIELDS: &[&str] = &["name",
"size",
"export_hash",
"paper_revision"];
impl ExportMetadata {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ExportMetadata, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ExportMetadata>, V::Error> {
let mut field_name = None;
let mut field_size = None;
let mut field_export_hash = None;
let mut field_paper_revision = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"name" => {
if field_name.is_some() {
return Err(::serde::de::Error::duplicate_field("name"));
}
field_name = Some(map.next_value()?);
}
"size" => {
if field_size.is_some() {
return Err(::serde::de::Error::duplicate_field("size"));
}
field_size = Some(map.next_value()?);
}
"export_hash" => {
if field_export_hash.is_some() {
return Err(::serde::de::Error::duplicate_field("export_hash"));
}
field_export_hash = Some(map.next_value()?);
}
"paper_revision" => {
if field_paper_revision.is_some() {
return Err(::serde::de::Error::duplicate_field("paper_revision"));
}
field_paper_revision = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ExportMetadata {
name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
size: field_size.ok_or_else(|| ::serde::de::Error::missing_field("size"))?,
export_hash: field_export_hash,
paper_revision: field_paper_revision,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("name", &self.name)?;
s.serialize_field("size", &self.size)?;
if let Some(val) = &self.export_hash {
s.serialize_field("export_hash", val)?;
}
if let Some(val) = &self.paper_revision {
s.serialize_field("paper_revision", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ExportMetadata {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ExportMetadata;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ExportMetadata struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ExportMetadata::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ExportMetadata", EXPORT_METADATA_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ExportMetadata {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ExportMetadata", 4)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct ExportResult {
pub export_metadata: ExportMetadata,
pub file_metadata: FileMetadata,
}
impl ExportResult {
pub fn new(export_metadata: ExportMetadata, file_metadata: FileMetadata) -> Self {
ExportResult {
export_metadata,
file_metadata,
}
}
}
const EXPORT_RESULT_FIELDS: &[&str] = &["export_metadata",
"file_metadata"];
impl ExportResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ExportResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ExportResult>, V::Error> {
let mut field_export_metadata = None;
let mut field_file_metadata = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"export_metadata" => {
if field_export_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("export_metadata"));
}
field_export_metadata = Some(map.next_value()?);
}
"file_metadata" => {
if field_file_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("file_metadata"));
}
field_file_metadata = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ExportResult {
export_metadata: field_export_metadata.ok_or_else(|| ::serde::de::Error::missing_field("export_metadata"))?,
file_metadata: field_file_metadata.ok_or_else(|| ::serde::de::Error::missing_field("file_metadata"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("export_metadata", &self.export_metadata)?;
s.serialize_field("file_metadata", &self.file_metadata)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ExportResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ExportResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ExportResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ExportResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ExportResult", EXPORT_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ExportResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ExportResult", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum FileCategory {
Image,
Document,
Pdf,
Spreadsheet,
Presentation,
Audio,
Video,
Folder,
Paper,
Others,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for FileCategory {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = FileCategory;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a FileCategory structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"image" => FileCategory::Image,
"document" => FileCategory::Document,
"pdf" => FileCategory::Pdf,
"spreadsheet" => FileCategory::Spreadsheet,
"presentation" => FileCategory::Presentation,
"audio" => FileCategory::Audio,
"video" => FileCategory::Video,
"folder" => FileCategory::Folder,
"paper" => FileCategory::Paper,
"others" => FileCategory::Others,
_ => FileCategory::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["image",
"document",
"pdf",
"spreadsheet",
"presentation",
"audio",
"video",
"folder",
"paper",
"others",
"other"];
deserializer.deserialize_struct("FileCategory", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for FileCategory {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
FileCategory::Image => {
let mut s = serializer.serialize_struct("FileCategory", 1)?;
s.serialize_field(".tag", "image")?;
s.end()
}
FileCategory::Document => {
let mut s = serializer.serialize_struct("FileCategory", 1)?;
s.serialize_field(".tag", "document")?;
s.end()
}
FileCategory::Pdf => {
let mut s = serializer.serialize_struct("FileCategory", 1)?;
s.serialize_field(".tag", "pdf")?;
s.end()
}
FileCategory::Spreadsheet => {
let mut s = serializer.serialize_struct("FileCategory", 1)?;
s.serialize_field(".tag", "spreadsheet")?;
s.end()
}
FileCategory::Presentation => {
let mut s = serializer.serialize_struct("FileCategory", 1)?;
s.serialize_field(".tag", "presentation")?;
s.end()
}
FileCategory::Audio => {
let mut s = serializer.serialize_struct("FileCategory", 1)?;
s.serialize_field(".tag", "audio")?;
s.end()
}
FileCategory::Video => {
let mut s = serializer.serialize_struct("FileCategory", 1)?;
s.serialize_field(".tag", "video")?;
s.end()
}
FileCategory::Folder => {
let mut s = serializer.serialize_struct("FileCategory", 1)?;
s.serialize_field(".tag", "folder")?;
s.end()
}
FileCategory::Paper => {
let mut s = serializer.serialize_struct("FileCategory", 1)?;
s.serialize_field(".tag", "paper")?;
s.end()
}
FileCategory::Others => {
let mut s = serializer.serialize_struct("FileCategory", 1)?;
s.serialize_field(".tag", "others")?;
s.end()
}
FileCategory::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct FileLock {
pub content: FileLockContent,
}
impl FileLock {
pub fn new(content: FileLockContent) -> Self {
FileLock {
content,
}
}
}
const FILE_LOCK_FIELDS: &[&str] = &["content"];
impl FileLock {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<FileLock, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<FileLock>, V::Error> {
let mut field_content = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"content" => {
if field_content.is_some() {
return Err(::serde::de::Error::duplicate_field("content"));
}
field_content = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = FileLock {
content: field_content.ok_or_else(|| ::serde::de::Error::missing_field("content"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("content", &self.content)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for FileLock {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = FileLock;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a FileLock struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
FileLock::internal_deserialize(map)
}
}
deserializer.deserialize_struct("FileLock", FILE_LOCK_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for FileLock {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("FileLock", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum FileLockContent {
Unlocked,
SingleUser(SingleUserLock),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for FileLockContent {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = FileLockContent;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a FileLockContent structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"unlocked" => FileLockContent::Unlocked,
"single_user" => FileLockContent::SingleUser(SingleUserLock::internal_deserialize(&mut map)?),
_ => FileLockContent::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["unlocked",
"single_user",
"other"];
deserializer.deserialize_struct("FileLockContent", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for FileLockContent {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
FileLockContent::Unlocked => {
let mut s = serializer.serialize_struct("FileLockContent", 1)?;
s.serialize_field(".tag", "unlocked")?;
s.end()
}
FileLockContent::SingleUser(ref x) => {
let mut s = serializer.serialize_struct("FileLockContent", 4)?;
s.serialize_field(".tag", "single_user")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
FileLockContent::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[non_exhaustive] pub struct FileLockMetadata {
pub is_lockholder: Option<bool>,
pub lockholder_name: Option<String>,
pub lockholder_account_id: Option<crate::users_common::AccountId>,
pub created: Option<crate::common::DropboxTimestamp>,
}
impl FileLockMetadata {
pub fn with_is_lockholder(mut self, value: bool) -> Self {
self.is_lockholder = Some(value);
self
}
pub fn with_lockholder_name(mut self, value: String) -> Self {
self.lockholder_name = Some(value);
self
}
pub fn with_lockholder_account_id(mut self, value: crate::users_common::AccountId) -> Self {
self.lockholder_account_id = Some(value);
self
}
pub fn with_created(mut self, value: crate::common::DropboxTimestamp) -> Self {
self.created = Some(value);
self
}
}
const FILE_LOCK_METADATA_FIELDS: &[&str] = &["is_lockholder",
"lockholder_name",
"lockholder_account_id",
"created"];
impl FileLockMetadata {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<FileLockMetadata, V::Error> {
let mut field_is_lockholder = None;
let mut field_lockholder_name = None;
let mut field_lockholder_account_id = None;
let mut field_created = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"is_lockholder" => {
if field_is_lockholder.is_some() {
return Err(::serde::de::Error::duplicate_field("is_lockholder"));
}
field_is_lockholder = Some(map.next_value()?);
}
"lockholder_name" => {
if field_lockholder_name.is_some() {
return Err(::serde::de::Error::duplicate_field("lockholder_name"));
}
field_lockholder_name = Some(map.next_value()?);
}
"lockholder_account_id" => {
if field_lockholder_account_id.is_some() {
return Err(::serde::de::Error::duplicate_field("lockholder_account_id"));
}
field_lockholder_account_id = Some(map.next_value()?);
}
"created" => {
if field_created.is_some() {
return Err(::serde::de::Error::duplicate_field("created"));
}
field_created = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = FileLockMetadata {
is_lockholder: field_is_lockholder,
lockholder_name: field_lockholder_name,
lockholder_account_id: field_lockholder_account_id,
created: field_created,
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
if let Some(val) = &self.is_lockholder {
s.serialize_field("is_lockholder", val)?;
}
if let Some(val) = &self.lockholder_name {
s.serialize_field("lockholder_name", val)?;
}
if let Some(val) = &self.lockholder_account_id {
s.serialize_field("lockholder_account_id", val)?;
}
if let Some(val) = &self.created {
s.serialize_field("created", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for FileLockMetadata {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = FileLockMetadata;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a FileLockMetadata struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
FileLockMetadata::internal_deserialize(map)
}
}
deserializer.deserialize_struct("FileLockMetadata", FILE_LOCK_METADATA_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for FileLockMetadata {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("FileLockMetadata", 4)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct FileMetadata {
pub name: String,
pub id: Id,
pub client_modified: crate::common::DropboxTimestamp,
pub server_modified: crate::common::DropboxTimestamp,
pub rev: Rev,
pub size: u64,
pub path_lower: Option<String>,
pub path_display: Option<String>,
pub parent_shared_folder_id: Option<crate::common::SharedFolderId>,
pub preview_url: Option<String>,
pub media_info: Option<MediaInfo>,
pub symlink_info: Option<SymlinkInfo>,
pub sharing_info: Option<FileSharingInfo>,
pub is_downloadable: bool,
pub export_info: Option<ExportInfo>,
pub property_groups: Option<Vec<crate::file_properties::PropertyGroup>>,
pub has_explicit_shared_members: Option<bool>,
pub content_hash: Option<Sha256HexHash>,
pub file_lock_info: Option<FileLockMetadata>,
}
impl FileMetadata {
pub fn new(
name: String,
id: Id,
client_modified: crate::common::DropboxTimestamp,
server_modified: crate::common::DropboxTimestamp,
rev: Rev,
size: u64,
) -> Self {
FileMetadata {
name,
id,
client_modified,
server_modified,
rev,
size,
path_lower: None,
path_display: None,
parent_shared_folder_id: None,
preview_url: None,
media_info: None,
symlink_info: None,
sharing_info: None,
is_downloadable: true,
export_info: None,
property_groups: None,
has_explicit_shared_members: None,
content_hash: None,
file_lock_info: None,
}
}
pub fn with_path_lower(mut self, value: String) -> Self {
self.path_lower = Some(value);
self
}
pub fn with_path_display(mut self, value: String) -> Self {
self.path_display = Some(value);
self
}
pub fn with_parent_shared_folder_id(mut self, value: crate::common::SharedFolderId) -> Self {
self.parent_shared_folder_id = Some(value);
self
}
pub fn with_preview_url(mut self, value: String) -> Self {
self.preview_url = Some(value);
self
}
pub fn with_media_info(mut self, value: MediaInfo) -> Self {
self.media_info = Some(value);
self
}
pub fn with_symlink_info(mut self, value: SymlinkInfo) -> Self {
self.symlink_info = Some(value);
self
}
pub fn with_sharing_info(mut self, value: FileSharingInfo) -> Self {
self.sharing_info = Some(value);
self
}
pub fn with_is_downloadable(mut self, value: bool) -> Self {
self.is_downloadable = value;
self
}
pub fn with_export_info(mut self, value: ExportInfo) -> Self {
self.export_info = Some(value);
self
}
pub fn with_property_groups(
mut self,
value: Vec<crate::file_properties::PropertyGroup>,
) -> Self {
self.property_groups = Some(value);
self
}
pub fn with_has_explicit_shared_members(mut self, value: bool) -> Self {
self.has_explicit_shared_members = Some(value);
self
}
pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
self.content_hash = Some(value);
self
}
pub fn with_file_lock_info(mut self, value: FileLockMetadata) -> Self {
self.file_lock_info = Some(value);
self
}
}
const FILE_METADATA_FIELDS: &[&str] = &["name",
"id",
"client_modified",
"server_modified",
"rev",
"size",
"path_lower",
"path_display",
"parent_shared_folder_id",
"preview_url",
"media_info",
"symlink_info",
"sharing_info",
"is_downloadable",
"export_info",
"property_groups",
"has_explicit_shared_members",
"content_hash",
"file_lock_info"];
impl FileMetadata {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<FileMetadata, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<FileMetadata>, V::Error> {
let mut field_name = None;
let mut field_id = None;
let mut field_client_modified = None;
let mut field_server_modified = None;
let mut field_rev = None;
let mut field_size = None;
let mut field_path_lower = None;
let mut field_path_display = None;
let mut field_parent_shared_folder_id = None;
let mut field_preview_url = None;
let mut field_media_info = None;
let mut field_symlink_info = None;
let mut field_sharing_info = None;
let mut field_is_downloadable = None;
let mut field_export_info = None;
let mut field_property_groups = None;
let mut field_has_explicit_shared_members = None;
let mut field_content_hash = None;
let mut field_file_lock_info = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"name" => {
if field_name.is_some() {
return Err(::serde::de::Error::duplicate_field("name"));
}
field_name = Some(map.next_value()?);
}
"id" => {
if field_id.is_some() {
return Err(::serde::de::Error::duplicate_field("id"));
}
field_id = Some(map.next_value()?);
}
"client_modified" => {
if field_client_modified.is_some() {
return Err(::serde::de::Error::duplicate_field("client_modified"));
}
field_client_modified = Some(map.next_value()?);
}
"server_modified" => {
if field_server_modified.is_some() {
return Err(::serde::de::Error::duplicate_field("server_modified"));
}
field_server_modified = Some(map.next_value()?);
}
"rev" => {
if field_rev.is_some() {
return Err(::serde::de::Error::duplicate_field("rev"));
}
field_rev = Some(map.next_value()?);
}
"size" => {
if field_size.is_some() {
return Err(::serde::de::Error::duplicate_field("size"));
}
field_size = Some(map.next_value()?);
}
"path_lower" => {
if field_path_lower.is_some() {
return Err(::serde::de::Error::duplicate_field("path_lower"));
}
field_path_lower = Some(map.next_value()?);
}
"path_display" => {
if field_path_display.is_some() {
return Err(::serde::de::Error::duplicate_field("path_display"));
}
field_path_display = Some(map.next_value()?);
}
"parent_shared_folder_id" => {
if field_parent_shared_folder_id.is_some() {
return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
}
field_parent_shared_folder_id = Some(map.next_value()?);
}
"preview_url" => {
if field_preview_url.is_some() {
return Err(::serde::de::Error::duplicate_field("preview_url"));
}
field_preview_url = Some(map.next_value()?);
}
"media_info" => {
if field_media_info.is_some() {
return Err(::serde::de::Error::duplicate_field("media_info"));
}
field_media_info = Some(map.next_value()?);
}
"symlink_info" => {
if field_symlink_info.is_some() {
return Err(::serde::de::Error::duplicate_field("symlink_info"));
}
field_symlink_info = Some(map.next_value()?);
}
"sharing_info" => {
if field_sharing_info.is_some() {
return Err(::serde::de::Error::duplicate_field("sharing_info"));
}
field_sharing_info = Some(map.next_value()?);
}
"is_downloadable" => {
if field_is_downloadable.is_some() {
return Err(::serde::de::Error::duplicate_field("is_downloadable"));
}
field_is_downloadable = Some(map.next_value()?);
}
"export_info" => {
if field_export_info.is_some() {
return Err(::serde::de::Error::duplicate_field("export_info"));
}
field_export_info = Some(map.next_value()?);
}
"property_groups" => {
if field_property_groups.is_some() {
return Err(::serde::de::Error::duplicate_field("property_groups"));
}
field_property_groups = Some(map.next_value()?);
}
"has_explicit_shared_members" => {
if field_has_explicit_shared_members.is_some() {
return Err(::serde::de::Error::duplicate_field("has_explicit_shared_members"));
}
field_has_explicit_shared_members = Some(map.next_value()?);
}
"content_hash" => {
if field_content_hash.is_some() {
return Err(::serde::de::Error::duplicate_field("content_hash"));
}
field_content_hash = Some(map.next_value()?);
}
"file_lock_info" => {
if field_file_lock_info.is_some() {
return Err(::serde::de::Error::duplicate_field("file_lock_info"));
}
field_file_lock_info = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = FileMetadata {
name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
client_modified: field_client_modified.ok_or_else(|| ::serde::de::Error::missing_field("client_modified"))?,
server_modified: field_server_modified.ok_or_else(|| ::serde::de::Error::missing_field("server_modified"))?,
rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
size: field_size.ok_or_else(|| ::serde::de::Error::missing_field("size"))?,
path_lower: field_path_lower,
path_display: field_path_display,
parent_shared_folder_id: field_parent_shared_folder_id,
preview_url: field_preview_url,
media_info: field_media_info,
symlink_info: field_symlink_info,
sharing_info: field_sharing_info,
is_downloadable: field_is_downloadable.unwrap_or(true),
export_info: field_export_info,
property_groups: field_property_groups,
has_explicit_shared_members: field_has_explicit_shared_members,
content_hash: field_content_hash,
file_lock_info: field_file_lock_info,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("name", &self.name)?;
s.serialize_field("id", &self.id)?;
s.serialize_field("client_modified", &self.client_modified)?;
s.serialize_field("server_modified", &self.server_modified)?;
s.serialize_field("rev", &self.rev)?;
s.serialize_field("size", &self.size)?;
if let Some(val) = &self.path_lower {
s.serialize_field("path_lower", val)?;
}
if let Some(val) = &self.path_display {
s.serialize_field("path_display", val)?;
}
if let Some(val) = &self.parent_shared_folder_id {
s.serialize_field("parent_shared_folder_id", val)?;
}
if let Some(val) = &self.preview_url {
s.serialize_field("preview_url", val)?;
}
if let Some(val) = &self.media_info {
s.serialize_field("media_info", val)?;
}
if let Some(val) = &self.symlink_info {
s.serialize_field("symlink_info", val)?;
}
if let Some(val) = &self.sharing_info {
s.serialize_field("sharing_info", val)?;
}
s.serialize_field("is_downloadable", &self.is_downloadable)?;
if let Some(val) = &self.export_info {
s.serialize_field("export_info", val)?;
}
if let Some(val) = &self.property_groups {
s.serialize_field("property_groups", val)?;
}
if let Some(val) = &self.has_explicit_shared_members {
s.serialize_field("has_explicit_shared_members", val)?;
}
if let Some(val) = &self.content_hash {
s.serialize_field("content_hash", val)?;
}
if let Some(val) = &self.file_lock_info {
s.serialize_field("file_lock_info", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for FileMetadata {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = FileMetadata;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a FileMetadata struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
FileMetadata::internal_deserialize(map)
}
}
deserializer.deserialize_struct("FileMetadata", FILE_METADATA_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for FileMetadata {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("FileMetadata", 19)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[non_exhaustive] pub struct FileOpsResult {
}
const FILE_OPS_RESULT_FIELDS: &[&str] = &[];
impl FileOpsResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<FileOpsResult, V::Error> {
crate::eat_json_fields(&mut map)?;
Ok(FileOpsResult {})
}
}
impl<'de> ::serde::de::Deserialize<'de> for FileOpsResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = FileOpsResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a FileOpsResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
FileOpsResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("FileOpsResult", FILE_OPS_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for FileOpsResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
serializer.serialize_struct("FileOpsResult", 0)?.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct FileSharingInfo {
pub read_only: bool,
pub parent_shared_folder_id: crate::common::SharedFolderId,
pub modified_by: Option<crate::users_common::AccountId>,
}
impl FileSharingInfo {
pub fn new(read_only: bool, parent_shared_folder_id: crate::common::SharedFolderId) -> Self {
FileSharingInfo {
read_only,
parent_shared_folder_id,
modified_by: None,
}
}
pub fn with_modified_by(mut self, value: crate::users_common::AccountId) -> Self {
self.modified_by = Some(value);
self
}
}
const FILE_SHARING_INFO_FIELDS: &[&str] = &["read_only",
"parent_shared_folder_id",
"modified_by"];
impl FileSharingInfo {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<FileSharingInfo, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<FileSharingInfo>, V::Error> {
let mut field_read_only = None;
let mut field_parent_shared_folder_id = None;
let mut field_modified_by = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"read_only" => {
if field_read_only.is_some() {
return Err(::serde::de::Error::duplicate_field("read_only"));
}
field_read_only = Some(map.next_value()?);
}
"parent_shared_folder_id" => {
if field_parent_shared_folder_id.is_some() {
return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
}
field_parent_shared_folder_id = Some(map.next_value()?);
}
"modified_by" => {
if field_modified_by.is_some() {
return Err(::serde::de::Error::duplicate_field("modified_by"));
}
field_modified_by = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = FileSharingInfo {
read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
parent_shared_folder_id: field_parent_shared_folder_id.ok_or_else(|| ::serde::de::Error::missing_field("parent_shared_folder_id"))?,
modified_by: field_modified_by,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("read_only", &self.read_only)?;
s.serialize_field("parent_shared_folder_id", &self.parent_shared_folder_id)?;
if let Some(val) = &self.modified_by {
s.serialize_field("modified_by", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for FileSharingInfo {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = FileSharingInfo;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a FileSharingInfo struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
FileSharingInfo::internal_deserialize(map)
}
}
deserializer.deserialize_struct("FileSharingInfo", FILE_SHARING_INFO_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for FileSharingInfo {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("FileSharingInfo", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum FileStatus {
Active,
Deleted,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for FileStatus {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = FileStatus;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a FileStatus structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"active" => FileStatus::Active,
"deleted" => FileStatus::Deleted,
_ => FileStatus::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["active",
"deleted",
"other"];
deserializer.deserialize_struct("FileStatus", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for FileStatus {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
FileStatus::Active => {
let mut s = serializer.serialize_struct("FileStatus", 1)?;
s.serialize_field(".tag", "active")?;
s.end()
}
FileStatus::Deleted => {
let mut s = serializer.serialize_struct("FileStatus", 1)?;
s.serialize_field(".tag", "deleted")?;
s.end()
}
FileStatus::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct FolderMetadata {
pub name: String,
pub id: Id,
pub path_lower: Option<String>,
pub path_display: Option<String>,
pub parent_shared_folder_id: Option<crate::common::SharedFolderId>,
pub preview_url: Option<String>,
pub shared_folder_id: Option<crate::common::SharedFolderId>,
pub sharing_info: Option<FolderSharingInfo>,
pub property_groups: Option<Vec<crate::file_properties::PropertyGroup>>,
}
impl FolderMetadata {
pub fn new(name: String, id: Id) -> Self {
FolderMetadata {
name,
id,
path_lower: None,
path_display: None,
parent_shared_folder_id: None,
preview_url: None,
shared_folder_id: None,
sharing_info: None,
property_groups: None,
}
}
pub fn with_path_lower(mut self, value: String) -> Self {
self.path_lower = Some(value);
self
}
pub fn with_path_display(mut self, value: String) -> Self {
self.path_display = Some(value);
self
}
pub fn with_parent_shared_folder_id(mut self, value: crate::common::SharedFolderId) -> Self {
self.parent_shared_folder_id = Some(value);
self
}
pub fn with_preview_url(mut self, value: String) -> Self {
self.preview_url = Some(value);
self
}
pub fn with_shared_folder_id(mut self, value: crate::common::SharedFolderId) -> Self {
self.shared_folder_id = Some(value);
self
}
pub fn with_sharing_info(mut self, value: FolderSharingInfo) -> Self {
self.sharing_info = Some(value);
self
}
pub fn with_property_groups(
mut self,
value: Vec<crate::file_properties::PropertyGroup>,
) -> Self {
self.property_groups = Some(value);
self
}
}
const FOLDER_METADATA_FIELDS: &[&str] = &["name",
"id",
"path_lower",
"path_display",
"parent_shared_folder_id",
"preview_url",
"shared_folder_id",
"sharing_info",
"property_groups"];
impl FolderMetadata {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<FolderMetadata, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<FolderMetadata>, V::Error> {
let mut field_name = None;
let mut field_id = None;
let mut field_path_lower = None;
let mut field_path_display = None;
let mut field_parent_shared_folder_id = None;
let mut field_preview_url = None;
let mut field_shared_folder_id = None;
let mut field_sharing_info = None;
let mut field_property_groups = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"name" => {
if field_name.is_some() {
return Err(::serde::de::Error::duplicate_field("name"));
}
field_name = Some(map.next_value()?);
}
"id" => {
if field_id.is_some() {
return Err(::serde::de::Error::duplicate_field("id"));
}
field_id = Some(map.next_value()?);
}
"path_lower" => {
if field_path_lower.is_some() {
return Err(::serde::de::Error::duplicate_field("path_lower"));
}
field_path_lower = Some(map.next_value()?);
}
"path_display" => {
if field_path_display.is_some() {
return Err(::serde::de::Error::duplicate_field("path_display"));
}
field_path_display = Some(map.next_value()?);
}
"parent_shared_folder_id" => {
if field_parent_shared_folder_id.is_some() {
return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
}
field_parent_shared_folder_id = Some(map.next_value()?);
}
"preview_url" => {
if field_preview_url.is_some() {
return Err(::serde::de::Error::duplicate_field("preview_url"));
}
field_preview_url = Some(map.next_value()?);
}
"shared_folder_id" => {
if field_shared_folder_id.is_some() {
return Err(::serde::de::Error::duplicate_field("shared_folder_id"));
}
field_shared_folder_id = Some(map.next_value()?);
}
"sharing_info" => {
if field_sharing_info.is_some() {
return Err(::serde::de::Error::duplicate_field("sharing_info"));
}
field_sharing_info = Some(map.next_value()?);
}
"property_groups" => {
if field_property_groups.is_some() {
return Err(::serde::de::Error::duplicate_field("property_groups"));
}
field_property_groups = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = FolderMetadata {
name: field_name.ok_or_else(|| ::serde::de::Error::missing_field("name"))?,
id: field_id.ok_or_else(|| ::serde::de::Error::missing_field("id"))?,
path_lower: field_path_lower,
path_display: field_path_display,
parent_shared_folder_id: field_parent_shared_folder_id,
preview_url: field_preview_url,
shared_folder_id: field_shared_folder_id,
sharing_info: field_sharing_info,
property_groups: field_property_groups,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("name", &self.name)?;
s.serialize_field("id", &self.id)?;
if let Some(val) = &self.path_lower {
s.serialize_field("path_lower", val)?;
}
if let Some(val) = &self.path_display {
s.serialize_field("path_display", val)?;
}
if let Some(val) = &self.parent_shared_folder_id {
s.serialize_field("parent_shared_folder_id", val)?;
}
if let Some(val) = &self.preview_url {
s.serialize_field("preview_url", val)?;
}
if let Some(val) = &self.shared_folder_id {
s.serialize_field("shared_folder_id", val)?;
}
if let Some(val) = &self.sharing_info {
s.serialize_field("sharing_info", val)?;
}
if let Some(val) = &self.property_groups {
s.serialize_field("property_groups", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for FolderMetadata {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = FolderMetadata;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a FolderMetadata struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
FolderMetadata::internal_deserialize(map)
}
}
deserializer.deserialize_struct("FolderMetadata", FOLDER_METADATA_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for FolderMetadata {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("FolderMetadata", 9)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct FolderSharingInfo {
pub read_only: bool,
pub parent_shared_folder_id: Option<crate::common::SharedFolderId>,
pub shared_folder_id: Option<crate::common::SharedFolderId>,
pub traverse_only: bool,
pub no_access: bool,
}
impl FolderSharingInfo {
pub fn new(read_only: bool) -> Self {
FolderSharingInfo {
read_only,
parent_shared_folder_id: None,
shared_folder_id: None,
traverse_only: false,
no_access: false,
}
}
pub fn with_parent_shared_folder_id(mut self, value: crate::common::SharedFolderId) -> Self {
self.parent_shared_folder_id = Some(value);
self
}
pub fn with_shared_folder_id(mut self, value: crate::common::SharedFolderId) -> Self {
self.shared_folder_id = Some(value);
self
}
pub fn with_traverse_only(mut self, value: bool) -> Self {
self.traverse_only = value;
self
}
pub fn with_no_access(mut self, value: bool) -> Self {
self.no_access = value;
self
}
}
const FOLDER_SHARING_INFO_FIELDS: &[&str] = &["read_only",
"parent_shared_folder_id",
"shared_folder_id",
"traverse_only",
"no_access"];
impl FolderSharingInfo {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<FolderSharingInfo, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<FolderSharingInfo>, V::Error> {
let mut field_read_only = None;
let mut field_parent_shared_folder_id = None;
let mut field_shared_folder_id = None;
let mut field_traverse_only = None;
let mut field_no_access = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"read_only" => {
if field_read_only.is_some() {
return Err(::serde::de::Error::duplicate_field("read_only"));
}
field_read_only = Some(map.next_value()?);
}
"parent_shared_folder_id" => {
if field_parent_shared_folder_id.is_some() {
return Err(::serde::de::Error::duplicate_field("parent_shared_folder_id"));
}
field_parent_shared_folder_id = Some(map.next_value()?);
}
"shared_folder_id" => {
if field_shared_folder_id.is_some() {
return Err(::serde::de::Error::duplicate_field("shared_folder_id"));
}
field_shared_folder_id = Some(map.next_value()?);
}
"traverse_only" => {
if field_traverse_only.is_some() {
return Err(::serde::de::Error::duplicate_field("traverse_only"));
}
field_traverse_only = Some(map.next_value()?);
}
"no_access" => {
if field_no_access.is_some() {
return Err(::serde::de::Error::duplicate_field("no_access"));
}
field_no_access = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = FolderSharingInfo {
read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
parent_shared_folder_id: field_parent_shared_folder_id,
shared_folder_id: field_shared_folder_id,
traverse_only: field_traverse_only.unwrap_or(false),
no_access: field_no_access.unwrap_or(false),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("read_only", &self.read_only)?;
if let Some(val) = &self.parent_shared_folder_id {
s.serialize_field("parent_shared_folder_id", val)?;
}
if let Some(val) = &self.shared_folder_id {
s.serialize_field("shared_folder_id", val)?;
}
s.serialize_field("traverse_only", &self.traverse_only)?;
s.serialize_field("no_access", &self.no_access)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for FolderSharingInfo {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = FolderSharingInfo;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a FolderSharingInfo struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
FolderSharingInfo::internal_deserialize(map)
}
}
deserializer.deserialize_struct("FolderSharingInfo", FOLDER_SHARING_INFO_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for FolderSharingInfo {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("FolderSharingInfo", 5)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct GetCopyReferenceArg {
pub path: ReadPath,
}
impl GetCopyReferenceArg {
pub fn new(path: ReadPath) -> Self {
GetCopyReferenceArg {
path,
}
}
}
const GET_COPY_REFERENCE_ARG_FIELDS: &[&str] = &["path"];
impl GetCopyReferenceArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<GetCopyReferenceArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<GetCopyReferenceArg>, V::Error> {
let mut field_path = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = GetCopyReferenceArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetCopyReferenceArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetCopyReferenceArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetCopyReferenceArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetCopyReferenceArg", GET_COPY_REFERENCE_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetCopyReferenceArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetCopyReferenceArg", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum GetCopyReferenceError {
Path(LookupError),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = GetCopyReferenceError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetCopyReferenceError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => GetCopyReferenceError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => GetCopyReferenceError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"other"];
deserializer.deserialize_struct("GetCopyReferenceError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for GetCopyReferenceError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
GetCopyReferenceError::Path(ref x) => {
let mut s = serializer.serialize_struct("GetCopyReferenceError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
GetCopyReferenceError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for GetCopyReferenceError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
GetCopyReferenceError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for GetCopyReferenceError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
GetCopyReferenceError::Path(inner) => write!(f, "{}", inner),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct GetCopyReferenceResult {
pub metadata: Metadata,
pub copy_reference: String,
pub expires: crate::common::DropboxTimestamp,
}
impl GetCopyReferenceResult {
pub fn new(
metadata: Metadata,
copy_reference: String,
expires: crate::common::DropboxTimestamp,
) -> Self {
GetCopyReferenceResult {
metadata,
copy_reference,
expires,
}
}
}
const GET_COPY_REFERENCE_RESULT_FIELDS: &[&str] = &["metadata",
"copy_reference",
"expires"];
impl GetCopyReferenceResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<GetCopyReferenceResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<GetCopyReferenceResult>, V::Error> {
let mut field_metadata = None;
let mut field_copy_reference = None;
let mut field_expires = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
"copy_reference" => {
if field_copy_reference.is_some() {
return Err(::serde::de::Error::duplicate_field("copy_reference"));
}
field_copy_reference = Some(map.next_value()?);
}
"expires" => {
if field_expires.is_some() {
return Err(::serde::de::Error::duplicate_field("expires"));
}
field_expires = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = GetCopyReferenceResult {
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
copy_reference: field_copy_reference.ok_or_else(|| ::serde::de::Error::missing_field("copy_reference"))?,
expires: field_expires.ok_or_else(|| ::serde::de::Error::missing_field("expires"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("metadata", &self.metadata)?;
s.serialize_field("copy_reference", &self.copy_reference)?;
s.serialize_field("expires", &self.expires)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetCopyReferenceResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetCopyReferenceResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetCopyReferenceResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetCopyReferenceResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetCopyReferenceResult", GET_COPY_REFERENCE_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetCopyReferenceResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetCopyReferenceResult", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct GetMetadataArg {
pub path: ReadPath,
pub include_media_info: bool,
pub include_deleted: bool,
pub include_has_explicit_shared_members: bool,
pub include_property_groups: Option<crate::file_properties::TemplateFilterBase>,
}
impl GetMetadataArg {
pub fn new(path: ReadPath) -> Self {
GetMetadataArg {
path,
include_media_info: false,
include_deleted: false,
include_has_explicit_shared_members: false,
include_property_groups: None,
}
}
pub fn with_include_media_info(mut self, value: bool) -> Self {
self.include_media_info = value;
self
}
pub fn with_include_deleted(mut self, value: bool) -> Self {
self.include_deleted = value;
self
}
pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
self.include_has_explicit_shared_members = value;
self
}
pub fn with_include_property_groups(
mut self,
value: crate::file_properties::TemplateFilterBase,
) -> Self {
self.include_property_groups = Some(value);
self
}
}
const GET_METADATA_ARG_FIELDS: &[&str] = &["path",
"include_media_info",
"include_deleted",
"include_has_explicit_shared_members",
"include_property_groups"];
impl GetMetadataArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<GetMetadataArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<GetMetadataArg>, V::Error> {
let mut field_path = None;
let mut field_include_media_info = None;
let mut field_include_deleted = None;
let mut field_include_has_explicit_shared_members = None;
let mut field_include_property_groups = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"include_media_info" => {
if field_include_media_info.is_some() {
return Err(::serde::de::Error::duplicate_field("include_media_info"));
}
field_include_media_info = Some(map.next_value()?);
}
"include_deleted" => {
if field_include_deleted.is_some() {
return Err(::serde::de::Error::duplicate_field("include_deleted"));
}
field_include_deleted = Some(map.next_value()?);
}
"include_has_explicit_shared_members" => {
if field_include_has_explicit_shared_members.is_some() {
return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
}
field_include_has_explicit_shared_members = Some(map.next_value()?);
}
"include_property_groups" => {
if field_include_property_groups.is_some() {
return Err(::serde::de::Error::duplicate_field("include_property_groups"));
}
field_include_property_groups = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = GetMetadataArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
include_media_info: field_include_media_info.unwrap_or(false),
include_deleted: field_include_deleted.unwrap_or(false),
include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
include_property_groups: field_include_property_groups,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("include_media_info", &self.include_media_info)?;
s.serialize_field("include_deleted", &self.include_deleted)?;
s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
if let Some(val) = &self.include_property_groups {
s.serialize_field("include_property_groups", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetMetadataArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetMetadataArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetMetadataArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetMetadataArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetMetadataArg", GET_METADATA_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetMetadataArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetMetadataArg", 5)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum GetMetadataError {
Path(LookupError),
}
impl<'de> ::serde::de::Deserialize<'de> for GetMetadataError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = GetMetadataError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetMetadataError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => GetMetadataError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path"];
deserializer.deserialize_struct("GetMetadataError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for GetMetadataError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
GetMetadataError::Path(ref x) => {
let mut s = serializer.serialize_struct("GetMetadataError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
}
}
}
impl ::std::error::Error for GetMetadataError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
GetMetadataError::Path(inner) => Some(inner),
}
}
}
impl ::std::fmt::Display for GetMetadataError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
GetMetadataError::Path(inner) => write!(f, "{}", inner),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct GetTagsArg {
pub paths: Vec<Path>,
}
impl GetTagsArg {
pub fn new(paths: Vec<Path>) -> Self {
GetTagsArg {
paths,
}
}
}
const GET_TAGS_ARG_FIELDS: &[&str] = &["paths"];
impl GetTagsArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<GetTagsArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<GetTagsArg>, V::Error> {
let mut field_paths = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"paths" => {
if field_paths.is_some() {
return Err(::serde::de::Error::duplicate_field("paths"));
}
field_paths = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = GetTagsArg {
paths: field_paths.ok_or_else(|| ::serde::de::Error::missing_field("paths"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("paths", &self.paths)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetTagsArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetTagsArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetTagsArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetTagsArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetTagsArg", GET_TAGS_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetTagsArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetTagsArg", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct GetTagsResult {
pub paths_to_tags: Vec<PathToTags>,
}
impl GetTagsResult {
pub fn new(paths_to_tags: Vec<PathToTags>) -> Self {
GetTagsResult {
paths_to_tags,
}
}
}
const GET_TAGS_RESULT_FIELDS: &[&str] = &["paths_to_tags"];
impl GetTagsResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<GetTagsResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<GetTagsResult>, V::Error> {
let mut field_paths_to_tags = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"paths_to_tags" => {
if field_paths_to_tags.is_some() {
return Err(::serde::de::Error::duplicate_field("paths_to_tags"));
}
field_paths_to_tags = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = GetTagsResult {
paths_to_tags: field_paths_to_tags.ok_or_else(|| ::serde::de::Error::missing_field("paths_to_tags"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("paths_to_tags", &self.paths_to_tags)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetTagsResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetTagsResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetTagsResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetTagsResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetTagsResult", GET_TAGS_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetTagsResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetTagsResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct GetTemporaryLinkArg {
pub path: ReadPath,
}
impl GetTemporaryLinkArg {
pub fn new(path: ReadPath) -> Self {
GetTemporaryLinkArg {
path,
}
}
}
const GET_TEMPORARY_LINK_ARG_FIELDS: &[&str] = &["path"];
impl GetTemporaryLinkArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<GetTemporaryLinkArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<GetTemporaryLinkArg>, V::Error> {
let mut field_path = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = GetTemporaryLinkArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetTemporaryLinkArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetTemporaryLinkArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetTemporaryLinkArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetTemporaryLinkArg", GET_TEMPORARY_LINK_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetTemporaryLinkArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetTemporaryLinkArg", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum GetTemporaryLinkError {
Path(LookupError),
EmailNotVerified,
UnsupportedFile,
NotAllowed,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = GetTemporaryLinkError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetTemporaryLinkError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => GetTemporaryLinkError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"email_not_verified" => GetTemporaryLinkError::EmailNotVerified,
"unsupported_file" => GetTemporaryLinkError::UnsupportedFile,
"not_allowed" => GetTemporaryLinkError::NotAllowed,
_ => GetTemporaryLinkError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"email_not_verified",
"unsupported_file",
"not_allowed",
"other"];
deserializer.deserialize_struct("GetTemporaryLinkError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for GetTemporaryLinkError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
GetTemporaryLinkError::Path(ref x) => {
let mut s = serializer.serialize_struct("GetTemporaryLinkError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
GetTemporaryLinkError::EmailNotVerified => {
let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
s.serialize_field(".tag", "email_not_verified")?;
s.end()
}
GetTemporaryLinkError::UnsupportedFile => {
let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
s.serialize_field(".tag", "unsupported_file")?;
s.end()
}
GetTemporaryLinkError::NotAllowed => {
let mut s = serializer.serialize_struct("GetTemporaryLinkError", 1)?;
s.serialize_field(".tag", "not_allowed")?;
s.end()
}
GetTemporaryLinkError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for GetTemporaryLinkError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
GetTemporaryLinkError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for GetTemporaryLinkError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
GetTemporaryLinkError::Path(inner) => write!(f, "{}", inner),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct GetTemporaryLinkResult {
pub metadata: FileMetadata,
pub link: String,
}
impl GetTemporaryLinkResult {
pub fn new(metadata: FileMetadata, link: String) -> Self {
GetTemporaryLinkResult {
metadata,
link,
}
}
}
const GET_TEMPORARY_LINK_RESULT_FIELDS: &[&str] = &["metadata",
"link"];
impl GetTemporaryLinkResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<GetTemporaryLinkResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<GetTemporaryLinkResult>, V::Error> {
let mut field_metadata = None;
let mut field_link = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
"link" => {
if field_link.is_some() {
return Err(::serde::de::Error::duplicate_field("link"));
}
field_link = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = GetTemporaryLinkResult {
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
link: field_link.ok_or_else(|| ::serde::de::Error::missing_field("link"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("metadata", &self.metadata)?;
s.serialize_field("link", &self.link)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryLinkResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetTemporaryLinkResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetTemporaryLinkResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetTemporaryLinkResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetTemporaryLinkResult", GET_TEMPORARY_LINK_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetTemporaryLinkResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetTemporaryLinkResult", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct GetTemporaryUploadLinkArg {
pub commit_info: CommitInfo,
pub duration: f64,
}
impl GetTemporaryUploadLinkArg {
pub fn new(commit_info: CommitInfo) -> Self {
GetTemporaryUploadLinkArg {
commit_info,
duration: 14400.0,
}
}
pub fn with_duration(mut self, value: f64) -> Self {
self.duration = value;
self
}
}
const GET_TEMPORARY_UPLOAD_LINK_ARG_FIELDS: &[&str] = &["commit_info",
"duration"];
impl GetTemporaryUploadLinkArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<GetTemporaryUploadLinkArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<GetTemporaryUploadLinkArg>, V::Error> {
let mut field_commit_info = None;
let mut field_duration = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"commit_info" => {
if field_commit_info.is_some() {
return Err(::serde::de::Error::duplicate_field("commit_info"));
}
field_commit_info = Some(map.next_value()?);
}
"duration" => {
if field_duration.is_some() {
return Err(::serde::de::Error::duplicate_field("duration"));
}
field_duration = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = GetTemporaryUploadLinkArg {
commit_info: field_commit_info.ok_or_else(|| ::serde::de::Error::missing_field("commit_info"))?,
duration: field_duration.unwrap_or(14400.0),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("commit_info", &self.commit_info)?;
s.serialize_field("duration", &self.duration)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryUploadLinkArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetTemporaryUploadLinkArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetTemporaryUploadLinkArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetTemporaryUploadLinkArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetTemporaryUploadLinkArg", GET_TEMPORARY_UPLOAD_LINK_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetTemporaryUploadLinkArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetTemporaryUploadLinkArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct GetTemporaryUploadLinkResult {
pub link: String,
}
impl GetTemporaryUploadLinkResult {
pub fn new(link: String) -> Self {
GetTemporaryUploadLinkResult {
link,
}
}
}
const GET_TEMPORARY_UPLOAD_LINK_RESULT_FIELDS: &[&str] = &["link"];
impl GetTemporaryUploadLinkResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<GetTemporaryUploadLinkResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<GetTemporaryUploadLinkResult>, V::Error> {
let mut field_link = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"link" => {
if field_link.is_some() {
return Err(::serde::de::Error::duplicate_field("link"));
}
field_link = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = GetTemporaryUploadLinkResult {
link: field_link.ok_or_else(|| ::serde::de::Error::missing_field("link"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("link", &self.link)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetTemporaryUploadLinkResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetTemporaryUploadLinkResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetTemporaryUploadLinkResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetTemporaryUploadLinkResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetTemporaryUploadLinkResult", GET_TEMPORARY_UPLOAD_LINK_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetTemporaryUploadLinkResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetTemporaryUploadLinkResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct GetThumbnailBatchArg {
pub entries: Vec<ThumbnailArg>,
}
impl GetThumbnailBatchArg {
pub fn new(entries: Vec<ThumbnailArg>) -> Self {
GetThumbnailBatchArg {
entries,
}
}
}
const GET_THUMBNAIL_BATCH_ARG_FIELDS: &[&str] = &["entries"];
impl GetThumbnailBatchArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<GetThumbnailBatchArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<GetThumbnailBatchArg>, V::Error> {
let mut field_entries = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = GetThumbnailBatchArg {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetThumbnailBatchArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetThumbnailBatchArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetThumbnailBatchArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetThumbnailBatchArg", GET_THUMBNAIL_BATCH_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetThumbnailBatchArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetThumbnailBatchArg", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum GetThumbnailBatchError {
TooManyFiles,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = GetThumbnailBatchError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetThumbnailBatchError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"too_many_files" => GetThumbnailBatchError::TooManyFiles,
_ => GetThumbnailBatchError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["too_many_files",
"other"];
deserializer.deserialize_struct("GetThumbnailBatchError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for GetThumbnailBatchError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
GetThumbnailBatchError::TooManyFiles => {
let mut s = serializer.serialize_struct("GetThumbnailBatchError", 1)?;
s.serialize_field(".tag", "too_many_files")?;
s.end()
}
GetThumbnailBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for GetThumbnailBatchError {
}
impl ::std::fmt::Display for GetThumbnailBatchError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
GetThumbnailBatchError::TooManyFiles => f.write_str("The operation involves more than 25 files."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct GetThumbnailBatchResult {
pub entries: Vec<GetThumbnailBatchResultEntry>,
}
impl GetThumbnailBatchResult {
pub fn new(entries: Vec<GetThumbnailBatchResultEntry>) -> Self {
GetThumbnailBatchResult {
entries,
}
}
}
const GET_THUMBNAIL_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
impl GetThumbnailBatchResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<GetThumbnailBatchResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<GetThumbnailBatchResult>, V::Error> {
let mut field_entries = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = GetThumbnailBatchResult {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetThumbnailBatchResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetThumbnailBatchResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetThumbnailBatchResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetThumbnailBatchResult", GET_THUMBNAIL_BATCH_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetThumbnailBatchResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetThumbnailBatchResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct GetThumbnailBatchResultData {
pub metadata: FileMetadata,
pub thumbnail: String,
}
impl GetThumbnailBatchResultData {
pub fn new(metadata: FileMetadata, thumbnail: String) -> Self {
GetThumbnailBatchResultData {
metadata,
thumbnail,
}
}
}
const GET_THUMBNAIL_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata",
"thumbnail"];
impl GetThumbnailBatchResultData {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<GetThumbnailBatchResultData, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<GetThumbnailBatchResultData>, V::Error> {
let mut field_metadata = None;
let mut field_thumbnail = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
"thumbnail" => {
if field_thumbnail.is_some() {
return Err(::serde::de::Error::duplicate_field("thumbnail"));
}
field_thumbnail = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = GetThumbnailBatchResultData {
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
thumbnail: field_thumbnail.ok_or_else(|| ::serde::de::Error::missing_field("thumbnail"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("metadata", &self.metadata)?;
s.serialize_field("thumbnail", &self.thumbnail)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResultData {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GetThumbnailBatchResultData;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetThumbnailBatchResultData struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GetThumbnailBatchResultData::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GetThumbnailBatchResultData", GET_THUMBNAIL_BATCH_RESULT_DATA_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GetThumbnailBatchResultData {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GetThumbnailBatchResultData", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub enum GetThumbnailBatchResultEntry {
Success(GetThumbnailBatchResultData),
Failure(ThumbnailError),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for GetThumbnailBatchResultEntry {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = GetThumbnailBatchResultEntry;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GetThumbnailBatchResultEntry structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"success" => GetThumbnailBatchResultEntry::Success(GetThumbnailBatchResultData::internal_deserialize(&mut map)?),
"failure" => {
match map.next_key()? {
Some("failure") => GetThumbnailBatchResultEntry::Failure(map.next_value()?),
None => return Err(de::Error::missing_field("failure")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => GetThumbnailBatchResultEntry::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["success",
"failure",
"other"];
deserializer.deserialize_struct("GetThumbnailBatchResultEntry", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for GetThumbnailBatchResultEntry {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
GetThumbnailBatchResultEntry::Success(ref x) => {
let mut s = serializer.serialize_struct("GetThumbnailBatchResultEntry", 3)?;
s.serialize_field(".tag", "success")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
GetThumbnailBatchResultEntry::Failure(ref x) => {
let mut s = serializer.serialize_struct("GetThumbnailBatchResultEntry", 2)?;
s.serialize_field(".tag", "failure")?;
s.serialize_field("failure", x)?;
s.end()
}
GetThumbnailBatchResultEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct GpsCoordinates {
pub latitude: f64,
pub longitude: f64,
}
impl GpsCoordinates {
pub fn new(latitude: f64, longitude: f64) -> Self {
GpsCoordinates {
latitude,
longitude,
}
}
}
const GPS_COORDINATES_FIELDS: &[&str] = &["latitude",
"longitude"];
impl GpsCoordinates {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<GpsCoordinates, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<GpsCoordinates>, V::Error> {
let mut field_latitude = None;
let mut field_longitude = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"latitude" => {
if field_latitude.is_some() {
return Err(::serde::de::Error::duplicate_field("latitude"));
}
field_latitude = Some(map.next_value()?);
}
"longitude" => {
if field_longitude.is_some() {
return Err(::serde::de::Error::duplicate_field("longitude"));
}
field_longitude = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = GpsCoordinates {
latitude: field_latitude.ok_or_else(|| ::serde::de::Error::missing_field("latitude"))?,
longitude: field_longitude.ok_or_else(|| ::serde::de::Error::missing_field("longitude"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("latitude", &self.latitude)?;
s.serialize_field("longitude", &self.longitude)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for GpsCoordinates {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = GpsCoordinates;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a GpsCoordinates struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
GpsCoordinates::internal_deserialize(map)
}
}
deserializer.deserialize_struct("GpsCoordinates", GPS_COORDINATES_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for GpsCoordinates {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("GpsCoordinates", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct HighlightSpan {
pub highlight_str: String,
pub is_highlighted: bool,
}
impl HighlightSpan {
pub fn new(highlight_str: String, is_highlighted: bool) -> Self {
HighlightSpan {
highlight_str,
is_highlighted,
}
}
}
const HIGHLIGHT_SPAN_FIELDS: &[&str] = &["highlight_str",
"is_highlighted"];
impl HighlightSpan {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<HighlightSpan, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<HighlightSpan>, V::Error> {
let mut field_highlight_str = None;
let mut field_is_highlighted = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"highlight_str" => {
if field_highlight_str.is_some() {
return Err(::serde::de::Error::duplicate_field("highlight_str"));
}
field_highlight_str = Some(map.next_value()?);
}
"is_highlighted" => {
if field_is_highlighted.is_some() {
return Err(::serde::de::Error::duplicate_field("is_highlighted"));
}
field_is_highlighted = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = HighlightSpan {
highlight_str: field_highlight_str.ok_or_else(|| ::serde::de::Error::missing_field("highlight_str"))?,
is_highlighted: field_is_highlighted.ok_or_else(|| ::serde::de::Error::missing_field("is_highlighted"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("highlight_str", &self.highlight_str)?;
s.serialize_field("is_highlighted", &self.is_highlighted)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for HighlightSpan {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = HighlightSpan;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a HighlightSpan struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
HighlightSpan::internal_deserialize(map)
}
}
deserializer.deserialize_struct("HighlightSpan", HIGHLIGHT_SPAN_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for HighlightSpan {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("HighlightSpan", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum ImportFormat {
Html,
Markdown,
PlainText,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for ImportFormat {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ImportFormat;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ImportFormat structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"html" => ImportFormat::Html,
"markdown" => ImportFormat::Markdown,
"plain_text" => ImportFormat::PlainText,
_ => ImportFormat::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["html",
"markdown",
"plain_text",
"other"];
deserializer.deserialize_struct("ImportFormat", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ImportFormat {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
ImportFormat::Html => {
let mut s = serializer.serialize_struct("ImportFormat", 1)?;
s.serialize_field(".tag", "html")?;
s.end()
}
ImportFormat::Markdown => {
let mut s = serializer.serialize_struct("ImportFormat", 1)?;
s.serialize_field(".tag", "markdown")?;
s.end()
}
ImportFormat::PlainText => {
let mut s = serializer.serialize_struct("ImportFormat", 1)?;
s.serialize_field(".tag", "plain_text")?;
s.end()
}
ImportFormat::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct ListFolderArg {
pub path: PathROrId,
pub recursive: bool,
pub include_media_info: bool,
pub include_deleted: bool,
pub include_has_explicit_shared_members: bool,
pub include_mounted_folders: bool,
pub limit: Option<u32>,
pub shared_link: Option<SharedLink>,
pub include_property_groups: Option<crate::file_properties::TemplateFilterBase>,
pub include_non_downloadable_files: bool,
}
impl ListFolderArg {
pub fn new(path: PathROrId) -> Self {
ListFolderArg {
path,
recursive: false,
include_media_info: false,
include_deleted: false,
include_has_explicit_shared_members: false,
include_mounted_folders: true,
limit: None,
shared_link: None,
include_property_groups: None,
include_non_downloadable_files: true,
}
}
pub fn with_recursive(mut self, value: bool) -> Self {
self.recursive = value;
self
}
pub fn with_include_media_info(mut self, value: bool) -> Self {
self.include_media_info = value;
self
}
pub fn with_include_deleted(mut self, value: bool) -> Self {
self.include_deleted = value;
self
}
pub fn with_include_has_explicit_shared_members(mut self, value: bool) -> Self {
self.include_has_explicit_shared_members = value;
self
}
pub fn with_include_mounted_folders(mut self, value: bool) -> Self {
self.include_mounted_folders = value;
self
}
pub fn with_limit(mut self, value: u32) -> Self {
self.limit = Some(value);
self
}
pub fn with_shared_link(mut self, value: SharedLink) -> Self {
self.shared_link = Some(value);
self
}
pub fn with_include_property_groups(
mut self,
value: crate::file_properties::TemplateFilterBase,
) -> Self {
self.include_property_groups = Some(value);
self
}
pub fn with_include_non_downloadable_files(mut self, value: bool) -> Self {
self.include_non_downloadable_files = value;
self
}
}
const LIST_FOLDER_ARG_FIELDS: &[&str] = &["path",
"recursive",
"include_media_info",
"include_deleted",
"include_has_explicit_shared_members",
"include_mounted_folders",
"limit",
"shared_link",
"include_property_groups",
"include_non_downloadable_files"];
impl ListFolderArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ListFolderArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ListFolderArg>, V::Error> {
let mut field_path = None;
let mut field_recursive = None;
let mut field_include_media_info = None;
let mut field_include_deleted = None;
let mut field_include_has_explicit_shared_members = None;
let mut field_include_mounted_folders = None;
let mut field_limit = None;
let mut field_shared_link = None;
let mut field_include_property_groups = None;
let mut field_include_non_downloadable_files = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"recursive" => {
if field_recursive.is_some() {
return Err(::serde::de::Error::duplicate_field("recursive"));
}
field_recursive = Some(map.next_value()?);
}
"include_media_info" => {
if field_include_media_info.is_some() {
return Err(::serde::de::Error::duplicate_field("include_media_info"));
}
field_include_media_info = Some(map.next_value()?);
}
"include_deleted" => {
if field_include_deleted.is_some() {
return Err(::serde::de::Error::duplicate_field("include_deleted"));
}
field_include_deleted = Some(map.next_value()?);
}
"include_has_explicit_shared_members" => {
if field_include_has_explicit_shared_members.is_some() {
return Err(::serde::de::Error::duplicate_field("include_has_explicit_shared_members"));
}
field_include_has_explicit_shared_members = Some(map.next_value()?);
}
"include_mounted_folders" => {
if field_include_mounted_folders.is_some() {
return Err(::serde::de::Error::duplicate_field("include_mounted_folders"));
}
field_include_mounted_folders = Some(map.next_value()?);
}
"limit" => {
if field_limit.is_some() {
return Err(::serde::de::Error::duplicate_field("limit"));
}
field_limit = Some(map.next_value()?);
}
"shared_link" => {
if field_shared_link.is_some() {
return Err(::serde::de::Error::duplicate_field("shared_link"));
}
field_shared_link = Some(map.next_value()?);
}
"include_property_groups" => {
if field_include_property_groups.is_some() {
return Err(::serde::de::Error::duplicate_field("include_property_groups"));
}
field_include_property_groups = Some(map.next_value()?);
}
"include_non_downloadable_files" => {
if field_include_non_downloadable_files.is_some() {
return Err(::serde::de::Error::duplicate_field("include_non_downloadable_files"));
}
field_include_non_downloadable_files = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ListFolderArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
recursive: field_recursive.unwrap_or(false),
include_media_info: field_include_media_info.unwrap_or(false),
include_deleted: field_include_deleted.unwrap_or(false),
include_has_explicit_shared_members: field_include_has_explicit_shared_members.unwrap_or(false),
include_mounted_folders: field_include_mounted_folders.unwrap_or(true),
limit: field_limit,
shared_link: field_shared_link,
include_property_groups: field_include_property_groups,
include_non_downloadable_files: field_include_non_downloadable_files.unwrap_or(true),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("recursive", &self.recursive)?;
s.serialize_field("include_media_info", &self.include_media_info)?;
s.serialize_field("include_deleted", &self.include_deleted)?;
s.serialize_field("include_has_explicit_shared_members", &self.include_has_explicit_shared_members)?;
s.serialize_field("include_mounted_folders", &self.include_mounted_folders)?;
if let Some(val) = &self.limit {
s.serialize_field("limit", val)?;
}
if let Some(val) = &self.shared_link {
s.serialize_field("shared_link", val)?;
}
if let Some(val) = &self.include_property_groups {
s.serialize_field("include_property_groups", val)?;
}
s.serialize_field("include_non_downloadable_files", &self.include_non_downloadable_files)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ListFolderArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ListFolderArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ListFolderArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ListFolderArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ListFolderArg", LIST_FOLDER_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ListFolderArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ListFolderArg", 10)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct ListFolderContinueArg {
pub cursor: ListFolderCursor,
}
impl ListFolderContinueArg {
pub fn new(cursor: ListFolderCursor) -> Self {
ListFolderContinueArg {
cursor,
}
}
}
const LIST_FOLDER_CONTINUE_ARG_FIELDS: &[&str] = &["cursor"];
impl ListFolderContinueArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ListFolderContinueArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ListFolderContinueArg>, V::Error> {
let mut field_cursor = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"cursor" => {
if field_cursor.is_some() {
return Err(::serde::de::Error::duplicate_field("cursor"));
}
field_cursor = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ListFolderContinueArg {
cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("cursor", &self.cursor)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ListFolderContinueArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ListFolderContinueArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ListFolderContinueArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ListFolderContinueArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ListFolderContinueArg", LIST_FOLDER_CONTINUE_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ListFolderContinueArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ListFolderContinueArg", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum ListFolderContinueError {
Path(LookupError),
Reset,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for ListFolderContinueError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ListFolderContinueError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ListFolderContinueError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => ListFolderContinueError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"reset" => ListFolderContinueError::Reset,
_ => ListFolderContinueError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"reset",
"other"];
deserializer.deserialize_struct("ListFolderContinueError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ListFolderContinueError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
ListFolderContinueError::Path(ref x) => {
let mut s = serializer.serialize_struct("ListFolderContinueError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
ListFolderContinueError::Reset => {
let mut s = serializer.serialize_struct("ListFolderContinueError", 1)?;
s.serialize_field(".tag", "reset")?;
s.end()
}
ListFolderContinueError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for ListFolderContinueError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
ListFolderContinueError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for ListFolderContinueError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
ListFolderContinueError::Path(inner) => write!(f, "{}", inner),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum ListFolderError {
Path(LookupError),
TemplateError(crate::file_properties::TemplateError),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for ListFolderError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ListFolderError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ListFolderError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => ListFolderError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"template_error" => {
match map.next_key()? {
Some("template_error") => ListFolderError::TemplateError(map.next_value()?),
None => return Err(de::Error::missing_field("template_error")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => ListFolderError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"template_error",
"other"];
deserializer.deserialize_struct("ListFolderError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ListFolderError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
ListFolderError::Path(ref x) => {
let mut s = serializer.serialize_struct("ListFolderError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
ListFolderError::TemplateError(ref x) => {
let mut s = serializer.serialize_struct("ListFolderError", 2)?;
s.serialize_field(".tag", "template_error")?;
s.serialize_field("template_error", x)?;
s.end()
}
ListFolderError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for ListFolderError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
ListFolderError::Path(inner) => Some(inner),
ListFolderError::TemplateError(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for ListFolderError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
ListFolderError::Path(inner) => write!(f, "{}", inner),
ListFolderError::TemplateError(inner) => write!(f, "{}", inner),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct ListFolderGetLatestCursorResult {
pub cursor: ListFolderCursor,
}
impl ListFolderGetLatestCursorResult {
pub fn new(cursor: ListFolderCursor) -> Self {
ListFolderGetLatestCursorResult {
cursor,
}
}
}
const LIST_FOLDER_GET_LATEST_CURSOR_RESULT_FIELDS: &[&str] = &["cursor"];
impl ListFolderGetLatestCursorResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ListFolderGetLatestCursorResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ListFolderGetLatestCursorResult>, V::Error> {
let mut field_cursor = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"cursor" => {
if field_cursor.is_some() {
return Err(::serde::de::Error::duplicate_field("cursor"));
}
field_cursor = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ListFolderGetLatestCursorResult {
cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("cursor", &self.cursor)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ListFolderGetLatestCursorResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ListFolderGetLatestCursorResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ListFolderGetLatestCursorResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ListFolderGetLatestCursorResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ListFolderGetLatestCursorResult", LIST_FOLDER_GET_LATEST_CURSOR_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ListFolderGetLatestCursorResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ListFolderGetLatestCursorResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct ListFolderLongpollArg {
pub cursor: ListFolderCursor,
pub timeout: u64,
}
impl ListFolderLongpollArg {
pub fn new(cursor: ListFolderCursor) -> Self {
ListFolderLongpollArg {
cursor,
timeout: 30,
}
}
pub fn with_timeout(mut self, value: u64) -> Self {
self.timeout = value;
self
}
}
const LIST_FOLDER_LONGPOLL_ARG_FIELDS: &[&str] = &["cursor",
"timeout"];
impl ListFolderLongpollArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ListFolderLongpollArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ListFolderLongpollArg>, V::Error> {
let mut field_cursor = None;
let mut field_timeout = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"cursor" => {
if field_cursor.is_some() {
return Err(::serde::de::Error::duplicate_field("cursor"));
}
field_cursor = Some(map.next_value()?);
}
"timeout" => {
if field_timeout.is_some() {
return Err(::serde::de::Error::duplicate_field("timeout"));
}
field_timeout = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ListFolderLongpollArg {
cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
timeout: field_timeout.unwrap_or(30),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("cursor", &self.cursor)?;
s.serialize_field("timeout", &self.timeout)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ListFolderLongpollArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ListFolderLongpollArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ListFolderLongpollArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ListFolderLongpollArg", LIST_FOLDER_LONGPOLL_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ListFolderLongpollArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ListFolderLongpollArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum ListFolderLongpollError {
Reset,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ListFolderLongpollError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ListFolderLongpollError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"reset" => ListFolderLongpollError::Reset,
_ => ListFolderLongpollError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["reset",
"other"];
deserializer.deserialize_struct("ListFolderLongpollError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ListFolderLongpollError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
ListFolderLongpollError::Reset => {
let mut s = serializer.serialize_struct("ListFolderLongpollError", 1)?;
s.serialize_field(".tag", "reset")?;
s.end()
}
ListFolderLongpollError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for ListFolderLongpollError {
}
impl ::std::fmt::Display for ListFolderLongpollError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
write!(f, "{:?}", *self)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct ListFolderLongpollResult {
pub changes: bool,
pub backoff: Option<u64>,
}
impl ListFolderLongpollResult {
pub fn new(changes: bool) -> Self {
ListFolderLongpollResult {
changes,
backoff: None,
}
}
pub fn with_backoff(mut self, value: u64) -> Self {
self.backoff = Some(value);
self
}
}
const LIST_FOLDER_LONGPOLL_RESULT_FIELDS: &[&str] = &["changes",
"backoff"];
impl ListFolderLongpollResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ListFolderLongpollResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ListFolderLongpollResult>, V::Error> {
let mut field_changes = None;
let mut field_backoff = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"changes" => {
if field_changes.is_some() {
return Err(::serde::de::Error::duplicate_field("changes"));
}
field_changes = Some(map.next_value()?);
}
"backoff" => {
if field_backoff.is_some() {
return Err(::serde::de::Error::duplicate_field("backoff"));
}
field_backoff = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ListFolderLongpollResult {
changes: field_changes.ok_or_else(|| ::serde::de::Error::missing_field("changes"))?,
backoff: field_backoff,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("changes", &self.changes)?;
if let Some(val) = &self.backoff {
s.serialize_field("backoff", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ListFolderLongpollResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ListFolderLongpollResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ListFolderLongpollResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ListFolderLongpollResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ListFolderLongpollResult", LIST_FOLDER_LONGPOLL_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ListFolderLongpollResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ListFolderLongpollResult", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct ListFolderResult {
pub entries: Vec<Metadata>,
pub cursor: ListFolderCursor,
pub has_more: bool,
}
impl ListFolderResult {
pub fn new(entries: Vec<Metadata>, cursor: ListFolderCursor, has_more: bool) -> Self {
ListFolderResult {
entries,
cursor,
has_more,
}
}
}
const LIST_FOLDER_RESULT_FIELDS: &[&str] = &["entries",
"cursor",
"has_more"];
impl ListFolderResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ListFolderResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ListFolderResult>, V::Error> {
let mut field_entries = None;
let mut field_cursor = None;
let mut field_has_more = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
"cursor" => {
if field_cursor.is_some() {
return Err(::serde::de::Error::duplicate_field("cursor"));
}
field_cursor = Some(map.next_value()?);
}
"has_more" => {
if field_has_more.is_some() {
return Err(::serde::de::Error::duplicate_field("has_more"));
}
field_has_more = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ListFolderResult {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
has_more: field_has_more.ok_or_else(|| ::serde::de::Error::missing_field("has_more"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
s.serialize_field("cursor", &self.cursor)?;
s.serialize_field("has_more", &self.has_more)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ListFolderResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ListFolderResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ListFolderResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ListFolderResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ListFolderResult", LIST_FOLDER_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ListFolderResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ListFolderResult", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct ListRevisionsArg {
pub path: PathOrId,
pub mode: ListRevisionsMode,
pub limit: u64,
}
impl ListRevisionsArg {
pub fn new(path: PathOrId) -> Self {
ListRevisionsArg {
path,
mode: ListRevisionsMode::Path,
limit: 10,
}
}
pub fn with_mode(mut self, value: ListRevisionsMode) -> Self {
self.mode = value;
self
}
pub fn with_limit(mut self, value: u64) -> Self {
self.limit = value;
self
}
}
const LIST_REVISIONS_ARG_FIELDS: &[&str] = &["path",
"mode",
"limit"];
impl ListRevisionsArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ListRevisionsArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ListRevisionsArg>, V::Error> {
let mut field_path = None;
let mut field_mode = None;
let mut field_limit = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"mode" => {
if field_mode.is_some() {
return Err(::serde::de::Error::duplicate_field("mode"));
}
field_mode = Some(map.next_value()?);
}
"limit" => {
if field_limit.is_some() {
return Err(::serde::de::Error::duplicate_field("limit"));
}
field_limit = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ListRevisionsArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
mode: field_mode.unwrap_or(ListRevisionsMode::Path),
limit: field_limit.unwrap_or(10),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("mode", &self.mode)?;
s.serialize_field("limit", &self.limit)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ListRevisionsArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ListRevisionsArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ListRevisionsArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ListRevisionsArg", LIST_REVISIONS_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ListRevisionsArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ListRevisionsArg", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum ListRevisionsError {
Path(LookupError),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ListRevisionsError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ListRevisionsError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => ListRevisionsError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => ListRevisionsError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"other"];
deserializer.deserialize_struct("ListRevisionsError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ListRevisionsError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
ListRevisionsError::Path(ref x) => {
let mut s = serializer.serialize_struct("ListRevisionsError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
ListRevisionsError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for ListRevisionsError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
ListRevisionsError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for ListRevisionsError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
ListRevisionsError::Path(inner) => write!(f, "{}", inner),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum ListRevisionsMode {
Path,
Id,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsMode {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ListRevisionsMode;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ListRevisionsMode structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => ListRevisionsMode::Path,
"id" => ListRevisionsMode::Id,
_ => ListRevisionsMode::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"id",
"other"];
deserializer.deserialize_struct("ListRevisionsMode", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ListRevisionsMode {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
ListRevisionsMode::Path => {
let mut s = serializer.serialize_struct("ListRevisionsMode", 1)?;
s.serialize_field(".tag", "path")?;
s.end()
}
ListRevisionsMode::Id => {
let mut s = serializer.serialize_struct("ListRevisionsMode", 1)?;
s.serialize_field(".tag", "id")?;
s.end()
}
ListRevisionsMode::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct ListRevisionsResult {
pub is_deleted: bool,
pub entries: Vec<FileMetadata>,
pub server_deleted: Option<crate::common::DropboxTimestamp>,
}
impl ListRevisionsResult {
pub fn new(is_deleted: bool, entries: Vec<FileMetadata>) -> Self {
ListRevisionsResult {
is_deleted,
entries,
server_deleted: None,
}
}
pub fn with_server_deleted(mut self, value: crate::common::DropboxTimestamp) -> Self {
self.server_deleted = Some(value);
self
}
}
const LIST_REVISIONS_RESULT_FIELDS: &[&str] = &["is_deleted",
"entries",
"server_deleted"];
impl ListRevisionsResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ListRevisionsResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ListRevisionsResult>, V::Error> {
let mut field_is_deleted = None;
let mut field_entries = None;
let mut field_server_deleted = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"is_deleted" => {
if field_is_deleted.is_some() {
return Err(::serde::de::Error::duplicate_field("is_deleted"));
}
field_is_deleted = Some(map.next_value()?);
}
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
"server_deleted" => {
if field_server_deleted.is_some() {
return Err(::serde::de::Error::duplicate_field("server_deleted"));
}
field_server_deleted = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ListRevisionsResult {
is_deleted: field_is_deleted.ok_or_else(|| ::serde::de::Error::missing_field("is_deleted"))?,
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
server_deleted: field_server_deleted,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("is_deleted", &self.is_deleted)?;
s.serialize_field("entries", &self.entries)?;
if let Some(val) = &self.server_deleted {
s.serialize_field("server_deleted", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ListRevisionsResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ListRevisionsResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ListRevisionsResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ListRevisionsResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ListRevisionsResult", LIST_REVISIONS_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ListRevisionsResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ListRevisionsResult", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct LockConflictError {
pub lock: FileLock,
}
impl LockConflictError {
pub fn new(lock: FileLock) -> Self {
LockConflictError {
lock,
}
}
}
const LOCK_CONFLICT_ERROR_FIELDS: &[&str] = &["lock"];
impl LockConflictError {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<LockConflictError, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<LockConflictError>, V::Error> {
let mut field_lock = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"lock" => {
if field_lock.is_some() {
return Err(::serde::de::Error::duplicate_field("lock"));
}
field_lock = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = LockConflictError {
lock: field_lock.ok_or_else(|| ::serde::de::Error::missing_field("lock"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("lock", &self.lock)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for LockConflictError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = LockConflictError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a LockConflictError struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
LockConflictError::internal_deserialize(map)
}
}
deserializer.deserialize_struct("LockConflictError", LOCK_CONFLICT_ERROR_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for LockConflictError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("LockConflictError", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct LockFileArg {
pub path: WritePathOrId,
}
impl LockFileArg {
pub fn new(path: WritePathOrId) -> Self {
LockFileArg {
path,
}
}
}
const LOCK_FILE_ARG_FIELDS: &[&str] = &["path"];
impl LockFileArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<LockFileArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<LockFileArg>, V::Error> {
let mut field_path = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = LockFileArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for LockFileArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = LockFileArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a LockFileArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
LockFileArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("LockFileArg", LOCK_FILE_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for LockFileArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("LockFileArg", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct LockFileBatchArg {
pub entries: Vec<LockFileArg>,
}
impl LockFileBatchArg {
pub fn new(entries: Vec<LockFileArg>) -> Self {
LockFileBatchArg {
entries,
}
}
}
const LOCK_FILE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
impl LockFileBatchArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<LockFileBatchArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<LockFileBatchArg>, V::Error> {
let mut field_entries = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = LockFileBatchArg {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for LockFileBatchArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = LockFileBatchArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a LockFileBatchArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
LockFileBatchArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("LockFileBatchArg", LOCK_FILE_BATCH_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for LockFileBatchArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("LockFileBatchArg", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct LockFileBatchResult {
pub entries: Vec<LockFileResultEntry>,
}
impl LockFileBatchResult {
pub fn new(entries: Vec<LockFileResultEntry>) -> Self {
LockFileBatchResult {
entries,
}
}
}
const LOCK_FILE_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
impl LockFileBatchResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<LockFileBatchResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<LockFileBatchResult>, V::Error> {
let mut field_entries = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = LockFileBatchResult {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for LockFileBatchResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = LockFileBatchResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a LockFileBatchResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
LockFileBatchResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("LockFileBatchResult", LOCK_FILE_BATCH_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for LockFileBatchResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("LockFileBatchResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum LockFileError {
PathLookup(LookupError),
TooManyWriteOperations,
TooManyFiles,
NoWritePermission,
CannotBeLocked,
FileNotShared,
LockConflict(LockConflictError),
InternalError,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for LockFileError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = LockFileError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a LockFileError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path_lookup" => {
match map.next_key()? {
Some("path_lookup") => LockFileError::PathLookup(map.next_value()?),
None => return Err(de::Error::missing_field("path_lookup")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"too_many_write_operations" => LockFileError::TooManyWriteOperations,
"too_many_files" => LockFileError::TooManyFiles,
"no_write_permission" => LockFileError::NoWritePermission,
"cannot_be_locked" => LockFileError::CannotBeLocked,
"file_not_shared" => LockFileError::FileNotShared,
"lock_conflict" => LockFileError::LockConflict(LockConflictError::internal_deserialize(&mut map)?),
"internal_error" => LockFileError::InternalError,
_ => LockFileError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path_lookup",
"too_many_write_operations",
"too_many_files",
"no_write_permission",
"cannot_be_locked",
"file_not_shared",
"lock_conflict",
"internal_error",
"other"];
deserializer.deserialize_struct("LockFileError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for LockFileError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
LockFileError::PathLookup(ref x) => {
let mut s = serializer.serialize_struct("LockFileError", 2)?;
s.serialize_field(".tag", "path_lookup")?;
s.serialize_field("path_lookup", x)?;
s.end()
}
LockFileError::TooManyWriteOperations => {
let mut s = serializer.serialize_struct("LockFileError", 1)?;
s.serialize_field(".tag", "too_many_write_operations")?;
s.end()
}
LockFileError::TooManyFiles => {
let mut s = serializer.serialize_struct("LockFileError", 1)?;
s.serialize_field(".tag", "too_many_files")?;
s.end()
}
LockFileError::NoWritePermission => {
let mut s = serializer.serialize_struct("LockFileError", 1)?;
s.serialize_field(".tag", "no_write_permission")?;
s.end()
}
LockFileError::CannotBeLocked => {
let mut s = serializer.serialize_struct("LockFileError", 1)?;
s.serialize_field(".tag", "cannot_be_locked")?;
s.end()
}
LockFileError::FileNotShared => {
let mut s = serializer.serialize_struct("LockFileError", 1)?;
s.serialize_field(".tag", "file_not_shared")?;
s.end()
}
LockFileError::LockConflict(ref x) => {
let mut s = serializer.serialize_struct("LockFileError", 2)?;
s.serialize_field(".tag", "lock_conflict")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
LockFileError::InternalError => {
let mut s = serializer.serialize_struct("LockFileError", 1)?;
s.serialize_field(".tag", "internal_error")?;
s.end()
}
LockFileError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for LockFileError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
LockFileError::PathLookup(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for LockFileError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
LockFileError::PathLookup(inner) => write!(f, "Could not find the specified resource: {}", inner),
LockFileError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
LockFileError::TooManyFiles => f.write_str("There are too many files in one request. Please retry with fewer files."),
LockFileError::NoWritePermission => f.write_str("The user does not have permissions to change the lock state or access the file."),
LockFileError::CannotBeLocked => f.write_str("Item is a type that cannot be locked."),
LockFileError::FileNotShared => f.write_str("Requested file is not currently shared."),
LockFileError::LockConflict(inner) => write!(f, "The user action conflicts with an existing lock on the file: {:?}", inner),
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."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct LockFileResult {
pub metadata: Metadata,
pub lock: FileLock,
}
impl LockFileResult {
pub fn new(metadata: Metadata, lock: FileLock) -> Self {
LockFileResult {
metadata,
lock,
}
}
}
const LOCK_FILE_RESULT_FIELDS: &[&str] = &["metadata",
"lock"];
impl LockFileResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<LockFileResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<LockFileResult>, V::Error> {
let mut field_metadata = None;
let mut field_lock = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
"lock" => {
if field_lock.is_some() {
return Err(::serde::de::Error::duplicate_field("lock"));
}
field_lock = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = LockFileResult {
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
lock: field_lock.ok_or_else(|| ::serde::de::Error::missing_field("lock"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("metadata", &self.metadata)?;
s.serialize_field("lock", &self.lock)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for LockFileResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = LockFileResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a LockFileResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
LockFileResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("LockFileResult", LOCK_FILE_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for LockFileResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("LockFileResult", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum LockFileResultEntry {
Success(LockFileResult),
Failure(LockFileError),
}
impl<'de> ::serde::de::Deserialize<'de> for LockFileResultEntry {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = LockFileResultEntry;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a LockFileResultEntry structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"success" => LockFileResultEntry::Success(LockFileResult::internal_deserialize(&mut map)?),
"failure" => {
match map.next_key()? {
Some("failure") => LockFileResultEntry::Failure(map.next_value()?),
None => return Err(de::Error::missing_field("failure")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["success",
"failure"];
deserializer.deserialize_struct("LockFileResultEntry", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for LockFileResultEntry {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
LockFileResultEntry::Success(ref x) => {
let mut s = serializer.serialize_struct("LockFileResultEntry", 3)?;
s.serialize_field(".tag", "success")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
LockFileResultEntry::Failure(ref x) => {
let mut s = serializer.serialize_struct("LockFileResultEntry", 2)?;
s.serialize_field(".tag", "failure")?;
s.serialize_field("failure", x)?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum LookupError {
MalformedPath(MalformedPathError),
NotFound,
NotFile,
NotFolder,
RestrictedContent,
UnsupportedContentType,
Locked,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for LookupError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = LookupError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a LookupError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"malformed_path" => {
match map.next_key()? {
Some("malformed_path") => LookupError::MalformedPath(map.next_value()?),
None => LookupError::MalformedPath(None),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"not_found" => LookupError::NotFound,
"not_file" => LookupError::NotFile,
"not_folder" => LookupError::NotFolder,
"restricted_content" => LookupError::RestrictedContent,
"unsupported_content_type" => LookupError::UnsupportedContentType,
"locked" => LookupError::Locked,
_ => LookupError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["malformed_path",
"not_found",
"not_file",
"not_folder",
"restricted_content",
"unsupported_content_type",
"locked",
"other"];
deserializer.deserialize_struct("LookupError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for LookupError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
LookupError::MalformedPath(ref x) => {
let n = if x.is_some() { 2 } else { 1 };
let mut s = serializer.serialize_struct("LookupError", n)?;
s.serialize_field(".tag", "malformed_path")?;
if let Some(ref x) = x {
s.serialize_field("malformed_path", &x)?;
}
s.end()
}
LookupError::NotFound => {
let mut s = serializer.serialize_struct("LookupError", 1)?;
s.serialize_field(".tag", "not_found")?;
s.end()
}
LookupError::NotFile => {
let mut s = serializer.serialize_struct("LookupError", 1)?;
s.serialize_field(".tag", "not_file")?;
s.end()
}
LookupError::NotFolder => {
let mut s = serializer.serialize_struct("LookupError", 1)?;
s.serialize_field(".tag", "not_folder")?;
s.end()
}
LookupError::RestrictedContent => {
let mut s = serializer.serialize_struct("LookupError", 1)?;
s.serialize_field(".tag", "restricted_content")?;
s.end()
}
LookupError::UnsupportedContentType => {
let mut s = serializer.serialize_struct("LookupError", 1)?;
s.serialize_field(".tag", "unsupported_content_type")?;
s.end()
}
LookupError::Locked => {
let mut s = serializer.serialize_struct("LookupError", 1)?;
s.serialize_field(".tag", "locked")?;
s.end()
}
LookupError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for LookupError {
}
impl ::std::fmt::Display for LookupError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
LookupError::MalformedPath(inner) => write!(f, "malformed_path: {:?}", inner),
LookupError::NotFound => f.write_str("There is nothing at the given path."),
LookupError::NotFile => f.write_str("We were expecting a file, but the given path refers to something that isn't a file."),
LookupError::NotFolder => f.write_str("We were expecting a folder, but the given path refers to something that isn't a folder."),
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."),
LookupError::UnsupportedContentType => f.write_str("This operation is not supported for this content type."),
LookupError::Locked => f.write_str("The given path is locked."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum MediaInfo {
Pending,
Metadata(MediaMetadata),
}
impl<'de> ::serde::de::Deserialize<'de> for MediaInfo {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = MediaInfo;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a MediaInfo structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"pending" => MediaInfo::Pending,
"metadata" => {
match map.next_key()? {
Some("metadata") => MediaInfo::Metadata(map.next_value()?),
None => return Err(de::Error::missing_field("metadata")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["pending",
"metadata"];
deserializer.deserialize_struct("MediaInfo", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for MediaInfo {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
MediaInfo::Pending => {
let mut s = serializer.serialize_struct("MediaInfo", 1)?;
s.serialize_field(".tag", "pending")?;
s.end()
}
MediaInfo::Metadata(ref x) => {
let mut s = serializer.serialize_struct("MediaInfo", 2)?;
s.serialize_field(".tag", "metadata")?;
s.serialize_field("metadata", x)?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum MediaMetadata {
Photo(PhotoMetadata),
Video(VideoMetadata),
}
impl<'de> ::serde::de::Deserialize<'de> for MediaMetadata {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = MediaMetadata;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a MediaMetadata structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
match tag {
"photo" => Ok(MediaMetadata::Photo(PhotoMetadata::internal_deserialize(map)?)),
"video" => Ok(MediaMetadata::Video(VideoMetadata::internal_deserialize(map)?)),
_ => Err(de::Error::unknown_variant(tag, VARIANTS))
}
}
}
const VARIANTS: &[&str] = &["photo",
"video"];
deserializer.deserialize_struct("MediaMetadata", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for MediaMetadata {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
MediaMetadata::Photo(ref x) => {
let mut s = serializer.serialize_struct("MediaMetadata", 4)?;
s.serialize_field(".tag", "photo")?;
s.serialize_field("dimensions", &x.dimensions)?;
s.serialize_field("location", &x.location)?;
s.serialize_field("time_taken", &x.time_taken)?;
s.end()
}
MediaMetadata::Video(ref x) => {
let mut s = serializer.serialize_struct("MediaMetadata", 5)?;
s.serialize_field(".tag", "video")?;
s.serialize_field("dimensions", &x.dimensions)?;
s.serialize_field("location", &x.location)?;
s.serialize_field("time_taken", &x.time_taken)?;
s.serialize_field("duration", &x.duration)?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum Metadata {
File(FileMetadata),
Folder(FolderMetadata),
Deleted(DeletedMetadata),
}
impl<'de> ::serde::de::Deserialize<'de> for Metadata {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = Metadata;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a Metadata structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
match tag {
"file" => Ok(Metadata::File(FileMetadata::internal_deserialize(map)?)),
"folder" => Ok(Metadata::Folder(FolderMetadata::internal_deserialize(map)?)),
"deleted" => Ok(Metadata::Deleted(DeletedMetadata::internal_deserialize(map)?)),
_ => Err(de::Error::unknown_variant(tag, VARIANTS))
}
}
}
const VARIANTS: &[&str] = &["file",
"folder",
"deleted"];
deserializer.deserialize_struct("Metadata", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for Metadata {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
Metadata::File(ref x) => {
let mut s = serializer.serialize_struct("Metadata", 20)?;
s.serialize_field(".tag", "file")?;
s.serialize_field("name", &x.name)?;
s.serialize_field("id", &x.id)?;
s.serialize_field("client_modified", &x.client_modified)?;
s.serialize_field("server_modified", &x.server_modified)?;
s.serialize_field("rev", &x.rev)?;
s.serialize_field("size", &x.size)?;
s.serialize_field("path_lower", &x.path_lower)?;
s.serialize_field("path_display", &x.path_display)?;
s.serialize_field("parent_shared_folder_id", &x.parent_shared_folder_id)?;
s.serialize_field("preview_url", &x.preview_url)?;
s.serialize_field("media_info", &x.media_info)?;
s.serialize_field("symlink_info", &x.symlink_info)?;
s.serialize_field("sharing_info", &x.sharing_info)?;
s.serialize_field("is_downloadable", &x.is_downloadable)?;
s.serialize_field("export_info", &x.export_info)?;
s.serialize_field("property_groups", &x.property_groups)?;
s.serialize_field("has_explicit_shared_members", &x.has_explicit_shared_members)?;
s.serialize_field("content_hash", &x.content_hash)?;
s.serialize_field("file_lock_info", &x.file_lock_info)?;
s.end()
}
Metadata::Folder(ref x) => {
let mut s = serializer.serialize_struct("Metadata", 10)?;
s.serialize_field(".tag", "folder")?;
s.serialize_field("name", &x.name)?;
s.serialize_field("id", &x.id)?;
s.serialize_field("path_lower", &x.path_lower)?;
s.serialize_field("path_display", &x.path_display)?;
s.serialize_field("parent_shared_folder_id", &x.parent_shared_folder_id)?;
s.serialize_field("preview_url", &x.preview_url)?;
s.serialize_field("shared_folder_id", &x.shared_folder_id)?;
s.serialize_field("sharing_info", &x.sharing_info)?;
s.serialize_field("property_groups", &x.property_groups)?;
s.end()
}
Metadata::Deleted(ref x) => {
let mut s = serializer.serialize_struct("Metadata", 6)?;
s.serialize_field(".tag", "deleted")?;
s.serialize_field("name", &x.name)?;
s.serialize_field("path_lower", &x.path_lower)?;
s.serialize_field("path_display", &x.path_display)?;
s.serialize_field("parent_shared_folder_id", &x.parent_shared_folder_id)?;
s.serialize_field("preview_url", &x.preview_url)?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub enum MetadataV2 {
Metadata(Metadata),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for MetadataV2 {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = MetadataV2;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a MetadataV2 structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"metadata" => {
match map.next_key()? {
Some("metadata") => MetadataV2::Metadata(map.next_value()?),
None => return Err(de::Error::missing_field("metadata")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => MetadataV2::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["metadata",
"other"];
deserializer.deserialize_struct("MetadataV2", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for MetadataV2 {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
MetadataV2::Metadata(ref x) => {
let mut s = serializer.serialize_struct("MetadataV2", 2)?;
s.serialize_field(".tag", "metadata")?;
s.serialize_field("metadata", x)?;
s.end()
}
MetadataV2::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct MinimalFileLinkMetadata {
pub url: String,
pub rev: Rev,
pub id: Option<Id>,
pub path: Option<String>,
}
impl MinimalFileLinkMetadata {
pub fn new(url: String, rev: Rev) -> Self {
MinimalFileLinkMetadata {
url,
rev,
id: None,
path: None,
}
}
pub fn with_id(mut self, value: Id) -> Self {
self.id = Some(value);
self
}
pub fn with_path(mut self, value: String) -> Self {
self.path = Some(value);
self
}
}
const MINIMAL_FILE_LINK_METADATA_FIELDS: &[&str] = &["url",
"rev",
"id",
"path"];
impl MinimalFileLinkMetadata {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<MinimalFileLinkMetadata, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<MinimalFileLinkMetadata>, V::Error> {
let mut field_url = None;
let mut field_rev = None;
let mut field_id = None;
let mut field_path = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"url" => {
if field_url.is_some() {
return Err(::serde::de::Error::duplicate_field("url"));
}
field_url = Some(map.next_value()?);
}
"rev" => {
if field_rev.is_some() {
return Err(::serde::de::Error::duplicate_field("rev"));
}
field_rev = Some(map.next_value()?);
}
"id" => {
if field_id.is_some() {
return Err(::serde::de::Error::duplicate_field("id"));
}
field_id = Some(map.next_value()?);
}
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = MinimalFileLinkMetadata {
url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
id: field_id,
path: field_path,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("url", &self.url)?;
s.serialize_field("rev", &self.rev)?;
if let Some(val) = &self.id {
s.serialize_field("id", val)?;
}
if let Some(val) = &self.path {
s.serialize_field("path", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for MinimalFileLinkMetadata {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = MinimalFileLinkMetadata;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a MinimalFileLinkMetadata struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
MinimalFileLinkMetadata::internal_deserialize(map)
}
}
deserializer.deserialize_struct("MinimalFileLinkMetadata", MINIMAL_FILE_LINK_METADATA_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for MinimalFileLinkMetadata {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("MinimalFileLinkMetadata", 4)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct MoveBatchArg {
pub entries: Vec<RelocationPath>,
pub autorename: bool,
pub allow_ownership_transfer: bool,
}
impl MoveBatchArg {
pub fn new(entries: Vec<RelocationPath>) -> Self {
MoveBatchArg {
entries,
autorename: false,
allow_ownership_transfer: false,
}
}
pub fn with_autorename(mut self, value: bool) -> Self {
self.autorename = value;
self
}
pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
self.allow_ownership_transfer = value;
self
}
}
const MOVE_BATCH_ARG_FIELDS: &[&str] = &["entries",
"autorename",
"allow_ownership_transfer"];
impl MoveBatchArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<MoveBatchArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<MoveBatchArg>, V::Error> {
let mut field_entries = None;
let mut field_autorename = None;
let mut field_allow_ownership_transfer = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
"autorename" => {
if field_autorename.is_some() {
return Err(::serde::de::Error::duplicate_field("autorename"));
}
field_autorename = Some(map.next_value()?);
}
"allow_ownership_transfer" => {
if field_allow_ownership_transfer.is_some() {
return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
}
field_allow_ownership_transfer = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = MoveBatchArg {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
autorename: field_autorename.unwrap_or(false),
allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
s.serialize_field("autorename", &self.autorename)?;
s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for MoveBatchArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = MoveBatchArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a MoveBatchArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
MoveBatchArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("MoveBatchArg", MOVE_BATCH_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for MoveBatchArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("MoveBatchArg", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum MoveIntoFamilyError {
IsSharedFolder,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for MoveIntoFamilyError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = MoveIntoFamilyError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a MoveIntoFamilyError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"is_shared_folder" => MoveIntoFamilyError::IsSharedFolder,
_ => MoveIntoFamilyError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["is_shared_folder",
"other"];
deserializer.deserialize_struct("MoveIntoFamilyError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for MoveIntoFamilyError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
MoveIntoFamilyError::IsSharedFolder => {
let mut s = serializer.serialize_struct("MoveIntoFamilyError", 1)?;
s.serialize_field(".tag", "is_shared_folder")?;
s.end()
}
MoveIntoFamilyError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for MoveIntoFamilyError {
}
impl ::std::fmt::Display for MoveIntoFamilyError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
MoveIntoFamilyError::IsSharedFolder => f.write_str("Moving shared folder into Family Room folder is not allowed."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum MoveIntoVaultError {
IsSharedFolder,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for MoveIntoVaultError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = MoveIntoVaultError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a MoveIntoVaultError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"is_shared_folder" => MoveIntoVaultError::IsSharedFolder,
_ => MoveIntoVaultError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["is_shared_folder",
"other"];
deserializer.deserialize_struct("MoveIntoVaultError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for MoveIntoVaultError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
MoveIntoVaultError::IsSharedFolder => {
let mut s = serializer.serialize_struct("MoveIntoVaultError", 1)?;
s.serialize_field(".tag", "is_shared_folder")?;
s.end()
}
MoveIntoVaultError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for MoveIntoVaultError {
}
impl ::std::fmt::Display for MoveIntoVaultError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
MoveIntoVaultError::IsSharedFolder => f.write_str("Moving shared folder into Vault is not allowed."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum PaperContentError {
InsufficientPermissions,
ContentMalformed,
DocLengthExceeded,
ImageSizeExceeded,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for PaperContentError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = PaperContentError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PaperContentError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"insufficient_permissions" => PaperContentError::InsufficientPermissions,
"content_malformed" => PaperContentError::ContentMalformed,
"doc_length_exceeded" => PaperContentError::DocLengthExceeded,
"image_size_exceeded" => PaperContentError::ImageSizeExceeded,
_ => PaperContentError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["insufficient_permissions",
"content_malformed",
"doc_length_exceeded",
"image_size_exceeded",
"other"];
deserializer.deserialize_struct("PaperContentError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for PaperContentError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
PaperContentError::InsufficientPermissions => {
let mut s = serializer.serialize_struct("PaperContentError", 1)?;
s.serialize_field(".tag", "insufficient_permissions")?;
s.end()
}
PaperContentError::ContentMalformed => {
let mut s = serializer.serialize_struct("PaperContentError", 1)?;
s.serialize_field(".tag", "content_malformed")?;
s.end()
}
PaperContentError::DocLengthExceeded => {
let mut s = serializer.serialize_struct("PaperContentError", 1)?;
s.serialize_field(".tag", "doc_length_exceeded")?;
s.end()
}
PaperContentError::ImageSizeExceeded => {
let mut s = serializer.serialize_struct("PaperContentError", 1)?;
s.serialize_field(".tag", "image_size_exceeded")?;
s.end()
}
PaperContentError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for PaperContentError {
}
impl ::std::fmt::Display for PaperContentError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
PaperContentError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
PaperContentError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
PaperContentError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
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."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct PaperCreateArg {
pub path: Path,
pub import_format: ImportFormat,
}
impl PaperCreateArg {
pub fn new(path: Path, import_format: ImportFormat) -> Self {
PaperCreateArg {
path,
import_format,
}
}
}
const PAPER_CREATE_ARG_FIELDS: &[&str] = &["path",
"import_format"];
impl PaperCreateArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<PaperCreateArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<PaperCreateArg>, V::Error> {
let mut field_path = None;
let mut field_import_format = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"import_format" => {
if field_import_format.is_some() {
return Err(::serde::de::Error::duplicate_field("import_format"));
}
field_import_format = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = PaperCreateArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
import_format: field_import_format.ok_or_else(|| ::serde::de::Error::missing_field("import_format"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("import_format", &self.import_format)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for PaperCreateArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = PaperCreateArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PaperCreateArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
PaperCreateArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("PaperCreateArg", PAPER_CREATE_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for PaperCreateArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("PaperCreateArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum PaperCreateError {
InsufficientPermissions,
ContentMalformed,
DocLengthExceeded,
ImageSizeExceeded,
InvalidPath,
EmailUnverified,
InvalidFileExtension,
PaperDisabled,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for PaperCreateError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = PaperCreateError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PaperCreateError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"insufficient_permissions" => PaperCreateError::InsufficientPermissions,
"content_malformed" => PaperCreateError::ContentMalformed,
"doc_length_exceeded" => PaperCreateError::DocLengthExceeded,
"image_size_exceeded" => PaperCreateError::ImageSizeExceeded,
"invalid_path" => PaperCreateError::InvalidPath,
"email_unverified" => PaperCreateError::EmailUnverified,
"invalid_file_extension" => PaperCreateError::InvalidFileExtension,
"paper_disabled" => PaperCreateError::PaperDisabled,
_ => PaperCreateError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["insufficient_permissions",
"content_malformed",
"doc_length_exceeded",
"image_size_exceeded",
"other",
"invalid_path",
"email_unverified",
"invalid_file_extension",
"paper_disabled"];
deserializer.deserialize_struct("PaperCreateError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for PaperCreateError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
PaperCreateError::InsufficientPermissions => {
let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
s.serialize_field(".tag", "insufficient_permissions")?;
s.end()
}
PaperCreateError::ContentMalformed => {
let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
s.serialize_field(".tag", "content_malformed")?;
s.end()
}
PaperCreateError::DocLengthExceeded => {
let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
s.serialize_field(".tag", "doc_length_exceeded")?;
s.end()
}
PaperCreateError::ImageSizeExceeded => {
let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
s.serialize_field(".tag", "image_size_exceeded")?;
s.end()
}
PaperCreateError::InvalidPath => {
let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
s.serialize_field(".tag", "invalid_path")?;
s.end()
}
PaperCreateError::EmailUnverified => {
let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
s.serialize_field(".tag", "email_unverified")?;
s.end()
}
PaperCreateError::InvalidFileExtension => {
let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
s.serialize_field(".tag", "invalid_file_extension")?;
s.end()
}
PaperCreateError::PaperDisabled => {
let mut s = serializer.serialize_struct("PaperCreateError", 1)?;
s.serialize_field(".tag", "paper_disabled")?;
s.end()
}
PaperCreateError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for PaperCreateError {
}
impl ::std::fmt::Display for PaperCreateError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
PaperCreateError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
PaperCreateError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
PaperCreateError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
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."),
PaperCreateError::InvalidPath => f.write_str("The file could not be saved to the specified location."),
PaperCreateError::EmailUnverified => f.write_str("The user's email must be verified to create Paper docs."),
PaperCreateError::InvalidFileExtension => f.write_str("The file path must end in .paper."),
PaperCreateError::PaperDisabled => f.write_str("Paper is disabled for your team."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct PaperCreateResult {
pub url: String,
pub result_path: String,
pub file_id: FileId,
pub paper_revision: i64,
}
impl PaperCreateResult {
pub fn new(url: String, result_path: String, file_id: FileId, paper_revision: i64) -> Self {
PaperCreateResult {
url,
result_path,
file_id,
paper_revision,
}
}
}
const PAPER_CREATE_RESULT_FIELDS: &[&str] = &["url",
"result_path",
"file_id",
"paper_revision"];
impl PaperCreateResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<PaperCreateResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<PaperCreateResult>, V::Error> {
let mut field_url = None;
let mut field_result_path = None;
let mut field_file_id = None;
let mut field_paper_revision = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"url" => {
if field_url.is_some() {
return Err(::serde::de::Error::duplicate_field("url"));
}
field_url = Some(map.next_value()?);
}
"result_path" => {
if field_result_path.is_some() {
return Err(::serde::de::Error::duplicate_field("result_path"));
}
field_result_path = Some(map.next_value()?);
}
"file_id" => {
if field_file_id.is_some() {
return Err(::serde::de::Error::duplicate_field("file_id"));
}
field_file_id = Some(map.next_value()?);
}
"paper_revision" => {
if field_paper_revision.is_some() {
return Err(::serde::de::Error::duplicate_field("paper_revision"));
}
field_paper_revision = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = PaperCreateResult {
url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
result_path: field_result_path.ok_or_else(|| ::serde::de::Error::missing_field("result_path"))?,
file_id: field_file_id.ok_or_else(|| ::serde::de::Error::missing_field("file_id"))?,
paper_revision: field_paper_revision.ok_or_else(|| ::serde::de::Error::missing_field("paper_revision"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("url", &self.url)?;
s.serialize_field("result_path", &self.result_path)?;
s.serialize_field("file_id", &self.file_id)?;
s.serialize_field("paper_revision", &self.paper_revision)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for PaperCreateResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = PaperCreateResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PaperCreateResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
PaperCreateResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("PaperCreateResult", PAPER_CREATE_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for PaperCreateResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("PaperCreateResult", 4)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum PaperDocUpdatePolicy {
Update,
Overwrite,
Prepend,
Append,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for PaperDocUpdatePolicy {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = PaperDocUpdatePolicy;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PaperDocUpdatePolicy structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"update" => PaperDocUpdatePolicy::Update,
"overwrite" => PaperDocUpdatePolicy::Overwrite,
"prepend" => PaperDocUpdatePolicy::Prepend,
"append" => PaperDocUpdatePolicy::Append,
_ => PaperDocUpdatePolicy::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["update",
"overwrite",
"prepend",
"append",
"other"];
deserializer.deserialize_struct("PaperDocUpdatePolicy", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for PaperDocUpdatePolicy {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
PaperDocUpdatePolicy::Update => {
let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
s.serialize_field(".tag", "update")?;
s.end()
}
PaperDocUpdatePolicy::Overwrite => {
let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
s.serialize_field(".tag", "overwrite")?;
s.end()
}
PaperDocUpdatePolicy::Prepend => {
let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
s.serialize_field(".tag", "prepend")?;
s.end()
}
PaperDocUpdatePolicy::Append => {
let mut s = serializer.serialize_struct("PaperDocUpdatePolicy", 1)?;
s.serialize_field(".tag", "append")?;
s.end()
}
PaperDocUpdatePolicy::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct PaperUpdateArg {
pub path: WritePathOrId,
pub import_format: ImportFormat,
pub doc_update_policy: PaperDocUpdatePolicy,
pub paper_revision: Option<i64>,
}
impl PaperUpdateArg {
pub fn new(
path: WritePathOrId,
import_format: ImportFormat,
doc_update_policy: PaperDocUpdatePolicy,
) -> Self {
PaperUpdateArg {
path,
import_format,
doc_update_policy,
paper_revision: None,
}
}
pub fn with_paper_revision(mut self, value: i64) -> Self {
self.paper_revision = Some(value);
self
}
}
const PAPER_UPDATE_ARG_FIELDS: &[&str] = &["path",
"import_format",
"doc_update_policy",
"paper_revision"];
impl PaperUpdateArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<PaperUpdateArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<PaperUpdateArg>, V::Error> {
let mut field_path = None;
let mut field_import_format = None;
let mut field_doc_update_policy = None;
let mut field_paper_revision = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"import_format" => {
if field_import_format.is_some() {
return Err(::serde::de::Error::duplicate_field("import_format"));
}
field_import_format = Some(map.next_value()?);
}
"doc_update_policy" => {
if field_doc_update_policy.is_some() {
return Err(::serde::de::Error::duplicate_field("doc_update_policy"));
}
field_doc_update_policy = Some(map.next_value()?);
}
"paper_revision" => {
if field_paper_revision.is_some() {
return Err(::serde::de::Error::duplicate_field("paper_revision"));
}
field_paper_revision = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = PaperUpdateArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
import_format: field_import_format.ok_or_else(|| ::serde::de::Error::missing_field("import_format"))?,
doc_update_policy: field_doc_update_policy.ok_or_else(|| ::serde::de::Error::missing_field("doc_update_policy"))?,
paper_revision: field_paper_revision,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("import_format", &self.import_format)?;
s.serialize_field("doc_update_policy", &self.doc_update_policy)?;
if let Some(val) = &self.paper_revision {
s.serialize_field("paper_revision", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = PaperUpdateArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PaperUpdateArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
PaperUpdateArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("PaperUpdateArg", PAPER_UPDATE_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for PaperUpdateArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("PaperUpdateArg", 4)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum PaperUpdateError {
InsufficientPermissions,
ContentMalformed,
DocLengthExceeded,
ImageSizeExceeded,
Path(LookupError),
RevisionMismatch,
DocArchived,
DocDeleted,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = PaperUpdateError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PaperUpdateError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"insufficient_permissions" => PaperUpdateError::InsufficientPermissions,
"content_malformed" => PaperUpdateError::ContentMalformed,
"doc_length_exceeded" => PaperUpdateError::DocLengthExceeded,
"image_size_exceeded" => PaperUpdateError::ImageSizeExceeded,
"path" => {
match map.next_key()? {
Some("path") => PaperUpdateError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"revision_mismatch" => PaperUpdateError::RevisionMismatch,
"doc_archived" => PaperUpdateError::DocArchived,
"doc_deleted" => PaperUpdateError::DocDeleted,
_ => PaperUpdateError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["insufficient_permissions",
"content_malformed",
"doc_length_exceeded",
"image_size_exceeded",
"other",
"path",
"revision_mismatch",
"doc_archived",
"doc_deleted"];
deserializer.deserialize_struct("PaperUpdateError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for PaperUpdateError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
PaperUpdateError::InsufficientPermissions => {
let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
s.serialize_field(".tag", "insufficient_permissions")?;
s.end()
}
PaperUpdateError::ContentMalformed => {
let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
s.serialize_field(".tag", "content_malformed")?;
s.end()
}
PaperUpdateError::DocLengthExceeded => {
let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
s.serialize_field(".tag", "doc_length_exceeded")?;
s.end()
}
PaperUpdateError::ImageSizeExceeded => {
let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
s.serialize_field(".tag", "image_size_exceeded")?;
s.end()
}
PaperUpdateError::Path(ref x) => {
let mut s = serializer.serialize_struct("PaperUpdateError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
PaperUpdateError::RevisionMismatch => {
let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
s.serialize_field(".tag", "revision_mismatch")?;
s.end()
}
PaperUpdateError::DocArchived => {
let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
s.serialize_field(".tag", "doc_archived")?;
s.end()
}
PaperUpdateError::DocDeleted => {
let mut s = serializer.serialize_struct("PaperUpdateError", 1)?;
s.serialize_field(".tag", "doc_deleted")?;
s.end()
}
PaperUpdateError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for PaperUpdateError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
PaperUpdateError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for PaperUpdateError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
PaperUpdateError::InsufficientPermissions => f.write_str("Your account does not have permissions to edit Paper docs."),
PaperUpdateError::ContentMalformed => f.write_str("The provided content was malformed and cannot be imported to Paper."),
PaperUpdateError::DocLengthExceeded => f.write_str("The Paper doc would be too large, split the content into multiple docs."),
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."),
PaperUpdateError::Path(inner) => write!(f, "{}", inner),
PaperUpdateError::RevisionMismatch => f.write_str("The provided revision does not match the document head."),
PaperUpdateError::DocArchived => f.write_str("This operation is not allowed on archived Paper docs."),
PaperUpdateError::DocDeleted => f.write_str("This operation is not allowed on deleted Paper docs."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct PaperUpdateResult {
pub paper_revision: i64,
}
impl PaperUpdateResult {
pub fn new(paper_revision: i64) -> Self {
PaperUpdateResult {
paper_revision,
}
}
}
const PAPER_UPDATE_RESULT_FIELDS: &[&str] = &["paper_revision"];
impl PaperUpdateResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<PaperUpdateResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<PaperUpdateResult>, V::Error> {
let mut field_paper_revision = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"paper_revision" => {
if field_paper_revision.is_some() {
return Err(::serde::de::Error::duplicate_field("paper_revision"));
}
field_paper_revision = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = PaperUpdateResult {
paper_revision: field_paper_revision.ok_or_else(|| ::serde::de::Error::missing_field("paper_revision"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("paper_revision", &self.paper_revision)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for PaperUpdateResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = PaperUpdateResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PaperUpdateResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
PaperUpdateResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("PaperUpdateResult", PAPER_UPDATE_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for PaperUpdateResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("PaperUpdateResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum PathOrLink {
Path(ReadPath),
Link(SharedLinkFileInfo),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for PathOrLink {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = PathOrLink;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PathOrLink structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => PathOrLink::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"link" => PathOrLink::Link(SharedLinkFileInfo::internal_deserialize(&mut map)?),
_ => PathOrLink::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"link",
"other"];
deserializer.deserialize_struct("PathOrLink", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for PathOrLink {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
PathOrLink::Path(ref x) => {
let mut s = serializer.serialize_struct("PathOrLink", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
PathOrLink::Link(ref x) => {
let mut s = serializer.serialize_struct("PathOrLink", 4)?;
s.serialize_field(".tag", "link")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
PathOrLink::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct PathToTags {
pub path: Path,
pub tags: Vec<Tag>,
}
impl PathToTags {
pub fn new(path: Path, tags: Vec<Tag>) -> Self {
PathToTags {
path,
tags,
}
}
}
const PATH_TO_TAGS_FIELDS: &[&str] = &["path",
"tags"];
impl PathToTags {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<PathToTags, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<PathToTags>, V::Error> {
let mut field_path = None;
let mut field_tags = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"tags" => {
if field_tags.is_some() {
return Err(::serde::de::Error::duplicate_field("tags"));
}
field_tags = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = PathToTags {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
tags: field_tags.ok_or_else(|| ::serde::de::Error::missing_field("tags"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("tags", &self.tags)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for PathToTags {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = PathToTags;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PathToTags struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
PathToTags::internal_deserialize(map)
}
}
deserializer.deserialize_struct("PathToTags", PATH_TO_TAGS_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for PathToTags {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("PathToTags", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Default)]
#[non_exhaustive] pub struct PhotoMetadata {
pub dimensions: Option<Dimensions>,
pub location: Option<GpsCoordinates>,
pub time_taken: Option<crate::common::DropboxTimestamp>,
}
impl PhotoMetadata {
pub fn with_dimensions(mut self, value: Dimensions) -> Self {
self.dimensions = Some(value);
self
}
pub fn with_location(mut self, value: GpsCoordinates) -> Self {
self.location = Some(value);
self
}
pub fn with_time_taken(mut self, value: crate::common::DropboxTimestamp) -> Self {
self.time_taken = Some(value);
self
}
}
const PHOTO_METADATA_FIELDS: &[&str] = &["dimensions",
"location",
"time_taken"];
impl PhotoMetadata {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<PhotoMetadata, V::Error> {
let mut field_dimensions = None;
let mut field_location = None;
let mut field_time_taken = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"dimensions" => {
if field_dimensions.is_some() {
return Err(::serde::de::Error::duplicate_field("dimensions"));
}
field_dimensions = Some(map.next_value()?);
}
"location" => {
if field_location.is_some() {
return Err(::serde::de::Error::duplicate_field("location"));
}
field_location = Some(map.next_value()?);
}
"time_taken" => {
if field_time_taken.is_some() {
return Err(::serde::de::Error::duplicate_field("time_taken"));
}
field_time_taken = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = PhotoMetadata {
dimensions: field_dimensions,
location: field_location,
time_taken: field_time_taken,
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
if let Some(val) = &self.dimensions {
s.serialize_field("dimensions", val)?;
}
if let Some(val) = &self.location {
s.serialize_field("location", val)?;
}
if let Some(val) = &self.time_taken {
s.serialize_field("time_taken", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for PhotoMetadata {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = PhotoMetadata;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PhotoMetadata struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
PhotoMetadata::internal_deserialize(map)
}
}
deserializer.deserialize_struct("PhotoMetadata", PHOTO_METADATA_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for PhotoMetadata {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("PhotoMetadata", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct PreviewArg {
pub path: ReadPath,
pub rev: Option<Rev>,
}
impl PreviewArg {
pub fn new(path: ReadPath) -> Self {
PreviewArg {
path,
rev: None,
}
}
pub fn with_rev(mut self, value: Rev) -> Self {
self.rev = Some(value);
self
}
}
const PREVIEW_ARG_FIELDS: &[&str] = &["path",
"rev"];
impl PreviewArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<PreviewArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<PreviewArg>, V::Error> {
let mut field_path = None;
let mut field_rev = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"rev" => {
if field_rev.is_some() {
return Err(::serde::de::Error::duplicate_field("rev"));
}
field_rev = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = PreviewArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
rev: field_rev,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
if let Some(val) = &self.rev {
s.serialize_field("rev", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for PreviewArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = PreviewArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PreviewArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
PreviewArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("PreviewArg", PREVIEW_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for PreviewArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("PreviewArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PreviewError {
Path(LookupError),
InProgress,
UnsupportedExtension,
UnsupportedContent,
}
impl<'de> ::serde::de::Deserialize<'de> for PreviewError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = PreviewError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PreviewError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => PreviewError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"in_progress" => PreviewError::InProgress,
"unsupported_extension" => PreviewError::UnsupportedExtension,
"unsupported_content" => PreviewError::UnsupportedContent,
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"in_progress",
"unsupported_extension",
"unsupported_content"];
deserializer.deserialize_struct("PreviewError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for PreviewError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
PreviewError::Path(ref x) => {
let mut s = serializer.serialize_struct("PreviewError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
PreviewError::InProgress => {
let mut s = serializer.serialize_struct("PreviewError", 1)?;
s.serialize_field(".tag", "in_progress")?;
s.end()
}
PreviewError::UnsupportedExtension => {
let mut s = serializer.serialize_struct("PreviewError", 1)?;
s.serialize_field(".tag", "unsupported_extension")?;
s.end()
}
PreviewError::UnsupportedContent => {
let mut s = serializer.serialize_struct("PreviewError", 1)?;
s.serialize_field(".tag", "unsupported_content")?;
s.end()
}
}
}
}
impl ::std::error::Error for PreviewError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
PreviewError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for PreviewError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
PreviewError::Path(inner) => write!(f, "An error occurs when downloading metadata for the file: {}", inner),
PreviewError::InProgress => f.write_str("This preview generation is still in progress and the file is not ready for preview yet."),
PreviewError::UnsupportedExtension => f.write_str("The file extension is not supported preview generation."),
PreviewError::UnsupportedContent => f.write_str("The file content is not supported for preview generation."),
}
}
}
#[derive(Debug, Clone, PartialEq, Default)]
#[non_exhaustive] pub struct PreviewResult {
pub file_metadata: Option<FileMetadata>,
pub link_metadata: Option<MinimalFileLinkMetadata>,
}
impl PreviewResult {
pub fn with_file_metadata(mut self, value: FileMetadata) -> Self {
self.file_metadata = Some(value);
self
}
pub fn with_link_metadata(mut self, value: MinimalFileLinkMetadata) -> Self {
self.link_metadata = Some(value);
self
}
}
const PREVIEW_RESULT_FIELDS: &[&str] = &["file_metadata",
"link_metadata"];
impl PreviewResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<PreviewResult, V::Error> {
let mut field_file_metadata = None;
let mut field_link_metadata = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"file_metadata" => {
if field_file_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("file_metadata"));
}
field_file_metadata = Some(map.next_value()?);
}
"link_metadata" => {
if field_link_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("link_metadata"));
}
field_link_metadata = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = PreviewResult {
file_metadata: field_file_metadata,
link_metadata: field_link_metadata,
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
if let Some(val) = &self.file_metadata {
s.serialize_field("file_metadata", val)?;
}
if let Some(val) = &self.link_metadata {
s.serialize_field("link_metadata", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for PreviewResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = PreviewResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a PreviewResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
PreviewResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("PreviewResult", PREVIEW_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for PreviewResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("PreviewResult", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct RelocationArg {
pub from_path: WritePathOrId,
pub to_path: WritePathOrId,
pub allow_shared_folder: bool,
pub autorename: bool,
pub allow_ownership_transfer: bool,
}
impl RelocationArg {
pub fn new(from_path: WritePathOrId, to_path: WritePathOrId) -> Self {
RelocationArg {
from_path,
to_path,
allow_shared_folder: false,
autorename: false,
allow_ownership_transfer: false,
}
}
pub fn with_allow_shared_folder(mut self, value: bool) -> Self {
self.allow_shared_folder = value;
self
}
pub fn with_autorename(mut self, value: bool) -> Self {
self.autorename = value;
self
}
pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
self.allow_ownership_transfer = value;
self
}
}
const RELOCATION_ARG_FIELDS: &[&str] = &["from_path",
"to_path",
"allow_shared_folder",
"autorename",
"allow_ownership_transfer"];
impl RelocationArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<RelocationArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<RelocationArg>, V::Error> {
let mut field_from_path = None;
let mut field_to_path = None;
let mut field_allow_shared_folder = None;
let mut field_autorename = None;
let mut field_allow_ownership_transfer = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"from_path" => {
if field_from_path.is_some() {
return Err(::serde::de::Error::duplicate_field("from_path"));
}
field_from_path = Some(map.next_value()?);
}
"to_path" => {
if field_to_path.is_some() {
return Err(::serde::de::Error::duplicate_field("to_path"));
}
field_to_path = Some(map.next_value()?);
}
"allow_shared_folder" => {
if field_allow_shared_folder.is_some() {
return Err(::serde::de::Error::duplicate_field("allow_shared_folder"));
}
field_allow_shared_folder = Some(map.next_value()?);
}
"autorename" => {
if field_autorename.is_some() {
return Err(::serde::de::Error::duplicate_field("autorename"));
}
field_autorename = Some(map.next_value()?);
}
"allow_ownership_transfer" => {
if field_allow_ownership_transfer.is_some() {
return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
}
field_allow_ownership_transfer = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = RelocationArg {
from_path: field_from_path.ok_or_else(|| ::serde::de::Error::missing_field("from_path"))?,
to_path: field_to_path.ok_or_else(|| ::serde::de::Error::missing_field("to_path"))?,
allow_shared_folder: field_allow_shared_folder.unwrap_or(false),
autorename: field_autorename.unwrap_or(false),
allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("from_path", &self.from_path)?;
s.serialize_field("to_path", &self.to_path)?;
s.serialize_field("allow_shared_folder", &self.allow_shared_folder)?;
s.serialize_field("autorename", &self.autorename)?;
s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = RelocationArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
RelocationArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("RelocationArg", RELOCATION_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for RelocationArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("RelocationArg", 5)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct RelocationBatchArg {
pub entries: Vec<RelocationPath>,
pub autorename: bool,
pub allow_shared_folder: bool,
pub allow_ownership_transfer: bool,
}
impl RelocationBatchArg {
pub fn new(entries: Vec<RelocationPath>) -> Self {
RelocationBatchArg {
entries,
autorename: false,
allow_shared_folder: false,
allow_ownership_transfer: false,
}
}
pub fn with_autorename(mut self, value: bool) -> Self {
self.autorename = value;
self
}
pub fn with_allow_shared_folder(mut self, value: bool) -> Self {
self.allow_shared_folder = value;
self
}
pub fn with_allow_ownership_transfer(mut self, value: bool) -> Self {
self.allow_ownership_transfer = value;
self
}
}
const RELOCATION_BATCH_ARG_FIELDS: &[&str] = &["entries",
"autorename",
"allow_shared_folder",
"allow_ownership_transfer"];
impl RelocationBatchArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<RelocationBatchArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<RelocationBatchArg>, V::Error> {
let mut field_entries = None;
let mut field_autorename = None;
let mut field_allow_shared_folder = None;
let mut field_allow_ownership_transfer = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
"autorename" => {
if field_autorename.is_some() {
return Err(::serde::de::Error::duplicate_field("autorename"));
}
field_autorename = Some(map.next_value()?);
}
"allow_shared_folder" => {
if field_allow_shared_folder.is_some() {
return Err(::serde::de::Error::duplicate_field("allow_shared_folder"));
}
field_allow_shared_folder = Some(map.next_value()?);
}
"allow_ownership_transfer" => {
if field_allow_ownership_transfer.is_some() {
return Err(::serde::de::Error::duplicate_field("allow_ownership_transfer"));
}
field_allow_ownership_transfer = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = RelocationBatchArg {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
autorename: field_autorename.unwrap_or(false),
allow_shared_folder: field_allow_shared_folder.unwrap_or(false),
allow_ownership_transfer: field_allow_ownership_transfer.unwrap_or(false),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
s.serialize_field("autorename", &self.autorename)?;
s.serialize_field("allow_shared_folder", &self.allow_shared_folder)?;
s.serialize_field("allow_ownership_transfer", &self.allow_ownership_transfer)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = RelocationBatchArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationBatchArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
RelocationBatchArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("RelocationBatchArg", RELOCATION_BATCH_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for RelocationBatchArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("RelocationBatchArg", 4)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct RelocationBatchArgBase {
pub entries: Vec<RelocationPath>,
pub autorename: bool,
}
impl RelocationBatchArgBase {
pub fn new(entries: Vec<RelocationPath>) -> Self {
RelocationBatchArgBase {
entries,
autorename: false,
}
}
pub fn with_autorename(mut self, value: bool) -> Self {
self.autorename = value;
self
}
}
const RELOCATION_BATCH_ARG_BASE_FIELDS: &[&str] = &["entries",
"autorename"];
impl RelocationBatchArgBase {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<RelocationBatchArgBase, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<RelocationBatchArgBase>, V::Error> {
let mut field_entries = None;
let mut field_autorename = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
"autorename" => {
if field_autorename.is_some() {
return Err(::serde::de::Error::duplicate_field("autorename"));
}
field_autorename = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = RelocationBatchArgBase {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
autorename: field_autorename.unwrap_or(false),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
s.serialize_field("autorename", &self.autorename)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchArgBase {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = RelocationBatchArgBase;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationBatchArgBase struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
RelocationBatchArgBase::internal_deserialize(map)
}
}
deserializer.deserialize_struct("RelocationBatchArgBase", RELOCATION_BATCH_ARG_BASE_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for RelocationBatchArgBase {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("RelocationBatchArgBase", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum RelocationBatchError {
FromLookup(LookupError),
FromWrite(WriteError),
To(WriteError),
CantCopySharedFolder,
CantNestSharedFolder,
CantMoveFolderIntoItself,
TooManyFiles,
DuplicatedOrNestedPaths,
CantTransferOwnership,
InsufficientQuota,
InternalError,
CantMoveSharedFolder,
CantMoveIntoVault(MoveIntoVaultError),
CantMoveIntoFamily(MoveIntoFamilyError),
TooManyWriteOperations,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = RelocationBatchError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationBatchError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"from_lookup" => {
match map.next_key()? {
Some("from_lookup") => RelocationBatchError::FromLookup(map.next_value()?),
None => return Err(de::Error::missing_field("from_lookup")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"from_write" => {
match map.next_key()? {
Some("from_write") => RelocationBatchError::FromWrite(map.next_value()?),
None => return Err(de::Error::missing_field("from_write")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"to" => {
match map.next_key()? {
Some("to") => RelocationBatchError::To(map.next_value()?),
None => return Err(de::Error::missing_field("to")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"cant_copy_shared_folder" => RelocationBatchError::CantCopySharedFolder,
"cant_nest_shared_folder" => RelocationBatchError::CantNestSharedFolder,
"cant_move_folder_into_itself" => RelocationBatchError::CantMoveFolderIntoItself,
"too_many_files" => RelocationBatchError::TooManyFiles,
"duplicated_or_nested_paths" => RelocationBatchError::DuplicatedOrNestedPaths,
"cant_transfer_ownership" => RelocationBatchError::CantTransferOwnership,
"insufficient_quota" => RelocationBatchError::InsufficientQuota,
"internal_error" => RelocationBatchError::InternalError,
"cant_move_shared_folder" => RelocationBatchError::CantMoveSharedFolder,
"cant_move_into_vault" => {
match map.next_key()? {
Some("cant_move_into_vault") => RelocationBatchError::CantMoveIntoVault(map.next_value()?),
None => return Err(de::Error::missing_field("cant_move_into_vault")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"cant_move_into_family" => {
match map.next_key()? {
Some("cant_move_into_family") => RelocationBatchError::CantMoveIntoFamily(map.next_value()?),
None => return Err(de::Error::missing_field("cant_move_into_family")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"too_many_write_operations" => RelocationBatchError::TooManyWriteOperations,
_ => RelocationBatchError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["from_lookup",
"from_write",
"to",
"cant_copy_shared_folder",
"cant_nest_shared_folder",
"cant_move_folder_into_itself",
"too_many_files",
"duplicated_or_nested_paths",
"cant_transfer_ownership",
"insufficient_quota",
"internal_error",
"cant_move_shared_folder",
"cant_move_into_vault",
"cant_move_into_family",
"other",
"too_many_write_operations"];
deserializer.deserialize_struct("RelocationBatchError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for RelocationBatchError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
RelocationBatchError::FromLookup(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
s.serialize_field(".tag", "from_lookup")?;
s.serialize_field("from_lookup", x)?;
s.end()
}
RelocationBatchError::FromWrite(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
s.serialize_field(".tag", "from_write")?;
s.serialize_field("from_write", x)?;
s.end()
}
RelocationBatchError::To(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
s.serialize_field(".tag", "to")?;
s.serialize_field("to", x)?;
s.end()
}
RelocationBatchError::CantCopySharedFolder => {
let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
s.serialize_field(".tag", "cant_copy_shared_folder")?;
s.end()
}
RelocationBatchError::CantNestSharedFolder => {
let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
s.serialize_field(".tag", "cant_nest_shared_folder")?;
s.end()
}
RelocationBatchError::CantMoveFolderIntoItself => {
let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
s.serialize_field(".tag", "cant_move_folder_into_itself")?;
s.end()
}
RelocationBatchError::TooManyFiles => {
let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
s.serialize_field(".tag", "too_many_files")?;
s.end()
}
RelocationBatchError::DuplicatedOrNestedPaths => {
let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
s.serialize_field(".tag", "duplicated_or_nested_paths")?;
s.end()
}
RelocationBatchError::CantTransferOwnership => {
let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
s.serialize_field(".tag", "cant_transfer_ownership")?;
s.end()
}
RelocationBatchError::InsufficientQuota => {
let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
s.serialize_field(".tag", "insufficient_quota")?;
s.end()
}
RelocationBatchError::InternalError => {
let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
s.serialize_field(".tag", "internal_error")?;
s.end()
}
RelocationBatchError::CantMoveSharedFolder => {
let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
s.serialize_field(".tag", "cant_move_shared_folder")?;
s.end()
}
RelocationBatchError::CantMoveIntoVault(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
s.serialize_field(".tag", "cant_move_into_vault")?;
s.serialize_field("cant_move_into_vault", x)?;
s.end()
}
RelocationBatchError::CantMoveIntoFamily(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchError", 2)?;
s.serialize_field(".tag", "cant_move_into_family")?;
s.serialize_field("cant_move_into_family", x)?;
s.end()
}
RelocationBatchError::TooManyWriteOperations => {
let mut s = serializer.serialize_struct("RelocationBatchError", 1)?;
s.serialize_field(".tag", "too_many_write_operations")?;
s.end()
}
RelocationBatchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for RelocationBatchError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
RelocationBatchError::FromLookup(inner) => Some(inner),
RelocationBatchError::FromWrite(inner) => Some(inner),
RelocationBatchError::To(inner) => Some(inner),
RelocationBatchError::CantMoveIntoVault(inner) => Some(inner),
RelocationBatchError::CantMoveIntoFamily(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for RelocationBatchError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
RelocationBatchError::FromLookup(inner) => write!(f, "{}", inner),
RelocationBatchError::FromWrite(inner) => write!(f, "{}", inner),
RelocationBatchError::To(inner) => write!(f, "{}", inner),
RelocationBatchError::CantCopySharedFolder => f.write_str("Shared folders can't be copied."),
RelocationBatchError::CantNestSharedFolder => f.write_str("Your move operation would result in nested shared folders. This is not allowed."),
RelocationBatchError::CantMoveFolderIntoItself => f.write_str("You cannot move a folder into itself."),
RelocationBatchError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
RelocationBatchError::InsufficientQuota => f.write_str("The current user does not have enough space to move or copy the files."),
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."),
RelocationBatchError::CantMoveSharedFolder => f.write_str("Can't move the shared folder to the given destination."),
RelocationBatchError::CantMoveIntoVault(inner) => write!(f, "Some content cannot be moved into Vault under certain circumstances, see detailed error: {}", inner),
RelocationBatchError::CantMoveIntoFamily(inner) => write!(f, "Some content cannot be moved into the Family Room folder under certain circumstances, see detailed error: {}", inner),
RelocationBatchError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum RelocationBatchErrorEntry {
RelocationError(RelocationError),
InternalError,
TooManyWriteOperations,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchErrorEntry {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = RelocationBatchErrorEntry;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationBatchErrorEntry structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"relocation_error" => {
match map.next_key()? {
Some("relocation_error") => RelocationBatchErrorEntry::RelocationError(map.next_value()?),
None => return Err(de::Error::missing_field("relocation_error")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"internal_error" => RelocationBatchErrorEntry::InternalError,
"too_many_write_operations" => RelocationBatchErrorEntry::TooManyWriteOperations,
_ => RelocationBatchErrorEntry::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["relocation_error",
"internal_error",
"too_many_write_operations",
"other"];
deserializer.deserialize_struct("RelocationBatchErrorEntry", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for RelocationBatchErrorEntry {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
RelocationBatchErrorEntry::RelocationError(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 2)?;
s.serialize_field(".tag", "relocation_error")?;
s.serialize_field("relocation_error", x)?;
s.end()
}
RelocationBatchErrorEntry::InternalError => {
let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 1)?;
s.serialize_field(".tag", "internal_error")?;
s.end()
}
RelocationBatchErrorEntry::TooManyWriteOperations => {
let mut s = serializer.serialize_struct("RelocationBatchErrorEntry", 1)?;
s.serialize_field(".tag", "too_many_write_operations")?;
s.end()
}
RelocationBatchErrorEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum RelocationBatchJobStatus {
InProgress,
Complete(RelocationBatchResult),
Failed(RelocationBatchError),
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchJobStatus {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = RelocationBatchJobStatus;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationBatchJobStatus structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"in_progress" => RelocationBatchJobStatus::InProgress,
"complete" => RelocationBatchJobStatus::Complete(RelocationBatchResult::internal_deserialize(&mut map)?),
"failed" => {
match map.next_key()? {
Some("failed") => RelocationBatchJobStatus::Failed(map.next_value()?),
None => return Err(de::Error::missing_field("failed")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["in_progress",
"complete",
"failed"];
deserializer.deserialize_struct("RelocationBatchJobStatus", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for RelocationBatchJobStatus {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
RelocationBatchJobStatus::InProgress => {
let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 1)?;
s.serialize_field(".tag", "in_progress")?;
s.end()
}
RelocationBatchJobStatus::Complete(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 2)?;
s.serialize_field(".tag", "complete")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
RelocationBatchJobStatus::Failed(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchJobStatus", 2)?;
s.serialize_field(".tag", "failed")?;
s.serialize_field("failed", x)?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub enum RelocationBatchLaunch {
AsyncJobId(crate::dbx_async::AsyncJobId),
Complete(RelocationBatchResult),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchLaunch {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = RelocationBatchLaunch;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationBatchLaunch structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"async_job_id" => {
match map.next_key()? {
Some("async_job_id") => RelocationBatchLaunch::AsyncJobId(map.next_value()?),
None => return Err(de::Error::missing_field("async_job_id")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"complete" => RelocationBatchLaunch::Complete(RelocationBatchResult::internal_deserialize(&mut map)?),
_ => RelocationBatchLaunch::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["async_job_id",
"complete",
"other"];
deserializer.deserialize_struct("RelocationBatchLaunch", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for RelocationBatchLaunch {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
RelocationBatchLaunch::AsyncJobId(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchLaunch", 2)?;
s.serialize_field(".tag", "async_job_id")?;
s.serialize_field("async_job_id", x)?;
s.end()
}
RelocationBatchLaunch::Complete(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchLaunch", 2)?;
s.serialize_field(".tag", "complete")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
RelocationBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct RelocationBatchResult {
pub entries: Vec<RelocationBatchResultData>,
}
impl RelocationBatchResult {
pub fn new(entries: Vec<RelocationBatchResultData>) -> Self {
RelocationBatchResult {
entries,
}
}
}
const RELOCATION_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
impl RelocationBatchResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<RelocationBatchResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<RelocationBatchResult>, V::Error> {
let mut field_entries = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = RelocationBatchResult {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = RelocationBatchResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationBatchResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
RelocationBatchResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("RelocationBatchResult", RELOCATION_BATCH_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for RelocationBatchResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("RelocationBatchResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct RelocationBatchResultData {
pub metadata: Metadata,
}
impl RelocationBatchResultData {
pub fn new(metadata: Metadata) -> Self {
RelocationBatchResultData {
metadata,
}
}
}
const RELOCATION_BATCH_RESULT_DATA_FIELDS: &[&str] = &["metadata"];
impl RelocationBatchResultData {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<RelocationBatchResultData, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<RelocationBatchResultData>, V::Error> {
let mut field_metadata = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = RelocationBatchResultData {
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("metadata", &self.metadata)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResultData {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = RelocationBatchResultData;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationBatchResultData struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
RelocationBatchResultData::internal_deserialize(map)
}
}
deserializer.deserialize_struct("RelocationBatchResultData", RELOCATION_BATCH_RESULT_DATA_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for RelocationBatchResultData {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("RelocationBatchResultData", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub enum RelocationBatchResultEntry {
Success(Metadata),
Failure(RelocationBatchErrorEntry),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchResultEntry {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = RelocationBatchResultEntry;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationBatchResultEntry structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"success" => {
match map.next_key()? {
Some("success") => RelocationBatchResultEntry::Success(map.next_value()?),
None => return Err(de::Error::missing_field("success")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"failure" => {
match map.next_key()? {
Some("failure") => RelocationBatchResultEntry::Failure(map.next_value()?),
None => return Err(de::Error::missing_field("failure")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => RelocationBatchResultEntry::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["success",
"failure",
"other"];
deserializer.deserialize_struct("RelocationBatchResultEntry", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for RelocationBatchResultEntry {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
RelocationBatchResultEntry::Success(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchResultEntry", 2)?;
s.serialize_field(".tag", "success")?;
s.serialize_field("success", x)?;
s.end()
}
RelocationBatchResultEntry::Failure(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchResultEntry", 2)?;
s.serialize_field(".tag", "failure")?;
s.serialize_field("failure", x)?;
s.end()
}
RelocationBatchResultEntry::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum RelocationBatchV2JobStatus {
InProgress,
Complete(RelocationBatchV2Result),
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2JobStatus {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = RelocationBatchV2JobStatus;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationBatchV2JobStatus structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"in_progress" => RelocationBatchV2JobStatus::InProgress,
"complete" => RelocationBatchV2JobStatus::Complete(RelocationBatchV2Result::internal_deserialize(&mut map)?),
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["in_progress",
"complete"];
deserializer.deserialize_struct("RelocationBatchV2JobStatus", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for RelocationBatchV2JobStatus {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
RelocationBatchV2JobStatus::InProgress => {
let mut s = serializer.serialize_struct("RelocationBatchV2JobStatus", 1)?;
s.serialize_field(".tag", "in_progress")?;
s.end()
}
RelocationBatchV2JobStatus::Complete(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchV2JobStatus", 2)?;
s.serialize_field(".tag", "complete")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum RelocationBatchV2Launch {
AsyncJobId(crate::dbx_async::AsyncJobId),
Complete(RelocationBatchV2Result),
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2Launch {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = RelocationBatchV2Launch;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationBatchV2Launch structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"async_job_id" => {
match map.next_key()? {
Some("async_job_id") => RelocationBatchV2Launch::AsyncJobId(map.next_value()?),
None => return Err(de::Error::missing_field("async_job_id")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"complete" => RelocationBatchV2Launch::Complete(RelocationBatchV2Result::internal_deserialize(&mut map)?),
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["async_job_id",
"complete"];
deserializer.deserialize_struct("RelocationBatchV2Launch", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for RelocationBatchV2Launch {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
RelocationBatchV2Launch::AsyncJobId(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchV2Launch", 2)?;
s.serialize_field(".tag", "async_job_id")?;
s.serialize_field("async_job_id", x)?;
s.end()
}
RelocationBatchV2Launch::Complete(ref x) => {
let mut s = serializer.serialize_struct("RelocationBatchV2Launch", 2)?;
s.serialize_field(".tag", "complete")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct RelocationBatchV2Result {
pub entries: Vec<RelocationBatchResultEntry>,
}
impl RelocationBatchV2Result {
pub fn new(entries: Vec<RelocationBatchResultEntry>) -> Self {
RelocationBatchV2Result {
entries,
}
}
}
const RELOCATION_BATCH_V2_RESULT_FIELDS: &[&str] = &["entries"];
impl RelocationBatchV2Result {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<RelocationBatchV2Result, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<RelocationBatchV2Result>, V::Error> {
let mut field_entries = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = RelocationBatchV2Result {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationBatchV2Result {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = RelocationBatchV2Result;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationBatchV2Result struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
RelocationBatchV2Result::internal_deserialize(map)
}
}
deserializer.deserialize_struct("RelocationBatchV2Result", RELOCATION_BATCH_V2_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for RelocationBatchV2Result {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("RelocationBatchV2Result", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum RelocationError {
FromLookup(LookupError),
FromWrite(WriteError),
To(WriteError),
CantCopySharedFolder,
CantNestSharedFolder,
CantMoveFolderIntoItself,
TooManyFiles,
DuplicatedOrNestedPaths,
CantTransferOwnership,
InsufficientQuota,
InternalError,
CantMoveSharedFolder,
CantMoveIntoVault(MoveIntoVaultError),
CantMoveIntoFamily(MoveIntoFamilyError),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = RelocationError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"from_lookup" => {
match map.next_key()? {
Some("from_lookup") => RelocationError::FromLookup(map.next_value()?),
None => return Err(de::Error::missing_field("from_lookup")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"from_write" => {
match map.next_key()? {
Some("from_write") => RelocationError::FromWrite(map.next_value()?),
None => return Err(de::Error::missing_field("from_write")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"to" => {
match map.next_key()? {
Some("to") => RelocationError::To(map.next_value()?),
None => return Err(de::Error::missing_field("to")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"cant_copy_shared_folder" => RelocationError::CantCopySharedFolder,
"cant_nest_shared_folder" => RelocationError::CantNestSharedFolder,
"cant_move_folder_into_itself" => RelocationError::CantMoveFolderIntoItself,
"too_many_files" => RelocationError::TooManyFiles,
"duplicated_or_nested_paths" => RelocationError::DuplicatedOrNestedPaths,
"cant_transfer_ownership" => RelocationError::CantTransferOwnership,
"insufficient_quota" => RelocationError::InsufficientQuota,
"internal_error" => RelocationError::InternalError,
"cant_move_shared_folder" => RelocationError::CantMoveSharedFolder,
"cant_move_into_vault" => {
match map.next_key()? {
Some("cant_move_into_vault") => RelocationError::CantMoveIntoVault(map.next_value()?),
None => return Err(de::Error::missing_field("cant_move_into_vault")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"cant_move_into_family" => {
match map.next_key()? {
Some("cant_move_into_family") => RelocationError::CantMoveIntoFamily(map.next_value()?),
None => return Err(de::Error::missing_field("cant_move_into_family")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => RelocationError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["from_lookup",
"from_write",
"to",
"cant_copy_shared_folder",
"cant_nest_shared_folder",
"cant_move_folder_into_itself",
"too_many_files",
"duplicated_or_nested_paths",
"cant_transfer_ownership",
"insufficient_quota",
"internal_error",
"cant_move_shared_folder",
"cant_move_into_vault",
"cant_move_into_family",
"other"];
deserializer.deserialize_struct("RelocationError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for RelocationError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
RelocationError::FromLookup(ref x) => {
let mut s = serializer.serialize_struct("RelocationError", 2)?;
s.serialize_field(".tag", "from_lookup")?;
s.serialize_field("from_lookup", x)?;
s.end()
}
RelocationError::FromWrite(ref x) => {
let mut s = serializer.serialize_struct("RelocationError", 2)?;
s.serialize_field(".tag", "from_write")?;
s.serialize_field("from_write", x)?;
s.end()
}
RelocationError::To(ref x) => {
let mut s = serializer.serialize_struct("RelocationError", 2)?;
s.serialize_field(".tag", "to")?;
s.serialize_field("to", x)?;
s.end()
}
RelocationError::CantCopySharedFolder => {
let mut s = serializer.serialize_struct("RelocationError", 1)?;
s.serialize_field(".tag", "cant_copy_shared_folder")?;
s.end()
}
RelocationError::CantNestSharedFolder => {
let mut s = serializer.serialize_struct("RelocationError", 1)?;
s.serialize_field(".tag", "cant_nest_shared_folder")?;
s.end()
}
RelocationError::CantMoveFolderIntoItself => {
let mut s = serializer.serialize_struct("RelocationError", 1)?;
s.serialize_field(".tag", "cant_move_folder_into_itself")?;
s.end()
}
RelocationError::TooManyFiles => {
let mut s = serializer.serialize_struct("RelocationError", 1)?;
s.serialize_field(".tag", "too_many_files")?;
s.end()
}
RelocationError::DuplicatedOrNestedPaths => {
let mut s = serializer.serialize_struct("RelocationError", 1)?;
s.serialize_field(".tag", "duplicated_or_nested_paths")?;
s.end()
}
RelocationError::CantTransferOwnership => {
let mut s = serializer.serialize_struct("RelocationError", 1)?;
s.serialize_field(".tag", "cant_transfer_ownership")?;
s.end()
}
RelocationError::InsufficientQuota => {
let mut s = serializer.serialize_struct("RelocationError", 1)?;
s.serialize_field(".tag", "insufficient_quota")?;
s.end()
}
RelocationError::InternalError => {
let mut s = serializer.serialize_struct("RelocationError", 1)?;
s.serialize_field(".tag", "internal_error")?;
s.end()
}
RelocationError::CantMoveSharedFolder => {
let mut s = serializer.serialize_struct("RelocationError", 1)?;
s.serialize_field(".tag", "cant_move_shared_folder")?;
s.end()
}
RelocationError::CantMoveIntoVault(ref x) => {
let mut s = serializer.serialize_struct("RelocationError", 2)?;
s.serialize_field(".tag", "cant_move_into_vault")?;
s.serialize_field("cant_move_into_vault", x)?;
s.end()
}
RelocationError::CantMoveIntoFamily(ref x) => {
let mut s = serializer.serialize_struct("RelocationError", 2)?;
s.serialize_field(".tag", "cant_move_into_family")?;
s.serialize_field("cant_move_into_family", x)?;
s.end()
}
RelocationError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for RelocationError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
RelocationError::FromLookup(inner) => Some(inner),
RelocationError::FromWrite(inner) => Some(inner),
RelocationError::To(inner) => Some(inner),
RelocationError::CantMoveIntoVault(inner) => Some(inner),
RelocationError::CantMoveIntoFamily(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for RelocationError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
RelocationError::FromLookup(inner) => write!(f, "{}", inner),
RelocationError::FromWrite(inner) => write!(f, "{}", inner),
RelocationError::To(inner) => write!(f, "{}", inner),
RelocationError::CantCopySharedFolder => f.write_str("Shared folders can't be copied."),
RelocationError::CantNestSharedFolder => f.write_str("Your move operation would result in nested shared folders. This is not allowed."),
RelocationError::CantMoveFolderIntoItself => f.write_str("You cannot move a folder into itself."),
RelocationError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
RelocationError::InsufficientQuota => f.write_str("The current user does not have enough space to move or copy the files."),
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."),
RelocationError::CantMoveSharedFolder => f.write_str("Can't move the shared folder to the given destination."),
RelocationError::CantMoveIntoVault(inner) => write!(f, "Some content cannot be moved into Vault under certain circumstances, see detailed error: {}", inner),
RelocationError::CantMoveIntoFamily(inner) => write!(f, "Some content cannot be moved into the Family Room folder under certain circumstances, see detailed error: {}", inner),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct RelocationPath {
pub from_path: WritePathOrId,
pub to_path: WritePathOrId,
}
impl RelocationPath {
pub fn new(from_path: WritePathOrId, to_path: WritePathOrId) -> Self {
RelocationPath {
from_path,
to_path,
}
}
}
const RELOCATION_PATH_FIELDS: &[&str] = &["from_path",
"to_path"];
impl RelocationPath {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<RelocationPath, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<RelocationPath>, V::Error> {
let mut field_from_path = None;
let mut field_to_path = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"from_path" => {
if field_from_path.is_some() {
return Err(::serde::de::Error::duplicate_field("from_path"));
}
field_from_path = Some(map.next_value()?);
}
"to_path" => {
if field_to_path.is_some() {
return Err(::serde::de::Error::duplicate_field("to_path"));
}
field_to_path = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = RelocationPath {
from_path: field_from_path.ok_or_else(|| ::serde::de::Error::missing_field("from_path"))?,
to_path: field_to_path.ok_or_else(|| ::serde::de::Error::missing_field("to_path"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("from_path", &self.from_path)?;
s.serialize_field("to_path", &self.to_path)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationPath {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = RelocationPath;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationPath struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
RelocationPath::internal_deserialize(map)
}
}
deserializer.deserialize_struct("RelocationPath", RELOCATION_PATH_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for RelocationPath {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("RelocationPath", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct RelocationResult {
pub metadata: Metadata,
}
impl RelocationResult {
pub fn new(metadata: Metadata) -> Self {
RelocationResult {
metadata,
}
}
}
const RELOCATION_RESULT_FIELDS: &[&str] = &["metadata"];
impl RelocationResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<RelocationResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<RelocationResult>, V::Error> {
let mut field_metadata = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = RelocationResult {
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("metadata", &self.metadata)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for RelocationResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = RelocationResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RelocationResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
RelocationResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("RelocationResult", RELOCATION_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for RelocationResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("RelocationResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct RemoveTagArg {
pub path: Path,
pub tag_text: TagText,
}
impl RemoveTagArg {
pub fn new(path: Path, tag_text: TagText) -> Self {
RemoveTagArg {
path,
tag_text,
}
}
}
const REMOVE_TAG_ARG_FIELDS: &[&str] = &["path",
"tag_text"];
impl RemoveTagArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<RemoveTagArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<RemoveTagArg>, V::Error> {
let mut field_path = None;
let mut field_tag_text = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"tag_text" => {
if field_tag_text.is_some() {
return Err(::serde::de::Error::duplicate_field("tag_text"));
}
field_tag_text = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = RemoveTagArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
tag_text: field_tag_text.ok_or_else(|| ::serde::de::Error::missing_field("tag_text"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("tag_text", &self.tag_text)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for RemoveTagArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = RemoveTagArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RemoveTagArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
RemoveTagArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("RemoveTagArg", REMOVE_TAG_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for RemoveTagArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("RemoveTagArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum RemoveTagError {
Path(LookupError),
TagNotPresent,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for RemoveTagError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = RemoveTagError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RemoveTagError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => RemoveTagError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"tag_not_present" => RemoveTagError::TagNotPresent,
_ => RemoveTagError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"other",
"tag_not_present"];
deserializer.deserialize_struct("RemoveTagError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for RemoveTagError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
RemoveTagError::Path(ref x) => {
let mut s = serializer.serialize_struct("RemoveTagError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
RemoveTagError::TagNotPresent => {
let mut s = serializer.serialize_struct("RemoveTagError", 1)?;
s.serialize_field(".tag", "tag_not_present")?;
s.end()
}
RemoveTagError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for RemoveTagError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
RemoveTagError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for RemoveTagError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
RemoveTagError::Path(inner) => write!(f, "{}", inner),
RemoveTagError::TagNotPresent => f.write_str("That tag doesn't exist at this path."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct RestoreArg {
pub path: WritePath,
pub rev: Rev,
}
impl RestoreArg {
pub fn new(path: WritePath, rev: Rev) -> Self {
RestoreArg {
path,
rev,
}
}
}
const RESTORE_ARG_FIELDS: &[&str] = &["path",
"rev"];
impl RestoreArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<RestoreArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<RestoreArg>, V::Error> {
let mut field_path = None;
let mut field_rev = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"rev" => {
if field_rev.is_some() {
return Err(::serde::de::Error::duplicate_field("rev"));
}
field_rev = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = RestoreArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
rev: field_rev.ok_or_else(|| ::serde::de::Error::missing_field("rev"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("rev", &self.rev)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for RestoreArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = RestoreArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RestoreArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
RestoreArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("RestoreArg", RESTORE_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for RestoreArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("RestoreArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum RestoreError {
PathLookup(LookupError),
PathWrite(WriteError),
InvalidRevision,
InProgress,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for RestoreError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = RestoreError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a RestoreError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path_lookup" => {
match map.next_key()? {
Some("path_lookup") => RestoreError::PathLookup(map.next_value()?),
None => return Err(de::Error::missing_field("path_lookup")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"path_write" => {
match map.next_key()? {
Some("path_write") => RestoreError::PathWrite(map.next_value()?),
None => return Err(de::Error::missing_field("path_write")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"invalid_revision" => RestoreError::InvalidRevision,
"in_progress" => RestoreError::InProgress,
_ => RestoreError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path_lookup",
"path_write",
"invalid_revision",
"in_progress",
"other"];
deserializer.deserialize_struct("RestoreError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for RestoreError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
RestoreError::PathLookup(ref x) => {
let mut s = serializer.serialize_struct("RestoreError", 2)?;
s.serialize_field(".tag", "path_lookup")?;
s.serialize_field("path_lookup", x)?;
s.end()
}
RestoreError::PathWrite(ref x) => {
let mut s = serializer.serialize_struct("RestoreError", 2)?;
s.serialize_field(".tag", "path_write")?;
s.serialize_field("path_write", x)?;
s.end()
}
RestoreError::InvalidRevision => {
let mut s = serializer.serialize_struct("RestoreError", 1)?;
s.serialize_field(".tag", "invalid_revision")?;
s.end()
}
RestoreError::InProgress => {
let mut s = serializer.serialize_struct("RestoreError", 1)?;
s.serialize_field(".tag", "in_progress")?;
s.end()
}
RestoreError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for RestoreError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
RestoreError::PathLookup(inner) => Some(inner),
RestoreError::PathWrite(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for RestoreError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
RestoreError::PathLookup(inner) => write!(f, "An error occurs when downloading metadata for the file: {}", inner),
RestoreError::PathWrite(inner) => write!(f, "An error occurs when trying to restore the file to that path: {}", inner),
RestoreError::InvalidRevision => f.write_str("The revision is invalid. It may not exist or may point to a deleted file."),
RestoreError::InProgress => f.write_str("The restore is currently executing, but has not yet completed."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct SaveCopyReferenceArg {
pub copy_reference: String,
pub path: Path,
}
impl SaveCopyReferenceArg {
pub fn new(copy_reference: String, path: Path) -> Self {
SaveCopyReferenceArg {
copy_reference,
path,
}
}
}
const SAVE_COPY_REFERENCE_ARG_FIELDS: &[&str] = &["copy_reference",
"path"];
impl SaveCopyReferenceArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SaveCopyReferenceArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SaveCopyReferenceArg>, V::Error> {
let mut field_copy_reference = None;
let mut field_path = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"copy_reference" => {
if field_copy_reference.is_some() {
return Err(::serde::de::Error::duplicate_field("copy_reference"));
}
field_copy_reference = Some(map.next_value()?);
}
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SaveCopyReferenceArg {
copy_reference: field_copy_reference.ok_or_else(|| ::serde::de::Error::missing_field("copy_reference"))?,
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("copy_reference", &self.copy_reference)?;
s.serialize_field("path", &self.path)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SaveCopyReferenceArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SaveCopyReferenceArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SaveCopyReferenceArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SaveCopyReferenceArg", SAVE_COPY_REFERENCE_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SaveCopyReferenceArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SaveCopyReferenceArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum SaveCopyReferenceError {
Path(WriteError),
InvalidCopyReference,
NoPermission,
NotFound,
TooManyFiles,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = SaveCopyReferenceError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SaveCopyReferenceError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => SaveCopyReferenceError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"invalid_copy_reference" => SaveCopyReferenceError::InvalidCopyReference,
"no_permission" => SaveCopyReferenceError::NoPermission,
"not_found" => SaveCopyReferenceError::NotFound,
"too_many_files" => SaveCopyReferenceError::TooManyFiles,
_ => SaveCopyReferenceError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"invalid_copy_reference",
"no_permission",
"not_found",
"too_many_files",
"other"];
deserializer.deserialize_struct("SaveCopyReferenceError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for SaveCopyReferenceError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
SaveCopyReferenceError::Path(ref x) => {
let mut s = serializer.serialize_struct("SaveCopyReferenceError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
SaveCopyReferenceError::InvalidCopyReference => {
let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
s.serialize_field(".tag", "invalid_copy_reference")?;
s.end()
}
SaveCopyReferenceError::NoPermission => {
let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
s.serialize_field(".tag", "no_permission")?;
s.end()
}
SaveCopyReferenceError::NotFound => {
let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
s.serialize_field(".tag", "not_found")?;
s.end()
}
SaveCopyReferenceError::TooManyFiles => {
let mut s = serializer.serialize_struct("SaveCopyReferenceError", 1)?;
s.serialize_field(".tag", "too_many_files")?;
s.end()
}
SaveCopyReferenceError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for SaveCopyReferenceError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
SaveCopyReferenceError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for SaveCopyReferenceError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
SaveCopyReferenceError::Path(inner) => write!(f, "{}", inner),
SaveCopyReferenceError::InvalidCopyReference => f.write_str("The copy reference is invalid."),
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."),
SaveCopyReferenceError::NotFound => f.write_str("The file referenced by the copy reference cannot be found."),
SaveCopyReferenceError::TooManyFiles => f.write_str("The operation would involve more than 10,000 files and folders."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct SaveCopyReferenceResult {
pub metadata: Metadata,
}
impl SaveCopyReferenceResult {
pub fn new(metadata: Metadata) -> Self {
SaveCopyReferenceResult {
metadata,
}
}
}
const SAVE_COPY_REFERENCE_RESULT_FIELDS: &[&str] = &["metadata"];
impl SaveCopyReferenceResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SaveCopyReferenceResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SaveCopyReferenceResult>, V::Error> {
let mut field_metadata = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SaveCopyReferenceResult {
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("metadata", &self.metadata)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SaveCopyReferenceResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SaveCopyReferenceResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SaveCopyReferenceResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SaveCopyReferenceResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SaveCopyReferenceResult", SAVE_COPY_REFERENCE_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SaveCopyReferenceResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SaveCopyReferenceResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct SaveUrlArg {
pub path: Path,
pub url: String,
}
impl SaveUrlArg {
pub fn new(path: Path, url: String) -> Self {
SaveUrlArg {
path,
url,
}
}
}
const SAVE_URL_ARG_FIELDS: &[&str] = &["path",
"url"];
impl SaveUrlArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SaveUrlArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SaveUrlArg>, V::Error> {
let mut field_path = None;
let mut field_url = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"url" => {
if field_url.is_some() {
return Err(::serde::de::Error::duplicate_field("url"));
}
field_url = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SaveUrlArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("url", &self.url)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SaveUrlArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SaveUrlArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SaveUrlArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SaveUrlArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SaveUrlArg", SAVE_URL_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SaveUrlArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SaveUrlArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum SaveUrlError {
Path(WriteError),
DownloadFailed,
InvalidUrl,
NotFound,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for SaveUrlError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = SaveUrlError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SaveUrlError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => SaveUrlError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"download_failed" => SaveUrlError::DownloadFailed,
"invalid_url" => SaveUrlError::InvalidUrl,
"not_found" => SaveUrlError::NotFound,
_ => SaveUrlError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"download_failed",
"invalid_url",
"not_found",
"other"];
deserializer.deserialize_struct("SaveUrlError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for SaveUrlError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
SaveUrlError::Path(ref x) => {
let mut s = serializer.serialize_struct("SaveUrlError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
SaveUrlError::DownloadFailed => {
let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
s.serialize_field(".tag", "download_failed")?;
s.end()
}
SaveUrlError::InvalidUrl => {
let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
s.serialize_field(".tag", "invalid_url")?;
s.end()
}
SaveUrlError::NotFound => {
let mut s = serializer.serialize_struct("SaveUrlError", 1)?;
s.serialize_field(".tag", "not_found")?;
s.end()
}
SaveUrlError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for SaveUrlError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
SaveUrlError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for SaveUrlError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
SaveUrlError::Path(inner) => write!(f, "{}", inner),
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."),
SaveUrlError::InvalidUrl => f.write_str("The given URL is invalid."),
SaveUrlError::NotFound => f.write_str("The file where the URL is saved to no longer exists."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum SaveUrlJobStatus {
InProgress,
Complete(FileMetadata),
Failed(SaveUrlError),
}
impl<'de> ::serde::de::Deserialize<'de> for SaveUrlJobStatus {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = SaveUrlJobStatus;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SaveUrlJobStatus structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"in_progress" => SaveUrlJobStatus::InProgress,
"complete" => SaveUrlJobStatus::Complete(FileMetadata::internal_deserialize(&mut map)?),
"failed" => {
match map.next_key()? {
Some("failed") => SaveUrlJobStatus::Failed(map.next_value()?),
None => return Err(de::Error::missing_field("failed")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["in_progress",
"complete",
"failed"];
deserializer.deserialize_struct("SaveUrlJobStatus", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for SaveUrlJobStatus {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
SaveUrlJobStatus::InProgress => {
let mut s = serializer.serialize_struct("SaveUrlJobStatus", 1)?;
s.serialize_field(".tag", "in_progress")?;
s.end()
}
SaveUrlJobStatus::Complete(ref x) => {
let mut s = serializer.serialize_struct("SaveUrlJobStatus", 20)?;
s.serialize_field(".tag", "complete")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
SaveUrlJobStatus::Failed(ref x) => {
let mut s = serializer.serialize_struct("SaveUrlJobStatus", 2)?;
s.serialize_field(".tag", "failed")?;
s.serialize_field("failed", x)?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum SaveUrlResult {
AsyncJobId(crate::dbx_async::AsyncJobId),
Complete(FileMetadata),
}
impl<'de> ::serde::de::Deserialize<'de> for SaveUrlResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = SaveUrlResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SaveUrlResult structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"async_job_id" => {
match map.next_key()? {
Some("async_job_id") => SaveUrlResult::AsyncJobId(map.next_value()?),
None => return Err(de::Error::missing_field("async_job_id")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"complete" => SaveUrlResult::Complete(FileMetadata::internal_deserialize(&mut map)?),
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["async_job_id",
"complete"];
deserializer.deserialize_struct("SaveUrlResult", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for SaveUrlResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
SaveUrlResult::AsyncJobId(ref x) => {
let mut s = serializer.serialize_struct("SaveUrlResult", 2)?;
s.serialize_field(".tag", "async_job_id")?;
s.serialize_field("async_job_id", x)?;
s.end()
}
SaveUrlResult::Complete(ref x) => {
let mut s = serializer.serialize_struct("SaveUrlResult", 20)?;
s.serialize_field(".tag", "complete")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct SearchArg {
pub path: PathROrId,
pub query: String,
pub start: u64,
pub max_results: u64,
pub mode: SearchMode,
}
impl SearchArg {
pub fn new(path: PathROrId, query: String) -> Self {
SearchArg {
path,
query,
start: 0,
max_results: 100,
mode: SearchMode::Filename,
}
}
pub fn with_start(mut self, value: u64) -> Self {
self.start = value;
self
}
pub fn with_max_results(mut self, value: u64) -> Self {
self.max_results = value;
self
}
pub fn with_mode(mut self, value: SearchMode) -> Self {
self.mode = value;
self
}
}
const SEARCH_ARG_FIELDS: &[&str] = &["path",
"query",
"start",
"max_results",
"mode"];
impl SearchArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SearchArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SearchArg>, V::Error> {
let mut field_path = None;
let mut field_query = None;
let mut field_start = None;
let mut field_max_results = None;
let mut field_mode = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"query" => {
if field_query.is_some() {
return Err(::serde::de::Error::duplicate_field("query"));
}
field_query = Some(map.next_value()?);
}
"start" => {
if field_start.is_some() {
return Err(::serde::de::Error::duplicate_field("start"));
}
field_start = Some(map.next_value()?);
}
"max_results" => {
if field_max_results.is_some() {
return Err(::serde::de::Error::duplicate_field("max_results"));
}
field_max_results = Some(map.next_value()?);
}
"mode" => {
if field_mode.is_some() {
return Err(::serde::de::Error::duplicate_field("mode"));
}
field_mode = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SearchArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
query: field_query.ok_or_else(|| ::serde::de::Error::missing_field("query"))?,
start: field_start.unwrap_or(0),
max_results: field_max_results.unwrap_or(100),
mode: field_mode.unwrap_or(SearchMode::Filename),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("query", &self.query)?;
s.serialize_field("start", &self.start)?;
s.serialize_field("max_results", &self.max_results)?;
s.serialize_field("mode", &self.mode)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SearchArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SearchArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SearchArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SearchArg", SEARCH_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SearchArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SearchArg", 5)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum SearchError {
Path(LookupError),
InvalidArgument(Option<String>),
InternalError,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for SearchError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = SearchError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => SearchError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"invalid_argument" => {
match map.next_key()? {
Some("invalid_argument") => SearchError::InvalidArgument(map.next_value()?),
None => SearchError::InvalidArgument(None),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"internal_error" => SearchError::InternalError,
_ => SearchError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"invalid_argument",
"internal_error",
"other"];
deserializer.deserialize_struct("SearchError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for SearchError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
SearchError::Path(ref x) => {
let mut s = serializer.serialize_struct("SearchError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
SearchError::InvalidArgument(ref x) => {
let n = if x.is_some() { 2 } else { 1 };
let mut s = serializer.serialize_struct("SearchError", n)?;
s.serialize_field(".tag", "invalid_argument")?;
if let Some(ref x) = x {
s.serialize_field("invalid_argument", &x)?;
}
s.end()
}
SearchError::InternalError => {
let mut s = serializer.serialize_struct("SearchError", 1)?;
s.serialize_field(".tag", "internal_error")?;
s.end()
}
SearchError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for SearchError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
SearchError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for SearchError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
SearchError::Path(inner) => write!(f, "{}", inner),
SearchError::InvalidArgument(None) => f.write_str("invalid_argument"),
SearchError::InvalidArgument(Some(inner)) => write!(f, "invalid_argument: {:?}", inner),
SearchError::InternalError => f.write_str("Something went wrong, please try again."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct SearchMatch {
pub match_type: SearchMatchType,
pub metadata: Metadata,
}
impl SearchMatch {
pub fn new(match_type: SearchMatchType, metadata: Metadata) -> Self {
SearchMatch {
match_type,
metadata,
}
}
}
const SEARCH_MATCH_FIELDS: &[&str] = &["match_type",
"metadata"];
impl SearchMatch {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SearchMatch, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SearchMatch>, V::Error> {
let mut field_match_type = None;
let mut field_metadata = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"match_type" => {
if field_match_type.is_some() {
return Err(::serde::de::Error::duplicate_field("match_type"));
}
field_match_type = Some(map.next_value()?);
}
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SearchMatch {
match_type: field_match_type.ok_or_else(|| ::serde::de::Error::missing_field("match_type"))?,
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("match_type", &self.match_type)?;
s.serialize_field("metadata", &self.metadata)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SearchMatch {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SearchMatch;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchMatch struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SearchMatch::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SearchMatch", SEARCH_MATCH_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SearchMatch {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SearchMatch", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[non_exhaustive] pub struct SearchMatchFieldOptions {
pub include_highlights: bool,
}
impl SearchMatchFieldOptions {
pub fn with_include_highlights(mut self, value: bool) -> Self {
self.include_highlights = value;
self
}
}
const SEARCH_MATCH_FIELD_OPTIONS_FIELDS: &[&str] = &["include_highlights"];
impl SearchMatchFieldOptions {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<SearchMatchFieldOptions, V::Error> {
let mut field_include_highlights = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"include_highlights" => {
if field_include_highlights.is_some() {
return Err(::serde::de::Error::duplicate_field("include_highlights"));
}
field_include_highlights = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = SearchMatchFieldOptions {
include_highlights: field_include_highlights.unwrap_or(false),
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("include_highlights", &self.include_highlights)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SearchMatchFieldOptions {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SearchMatchFieldOptions;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchMatchFieldOptions struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SearchMatchFieldOptions::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SearchMatchFieldOptions", SEARCH_MATCH_FIELD_OPTIONS_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SearchMatchFieldOptions {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SearchMatchFieldOptions", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SearchMatchType {
Filename,
Content,
Both,
}
impl<'de> ::serde::de::Deserialize<'de> for SearchMatchType {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = SearchMatchType;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchMatchType structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"filename" => SearchMatchType::Filename,
"content" => SearchMatchType::Content,
"both" => SearchMatchType::Both,
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["filename",
"content",
"both"];
deserializer.deserialize_struct("SearchMatchType", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for SearchMatchType {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
SearchMatchType::Filename => {
let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
s.serialize_field(".tag", "filename")?;
s.end()
}
SearchMatchType::Content => {
let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
s.serialize_field(".tag", "content")?;
s.end()
}
SearchMatchType::Both => {
let mut s = serializer.serialize_struct("SearchMatchType", 1)?;
s.serialize_field(".tag", "both")?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum SearchMatchTypeV2 {
Filename,
FileContent,
FilenameAndContent,
ImageContent,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for SearchMatchTypeV2 {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = SearchMatchTypeV2;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchMatchTypeV2 structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"filename" => SearchMatchTypeV2::Filename,
"file_content" => SearchMatchTypeV2::FileContent,
"filename_and_content" => SearchMatchTypeV2::FilenameAndContent,
"image_content" => SearchMatchTypeV2::ImageContent,
_ => SearchMatchTypeV2::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["filename",
"file_content",
"filename_and_content",
"image_content",
"other"];
deserializer.deserialize_struct("SearchMatchTypeV2", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for SearchMatchTypeV2 {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
SearchMatchTypeV2::Filename => {
let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
s.serialize_field(".tag", "filename")?;
s.end()
}
SearchMatchTypeV2::FileContent => {
let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
s.serialize_field(".tag", "file_content")?;
s.end()
}
SearchMatchTypeV2::FilenameAndContent => {
let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
s.serialize_field(".tag", "filename_and_content")?;
s.end()
}
SearchMatchTypeV2::ImageContent => {
let mut s = serializer.serialize_struct("SearchMatchTypeV2", 1)?;
s.serialize_field(".tag", "image_content")?;
s.end()
}
SearchMatchTypeV2::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct SearchMatchV2 {
pub metadata: MetadataV2,
pub match_type: Option<SearchMatchTypeV2>,
pub highlight_spans: Option<Vec<HighlightSpan>>,
}
impl SearchMatchV2 {
pub fn new(metadata: MetadataV2) -> Self {
SearchMatchV2 {
metadata,
match_type: None,
highlight_spans: None,
}
}
pub fn with_match_type(mut self, value: SearchMatchTypeV2) -> Self {
self.match_type = Some(value);
self
}
pub fn with_highlight_spans(mut self, value: Vec<HighlightSpan>) -> Self {
self.highlight_spans = Some(value);
self
}
}
const SEARCH_MATCH_V2_FIELDS: &[&str] = &["metadata",
"match_type",
"highlight_spans"];
impl SearchMatchV2 {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SearchMatchV2, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SearchMatchV2>, V::Error> {
let mut field_metadata = None;
let mut field_match_type = None;
let mut field_highlight_spans = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"metadata" => {
if field_metadata.is_some() {
return Err(::serde::de::Error::duplicate_field("metadata"));
}
field_metadata = Some(map.next_value()?);
}
"match_type" => {
if field_match_type.is_some() {
return Err(::serde::de::Error::duplicate_field("match_type"));
}
field_match_type = Some(map.next_value()?);
}
"highlight_spans" => {
if field_highlight_spans.is_some() {
return Err(::serde::de::Error::duplicate_field("highlight_spans"));
}
field_highlight_spans = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SearchMatchV2 {
metadata: field_metadata.ok_or_else(|| ::serde::de::Error::missing_field("metadata"))?,
match_type: field_match_type,
highlight_spans: field_highlight_spans,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("metadata", &self.metadata)?;
if let Some(val) = &self.match_type {
s.serialize_field("match_type", val)?;
}
if let Some(val) = &self.highlight_spans {
s.serialize_field("highlight_spans", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SearchMatchV2 {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SearchMatchV2;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchMatchV2 struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SearchMatchV2::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SearchMatchV2", SEARCH_MATCH_V2_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SearchMatchV2 {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SearchMatchV2", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SearchMode {
Filename,
FilenameAndContent,
DeletedFilename,
}
impl<'de> ::serde::de::Deserialize<'de> for SearchMode {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = SearchMode;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchMode structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"filename" => SearchMode::Filename,
"filename_and_content" => SearchMode::FilenameAndContent,
"deleted_filename" => SearchMode::DeletedFilename,
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["filename",
"filename_and_content",
"deleted_filename"];
deserializer.deserialize_struct("SearchMode", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for SearchMode {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
SearchMode::Filename => {
let mut s = serializer.serialize_struct("SearchMode", 1)?;
s.serialize_field(".tag", "filename")?;
s.end()
}
SearchMode::FilenameAndContent => {
let mut s = serializer.serialize_struct("SearchMode", 1)?;
s.serialize_field(".tag", "filename_and_content")?;
s.end()
}
SearchMode::DeletedFilename => {
let mut s = serializer.serialize_struct("SearchMode", 1)?;
s.serialize_field(".tag", "deleted_filename")?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct SearchOptions {
pub path: Option<PathROrId>,
pub max_results: u64,
pub order_by: Option<SearchOrderBy>,
pub file_status: FileStatus,
pub filename_only: bool,
pub file_extensions: Option<Vec<String>>,
pub file_categories: Option<Vec<FileCategory>>,
}
impl Default for SearchOptions {
fn default() -> Self {
SearchOptions {
path: None,
max_results: 100,
order_by: None,
file_status: FileStatus::Active,
filename_only: false,
file_extensions: None,
file_categories: None,
}
}
}
impl SearchOptions {
pub fn with_path(mut self, value: PathROrId) -> Self {
self.path = Some(value);
self
}
pub fn with_max_results(mut self, value: u64) -> Self {
self.max_results = value;
self
}
pub fn with_order_by(mut self, value: SearchOrderBy) -> Self {
self.order_by = Some(value);
self
}
pub fn with_file_status(mut self, value: FileStatus) -> Self {
self.file_status = value;
self
}
pub fn with_filename_only(mut self, value: bool) -> Self {
self.filename_only = value;
self
}
pub fn with_file_extensions(mut self, value: Vec<String>) -> Self {
self.file_extensions = Some(value);
self
}
pub fn with_file_categories(mut self, value: Vec<FileCategory>) -> Self {
self.file_categories = Some(value);
self
}
}
const SEARCH_OPTIONS_FIELDS: &[&str] = &["path",
"max_results",
"order_by",
"file_status",
"filename_only",
"file_extensions",
"file_categories"];
impl SearchOptions {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<SearchOptions, V::Error> {
let mut field_path = None;
let mut field_max_results = None;
let mut field_order_by = None;
let mut field_file_status = None;
let mut field_filename_only = None;
let mut field_file_extensions = None;
let mut field_file_categories = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"max_results" => {
if field_max_results.is_some() {
return Err(::serde::de::Error::duplicate_field("max_results"));
}
field_max_results = Some(map.next_value()?);
}
"order_by" => {
if field_order_by.is_some() {
return Err(::serde::de::Error::duplicate_field("order_by"));
}
field_order_by = Some(map.next_value()?);
}
"file_status" => {
if field_file_status.is_some() {
return Err(::serde::de::Error::duplicate_field("file_status"));
}
field_file_status = Some(map.next_value()?);
}
"filename_only" => {
if field_filename_only.is_some() {
return Err(::serde::de::Error::duplicate_field("filename_only"));
}
field_filename_only = Some(map.next_value()?);
}
"file_extensions" => {
if field_file_extensions.is_some() {
return Err(::serde::de::Error::duplicate_field("file_extensions"));
}
field_file_extensions = Some(map.next_value()?);
}
"file_categories" => {
if field_file_categories.is_some() {
return Err(::serde::de::Error::duplicate_field("file_categories"));
}
field_file_categories = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = SearchOptions {
path: field_path,
max_results: field_max_results.unwrap_or(100),
order_by: field_order_by,
file_status: field_file_status.unwrap_or(FileStatus::Active),
filename_only: field_filename_only.unwrap_or(false),
file_extensions: field_file_extensions,
file_categories: field_file_categories,
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
if let Some(val) = &self.path {
s.serialize_field("path", val)?;
}
s.serialize_field("max_results", &self.max_results)?;
if let Some(val) = &self.order_by {
s.serialize_field("order_by", val)?;
}
s.serialize_field("file_status", &self.file_status)?;
s.serialize_field("filename_only", &self.filename_only)?;
if let Some(val) = &self.file_extensions {
s.serialize_field("file_extensions", val)?;
}
if let Some(val) = &self.file_categories {
s.serialize_field("file_categories", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SearchOptions {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SearchOptions;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchOptions struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SearchOptions::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SearchOptions", SEARCH_OPTIONS_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SearchOptions {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SearchOptions", 7)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum SearchOrderBy {
Relevance,
LastModifiedTime,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for SearchOrderBy {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = SearchOrderBy;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchOrderBy structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"relevance" => SearchOrderBy::Relevance,
"last_modified_time" => SearchOrderBy::LastModifiedTime,
_ => SearchOrderBy::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["relevance",
"last_modified_time",
"other"];
deserializer.deserialize_struct("SearchOrderBy", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for SearchOrderBy {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
SearchOrderBy::Relevance => {
let mut s = serializer.serialize_struct("SearchOrderBy", 1)?;
s.serialize_field(".tag", "relevance")?;
s.end()
}
SearchOrderBy::LastModifiedTime => {
let mut s = serializer.serialize_struct("SearchOrderBy", 1)?;
s.serialize_field(".tag", "last_modified_time")?;
s.end()
}
SearchOrderBy::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct SearchResult {
pub matches: Vec<SearchMatch>,
pub more: bool,
pub start: u64,
}
impl SearchResult {
pub fn new(matches: Vec<SearchMatch>, more: bool, start: u64) -> Self {
SearchResult {
matches,
more,
start,
}
}
}
const SEARCH_RESULT_FIELDS: &[&str] = &["matches",
"more",
"start"];
impl SearchResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SearchResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SearchResult>, V::Error> {
let mut field_matches = None;
let mut field_more = None;
let mut field_start = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"matches" => {
if field_matches.is_some() {
return Err(::serde::de::Error::duplicate_field("matches"));
}
field_matches = Some(map.next_value()?);
}
"more" => {
if field_more.is_some() {
return Err(::serde::de::Error::duplicate_field("more"));
}
field_more = Some(map.next_value()?);
}
"start" => {
if field_start.is_some() {
return Err(::serde::de::Error::duplicate_field("start"));
}
field_start = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SearchResult {
matches: field_matches.ok_or_else(|| ::serde::de::Error::missing_field("matches"))?,
more: field_more.ok_or_else(|| ::serde::de::Error::missing_field("more"))?,
start: field_start.ok_or_else(|| ::serde::de::Error::missing_field("start"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("matches", &self.matches)?;
s.serialize_field("more", &self.more)?;
s.serialize_field("start", &self.start)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SearchResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SearchResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SearchResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SearchResult", SEARCH_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SearchResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SearchResult", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct SearchV2Arg {
pub query: String,
pub options: Option<SearchOptions>,
pub match_field_options: Option<SearchMatchFieldOptions>,
pub include_highlights: Option<bool>,
}
impl SearchV2Arg {
pub fn new(query: String) -> Self {
SearchV2Arg {
query,
options: None,
match_field_options: None,
include_highlights: None,
}
}
pub fn with_options(mut self, value: SearchOptions) -> Self {
self.options = Some(value);
self
}
pub fn with_match_field_options(mut self, value: SearchMatchFieldOptions) -> Self {
self.match_field_options = Some(value);
self
}
pub fn with_include_highlights(mut self, value: bool) -> Self {
self.include_highlights = Some(value);
self
}
}
const SEARCH_V2_ARG_FIELDS: &[&str] = &["query",
"options",
"match_field_options",
"include_highlights"];
impl SearchV2Arg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SearchV2Arg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SearchV2Arg>, V::Error> {
let mut field_query = None;
let mut field_options = None;
let mut field_match_field_options = None;
let mut field_include_highlights = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"query" => {
if field_query.is_some() {
return Err(::serde::de::Error::duplicate_field("query"));
}
field_query = Some(map.next_value()?);
}
"options" => {
if field_options.is_some() {
return Err(::serde::de::Error::duplicate_field("options"));
}
field_options = Some(map.next_value()?);
}
"match_field_options" => {
if field_match_field_options.is_some() {
return Err(::serde::de::Error::duplicate_field("match_field_options"));
}
field_match_field_options = Some(map.next_value()?);
}
"include_highlights" => {
if field_include_highlights.is_some() {
return Err(::serde::de::Error::duplicate_field("include_highlights"));
}
field_include_highlights = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SearchV2Arg {
query: field_query.ok_or_else(|| ::serde::de::Error::missing_field("query"))?,
options: field_options,
match_field_options: field_match_field_options,
include_highlights: field_include_highlights,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("query", &self.query)?;
if let Some(val) = &self.options {
s.serialize_field("options", val)?;
}
if let Some(val) = &self.match_field_options {
s.serialize_field("match_field_options", val)?;
}
if let Some(val) = &self.include_highlights {
s.serialize_field("include_highlights", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SearchV2Arg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SearchV2Arg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchV2Arg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SearchV2Arg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SearchV2Arg", SEARCH_V2_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SearchV2Arg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SearchV2Arg", 4)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct SearchV2ContinueArg {
pub cursor: SearchV2Cursor,
}
impl SearchV2ContinueArg {
pub fn new(cursor: SearchV2Cursor) -> Self {
SearchV2ContinueArg {
cursor,
}
}
}
const SEARCH_V2_CONTINUE_ARG_FIELDS: &[&str] = &["cursor"];
impl SearchV2ContinueArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SearchV2ContinueArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SearchV2ContinueArg>, V::Error> {
let mut field_cursor = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"cursor" => {
if field_cursor.is_some() {
return Err(::serde::de::Error::duplicate_field("cursor"));
}
field_cursor = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SearchV2ContinueArg {
cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("cursor", &self.cursor)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SearchV2ContinueArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SearchV2ContinueArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchV2ContinueArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SearchV2ContinueArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SearchV2ContinueArg", SEARCH_V2_CONTINUE_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SearchV2ContinueArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SearchV2ContinueArg", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct SearchV2Result {
pub matches: Vec<SearchMatchV2>,
pub has_more: bool,
pub cursor: Option<SearchV2Cursor>,
}
impl SearchV2Result {
pub fn new(matches: Vec<SearchMatchV2>, has_more: bool) -> Self {
SearchV2Result {
matches,
has_more,
cursor: None,
}
}
pub fn with_cursor(mut self, value: SearchV2Cursor) -> Self {
self.cursor = Some(value);
self
}
}
const SEARCH_V2_RESULT_FIELDS: &[&str] = &["matches",
"has_more",
"cursor"];
impl SearchV2Result {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SearchV2Result, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SearchV2Result>, V::Error> {
let mut field_matches = None;
let mut field_has_more = None;
let mut field_cursor = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"matches" => {
if field_matches.is_some() {
return Err(::serde::de::Error::duplicate_field("matches"));
}
field_matches = Some(map.next_value()?);
}
"has_more" => {
if field_has_more.is_some() {
return Err(::serde::de::Error::duplicate_field("has_more"));
}
field_has_more = Some(map.next_value()?);
}
"cursor" => {
if field_cursor.is_some() {
return Err(::serde::de::Error::duplicate_field("cursor"));
}
field_cursor = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SearchV2Result {
matches: field_matches.ok_or_else(|| ::serde::de::Error::missing_field("matches"))?,
has_more: field_has_more.ok_or_else(|| ::serde::de::Error::missing_field("has_more"))?,
cursor: field_cursor,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("matches", &self.matches)?;
s.serialize_field("has_more", &self.has_more)?;
if let Some(val) = &self.cursor {
s.serialize_field("cursor", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SearchV2Result {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SearchV2Result;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SearchV2Result struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SearchV2Result::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SearchV2Result", SEARCH_V2_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SearchV2Result {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SearchV2Result", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct SharedLink {
pub url: SharedLinkUrl,
pub password: Option<String>,
}
impl SharedLink {
pub fn new(url: SharedLinkUrl) -> Self {
SharedLink {
url,
password: None,
}
}
pub fn with_password(mut self, value: String) -> Self {
self.password = Some(value);
self
}
}
const SHARED_LINK_FIELDS: &[&str] = &["url",
"password"];
impl SharedLink {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SharedLink, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SharedLink>, V::Error> {
let mut field_url = None;
let mut field_password = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"url" => {
if field_url.is_some() {
return Err(::serde::de::Error::duplicate_field("url"));
}
field_url = Some(map.next_value()?);
}
"password" => {
if field_password.is_some() {
return Err(::serde::de::Error::duplicate_field("password"));
}
field_password = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SharedLink {
url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
password: field_password,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("url", &self.url)?;
if let Some(val) = &self.password {
s.serialize_field("password", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SharedLink {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SharedLink;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SharedLink struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SharedLink::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SharedLink", SHARED_LINK_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SharedLink {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SharedLink", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct SharedLinkFileInfo {
pub url: String,
pub path: Option<String>,
pub password: Option<String>,
}
impl SharedLinkFileInfo {
pub fn new(url: String) -> Self {
SharedLinkFileInfo {
url,
path: None,
password: None,
}
}
pub fn with_path(mut self, value: String) -> Self {
self.path = Some(value);
self
}
pub fn with_password(mut self, value: String) -> Self {
self.password = Some(value);
self
}
}
const SHARED_LINK_FILE_INFO_FIELDS: &[&str] = &["url",
"path",
"password"];
impl SharedLinkFileInfo {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SharedLinkFileInfo, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SharedLinkFileInfo>, V::Error> {
let mut field_url = None;
let mut field_path = None;
let mut field_password = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"url" => {
if field_url.is_some() {
return Err(::serde::de::Error::duplicate_field("url"));
}
field_url = Some(map.next_value()?);
}
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"password" => {
if field_password.is_some() {
return Err(::serde::de::Error::duplicate_field("password"));
}
field_password = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SharedLinkFileInfo {
url: field_url.ok_or_else(|| ::serde::de::Error::missing_field("url"))?,
path: field_path,
password: field_password,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("url", &self.url)?;
if let Some(val) = &self.path {
s.serialize_field("path", val)?;
}
if let Some(val) = &self.password {
s.serialize_field("password", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SharedLinkFileInfo {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SharedLinkFileInfo;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SharedLinkFileInfo struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SharedLinkFileInfo::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SharedLinkFileInfo", SHARED_LINK_FILE_INFO_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SharedLinkFileInfo {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SharedLinkFileInfo", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct SharingInfo {
pub read_only: bool,
}
impl SharingInfo {
pub fn new(read_only: bool) -> Self {
SharingInfo {
read_only,
}
}
}
const SHARING_INFO_FIELDS: &[&str] = &["read_only"];
impl SharingInfo {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SharingInfo, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SharingInfo>, V::Error> {
let mut field_read_only = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"read_only" => {
if field_read_only.is_some() {
return Err(::serde::de::Error::duplicate_field("read_only"));
}
field_read_only = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SharingInfo {
read_only: field_read_only.ok_or_else(|| ::serde::de::Error::missing_field("read_only"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("read_only", &self.read_only)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SharingInfo {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SharingInfo;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SharingInfo struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SharingInfo::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SharingInfo", SHARING_INFO_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SharingInfo {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SharingInfo", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct SingleUserLock {
pub created: crate::common::DropboxTimestamp,
pub lock_holder_account_id: crate::users_common::AccountId,
pub lock_holder_team_id: Option<String>,
}
impl SingleUserLock {
pub fn new(
created: crate::common::DropboxTimestamp,
lock_holder_account_id: crate::users_common::AccountId,
) -> Self {
SingleUserLock {
created,
lock_holder_account_id,
lock_holder_team_id: None,
}
}
pub fn with_lock_holder_team_id(mut self, value: String) -> Self {
self.lock_holder_team_id = Some(value);
self
}
}
const SINGLE_USER_LOCK_FIELDS: &[&str] = &["created",
"lock_holder_account_id",
"lock_holder_team_id"];
impl SingleUserLock {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SingleUserLock, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SingleUserLock>, V::Error> {
let mut field_created = None;
let mut field_lock_holder_account_id = None;
let mut field_lock_holder_team_id = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"created" => {
if field_created.is_some() {
return Err(::serde::de::Error::duplicate_field("created"));
}
field_created = Some(map.next_value()?);
}
"lock_holder_account_id" => {
if field_lock_holder_account_id.is_some() {
return Err(::serde::de::Error::duplicate_field("lock_holder_account_id"));
}
field_lock_holder_account_id = Some(map.next_value()?);
}
"lock_holder_team_id" => {
if field_lock_holder_team_id.is_some() {
return Err(::serde::de::Error::duplicate_field("lock_holder_team_id"));
}
field_lock_holder_team_id = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SingleUserLock {
created: field_created.ok_or_else(|| ::serde::de::Error::missing_field("created"))?,
lock_holder_account_id: field_lock_holder_account_id.ok_or_else(|| ::serde::de::Error::missing_field("lock_holder_account_id"))?,
lock_holder_team_id: field_lock_holder_team_id,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("created", &self.created)?;
s.serialize_field("lock_holder_account_id", &self.lock_holder_account_id)?;
if let Some(val) = &self.lock_holder_team_id {
s.serialize_field("lock_holder_team_id", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SingleUserLock {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SingleUserLock;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SingleUserLock struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SingleUserLock::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SingleUserLock", SINGLE_USER_LOCK_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SingleUserLock {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SingleUserLock", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct SymlinkInfo {
pub target: String,
}
impl SymlinkInfo {
pub fn new(target: String) -> Self {
SymlinkInfo {
target,
}
}
}
const SYMLINK_INFO_FIELDS: &[&str] = &["target"];
impl SymlinkInfo {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<SymlinkInfo, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<SymlinkInfo>, V::Error> {
let mut field_target = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"target" => {
if field_target.is_some() {
return Err(::serde::de::Error::duplicate_field("target"));
}
field_target = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = SymlinkInfo {
target: field_target.ok_or_else(|| ::serde::de::Error::missing_field("target"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("target", &self.target)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for SymlinkInfo {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = SymlinkInfo;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SymlinkInfo struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
SymlinkInfo::internal_deserialize(map)
}
}
deserializer.deserialize_struct("SymlinkInfo", SYMLINK_INFO_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for SymlinkInfo {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("SymlinkInfo", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum SyncSetting {
Default,
NotSynced,
NotSyncedInactive,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for SyncSetting {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = SyncSetting;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SyncSetting structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"default" => SyncSetting::Default,
"not_synced" => SyncSetting::NotSynced,
"not_synced_inactive" => SyncSetting::NotSyncedInactive,
_ => SyncSetting::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["default",
"not_synced",
"not_synced_inactive",
"other"];
deserializer.deserialize_struct("SyncSetting", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for SyncSetting {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
SyncSetting::Default => {
let mut s = serializer.serialize_struct("SyncSetting", 1)?;
s.serialize_field(".tag", "default")?;
s.end()
}
SyncSetting::NotSynced => {
let mut s = serializer.serialize_struct("SyncSetting", 1)?;
s.serialize_field(".tag", "not_synced")?;
s.end()
}
SyncSetting::NotSyncedInactive => {
let mut s = serializer.serialize_struct("SyncSetting", 1)?;
s.serialize_field(".tag", "not_synced_inactive")?;
s.end()
}
SyncSetting::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum SyncSettingArg {
Default,
NotSynced,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for SyncSettingArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = SyncSettingArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SyncSettingArg structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"default" => SyncSettingArg::Default,
"not_synced" => SyncSettingArg::NotSynced,
_ => SyncSettingArg::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["default",
"not_synced",
"other"];
deserializer.deserialize_struct("SyncSettingArg", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for SyncSettingArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
SyncSettingArg::Default => {
let mut s = serializer.serialize_struct("SyncSettingArg", 1)?;
s.serialize_field(".tag", "default")?;
s.end()
}
SyncSettingArg::NotSynced => {
let mut s = serializer.serialize_struct("SyncSettingArg", 1)?;
s.serialize_field(".tag", "not_synced")?;
s.end()
}
SyncSettingArg::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum SyncSettingsError {
Path(LookupError),
UnsupportedCombination,
UnsupportedConfiguration,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for SyncSettingsError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = SyncSettingsError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a SyncSettingsError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => SyncSettingsError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"unsupported_combination" => SyncSettingsError::UnsupportedCombination,
"unsupported_configuration" => SyncSettingsError::UnsupportedConfiguration,
_ => SyncSettingsError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"unsupported_combination",
"unsupported_configuration",
"other"];
deserializer.deserialize_struct("SyncSettingsError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for SyncSettingsError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
SyncSettingsError::Path(ref x) => {
let mut s = serializer.serialize_struct("SyncSettingsError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
SyncSettingsError::UnsupportedCombination => {
let mut s = serializer.serialize_struct("SyncSettingsError", 1)?;
s.serialize_field(".tag", "unsupported_combination")?;
s.end()
}
SyncSettingsError::UnsupportedConfiguration => {
let mut s = serializer.serialize_struct("SyncSettingsError", 1)?;
s.serialize_field(".tag", "unsupported_configuration")?;
s.end()
}
SyncSettingsError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for SyncSettingsError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
SyncSettingsError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for SyncSettingsError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
SyncSettingsError::Path(inner) => write!(f, "{}", inner),
SyncSettingsError::UnsupportedCombination => f.write_str("Setting this combination of sync settings simultaneously is not supported."),
SyncSettingsError::UnsupportedConfiguration => f.write_str("The specified configuration is not supported."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum Tag {
UserGeneratedTag(UserGeneratedTag),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for Tag {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = Tag;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a Tag structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"user_generated_tag" => Tag::UserGeneratedTag(UserGeneratedTag::internal_deserialize(&mut map)?),
_ => Tag::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["user_generated_tag",
"other"];
deserializer.deserialize_struct("Tag", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for Tag {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
Tag::UserGeneratedTag(ref x) => {
let mut s = serializer.serialize_struct("Tag", 2)?;
s.serialize_field(".tag", "user_generated_tag")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
Tag::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct ThumbnailArg {
pub path: ReadPath,
pub format: ThumbnailFormat,
pub size: ThumbnailSize,
pub mode: ThumbnailMode,
}
impl ThumbnailArg {
pub fn new(path: ReadPath) -> Self {
ThumbnailArg {
path,
format: ThumbnailFormat::Jpeg,
size: ThumbnailSize::W64h64,
mode: ThumbnailMode::Strict,
}
}
pub fn with_format(mut self, value: ThumbnailFormat) -> Self {
self.format = value;
self
}
pub fn with_size(mut self, value: ThumbnailSize) -> Self {
self.size = value;
self
}
pub fn with_mode(mut self, value: ThumbnailMode) -> Self {
self.mode = value;
self
}
}
const THUMBNAIL_ARG_FIELDS: &[&str] = &["path",
"format",
"size",
"mode"];
impl ThumbnailArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ThumbnailArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ThumbnailArg>, V::Error> {
let mut field_path = None;
let mut field_format = None;
let mut field_size = None;
let mut field_mode = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"format" => {
if field_format.is_some() {
return Err(::serde::de::Error::duplicate_field("format"));
}
field_format = Some(map.next_value()?);
}
"size" => {
if field_size.is_some() {
return Err(::serde::de::Error::duplicate_field("size"));
}
field_size = Some(map.next_value()?);
}
"mode" => {
if field_mode.is_some() {
return Err(::serde::de::Error::duplicate_field("mode"));
}
field_mode = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ThumbnailArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
format: field_format.unwrap_or(ThumbnailFormat::Jpeg),
size: field_size.unwrap_or(ThumbnailSize::W64h64),
mode: field_mode.unwrap_or(ThumbnailMode::Strict),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("format", &self.format)?;
s.serialize_field("size", &self.size)?;
s.serialize_field("mode", &self.mode)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ThumbnailArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ThumbnailArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ThumbnailArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ThumbnailArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ThumbnailArg", THUMBNAIL_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ThumbnailArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ThumbnailArg", 4)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ThumbnailError {
Path(LookupError),
UnsupportedExtension,
UnsupportedImage,
ConversionError,
}
impl<'de> ::serde::de::Deserialize<'de> for ThumbnailError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ThumbnailError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ThumbnailError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => ThumbnailError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"unsupported_extension" => ThumbnailError::UnsupportedExtension,
"unsupported_image" => ThumbnailError::UnsupportedImage,
"conversion_error" => ThumbnailError::ConversionError,
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"unsupported_extension",
"unsupported_image",
"conversion_error"];
deserializer.deserialize_struct("ThumbnailError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ThumbnailError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
ThumbnailError::Path(ref x) => {
let mut s = serializer.serialize_struct("ThumbnailError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
ThumbnailError::UnsupportedExtension => {
let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
s.serialize_field(".tag", "unsupported_extension")?;
s.end()
}
ThumbnailError::UnsupportedImage => {
let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
s.serialize_field(".tag", "unsupported_image")?;
s.end()
}
ThumbnailError::ConversionError => {
let mut s = serializer.serialize_struct("ThumbnailError", 1)?;
s.serialize_field(".tag", "conversion_error")?;
s.end()
}
}
}
}
impl ::std::error::Error for ThumbnailError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
ThumbnailError::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for ThumbnailError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
ThumbnailError::Path(inner) => write!(f, "An error occurs when downloading metadata for the image: {}", inner),
ThumbnailError::UnsupportedExtension => f.write_str("The file extension doesn't allow conversion to a thumbnail."),
ThumbnailError::UnsupportedImage => f.write_str("The image cannot be converted to a thumbnail."),
ThumbnailError::ConversionError => f.write_str("An error occurs during thumbnail conversion."),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ThumbnailFormat {
Jpeg,
Png,
}
impl<'de> ::serde::de::Deserialize<'de> for ThumbnailFormat {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ThumbnailFormat;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ThumbnailFormat structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"jpeg" => ThumbnailFormat::Jpeg,
"png" => ThumbnailFormat::Png,
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["jpeg",
"png"];
deserializer.deserialize_struct("ThumbnailFormat", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ThumbnailFormat {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
ThumbnailFormat::Jpeg => {
let mut s = serializer.serialize_struct("ThumbnailFormat", 1)?;
s.serialize_field(".tag", "jpeg")?;
s.end()
}
ThumbnailFormat::Png => {
let mut s = serializer.serialize_struct("ThumbnailFormat", 1)?;
s.serialize_field(".tag", "png")?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ThumbnailMode {
Strict,
Bestfit,
FitoneBestfit,
}
impl<'de> ::serde::de::Deserialize<'de> for ThumbnailMode {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ThumbnailMode;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ThumbnailMode structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"strict" => ThumbnailMode::Strict,
"bestfit" => ThumbnailMode::Bestfit,
"fitone_bestfit" => ThumbnailMode::FitoneBestfit,
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["strict",
"bestfit",
"fitone_bestfit"];
deserializer.deserialize_struct("ThumbnailMode", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ThumbnailMode {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
ThumbnailMode::Strict => {
let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
s.serialize_field(".tag", "strict")?;
s.end()
}
ThumbnailMode::Bestfit => {
let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
s.serialize_field(".tag", "bestfit")?;
s.end()
}
ThumbnailMode::FitoneBestfit => {
let mut s = serializer.serialize_struct("ThumbnailMode", 1)?;
s.serialize_field(".tag", "fitone_bestfit")?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ThumbnailSize {
W32h32,
W64h64,
W128h128,
W256h256,
W480h320,
W640h480,
W960h640,
W1024h768,
W2048h1536,
}
impl<'de> ::serde::de::Deserialize<'de> for ThumbnailSize {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ThumbnailSize;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ThumbnailSize structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"w32h32" => ThumbnailSize::W32h32,
"w64h64" => ThumbnailSize::W64h64,
"w128h128" => ThumbnailSize::W128h128,
"w256h256" => ThumbnailSize::W256h256,
"w480h320" => ThumbnailSize::W480h320,
"w640h480" => ThumbnailSize::W640h480,
"w960h640" => ThumbnailSize::W960h640,
"w1024h768" => ThumbnailSize::W1024h768,
"w2048h1536" => ThumbnailSize::W2048h1536,
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["w32h32",
"w64h64",
"w128h128",
"w256h256",
"w480h320",
"w640h480",
"w960h640",
"w1024h768",
"w2048h1536"];
deserializer.deserialize_struct("ThumbnailSize", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ThumbnailSize {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
ThumbnailSize::W32h32 => {
let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
s.serialize_field(".tag", "w32h32")?;
s.end()
}
ThumbnailSize::W64h64 => {
let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
s.serialize_field(".tag", "w64h64")?;
s.end()
}
ThumbnailSize::W128h128 => {
let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
s.serialize_field(".tag", "w128h128")?;
s.end()
}
ThumbnailSize::W256h256 => {
let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
s.serialize_field(".tag", "w256h256")?;
s.end()
}
ThumbnailSize::W480h320 => {
let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
s.serialize_field(".tag", "w480h320")?;
s.end()
}
ThumbnailSize::W640h480 => {
let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
s.serialize_field(".tag", "w640h480")?;
s.end()
}
ThumbnailSize::W960h640 => {
let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
s.serialize_field(".tag", "w960h640")?;
s.end()
}
ThumbnailSize::W1024h768 => {
let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
s.serialize_field(".tag", "w1024h768")?;
s.end()
}
ThumbnailSize::W2048h1536 => {
let mut s = serializer.serialize_struct("ThumbnailSize", 1)?;
s.serialize_field(".tag", "w2048h1536")?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct ThumbnailV2Arg {
pub resource: PathOrLink,
pub format: ThumbnailFormat,
pub size: ThumbnailSize,
pub mode: ThumbnailMode,
}
impl ThumbnailV2Arg {
pub fn new(resource: PathOrLink) -> Self {
ThumbnailV2Arg {
resource,
format: ThumbnailFormat::Jpeg,
size: ThumbnailSize::W64h64,
mode: ThumbnailMode::Strict,
}
}
pub fn with_format(mut self, value: ThumbnailFormat) -> Self {
self.format = value;
self
}
pub fn with_size(mut self, value: ThumbnailSize) -> Self {
self.size = value;
self
}
pub fn with_mode(mut self, value: ThumbnailMode) -> Self {
self.mode = value;
self
}
}
const THUMBNAIL_V2_ARG_FIELDS: &[&str] = &["resource",
"format",
"size",
"mode"];
impl ThumbnailV2Arg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<ThumbnailV2Arg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<ThumbnailV2Arg>, V::Error> {
let mut field_resource = None;
let mut field_format = None;
let mut field_size = None;
let mut field_mode = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"resource" => {
if field_resource.is_some() {
return Err(::serde::de::Error::duplicate_field("resource"));
}
field_resource = Some(map.next_value()?);
}
"format" => {
if field_format.is_some() {
return Err(::serde::de::Error::duplicate_field("format"));
}
field_format = Some(map.next_value()?);
}
"size" => {
if field_size.is_some() {
return Err(::serde::de::Error::duplicate_field("size"));
}
field_size = Some(map.next_value()?);
}
"mode" => {
if field_mode.is_some() {
return Err(::serde::de::Error::duplicate_field("mode"));
}
field_mode = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = ThumbnailV2Arg {
resource: field_resource.ok_or_else(|| ::serde::de::Error::missing_field("resource"))?,
format: field_format.unwrap_or(ThumbnailFormat::Jpeg),
size: field_size.unwrap_or(ThumbnailSize::W64h64),
mode: field_mode.unwrap_or(ThumbnailMode::Strict),
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("resource", &self.resource)?;
s.serialize_field("format", &self.format)?;
s.serialize_field("size", &self.size)?;
s.serialize_field("mode", &self.mode)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for ThumbnailV2Arg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = ThumbnailV2Arg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ThumbnailV2Arg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
ThumbnailV2Arg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("ThumbnailV2Arg", THUMBNAIL_V2_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for ThumbnailV2Arg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("ThumbnailV2Arg", 4)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum ThumbnailV2Error {
Path(LookupError),
UnsupportedExtension,
UnsupportedImage,
ConversionError,
AccessDenied,
NotFound,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for ThumbnailV2Error {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = ThumbnailV2Error;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a ThumbnailV2Error structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => {
match map.next_key()? {
Some("path") => ThumbnailV2Error::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"unsupported_extension" => ThumbnailV2Error::UnsupportedExtension,
"unsupported_image" => ThumbnailV2Error::UnsupportedImage,
"conversion_error" => ThumbnailV2Error::ConversionError,
"access_denied" => ThumbnailV2Error::AccessDenied,
"not_found" => ThumbnailV2Error::NotFound,
_ => ThumbnailV2Error::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"unsupported_extension",
"unsupported_image",
"conversion_error",
"access_denied",
"not_found",
"other"];
deserializer.deserialize_struct("ThumbnailV2Error", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for ThumbnailV2Error {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
ThumbnailV2Error::Path(ref x) => {
let mut s = serializer.serialize_struct("ThumbnailV2Error", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
ThumbnailV2Error::UnsupportedExtension => {
let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
s.serialize_field(".tag", "unsupported_extension")?;
s.end()
}
ThumbnailV2Error::UnsupportedImage => {
let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
s.serialize_field(".tag", "unsupported_image")?;
s.end()
}
ThumbnailV2Error::ConversionError => {
let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
s.serialize_field(".tag", "conversion_error")?;
s.end()
}
ThumbnailV2Error::AccessDenied => {
let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
s.serialize_field(".tag", "access_denied")?;
s.end()
}
ThumbnailV2Error::NotFound => {
let mut s = serializer.serialize_struct("ThumbnailV2Error", 1)?;
s.serialize_field(".tag", "not_found")?;
s.end()
}
ThumbnailV2Error::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for ThumbnailV2Error {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
ThumbnailV2Error::Path(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for ThumbnailV2Error {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
ThumbnailV2Error::Path(inner) => write!(f, "An error occurred when downloading metadata for the image: {}", inner),
ThumbnailV2Error::UnsupportedExtension => f.write_str("The file extension doesn't allow conversion to a thumbnail."),
ThumbnailV2Error::UnsupportedImage => f.write_str("The image cannot be converted to a thumbnail."),
ThumbnailV2Error::ConversionError => f.write_str("An error occurred during thumbnail conversion."),
ThumbnailV2Error::AccessDenied => f.write_str("Access to this shared link is forbidden."),
ThumbnailV2Error::NotFound => f.write_str("The shared link does not exist."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct UnlockFileArg {
pub path: WritePathOrId,
}
impl UnlockFileArg {
pub fn new(path: WritePathOrId) -> Self {
UnlockFileArg {
path,
}
}
}
const UNLOCK_FILE_ARG_FIELDS: &[&str] = &["path"];
impl UnlockFileArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UnlockFileArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UnlockFileArg>, V::Error> {
let mut field_path = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UnlockFileArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UnlockFileArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UnlockFileArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UnlockFileArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UnlockFileArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UnlockFileArg", UNLOCK_FILE_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UnlockFileArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UnlockFileArg", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct UnlockFileBatchArg {
pub entries: Vec<UnlockFileArg>,
}
impl UnlockFileBatchArg {
pub fn new(entries: Vec<UnlockFileArg>) -> Self {
UnlockFileBatchArg {
entries,
}
}
}
const UNLOCK_FILE_BATCH_ARG_FIELDS: &[&str] = &["entries"];
impl UnlockFileBatchArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UnlockFileBatchArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UnlockFileBatchArg>, V::Error> {
let mut field_entries = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UnlockFileBatchArg {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UnlockFileBatchArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UnlockFileBatchArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UnlockFileBatchArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UnlockFileBatchArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UnlockFileBatchArg", UNLOCK_FILE_BATCH_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UnlockFileBatchArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UnlockFileBatchArg", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct UploadArg {
pub path: WritePathOrId,
pub mode: WriteMode,
pub autorename: bool,
pub client_modified: Option<crate::common::DropboxTimestamp>,
pub mute: bool,
pub property_groups: Option<Vec<crate::file_properties::PropertyGroup>>,
pub strict_conflict: bool,
pub content_hash: Option<Sha256HexHash>,
}
impl UploadArg {
pub fn new(path: WritePathOrId) -> Self {
UploadArg {
path,
mode: WriteMode::Add,
autorename: false,
client_modified: None,
mute: false,
property_groups: None,
strict_conflict: false,
content_hash: None,
}
}
pub fn with_mode(mut self, value: WriteMode) -> Self {
self.mode = value;
self
}
pub fn with_autorename(mut self, value: bool) -> Self {
self.autorename = value;
self
}
pub fn with_client_modified(mut self, value: crate::common::DropboxTimestamp) -> Self {
self.client_modified = Some(value);
self
}
pub fn with_mute(mut self, value: bool) -> Self {
self.mute = value;
self
}
pub fn with_property_groups(
mut self,
value: Vec<crate::file_properties::PropertyGroup>,
) -> Self {
self.property_groups = Some(value);
self
}
pub fn with_strict_conflict(mut self, value: bool) -> Self {
self.strict_conflict = value;
self
}
pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
self.content_hash = Some(value);
self
}
}
const UPLOAD_ARG_FIELDS: &[&str] = &["path",
"mode",
"autorename",
"client_modified",
"mute",
"property_groups",
"strict_conflict",
"content_hash"];
impl UploadArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UploadArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UploadArg>, V::Error> {
let mut field_path = None;
let mut field_mode = None;
let mut field_autorename = None;
let mut field_client_modified = None;
let mut field_mute = None;
let mut field_property_groups = None;
let mut field_strict_conflict = None;
let mut field_content_hash = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"path" => {
if field_path.is_some() {
return Err(::serde::de::Error::duplicate_field("path"));
}
field_path = Some(map.next_value()?);
}
"mode" => {
if field_mode.is_some() {
return Err(::serde::de::Error::duplicate_field("mode"));
}
field_mode = Some(map.next_value()?);
}
"autorename" => {
if field_autorename.is_some() {
return Err(::serde::de::Error::duplicate_field("autorename"));
}
field_autorename = Some(map.next_value()?);
}
"client_modified" => {
if field_client_modified.is_some() {
return Err(::serde::de::Error::duplicate_field("client_modified"));
}
field_client_modified = Some(map.next_value()?);
}
"mute" => {
if field_mute.is_some() {
return Err(::serde::de::Error::duplicate_field("mute"));
}
field_mute = Some(map.next_value()?);
}
"property_groups" => {
if field_property_groups.is_some() {
return Err(::serde::de::Error::duplicate_field("property_groups"));
}
field_property_groups = Some(map.next_value()?);
}
"strict_conflict" => {
if field_strict_conflict.is_some() {
return Err(::serde::de::Error::duplicate_field("strict_conflict"));
}
field_strict_conflict = Some(map.next_value()?);
}
"content_hash" => {
if field_content_hash.is_some() {
return Err(::serde::de::Error::duplicate_field("content_hash"));
}
field_content_hash = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UploadArg {
path: field_path.ok_or_else(|| ::serde::de::Error::missing_field("path"))?,
mode: field_mode.unwrap_or(WriteMode::Add),
autorename: field_autorename.unwrap_or(false),
client_modified: field_client_modified,
mute: field_mute.unwrap_or(false),
property_groups: field_property_groups,
strict_conflict: field_strict_conflict.unwrap_or(false),
content_hash: field_content_hash,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("path", &self.path)?;
s.serialize_field("mode", &self.mode)?;
s.serialize_field("autorename", &self.autorename)?;
if let Some(val) = &self.client_modified {
s.serialize_field("client_modified", val)?;
}
s.serialize_field("mute", &self.mute)?;
if let Some(val) = &self.property_groups {
s.serialize_field("property_groups", val)?;
}
s.serialize_field("strict_conflict", &self.strict_conflict)?;
if let Some(val) = &self.content_hash {
s.serialize_field("content_hash", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UploadArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UploadArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UploadArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UploadArg", UPLOAD_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UploadArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UploadArg", 8)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum UploadError {
Path(UploadWriteFailed),
PropertiesError(crate::file_properties::InvalidPropertyGroupError),
PayloadTooLarge,
ContentHashMismatch,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for UploadError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = UploadError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"path" => UploadError::Path(UploadWriteFailed::internal_deserialize(&mut map)?),
"properties_error" => {
match map.next_key()? {
Some("properties_error") => UploadError::PropertiesError(map.next_value()?),
None => return Err(de::Error::missing_field("properties_error")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"payload_too_large" => UploadError::PayloadTooLarge,
"content_hash_mismatch" => UploadError::ContentHashMismatch,
_ => UploadError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["path",
"properties_error",
"payload_too_large",
"content_hash_mismatch",
"other"];
deserializer.deserialize_struct("UploadError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for UploadError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
UploadError::Path(ref x) => {
let mut s = serializer.serialize_struct("UploadError", 3)?;
s.serialize_field(".tag", "path")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
UploadError::PropertiesError(ref x) => {
let mut s = serializer.serialize_struct("UploadError", 2)?;
s.serialize_field(".tag", "properties_error")?;
s.serialize_field("properties_error", x)?;
s.end()
}
UploadError::PayloadTooLarge => {
let mut s = serializer.serialize_struct("UploadError", 1)?;
s.serialize_field(".tag", "payload_too_large")?;
s.end()
}
UploadError::ContentHashMismatch => {
let mut s = serializer.serialize_struct("UploadError", 1)?;
s.serialize_field(".tag", "content_hash_mismatch")?;
s.end()
}
UploadError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for UploadError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
UploadError::PropertiesError(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for UploadError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
UploadError::Path(inner) => write!(f, "Unable to save the uploaded contents to a file: {:?}", inner),
UploadError::PropertiesError(inner) => write!(f, "The supplied property group is invalid. The file has uploaded without property groups: {}", inner),
UploadError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MB."),
UploadError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct UploadSessionAppendArg {
pub cursor: UploadSessionCursor,
pub close: bool,
pub content_hash: Option<Sha256HexHash>,
}
impl UploadSessionAppendArg {
pub fn new(cursor: UploadSessionCursor) -> Self {
UploadSessionAppendArg {
cursor,
close: false,
content_hash: None,
}
}
pub fn with_close(mut self, value: bool) -> Self {
self.close = value;
self
}
pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
self.content_hash = Some(value);
self
}
}
const UPLOAD_SESSION_APPEND_ARG_FIELDS: &[&str] = &["cursor",
"close",
"content_hash"];
impl UploadSessionAppendArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UploadSessionAppendArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UploadSessionAppendArg>, V::Error> {
let mut field_cursor = None;
let mut field_close = None;
let mut field_content_hash = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"cursor" => {
if field_cursor.is_some() {
return Err(::serde::de::Error::duplicate_field("cursor"));
}
field_cursor = Some(map.next_value()?);
}
"close" => {
if field_close.is_some() {
return Err(::serde::de::Error::duplicate_field("close"));
}
field_close = Some(map.next_value()?);
}
"content_hash" => {
if field_content_hash.is_some() {
return Err(::serde::de::Error::duplicate_field("content_hash"));
}
field_content_hash = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UploadSessionAppendArg {
cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
close: field_close.unwrap_or(false),
content_hash: field_content_hash,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("cursor", &self.cursor)?;
s.serialize_field("close", &self.close)?;
if let Some(val) = &self.content_hash {
s.serialize_field("content_hash", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UploadSessionAppendArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionAppendArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UploadSessionAppendArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UploadSessionAppendArg", UPLOAD_SESSION_APPEND_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionAppendArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UploadSessionAppendArg", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum UploadSessionAppendError {
NotFound,
IncorrectOffset(UploadSessionOffsetError),
Closed,
NotClosed,
TooLarge,
ConcurrentSessionInvalidOffset,
ConcurrentSessionInvalidDataSize,
PayloadTooLarge,
ContentHashMismatch,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionAppendError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = UploadSessionAppendError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionAppendError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"not_found" => UploadSessionAppendError::NotFound,
"incorrect_offset" => UploadSessionAppendError::IncorrectOffset(UploadSessionOffsetError::internal_deserialize(&mut map)?),
"closed" => UploadSessionAppendError::Closed,
"not_closed" => UploadSessionAppendError::NotClosed,
"too_large" => UploadSessionAppendError::TooLarge,
"concurrent_session_invalid_offset" => UploadSessionAppendError::ConcurrentSessionInvalidOffset,
"concurrent_session_invalid_data_size" => UploadSessionAppendError::ConcurrentSessionInvalidDataSize,
"payload_too_large" => UploadSessionAppendError::PayloadTooLarge,
"content_hash_mismatch" => UploadSessionAppendError::ContentHashMismatch,
_ => UploadSessionAppendError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["not_found",
"incorrect_offset",
"closed",
"not_closed",
"too_large",
"concurrent_session_invalid_offset",
"concurrent_session_invalid_data_size",
"payload_too_large",
"other",
"content_hash_mismatch"];
deserializer.deserialize_struct("UploadSessionAppendError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionAppendError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
UploadSessionAppendError::NotFound => {
let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
s.serialize_field(".tag", "not_found")?;
s.end()
}
UploadSessionAppendError::IncorrectOffset(ref x) => {
let mut s = serializer.serialize_struct("UploadSessionAppendError", 2)?;
s.serialize_field(".tag", "incorrect_offset")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
UploadSessionAppendError::Closed => {
let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
s.serialize_field(".tag", "closed")?;
s.end()
}
UploadSessionAppendError::NotClosed => {
let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
s.serialize_field(".tag", "not_closed")?;
s.end()
}
UploadSessionAppendError::TooLarge => {
let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
s.serialize_field(".tag", "too_large")?;
s.end()
}
UploadSessionAppendError::ConcurrentSessionInvalidOffset => {
let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
s.serialize_field(".tag", "concurrent_session_invalid_offset")?;
s.end()
}
UploadSessionAppendError::ConcurrentSessionInvalidDataSize => {
let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
s.serialize_field(".tag", "concurrent_session_invalid_data_size")?;
s.end()
}
UploadSessionAppendError::PayloadTooLarge => {
let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
s.serialize_field(".tag", "payload_too_large")?;
s.end()
}
UploadSessionAppendError::ContentHashMismatch => {
let mut s = serializer.serialize_struct("UploadSessionAppendError", 1)?;
s.serialize_field(".tag", "content_hash_mismatch")?;
s.end()
}
UploadSessionAppendError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for UploadSessionAppendError {
}
impl ::std::fmt::Display for UploadSessionAppendError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
UploadSessionAppendError::NotFound => f.write_str("The upload session ID was not found or has expired. Upload sessions are valid for 7 days."),
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),
UploadSessionAppendError::Closed => f.write_str("You are attempting to append data to an upload session that has already been closed (i.e. committed)."),
UploadSessionAppendError::NotClosed => f.write_str("The session must be closed before calling upload_session/finish_batch."),
UploadSessionAppendError::TooLarge => f.write_str("You can not append to the upload session because the size of a file should not reach the max file size limit (i.e. 350GB)."),
UploadSessionAppendError::ConcurrentSessionInvalidOffset => f.write_str("For concurrent upload sessions, offset needs to be multiple of 4194304 bytes."),
UploadSessionAppendError::ConcurrentSessionInvalidDataSize => f.write_str("For concurrent upload sessions, only chunks with size multiple of 4194304 bytes can be uploaded."),
UploadSessionAppendError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MB."),
UploadSessionAppendError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct UploadSessionCursor {
pub session_id: String,
pub offset: u64,
}
impl UploadSessionCursor {
pub fn new(session_id: String, offset: u64) -> Self {
UploadSessionCursor {
session_id,
offset,
}
}
}
const UPLOAD_SESSION_CURSOR_FIELDS: &[&str] = &["session_id",
"offset"];
impl UploadSessionCursor {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UploadSessionCursor, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UploadSessionCursor>, V::Error> {
let mut field_session_id = None;
let mut field_offset = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"session_id" => {
if field_session_id.is_some() {
return Err(::serde::de::Error::duplicate_field("session_id"));
}
field_session_id = Some(map.next_value()?);
}
"offset" => {
if field_offset.is_some() {
return Err(::serde::de::Error::duplicate_field("offset"));
}
field_offset = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UploadSessionCursor {
session_id: field_session_id.ok_or_else(|| ::serde::de::Error::missing_field("session_id"))?,
offset: field_offset.ok_or_else(|| ::serde::de::Error::missing_field("offset"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("session_id", &self.session_id)?;
s.serialize_field("offset", &self.offset)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionCursor {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UploadSessionCursor;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionCursor struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UploadSessionCursor::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UploadSessionCursor", UPLOAD_SESSION_CURSOR_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionCursor {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UploadSessionCursor", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct UploadSessionFinishArg {
pub cursor: UploadSessionCursor,
pub commit: CommitInfo,
pub content_hash: Option<Sha256HexHash>,
}
impl UploadSessionFinishArg {
pub fn new(cursor: UploadSessionCursor, commit: CommitInfo) -> Self {
UploadSessionFinishArg {
cursor,
commit,
content_hash: None,
}
}
pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
self.content_hash = Some(value);
self
}
}
const UPLOAD_SESSION_FINISH_ARG_FIELDS: &[&str] = &["cursor",
"commit",
"content_hash"];
impl UploadSessionFinishArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UploadSessionFinishArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UploadSessionFinishArg>, V::Error> {
let mut field_cursor = None;
let mut field_commit = None;
let mut field_content_hash = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"cursor" => {
if field_cursor.is_some() {
return Err(::serde::de::Error::duplicate_field("cursor"));
}
field_cursor = Some(map.next_value()?);
}
"commit" => {
if field_commit.is_some() {
return Err(::serde::de::Error::duplicate_field("commit"));
}
field_commit = Some(map.next_value()?);
}
"content_hash" => {
if field_content_hash.is_some() {
return Err(::serde::de::Error::duplicate_field("content_hash"));
}
field_content_hash = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UploadSessionFinishArg {
cursor: field_cursor.ok_or_else(|| ::serde::de::Error::missing_field("cursor"))?,
commit: field_commit.ok_or_else(|| ::serde::de::Error::missing_field("commit"))?,
content_hash: field_content_hash,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("cursor", &self.cursor)?;
s.serialize_field("commit", &self.commit)?;
if let Some(val) = &self.content_hash {
s.serialize_field("content_hash", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UploadSessionFinishArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionFinishArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UploadSessionFinishArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UploadSessionFinishArg", UPLOAD_SESSION_FINISH_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionFinishArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UploadSessionFinishArg", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct UploadSessionFinishBatchArg {
pub entries: Vec<UploadSessionFinishArg>,
}
impl UploadSessionFinishBatchArg {
pub fn new(entries: Vec<UploadSessionFinishArg>) -> Self {
UploadSessionFinishBatchArg {
entries,
}
}
}
const UPLOAD_SESSION_FINISH_BATCH_ARG_FIELDS: &[&str] = &["entries"];
impl UploadSessionFinishBatchArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UploadSessionFinishBatchArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UploadSessionFinishBatchArg>, V::Error> {
let mut field_entries = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UploadSessionFinishBatchArg {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UploadSessionFinishBatchArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionFinishBatchArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UploadSessionFinishBatchArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UploadSessionFinishBatchArg", UPLOAD_SESSION_FINISH_BATCH_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionFinishBatchArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UploadSessionFinishBatchArg", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum UploadSessionFinishBatchJobStatus {
InProgress,
Complete(UploadSessionFinishBatchResult),
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchJobStatus {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = UploadSessionFinishBatchJobStatus;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionFinishBatchJobStatus structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"in_progress" => UploadSessionFinishBatchJobStatus::InProgress,
"complete" => UploadSessionFinishBatchJobStatus::Complete(UploadSessionFinishBatchResult::internal_deserialize(&mut map)?),
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["in_progress",
"complete"];
deserializer.deserialize_struct("UploadSessionFinishBatchJobStatus", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionFinishBatchJobStatus {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
UploadSessionFinishBatchJobStatus::InProgress => {
let mut s = serializer.serialize_struct("UploadSessionFinishBatchJobStatus", 1)?;
s.serialize_field(".tag", "in_progress")?;
s.end()
}
UploadSessionFinishBatchJobStatus::Complete(ref x) => {
let mut s = serializer.serialize_struct("UploadSessionFinishBatchJobStatus", 2)?;
s.serialize_field(".tag", "complete")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub enum UploadSessionFinishBatchLaunch {
AsyncJobId(crate::dbx_async::AsyncJobId),
Complete(UploadSessionFinishBatchResult),
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchLaunch {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = UploadSessionFinishBatchLaunch;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionFinishBatchLaunch structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"async_job_id" => {
match map.next_key()? {
Some("async_job_id") => UploadSessionFinishBatchLaunch::AsyncJobId(map.next_value()?),
None => return Err(de::Error::missing_field("async_job_id")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"complete" => UploadSessionFinishBatchLaunch::Complete(UploadSessionFinishBatchResult::internal_deserialize(&mut map)?),
_ => UploadSessionFinishBatchLaunch::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["async_job_id",
"complete",
"other"];
deserializer.deserialize_struct("UploadSessionFinishBatchLaunch", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionFinishBatchLaunch {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
UploadSessionFinishBatchLaunch::AsyncJobId(ref x) => {
let mut s = serializer.serialize_struct("UploadSessionFinishBatchLaunch", 2)?;
s.serialize_field(".tag", "async_job_id")?;
s.serialize_field("async_job_id", x)?;
s.end()
}
UploadSessionFinishBatchLaunch::Complete(ref x) => {
let mut s = serializer.serialize_struct("UploadSessionFinishBatchLaunch", 2)?;
s.serialize_field(".tag", "complete")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
UploadSessionFinishBatchLaunch::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive] pub struct UploadSessionFinishBatchResult {
pub entries: Vec<UploadSessionFinishBatchResultEntry>,
}
impl UploadSessionFinishBatchResult {
pub fn new(entries: Vec<UploadSessionFinishBatchResultEntry>) -> Self {
UploadSessionFinishBatchResult {
entries,
}
}
}
const UPLOAD_SESSION_FINISH_BATCH_RESULT_FIELDS: &[&str] = &["entries"];
impl UploadSessionFinishBatchResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UploadSessionFinishBatchResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UploadSessionFinishBatchResult>, V::Error> {
let mut field_entries = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"entries" => {
if field_entries.is_some() {
return Err(::serde::de::Error::duplicate_field("entries"));
}
field_entries = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UploadSessionFinishBatchResult {
entries: field_entries.ok_or_else(|| ::serde::de::Error::missing_field("entries"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("entries", &self.entries)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UploadSessionFinishBatchResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionFinishBatchResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UploadSessionFinishBatchResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UploadSessionFinishBatchResult", UPLOAD_SESSION_FINISH_BATCH_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionFinishBatchResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UploadSessionFinishBatchResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum UploadSessionFinishBatchResultEntry {
Success(FileMetadata),
Failure(UploadSessionFinishError),
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishBatchResultEntry {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = UploadSessionFinishBatchResultEntry;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionFinishBatchResultEntry structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"success" => UploadSessionFinishBatchResultEntry::Success(FileMetadata::internal_deserialize(&mut map)?),
"failure" => {
match map.next_key()? {
Some("failure") => UploadSessionFinishBatchResultEntry::Failure(map.next_value()?),
None => return Err(de::Error::missing_field("failure")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["success",
"failure"];
deserializer.deserialize_struct("UploadSessionFinishBatchResultEntry", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionFinishBatchResultEntry {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
UploadSessionFinishBatchResultEntry::Success(ref x) => {
let mut s = serializer.serialize_struct("UploadSessionFinishBatchResultEntry", 20)?;
s.serialize_field(".tag", "success")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
UploadSessionFinishBatchResultEntry::Failure(ref x) => {
let mut s = serializer.serialize_struct("UploadSessionFinishBatchResultEntry", 2)?;
s.serialize_field(".tag", "failure")?;
s.serialize_field("failure", x)?;
s.end()
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum UploadSessionFinishError {
LookupFailed(UploadSessionLookupError),
Path(WriteError),
PropertiesError(crate::file_properties::InvalidPropertyGroupError),
TooManySharedFolderTargets,
TooManyWriteOperations,
ConcurrentSessionDataNotAllowed,
ConcurrentSessionNotClosed,
ConcurrentSessionMissingData,
PayloadTooLarge,
ContentHashMismatch,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionFinishError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = UploadSessionFinishError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionFinishError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"lookup_failed" => {
match map.next_key()? {
Some("lookup_failed") => UploadSessionFinishError::LookupFailed(map.next_value()?),
None => return Err(de::Error::missing_field("lookup_failed")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"path" => {
match map.next_key()? {
Some("path") => UploadSessionFinishError::Path(map.next_value()?),
None => return Err(de::Error::missing_field("path")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"properties_error" => {
match map.next_key()? {
Some("properties_error") => UploadSessionFinishError::PropertiesError(map.next_value()?),
None => return Err(de::Error::missing_field("properties_error")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"too_many_shared_folder_targets" => UploadSessionFinishError::TooManySharedFolderTargets,
"too_many_write_operations" => UploadSessionFinishError::TooManyWriteOperations,
"concurrent_session_data_not_allowed" => UploadSessionFinishError::ConcurrentSessionDataNotAllowed,
"concurrent_session_not_closed" => UploadSessionFinishError::ConcurrentSessionNotClosed,
"concurrent_session_missing_data" => UploadSessionFinishError::ConcurrentSessionMissingData,
"payload_too_large" => UploadSessionFinishError::PayloadTooLarge,
"content_hash_mismatch" => UploadSessionFinishError::ContentHashMismatch,
_ => UploadSessionFinishError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["lookup_failed",
"path",
"properties_error",
"too_many_shared_folder_targets",
"too_many_write_operations",
"concurrent_session_data_not_allowed",
"concurrent_session_not_closed",
"concurrent_session_missing_data",
"payload_too_large",
"content_hash_mismatch",
"other"];
deserializer.deserialize_struct("UploadSessionFinishError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionFinishError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
UploadSessionFinishError::LookupFailed(ref x) => {
let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
s.serialize_field(".tag", "lookup_failed")?;
s.serialize_field("lookup_failed", x)?;
s.end()
}
UploadSessionFinishError::Path(ref x) => {
let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
s.serialize_field(".tag", "path")?;
s.serialize_field("path", x)?;
s.end()
}
UploadSessionFinishError::PropertiesError(ref x) => {
let mut s = serializer.serialize_struct("UploadSessionFinishError", 2)?;
s.serialize_field(".tag", "properties_error")?;
s.serialize_field("properties_error", x)?;
s.end()
}
UploadSessionFinishError::TooManySharedFolderTargets => {
let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
s.serialize_field(".tag", "too_many_shared_folder_targets")?;
s.end()
}
UploadSessionFinishError::TooManyWriteOperations => {
let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
s.serialize_field(".tag", "too_many_write_operations")?;
s.end()
}
UploadSessionFinishError::ConcurrentSessionDataNotAllowed => {
let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
s.serialize_field(".tag", "concurrent_session_data_not_allowed")?;
s.end()
}
UploadSessionFinishError::ConcurrentSessionNotClosed => {
let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
s.serialize_field(".tag", "concurrent_session_not_closed")?;
s.end()
}
UploadSessionFinishError::ConcurrentSessionMissingData => {
let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
s.serialize_field(".tag", "concurrent_session_missing_data")?;
s.end()
}
UploadSessionFinishError::PayloadTooLarge => {
let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
s.serialize_field(".tag", "payload_too_large")?;
s.end()
}
UploadSessionFinishError::ContentHashMismatch => {
let mut s = serializer.serialize_struct("UploadSessionFinishError", 1)?;
s.serialize_field(".tag", "content_hash_mismatch")?;
s.end()
}
UploadSessionFinishError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for UploadSessionFinishError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
UploadSessionFinishError::LookupFailed(inner) => Some(inner),
UploadSessionFinishError::Path(inner) => Some(inner),
UploadSessionFinishError::PropertiesError(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for UploadSessionFinishError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
UploadSessionFinishError::LookupFailed(inner) => write!(f, "The session arguments are incorrect; the value explains the reason: {}", inner),
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),
UploadSessionFinishError::PropertiesError(inner) => write!(f, "The supplied property group is invalid. The file has uploaded without property groups: {}", inner),
UploadSessionFinishError::TooManySharedFolderTargets => f.write_str("The batch request commits files into too many different shared folders. Please limit your batch request to files contained in a single shared folder."),
UploadSessionFinishError::TooManyWriteOperations => f.write_str("There are too many write operations happening in the user's Dropbox. You should retry uploading this file."),
UploadSessionFinishError::ConcurrentSessionDataNotAllowed => f.write_str("Uploading data not allowed when finishing concurrent upload session."),
UploadSessionFinishError::ConcurrentSessionNotClosed => f.write_str("Concurrent upload sessions need to be closed before finishing."),
UploadSessionFinishError::ConcurrentSessionMissingData => f.write_str("Not all pieces of data were uploaded before trying to finish the session."),
UploadSessionFinishError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MB."),
UploadSessionFinishError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum UploadSessionLookupError {
NotFound,
IncorrectOffset(UploadSessionOffsetError),
Closed,
NotClosed,
TooLarge,
ConcurrentSessionInvalidOffset,
ConcurrentSessionInvalidDataSize,
PayloadTooLarge,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionLookupError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = UploadSessionLookupError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionLookupError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"not_found" => UploadSessionLookupError::NotFound,
"incorrect_offset" => UploadSessionLookupError::IncorrectOffset(UploadSessionOffsetError::internal_deserialize(&mut map)?),
"closed" => UploadSessionLookupError::Closed,
"not_closed" => UploadSessionLookupError::NotClosed,
"too_large" => UploadSessionLookupError::TooLarge,
"concurrent_session_invalid_offset" => UploadSessionLookupError::ConcurrentSessionInvalidOffset,
"concurrent_session_invalid_data_size" => UploadSessionLookupError::ConcurrentSessionInvalidDataSize,
"payload_too_large" => UploadSessionLookupError::PayloadTooLarge,
_ => UploadSessionLookupError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["not_found",
"incorrect_offset",
"closed",
"not_closed",
"too_large",
"concurrent_session_invalid_offset",
"concurrent_session_invalid_data_size",
"payload_too_large",
"other"];
deserializer.deserialize_struct("UploadSessionLookupError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionLookupError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
UploadSessionLookupError::NotFound => {
let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
s.serialize_field(".tag", "not_found")?;
s.end()
}
UploadSessionLookupError::IncorrectOffset(ref x) => {
let mut s = serializer.serialize_struct("UploadSessionLookupError", 2)?;
s.serialize_field(".tag", "incorrect_offset")?;
x.internal_serialize::<S>(&mut s)?;
s.end()
}
UploadSessionLookupError::Closed => {
let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
s.serialize_field(".tag", "closed")?;
s.end()
}
UploadSessionLookupError::NotClosed => {
let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
s.serialize_field(".tag", "not_closed")?;
s.end()
}
UploadSessionLookupError::TooLarge => {
let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
s.serialize_field(".tag", "too_large")?;
s.end()
}
UploadSessionLookupError::ConcurrentSessionInvalidOffset => {
let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
s.serialize_field(".tag", "concurrent_session_invalid_offset")?;
s.end()
}
UploadSessionLookupError::ConcurrentSessionInvalidDataSize => {
let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
s.serialize_field(".tag", "concurrent_session_invalid_data_size")?;
s.end()
}
UploadSessionLookupError::PayloadTooLarge => {
let mut s = serializer.serialize_struct("UploadSessionLookupError", 1)?;
s.serialize_field(".tag", "payload_too_large")?;
s.end()
}
UploadSessionLookupError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for UploadSessionLookupError {
}
impl ::std::fmt::Display for UploadSessionLookupError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
UploadSessionLookupError::NotFound => f.write_str("The upload session ID was not found or has expired. Upload sessions are valid for 7 days."),
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),
UploadSessionLookupError::Closed => f.write_str("You are attempting to append data to an upload session that has already been closed (i.e. committed)."),
UploadSessionLookupError::NotClosed => f.write_str("The session must be closed before calling upload_session/finish_batch."),
UploadSessionLookupError::TooLarge => f.write_str("You can not append to the upload session because the size of a file should not reach the max file size limit (i.e. 350GB)."),
UploadSessionLookupError::ConcurrentSessionInvalidOffset => f.write_str("For concurrent upload sessions, offset needs to be multiple of 4194304 bytes."),
UploadSessionLookupError::ConcurrentSessionInvalidDataSize => f.write_str("For concurrent upload sessions, only chunks with size multiple of 4194304 bytes can be uploaded."),
UploadSessionLookupError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MB."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct UploadSessionOffsetError {
pub correct_offset: u64,
}
impl UploadSessionOffsetError {
pub fn new(correct_offset: u64) -> Self {
UploadSessionOffsetError {
correct_offset,
}
}
}
const UPLOAD_SESSION_OFFSET_ERROR_FIELDS: &[&str] = &["correct_offset"];
impl UploadSessionOffsetError {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UploadSessionOffsetError, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UploadSessionOffsetError>, V::Error> {
let mut field_correct_offset = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"correct_offset" => {
if field_correct_offset.is_some() {
return Err(::serde::de::Error::duplicate_field("correct_offset"));
}
field_correct_offset = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UploadSessionOffsetError {
correct_offset: field_correct_offset.ok_or_else(|| ::serde::de::Error::missing_field("correct_offset"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("correct_offset", &self.correct_offset)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionOffsetError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UploadSessionOffsetError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionOffsetError struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UploadSessionOffsetError::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UploadSessionOffsetError", UPLOAD_SESSION_OFFSET_ERROR_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionOffsetError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UploadSessionOffsetError", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[non_exhaustive] pub struct UploadSessionStartArg {
pub close: bool,
pub session_type: Option<UploadSessionType>,
pub content_hash: Option<Sha256HexHash>,
}
impl UploadSessionStartArg {
pub fn with_close(mut self, value: bool) -> Self {
self.close = value;
self
}
pub fn with_session_type(mut self, value: UploadSessionType) -> Self {
self.session_type = Some(value);
self
}
pub fn with_content_hash(mut self, value: Sha256HexHash) -> Self {
self.content_hash = Some(value);
self
}
}
const UPLOAD_SESSION_START_ARG_FIELDS: &[&str] = &["close",
"session_type",
"content_hash"];
impl UploadSessionStartArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<UploadSessionStartArg, V::Error> {
let mut field_close = None;
let mut field_session_type = None;
let mut field_content_hash = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"close" => {
if field_close.is_some() {
return Err(::serde::de::Error::duplicate_field("close"));
}
field_close = Some(map.next_value()?);
}
"session_type" => {
if field_session_type.is_some() {
return Err(::serde::de::Error::duplicate_field("session_type"));
}
field_session_type = Some(map.next_value()?);
}
"content_hash" => {
if field_content_hash.is_some() {
return Err(::serde::de::Error::duplicate_field("content_hash"));
}
field_content_hash = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = UploadSessionStartArg {
close: field_close.unwrap_or(false),
session_type: field_session_type,
content_hash: field_content_hash,
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("close", &self.close)?;
if let Some(val) = &self.session_type {
s.serialize_field("session_type", val)?;
}
if let Some(val) = &self.content_hash {
s.serialize_field("content_hash", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UploadSessionStartArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionStartArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UploadSessionStartArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UploadSessionStartArg", UPLOAD_SESSION_START_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionStartArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UploadSessionStartArg", 3)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct UploadSessionStartBatchArg {
pub num_sessions: u64,
pub session_type: Option<UploadSessionType>,
}
impl UploadSessionStartBatchArg {
pub fn new(num_sessions: u64) -> Self {
UploadSessionStartBatchArg {
num_sessions,
session_type: None,
}
}
pub fn with_session_type(mut self, value: UploadSessionType) -> Self {
self.session_type = Some(value);
self
}
}
const UPLOAD_SESSION_START_BATCH_ARG_FIELDS: &[&str] = &["num_sessions",
"session_type"];
impl UploadSessionStartBatchArg {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UploadSessionStartBatchArg, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UploadSessionStartBatchArg>, V::Error> {
let mut field_num_sessions = None;
let mut field_session_type = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"num_sessions" => {
if field_num_sessions.is_some() {
return Err(::serde::de::Error::duplicate_field("num_sessions"));
}
field_num_sessions = Some(map.next_value()?);
}
"session_type" => {
if field_session_type.is_some() {
return Err(::serde::de::Error::duplicate_field("session_type"));
}
field_session_type = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UploadSessionStartBatchArg {
num_sessions: field_num_sessions.ok_or_else(|| ::serde::de::Error::missing_field("num_sessions"))?,
session_type: field_session_type,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("num_sessions", &self.num_sessions)?;
if let Some(val) = &self.session_type {
s.serialize_field("session_type", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartBatchArg {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UploadSessionStartBatchArg;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionStartBatchArg struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UploadSessionStartBatchArg::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UploadSessionStartBatchArg", UPLOAD_SESSION_START_BATCH_ARG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionStartBatchArg {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UploadSessionStartBatchArg", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct UploadSessionStartBatchResult {
pub session_ids: Vec<String>,
}
impl UploadSessionStartBatchResult {
pub fn new(session_ids: Vec<String>) -> Self {
UploadSessionStartBatchResult {
session_ids,
}
}
}
const UPLOAD_SESSION_START_BATCH_RESULT_FIELDS: &[&str] = &["session_ids"];
impl UploadSessionStartBatchResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UploadSessionStartBatchResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UploadSessionStartBatchResult>, V::Error> {
let mut field_session_ids = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"session_ids" => {
if field_session_ids.is_some() {
return Err(::serde::de::Error::duplicate_field("session_ids"));
}
field_session_ids = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UploadSessionStartBatchResult {
session_ids: field_session_ids.ok_or_else(|| ::serde::de::Error::missing_field("session_ids"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("session_ids", &self.session_ids)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartBatchResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UploadSessionStartBatchResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionStartBatchResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UploadSessionStartBatchResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UploadSessionStartBatchResult", UPLOAD_SESSION_START_BATCH_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionStartBatchResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UploadSessionStartBatchResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum UploadSessionStartError {
ConcurrentSessionDataNotAllowed,
ConcurrentSessionCloseNotAllowed,
PayloadTooLarge,
ContentHashMismatch,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = UploadSessionStartError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionStartError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"concurrent_session_data_not_allowed" => UploadSessionStartError::ConcurrentSessionDataNotAllowed,
"concurrent_session_close_not_allowed" => UploadSessionStartError::ConcurrentSessionCloseNotAllowed,
"payload_too_large" => UploadSessionStartError::PayloadTooLarge,
"content_hash_mismatch" => UploadSessionStartError::ContentHashMismatch,
_ => UploadSessionStartError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["concurrent_session_data_not_allowed",
"concurrent_session_close_not_allowed",
"payload_too_large",
"content_hash_mismatch",
"other"];
deserializer.deserialize_struct("UploadSessionStartError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionStartError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
UploadSessionStartError::ConcurrentSessionDataNotAllowed => {
let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
s.serialize_field(".tag", "concurrent_session_data_not_allowed")?;
s.end()
}
UploadSessionStartError::ConcurrentSessionCloseNotAllowed => {
let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
s.serialize_field(".tag", "concurrent_session_close_not_allowed")?;
s.end()
}
UploadSessionStartError::PayloadTooLarge => {
let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
s.serialize_field(".tag", "payload_too_large")?;
s.end()
}
UploadSessionStartError::ContentHashMismatch => {
let mut s = serializer.serialize_struct("UploadSessionStartError", 1)?;
s.serialize_field(".tag", "content_hash_mismatch")?;
s.end()
}
UploadSessionStartError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for UploadSessionStartError {
}
impl ::std::fmt::Display for UploadSessionStartError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
UploadSessionStartError::ConcurrentSessionDataNotAllowed => f.write_str("Uploading data not allowed when starting concurrent upload session."),
UploadSessionStartError::ConcurrentSessionCloseNotAllowed => f.write_str("Can not start a closed concurrent upload session."),
UploadSessionStartError::PayloadTooLarge => f.write_str("The request payload must be at most 150 MB."),
UploadSessionStartError::ContentHashMismatch => f.write_str("The content received by the Dropbox server in this call does not match the provided content hash."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct UploadSessionStartResult {
pub session_id: String,
}
impl UploadSessionStartResult {
pub fn new(session_id: String) -> Self {
UploadSessionStartResult {
session_id,
}
}
}
const UPLOAD_SESSION_START_RESULT_FIELDS: &[&str] = &["session_id"];
impl UploadSessionStartResult {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UploadSessionStartResult, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UploadSessionStartResult>, V::Error> {
let mut field_session_id = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"session_id" => {
if field_session_id.is_some() {
return Err(::serde::de::Error::duplicate_field("session_id"));
}
field_session_id = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UploadSessionStartResult {
session_id: field_session_id.ok_or_else(|| ::serde::de::Error::missing_field("session_id"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("session_id", &self.session_id)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionStartResult {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UploadSessionStartResult;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionStartResult struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UploadSessionStartResult::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UploadSessionStartResult", UPLOAD_SESSION_START_RESULT_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionStartResult {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UploadSessionStartResult", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum UploadSessionType {
Sequential,
Concurrent,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for UploadSessionType {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = UploadSessionType;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadSessionType structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"sequential" => UploadSessionType::Sequential,
"concurrent" => UploadSessionType::Concurrent,
_ => UploadSessionType::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["sequential",
"concurrent",
"other"];
deserializer.deserialize_struct("UploadSessionType", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for UploadSessionType {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
UploadSessionType::Sequential => {
let mut s = serializer.serialize_struct("UploadSessionType", 1)?;
s.serialize_field(".tag", "sequential")?;
s.end()
}
UploadSessionType::Concurrent => {
let mut s = serializer.serialize_struct("UploadSessionType", 1)?;
s.serialize_field(".tag", "concurrent")?;
s.end()
}
UploadSessionType::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct UploadWriteFailed {
pub reason: WriteError,
pub upload_session_id: String,
}
impl UploadWriteFailed {
pub fn new(reason: WriteError, upload_session_id: String) -> Self {
UploadWriteFailed {
reason,
upload_session_id,
}
}
}
const UPLOAD_WRITE_FAILED_FIELDS: &[&str] = &["reason",
"upload_session_id"];
impl UploadWriteFailed {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UploadWriteFailed, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UploadWriteFailed>, V::Error> {
let mut field_reason = None;
let mut field_upload_session_id = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"reason" => {
if field_reason.is_some() {
return Err(::serde::de::Error::duplicate_field("reason"));
}
field_reason = Some(map.next_value()?);
}
"upload_session_id" => {
if field_upload_session_id.is_some() {
return Err(::serde::de::Error::duplicate_field("upload_session_id"));
}
field_upload_session_id = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UploadWriteFailed {
reason: field_reason.ok_or_else(|| ::serde::de::Error::missing_field("reason"))?,
upload_session_id: field_upload_session_id.ok_or_else(|| ::serde::de::Error::missing_field("upload_session_id"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("reason", &self.reason)?;
s.serialize_field("upload_session_id", &self.upload_session_id)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UploadWriteFailed {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UploadWriteFailed;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UploadWriteFailed struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UploadWriteFailed::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UploadWriteFailed", UPLOAD_WRITE_FAILED_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UploadWriteFailed {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UploadWriteFailed", 2)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub struct UserGeneratedTag {
pub tag_text: TagText,
}
impl UserGeneratedTag {
pub fn new(tag_text: TagText) -> Self {
UserGeneratedTag {
tag_text,
}
}
}
const USER_GENERATED_TAG_FIELDS: &[&str] = &["tag_text"];
impl UserGeneratedTag {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
map: V,
) -> Result<UserGeneratedTag, V::Error> {
Self::internal_deserialize_opt(map, false).map(Option::unwrap)
}
pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
optional: bool,
) -> Result<Option<UserGeneratedTag>, V::Error> {
let mut field_tag_text = None;
let mut nothing = true;
while let Some(key) = map.next_key::<&str>()? {
nothing = false;
match key {
"tag_text" => {
if field_tag_text.is_some() {
return Err(::serde::de::Error::duplicate_field("tag_text"));
}
field_tag_text = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
if optional && nothing {
return Ok(None);
}
let result = UserGeneratedTag {
tag_text: field_tag_text.ok_or_else(|| ::serde::de::Error::missing_field("tag_text"))?,
};
Ok(Some(result))
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
s.serialize_field("tag_text", &self.tag_text)?;
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for UserGeneratedTag {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = UserGeneratedTag;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a UserGeneratedTag struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
UserGeneratedTag::internal_deserialize(map)
}
}
deserializer.deserialize_struct("UserGeneratedTag", USER_GENERATED_TAG_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for UserGeneratedTag {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("UserGeneratedTag", 1)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Default)]
#[non_exhaustive] pub struct VideoMetadata {
pub dimensions: Option<Dimensions>,
pub location: Option<GpsCoordinates>,
pub time_taken: Option<crate::common::DropboxTimestamp>,
pub duration: Option<u64>,
}
impl VideoMetadata {
pub fn with_dimensions(mut self, value: Dimensions) -> Self {
self.dimensions = Some(value);
self
}
pub fn with_location(mut self, value: GpsCoordinates) -> Self {
self.location = Some(value);
self
}
pub fn with_time_taken(mut self, value: crate::common::DropboxTimestamp) -> Self {
self.time_taken = Some(value);
self
}
pub fn with_duration(mut self, value: u64) -> Self {
self.duration = Some(value);
self
}
}
const VIDEO_METADATA_FIELDS: &[&str] = &["dimensions",
"location",
"time_taken",
"duration"];
impl VideoMetadata {
pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
mut map: V,
) -> Result<VideoMetadata, V::Error> {
let mut field_dimensions = None;
let mut field_location = None;
let mut field_time_taken = None;
let mut field_duration = None;
while let Some(key) = map.next_key::<&str>()? {
match key {
"dimensions" => {
if field_dimensions.is_some() {
return Err(::serde::de::Error::duplicate_field("dimensions"));
}
field_dimensions = Some(map.next_value()?);
}
"location" => {
if field_location.is_some() {
return Err(::serde::de::Error::duplicate_field("location"));
}
field_location = Some(map.next_value()?);
}
"time_taken" => {
if field_time_taken.is_some() {
return Err(::serde::de::Error::duplicate_field("time_taken"));
}
field_time_taken = Some(map.next_value()?);
}
"duration" => {
if field_duration.is_some() {
return Err(::serde::de::Error::duplicate_field("duration"));
}
field_duration = Some(map.next_value()?);
}
_ => {
map.next_value::<::serde_json::Value>()?;
}
}
}
let result = VideoMetadata {
dimensions: field_dimensions,
location: field_location,
time_taken: field_time_taken,
duration: field_duration,
};
Ok(result)
}
pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
&self,
s: &mut S::SerializeStruct,
) -> Result<(), S::Error> {
use serde::ser::SerializeStruct;
if let Some(val) = &self.dimensions {
s.serialize_field("dimensions", val)?;
}
if let Some(val) = &self.location {
s.serialize_field("location", val)?;
}
if let Some(val) = &self.time_taken {
s.serialize_field("time_taken", val)?;
}
if let Some(val) = &self.duration {
s.serialize_field("duration", val)?;
}
Ok(())
}
}
impl<'de> ::serde::de::Deserialize<'de> for VideoMetadata {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{MapAccess, Visitor};
struct StructVisitor;
impl<'de> Visitor<'de> for StructVisitor {
type Value = VideoMetadata;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a VideoMetadata struct")
}
fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
VideoMetadata::internal_deserialize(map)
}
}
deserializer.deserialize_struct("VideoMetadata", VIDEO_METADATA_FIELDS, StructVisitor)
}
}
impl ::serde::ser::Serialize for VideoMetadata {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
let mut s = serializer.serialize_struct("VideoMetadata", 4)?;
self.internal_serialize::<S>(&mut s)?;
s.end()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum WriteConflictError {
File,
Folder,
FileAncestor,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for WriteConflictError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = WriteConflictError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a WriteConflictError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"file" => WriteConflictError::File,
"folder" => WriteConflictError::Folder,
"file_ancestor" => WriteConflictError::FileAncestor,
_ => WriteConflictError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["file",
"folder",
"file_ancestor",
"other"];
deserializer.deserialize_struct("WriteConflictError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for WriteConflictError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
WriteConflictError::File => {
let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
s.serialize_field(".tag", "file")?;
s.end()
}
WriteConflictError::Folder => {
let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
s.serialize_field(".tag", "folder")?;
s.end()
}
WriteConflictError::FileAncestor => {
let mut s = serializer.serialize_struct("WriteConflictError", 1)?;
s.serialize_field(".tag", "file_ancestor")?;
s.end()
}
WriteConflictError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for WriteConflictError {
}
impl ::std::fmt::Display for WriteConflictError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
WriteConflictError::File => f.write_str("There's a file in the way."),
WriteConflictError::Folder => f.write_str("There's a folder in the way."),
WriteConflictError::FileAncestor => f.write_str("There's a file at an ancestor path, so we couldn't create the required parent folders."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive] pub enum WriteError {
MalformedPath(MalformedPathError),
Conflict(WriteConflictError),
NoWritePermission,
InsufficientSpace,
DisallowedName,
TeamFolder,
OperationSuppressed,
TooManyWriteOperations,
Other,
}
impl<'de> ::serde::de::Deserialize<'de> for WriteError {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = WriteError;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a WriteError structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"malformed_path" => {
match map.next_key()? {
Some("malformed_path") => WriteError::MalformedPath(map.next_value()?),
None => WriteError::MalformedPath(None),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"conflict" => {
match map.next_key()? {
Some("conflict") => WriteError::Conflict(map.next_value()?),
None => return Err(de::Error::missing_field("conflict")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
"no_write_permission" => WriteError::NoWritePermission,
"insufficient_space" => WriteError::InsufficientSpace,
"disallowed_name" => WriteError::DisallowedName,
"team_folder" => WriteError::TeamFolder,
"operation_suppressed" => WriteError::OperationSuppressed,
"too_many_write_operations" => WriteError::TooManyWriteOperations,
_ => WriteError::Other,
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["malformed_path",
"conflict",
"no_write_permission",
"insufficient_space",
"disallowed_name",
"team_folder",
"operation_suppressed",
"too_many_write_operations",
"other"];
deserializer.deserialize_struct("WriteError", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for WriteError {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
WriteError::MalformedPath(ref x) => {
let n = if x.is_some() { 2 } else { 1 };
let mut s = serializer.serialize_struct("WriteError", n)?;
s.serialize_field(".tag", "malformed_path")?;
if let Some(ref x) = x {
s.serialize_field("malformed_path", &x)?;
}
s.end()
}
WriteError::Conflict(ref x) => {
let mut s = serializer.serialize_struct("WriteError", 2)?;
s.serialize_field(".tag", "conflict")?;
s.serialize_field("conflict", x)?;
s.end()
}
WriteError::NoWritePermission => {
let mut s = serializer.serialize_struct("WriteError", 1)?;
s.serialize_field(".tag", "no_write_permission")?;
s.end()
}
WriteError::InsufficientSpace => {
let mut s = serializer.serialize_struct("WriteError", 1)?;
s.serialize_field(".tag", "insufficient_space")?;
s.end()
}
WriteError::DisallowedName => {
let mut s = serializer.serialize_struct("WriteError", 1)?;
s.serialize_field(".tag", "disallowed_name")?;
s.end()
}
WriteError::TeamFolder => {
let mut s = serializer.serialize_struct("WriteError", 1)?;
s.serialize_field(".tag", "team_folder")?;
s.end()
}
WriteError::OperationSuppressed => {
let mut s = serializer.serialize_struct("WriteError", 1)?;
s.serialize_field(".tag", "operation_suppressed")?;
s.end()
}
WriteError::TooManyWriteOperations => {
let mut s = serializer.serialize_struct("WriteError", 1)?;
s.serialize_field(".tag", "too_many_write_operations")?;
s.end()
}
WriteError::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
}
}
}
impl ::std::error::Error for WriteError {
fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
match self {
WriteError::Conflict(inner) => Some(inner),
_ => None,
}
}
}
impl ::std::fmt::Display for WriteError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match self {
WriteError::MalformedPath(inner) => write!(f, "malformed_path: {:?}", inner),
WriteError::Conflict(inner) => write!(f, "Couldn't write to the target path because there was something in the way: {}", inner),
WriteError::NoWritePermission => f.write_str("The user doesn't have permissions to write to the target location."),
WriteError::InsufficientSpace => f.write_str("The user doesn't have enough available space (bytes) to write more data."),
WriteError::DisallowedName => f.write_str("Dropbox will not save the file or folder because of its name."),
WriteError::TeamFolder => f.write_str("This endpoint cannot move or delete team folders."),
WriteError::OperationSuppressed => f.write_str("This file operation is not allowed at this path."),
WriteError::TooManyWriteOperations => f.write_str("There are too many write operations in user's Dropbox. Please retry this request."),
_ => write!(f, "{:?}", *self),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum WriteMode {
Add,
Overwrite,
Update(Rev),
}
impl<'de> ::serde::de::Deserialize<'de> for WriteMode {
fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
use serde::de::{self, MapAccess, Visitor};
struct EnumVisitor;
impl<'de> Visitor<'de> for EnumVisitor {
type Value = WriteMode;
fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
f.write_str("a WriteMode structure")
}
fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
let tag: &str = match map.next_key()? {
Some(".tag") => map.next_value()?,
_ => return Err(de::Error::missing_field(".tag"))
};
let value = match tag {
"add" => WriteMode::Add,
"overwrite" => WriteMode::Overwrite,
"update" => {
match map.next_key()? {
Some("update") => WriteMode::Update(map.next_value()?),
None => return Err(de::Error::missing_field("update")),
_ => return Err(de::Error::unknown_field(tag, VARIANTS))
}
}
_ => return Err(de::Error::unknown_variant(tag, VARIANTS))
};
crate::eat_json_fields(&mut map)?;
Ok(value)
}
}
const VARIANTS: &[&str] = &["add",
"overwrite",
"update"];
deserializer.deserialize_struct("WriteMode", VARIANTS, EnumVisitor)
}
}
impl ::serde::ser::Serialize for WriteMode {
fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
use serde::ser::SerializeStruct;
match *self {
WriteMode::Add => {
let mut s = serializer.serialize_struct("WriteMode", 1)?;
s.serialize_field(".tag", "add")?;
s.end()
}
WriteMode::Overwrite => {
let mut s = serializer.serialize_struct("WriteMode", 1)?;
s.serialize_field(".tag", "overwrite")?;
s.end()
}
WriteMode::Update(ref x) => {
let mut s = serializer.serialize_struct("WriteMode", 2)?;
s.serialize_field(".tag", "update")?;
s.serialize_field("update", x)?;
s.end()
}
}
}
}