pub struct StoredObject {
pub key: String,
pub size: u64,
pub content_type: String,
pub etag: String,
pub uploaded_at: i64,
pub filename: Option<String>,
}Expand description
An object in the bucket, as head and list describe it (without its bytes).
§Examples
use ocre::storage::StoredObject;
let object = StoredObject {
key: "uploads/2u1Vd0zJ8sQqS6rJq0rVmA".into(),
size: 2048,
content_type: "image/png".into(),
etag: "b6ab5f279cbcf9a1b96b3ab5b207cf94".into(),
uploaded_at: 1_790_000_000,
filename: None,
};
let attachment = object.attachment("C:\\me.png");
assert_eq!((attachment.filename.as_str(), attachment.size), ("me.png", 2048));Fields§
§key: StringObject key.
size: u64Size in bytes.
content_type: StringContent type recorded with the object (application/octet-stream when none was).
etag: StringR2’s entity tag, unquoted (the MD5 of the content for single-part uploads).
uploaded_at: i64Upload time, in Unix seconds (compare with crate::now).
filename: Option<String>File name recorded by store and friends; None for objects uploaded directly.
Implementations§
Source§impl StoredObject
impl StoredObject
Sourcepub fn attachment(&self, filename: &str) -> Attachment
pub fn attachment(&self, filename: &str) -> Attachment
The Attachment of this object under filename (cleaned up), with its recorded size and type.
Check the object against Rules first (attach_direct_upload does both).
§Examples
let object = ocre::storage::StoredObject { key: "k".into(), size: 3, content_type: "text/plain".into(), ..Default::default() };
assert_eq!(object.attachment("a.txt").content_type, "text/plain");Trait Implementations§
Source§impl Clone for StoredObject
impl Clone for StoredObject
Source§fn clone(&self) -> StoredObject
fn clone(&self) -> StoredObject
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StoredObject
impl Debug for StoredObject
Source§impl Default for StoredObject
impl Default for StoredObject
Source§fn default() -> StoredObject
fn default() -> StoredObject
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for StoredObject
impl<'de> Deserialize<'de> for StoredObject
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for StoredObject
Source§impl PartialEq for StoredObject
impl PartialEq for StoredObject
Source§fn eq(&self, other: &StoredObject) -> bool
fn eq(&self, other: &StoredObject) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for StoredObject
impl Serialize for StoredObject
impl StructuralPartialEq for StoredObject
Auto Trait Implementations§
impl Freeze for StoredObject
impl RefUnwindSafe for StoredObject
impl Send for StoredObject
impl Sync for StoredObject
impl Unpin for StoredObject
impl UnsafeUnpin for StoredObject
impl UnwindSafe for StoredObject
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.