use std::time::SystemTime;
use bytes::Bytes;
#[derive(Debug, Clone, Default)]
pub struct ObjectMetadata {
pub key: String,
pub size: u64,
pub content_type: Option<String>,
pub etag: Option<String>,
pub last_modified: Option<SystemTime>,
}
#[derive(Debug, Clone, Default)]
pub struct PutOptions {
pub content_type: Option<String>,
pub insert_only: bool,
}
impl PutOptions {
pub fn with_content_type(content_type: impl Into<String>) -> Self {
PutOptions {
content_type: Some(content_type.into()),
insert_only: false,
}
}
}
#[derive(Debug, Clone, Default)]
pub struct ListOutcome {
pub items: Vec<ObjectMetadata>,
pub next_marker: Option<String>,
}
#[derive(Debug, Clone)]
pub enum PutBody {
Bytes(Bytes),
}
impl PutBody {
pub fn into_bytes(self) -> Bytes {
match self {
PutBody::Bytes(b) => b,
}
}
pub fn len(&self) -> usize {
match self {
PutBody::Bytes(b) => b.len(),
}
}
pub fn is_empty(&self) -> bool {
self.len() == 0
}
}
impl From<Vec<u8>> for PutBody {
fn from(v: Vec<u8>) -> Self {
PutBody::Bytes(Bytes::from(v))
}
}
impl From<Bytes> for PutBody {
fn from(b: Bytes) -> Self {
PutBody::Bytes(b)
}
}
impl From<&'static [u8]> for PutBody {
fn from(s: &'static [u8]) -> Self {
PutBody::Bytes(Bytes::from_static(s))
}
}