pub struct ContextPacket {
pub id: Uuid,
pub content: String,
pub created_at: DateTime<Utc>,
pub expires_at: Option<DateTime<Utc>>,
pub compression: CompressionLevel,
pub hash: Hash,
pub parent_hash: Option<Hash>,
pub source_agent: Option<Uuid>,
pub importance: f64,
}Expand description
A context packet - the unit of information in VEX
Fields§
§id: UuidUnique identifier for this packet
content: StringThe actual content
created_at: DateTime<Utc>When this context was created
expires_at: Option<DateTime<Utc>>When this context expires (if applicable)
compression: CompressionLevelCompression level applied
hash: HashSHA-256 hash of the content
parent_hash: Option<Hash>Hash of the parent packet (for chaining)
source_agent: Option<Uuid>Source agent ID
importance: f64Importance score (0.0 - 1.0)
Implementations§
Source§impl ContextPacket
impl ContextPacket
Sourcepub fn new(content: &str) -> Self
pub fn new(content: &str) -> Self
Create a new context packet with the given content Content is truncated if it exceeds MAX_CONTENT_SIZE
Sourcepub fn with_ttl(content: &str, ttl: Duration) -> Self
pub fn with_ttl(content: &str, ttl: Duration) -> Self
Create a context packet with a TTL (time-to-live)
Sourcepub fn compute_hash(content: &str) -> Hash
pub fn compute_hash(content: &str) -> Hash
Compute SHA-256 hash of content
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if this packet has expired
Sourcepub fn compress(&self, level: CompressionLevel) -> Self
pub fn compress(&self, level: CompressionLevel) -> Self
Create a compressed version of this packet
Sourcepub fn chain_to(&mut self, parent: &ContextPacket)
pub fn chain_to(&mut self, parent: &ContextPacket)
Chain this packet to a parent
Trait Implementations§
Source§impl Clone for ContextPacket
impl Clone for ContextPacket
Source§fn clone(&self) -> ContextPacket
fn clone(&self) -> ContextPacket
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextPacket
impl Debug for ContextPacket
Source§impl<'de> Deserialize<'de> for ContextPacket
impl<'de> Deserialize<'de> for ContextPacket
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
Auto Trait Implementations§
impl Freeze for ContextPacket
impl RefUnwindSafe for ContextPacket
impl Send for ContextPacket
impl Sync for ContextPacket
impl Unpin for ContextPacket
impl UnwindSafe for ContextPacket
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)