明确 Raw 编辑零拷贝上传约束

补充 Bytes 所有权与 streaming multipart 注释

增加共享字节缓冲不转换的回归测试
This commit is contained in:
2026-09-12 11:18:14 +08:00
parent 551fb6609a
commit 9c04561419
@@ -25,6 +25,8 @@ pub struct RawImageEditOptions {
}
#[derive(Clone, Debug)]
/// Multipart input owned by the raw-edit endpoint. `Bytes` keeps the Axum
/// upload buffer shared until reqwest consumes it, avoiding a full-image copy.
pub struct RawImageEditImage {
pub bytes: Bytes,
pub mime_type: String,
@@ -489,4 +491,18 @@ mod tests {
"raw_image_edit:构造请求客户端失败:builder failed"
);
}
#[test]
fn raw_edit_image_owns_shared_bytes_without_conversion() {
let bytes = bytes::Bytes::from_static(b"raw-image");
let pointer = bytes.as_ptr();
let image = RawImageEditImage {
bytes,
mime_type: "image/png".to_string(),
file_name: "image.png".to_string(),
};
assert_eq!(image.bytes.as_ptr(), pointer);
assert_eq!(image.bytes.as_ref(), b"raw-image");
}
}