Skip to main content

helix_core/effect/
io.rs

1use bytes::Bytes;
2
3use super::{FileUploadProgressPolicy, FileUploadUrls};
4
5/// HTTP 请求(driver 的 HttpRequester 解析并发出)
6#[derive(Debug, Clone)]
7pub struct HttpRequest {
8    pub method: String, // "GET" / "POST" / etc.
9    pub url: String,
10    pub headers: Vec<(String, String)>,
11    pub body: Option<Bytes>,
12}
13
14/// HTTP 响应(driver 包装后通过 PortReply 回传)
15#[derive(Debug, Clone)]
16pub struct HttpResponse {
17    pub status: u16,
18    pub headers: Vec<(String, String)>,
19    pub body: Bytes,
20}
21
22/// 本地文件上传请求(driver 读取本地路径并执行真实上传)。
23#[derive(Debug, Clone)]
24pub struct FileUploadRequest {
25    pub local_path: String,
26    pub object_key: String,
27    pub method: String,
28    pub urls: FileUploadUrls,
29    pub headers: Vec<(String, String)>,
30    pub content_type: Option<String>,
31    pub size: Option<u64>,
32}
33
34impl FileUploadRequest {
35    /// 进度策略随已有私有 URL 封装携带,避免破坏公开结构体的字段级构造兼容。
36    pub fn progress_policy(&self) -> FileUploadProgressPolicy {
37        self.urls.progress_policy()
38    }
39}
40
41/// 文件上传结果(driver 包装后通过 PortReply 回传)。
42#[derive(Debug, Clone)]
43pub struct FileUploadResponse {
44    pub object_key: String,
45    pub public_url: String,
46    pub etag: Option<String>,
47}