async_dashscope/operation/file/
output.rs

1use serde::{Deserialize, Serialize};
2
3/// 文件上传输出
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct FileUploadOutput {
6    /// 请求ID
7    pub request_id: String,
8    /// 响应数据
9    pub data: FileUploadData,
10}
11
12/// 文件上传数据
13#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct FileUploadData {
15    /// 已上传的文件列表
16    #[serde(rename = "uploaded_files")]
17    pub uploaded_files: Vec<UploadedFile>,
18    /// 上传失败的文件列表
19    #[serde(rename = "failed_uploads")]
20    pub failed_uploads: Vec<FailedUpload>,
21}
22
23/// 已上传的文件信息
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct UploadedFile {
26    /// 文件ID
27    #[serde(rename = "file_id")]
28    pub file_id: String,
29    /// 文件名
30    pub name: String,
31}
32
33/// 上传失败的文件信息
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct FailedUpload {
36    /// 文件名
37    pub name: String,
38    /// 错误代码
39    pub code: String,
40    /// 错误消息
41    pub message: String,
42}
43
44/// 文件列表输出
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct FileListOutput {
47    /// 请求ID
48    pub request_id: String,
49    /// 响应数据
50    pub data: FileListData,
51}
52
53/// 文件列表数据
54#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct FileListData {
56    /// 总数
57    pub total: u64,
58    /// 分页大小
59    pub page_size: u64,
60    /// 当前页
61    pub page_no: u64,
62    /// 文件列表
63    pub files: Vec<FileInfo>,
64}
65
66/// 文件信息
67#[derive(Debug, Clone, Serialize, Deserialize)]
68pub struct FileInfo {
69    /// ID (列表接口有此字段,单个文件查询可能没有)
70    #[serde(default, skip_serializing_if = "Option::is_none")]
71    pub id: Option<u64>,
72    /// 文件ID
73    #[serde(rename = "file_id")]
74    pub file_id: String,
75    /// 文件名
76    pub name: String,
77    /// 描述
78    pub description: Option<String>,
79    /// 文件大小(字节)
80    pub size: u64,
81    /// MD5
82    pub md5: String,
83    /// 创建时间
84    pub gmt_create: Option<String>,
85    /// URL
86    pub url: Option<String>,
87    /// 区域 (列表接口有此字段,单个文件查询可能没有)
88    #[serde(default, skip_serializing_if = "Option::is_none")]
89    pub region: Option<String>,
90    /// 用户ID (列表接口有此字段,单个文件查询可能没有)
91    #[serde(default, skip_serializing_if = "Option::is_none")]
92    pub user_id: Option<String>,
93    /// API密钥ID (列表接口有此字段,单个文件查询可能没有)
94    #[serde(default, skip_serializing_if = "Option::is_none")]
95    pub api_key_id: Option<String>,
96    /// 用途 (列表接口有此字段,单个文件查询可能没有)
97    #[serde(default, skip_serializing_if = "Option::is_none")]
98    pub purpose: Option<String>,
99}
100
101/// 单个文件信息输出
102#[derive(Debug, Clone, Serialize, Deserialize)]
103pub struct FileRetrieveOutput {
104    /// 请求ID
105    pub request_id: String,
106    /// 文件信息
107    pub data: FileInfo,
108}
109
110/// 文件删除输出
111#[derive(Debug, Clone, Serialize, Deserialize)]
112pub struct FileDeleteOutput {
113    /// 请求ID
114    pub request_id: String,
115    /// 错误代码(可选,仅在失败时存在)
116    #[serde(default, skip_serializing_if = "Option::is_none")]
117    pub code: Option<String>,
118    /// 错误消息(可选,仅在失败时存在)
119    #[serde(default, skip_serializing_if = "Option::is_none")]
120    pub message: Option<String>,
121}