pub struct CompactAttachment {Show 15 fields
pub id: [u8; 32],
pub key: [u8; 32],
pub nonce: [u8; 16],
pub size: u64,
pub flags: AttachmentFlags,
pub extension: Box<str>,
pub url: Box<str>,
pub path: Box<str>,
pub img_meta: Option<Box<ImageMetadata>>,
pub group_id: Option<Box<[u8; 32]>>,
pub original_hash: Option<Box<[u8; 32]>>,
pub webxdc_topic: Option<Box<str>>,
pub mls_filename: Option<Box<str>>,
pub scheme_version: Option<Box<str>>,
pub name: String,
}Expand description
Memory-efficient attachment with binary hashes and compact strings.
Compared to the regular Attachment struct (~320+ bytes):
- id (SHA256):
[u8; 32]instead of hex String (saves ~56 bytes) - key:
[u8; 32]instead of String (saves ~56 bytes) - nonce:
[u8; 16]instead of String (saves ~32 bytes) - Bools packed into AttachmentFlags (saves padding)
- Strings use Box
(saves 8 bytes each) - Rare fields boxed (saves ~100+ bytes when None)
- Total: ~120 bytes vs ~320 bytes (62% savings!)
Fields§
§id: [u8; 32]SHA256 file hash as binary (was hex String)
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
flags: AttachmentFlagsPacked boolean flags (downloading, downloaded)
extension: Box<str>File extension (e.g., “png”, “mp4”)
url: Box<str>Host URL (blossom server, etc.)
path: Box<str>Local file path (empty if not downloaded)
img_meta: Option<Box<ImageMetadata>>Image metadata (only for images/videos)
group_id: Option<Box<[u8; 32]>>Legacy group ID for key derivation
original_hash: Option<Box<[u8; 32]>>Original file hash before encryption
webxdc_topic: Option<Box<str>>WebXDC topic (Mini Apps only - very rare)
mls_filename: Option<Box<str>>Legacy filename for AAD
scheme_version: Option<Box<str>>Scheme version (e.g., “mip04-v1”)
name: StringOriginal filename (e.g. “memories.zip”). Empty = fallback to {hash}.{ext}
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)
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 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§fn clone(&self) -> CompactAttachment
fn clone(&self) -> CompactAttachment
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CompactAttachment
impl Debug for CompactAttachment
Auto Trait Implementations§
impl Freeze 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