pub struct ChainEvent {
pub hash: Vec<u8>,
pub parent_hash: Option<Vec<u8>>,
pub event_type: String,
pub data: Vec<u8>,
pub timestamp: u64,
pub description: Option<String>,
}Expand description
§Chain Event
ChainEvent represents a single immutable event in an actor’s execution history.
Each event is cryptographically linked to its parent through hash references,
forming a tamper-evident chain of events that can be verified for integrity.
§Purpose
This struct is the core building block of the audit system in Theater. It captures a specific action or state change, stores the relevant data, and maintains the cryptographic linking that ensures the integrity of the event history. Events are content-addressed, meaning they are identified by a hash of their content.
§Example
use theater::chain::ChainEvent;
use theater::events::ChainEventData;
// Create an event
let data = vec![1, 2, 3, 4]; // Example binary data
let event = ChainEvent {
hash: vec![], // Will be filled by the system
parent_hash: None, // This is a root event with no parent
event_type: "example".to_string(),
data,
timestamp: chrono::Utc::now().timestamp() as u64,
description: Some("Example event".to_string()),
};§Security
The hash of each event is calculated based on its content, and each event references its parent’s hash. This creates a chain of cryptographic links that makes it impossible to modify any event without breaking the chain, allowing for verification of the entire history.
§Implementation Notes
Events are serialized to JSON for storage and transmission. The Display implementation
provides a human-readable representation of the event, making events easier to read in logs
and debugging output.
Fields§
§hash: Vec<u8>Cryptographic hash of this event’s content, used as its identifier. This is calculated based on all other fields except the hash itself.
parent_hash: Option<Vec<u8>>Hash of the parent event, or None if this is the first event in the chain. This creates the cryptographic linking between events.
event_type: StringType identifier for the event, used to categorize and filter events. Common types include “state_change”, “message”, “http_request”, etc.
data: Vec<u8>The actual payload of the event, typically serialized structured data.
timestamp: u64Unix timestamp (in seconds) when the event was created.
description: Option<String>Optional human-readable description of the event for logging and debugging.
Trait Implementations§
Source§impl Clone for ChainEvent
impl Clone for ChainEvent
Source§fn clone(&self) -> ChainEvent
fn clone(&self) -> ChainEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChainEvent
impl Debug for ChainEvent
Source§impl<'de> Deserialize<'de> for ChainEvent
impl<'de> Deserialize<'de> for ChainEvent
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>,
Source§impl Display for ChainEvent
impl Display for ChainEvent
Source§impl Hash for ChainEvent
impl Hash for ChainEvent
Source§impl PartialEq for ChainEvent
impl PartialEq for ChainEvent
Source§impl Serialize for ChainEvent
impl Serialize for ChainEvent
impl ComponentType for ChainEvent
impl Eq for ChainEvent
impl Lift for ChainEvent
impl Lower for ChainEvent
Auto Trait Implementations§
impl Freeze for ChainEvent
impl RefUnwindSafe for ChainEvent
impl Send for ChainEvent
impl Sync for ChainEvent
impl Unpin for ChainEvent
impl UnwindSafe for ChainEvent
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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