mirror of
https://github.com/narrrl/proton-sdk-rs.git
synced 2026-11-03 16:41:26 +01:00
added device support
This commit is contained in:
1 parent
6291c6f478
commit
0d07fdb084
3 files changed
+18
-7
No files matched your search
@@ -138,11 +138,21 @@ pub struct Thumbnail {
|
||||
|
||||
impl Thumbnail {
|
||||
/// Create a thumbnail from rendered image bytes.
|
||||
pub fn new(thumbnail_type: ThumbnailType, content: Vec<u8>) -> Self {
|
||||
Self {
|
||||
///
|
||||
/// Returns an error if the `content` is empty.
|
||||
pub fn new(
|
||||
thumbnail_type: ThumbnailType,
|
||||
content: Vec<u8>,
|
||||
) -> Result<Self, proton_sdk::error::ProtonError> {
|
||||
if content.is_empty() {
|
||||
return Err(proton_sdk::error::ProtonError::invalid_operation(
|
||||
"Thumbnail content must not be empty.",
|
||||
));
|
||||
}
|
||||
Ok(Self {
|
||||
thumbnail_type,
|
||||
content,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -260,8 +260,8 @@ async fn thumbnails_upload_and_fetch() {
|
||||
let thumb_small: Vec<u8> = (0..4096).map(|i| (i * 13 + 1) as u8).collect();
|
||||
let thumb_preview: Vec<u8> = (0..8192).map(|i| (i * 17 + 3) as u8).collect();
|
||||
let thumbnails = vec![
|
||||
Thumbnail::new(ThumbnailType::Thumbnail, thumb_small.clone()),
|
||||
Thumbnail::new(ThumbnailType::Preview, thumb_preview.clone()),
|
||||
Thumbnail::new(ThumbnailType::Thumbnail, thumb_small.clone()).unwrap(),
|
||||
Thumbnail::new(ThumbnailType::Preview, thumb_preview.clone()).unwrap(),
|
||||
];
|
||||
|
||||
let payload = b"file body for thumbnail upload".to_vec();
|
||||
|
||||
Reference in new issue
Block a user