pub struct CompactAttachment {
pub key: [u8; 32],
pub nonce: [u8; 16],
pub size: u64,
pub url: Box<str>,
/* private fields */
}Expand description
Memory-efficient attachment: binary hashes, the extension as a code, the local path derived from the id or name when it can be, image metadata in one allocation, and the rarely-set fields behind one box.
Fields§
§key: [u8; 32]Encryption key - 32 bytes (empty = legacy derived)
nonce: [u8; 16]Encryption nonce - 16 bytes (AES-256-GCM with 0xChat compatibility)
size: u64File size in bytes
url: Box<str>Host URL (blossom server, etc.)
Implementations§
Source§impl CompactAttachment
impl CompactAttachment
pub fn downloaded(&self) -> bool
pub fn downloading(&self) -> bool
pub fn set_downloaded(&mut self, value: bool)
pub fn set_downloading(&mut self, value: bool)
pub fn verified(&self) -> bool
pub fn set_verified(&mut self, value: bool)
Sourcepub fn nonce_hex(&self) -> String
pub fn nonce_hex(&self) -> String
Get nonce as hex string (empty if zeros, respects original length)
Sourcepub fn path(&self) -> Cow<'_, str>
pub fn path(&self) -> Cow<'_, str>
Local file path (empty if not downloaded). Allocates only for a derived path.
pub fn id(&self) -> &[u8; 32]
pub fn name(&self) -> &str
pub fn flags(&self) -> AttachmentFlags
Sourcepub fn set_id(&mut self, id: [u8; 32])
pub fn set_id(&mut self, id: [u8; 32])
The path and original hash stay what they were: both may be derived from the id.
Sourcepub fn set_name(&mut self, name: &str)
pub fn set_name(&mut self, name: &str)
The path stays what it was: it may be derived from the name.
pub fn set_path(&mut self, path: String)
Sourcepub fn img_meta(&self) -> Option<ImageMetadata>
pub fn img_meta(&self) -> Option<ImageMetadata>
Image dimensions and thumbhash (only for images/videos)
pub fn has_img_meta(&self) -> bool
pub fn set_img_meta(&mut self, meta: Option<&ImageMetadata>)
Sourcepub fn original_hash(&self) -> Option<[u8; 32]>
pub fn original_hash(&self) -> Option<[u8; 32]>
Original file hash before encryption
Sourcepub fn webxdc_topic(&self) -> Option<&str>
pub fn webxdc_topic(&self) -> Option<&str>
WebXDC topic (Mini Apps only)
Sourcepub fn fallback_urls(&self) -> &[Box<str>]
pub fn fallback_urls(&self) -> &[Box<str>]
Mirror URLs for the same ciphertext
pub fn set_fallback_urls(&mut self, urls: impl IntoIterator<Item = Box<str>>)
Sourcepub fn from_attachment(att: &Attachment) -> Self
pub fn from_attachment(att: &Attachment) -> Self
Convert from regular Attachment (borrowed)
Sourcepub fn from_attachment_owned(att: Attachment) -> Self
pub fn from_attachment_owned(att: Attachment) -> Self
Convert from regular Attachment (owned) - zero-copy where possible
Sourcepub fn to_attachment(&self) -> Attachment
pub fn to_attachment(&self) -> Attachment
Convert back to regular Attachment
Trait Implementations§
Source§impl Clone for CompactAttachment
impl Clone for CompactAttachment
Source§impl Debug for CompactAttachment
impl Debug for CompactAttachment
Auto Trait Implementations§
impl Forget for CompactAttachment
impl Freeze for CompactAttachment
impl Move for CompactAttachment
impl RefUnwindSafe for CompactAttachment
impl Send for CompactAttachment
impl Sync for CompactAttachment
impl Unpin for CompactAttachment
impl UnsafeUnpin for CompactAttachment
impl UnwindSafe for CompactAttachment
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more