aliyun_oss_rust_sdk/
entity.rs1use serde::{Deserialize, Serialize};
2use crate::request::Seconds;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct PolicyResp {
6 pub access_id: String,
7 pub host: String,
8 pub policy: String,
9 pub signature: String,
10 pub success_action_status: u8,
11}
12
13unsafe impl Send for PolicyResp {}
14
15unsafe impl Sync for PolicyResp {}
16
17#[derive(Debug, Clone)]
19pub struct PolicyBuilder {
20 pub expire: Seconds,
21 pub upload_dir: String,
22 pub content_type: String,
23 pub max_upload_size: i64,
24}
25
26unsafe impl Send for PolicyBuilder {}
27
28unsafe impl Sync for PolicyBuilder {}
29
30impl Default for PolicyBuilder {
31 fn default() -> Self {
32 Self::new()
33 }
34}
35
36impl PolicyBuilder {
37 pub fn new() -> Self {
38 Self {
39 expire: 60,upload_dir: "".to_string(),
41 content_type: "text/plain".to_string(),max_upload_size: 100 * 1024 * 1024,}
44 }
45 pub fn with_expire(mut self, expire: Seconds) -> Self {
46 self.expire = expire;
47 self
48 }
49 pub fn with_upload_dir<S: AsRef<str>>(mut self, upload_dir: S) -> Self {
50 self.upload_dir = upload_dir.as_ref().to_string();
51 self
52 }
53 pub fn with_content_type<S: AsRef<str>>(mut self, content_type: S) -> Self {
54 self.content_type = content_type.as_ref().to_string();
55 self
56 }
57 pub fn with_max_upload_size(mut self, max_upload_size: i64) -> Self {
58 self.max_upload_size = max_upload_size;
59 self
60 }
61}