pub struct DataCapsule { /* private fields */ }Expand description
Executable Data Capsule
Encapsulates encrypted data AND logic predicate. Data cannot be “read” - only “executed” via run_access_protocol().
Implementations§
Source§impl DataCapsule
impl DataCapsule
Sourcepub fn new(
id: impl Into<String>,
data: &[u8],
predicate: Box<dyn AccessPredicate>,
max_executions: u64,
ttl_seconds: u64,
) -> Result<Self>
pub fn new( id: impl Into<String>, data: &[u8], predicate: Box<dyn AccessPredicate>, max_executions: u64, ttl_seconds: u64, ) -> Result<Self>
Create new data capsule
§Arguments
id- Unique capsule identifierdata- Raw data to encapsulatepredicate- Access control predicatemax_executions- Max allowed executions (0 = unlimited)ttl_seconds- Time to live (0 = forever)
Sourcepub fn run_access_protocol(&self, context: &ExecutionContext) -> ExecutionResult
pub fn run_access_protocol(&self, context: &ExecutionContext) -> ExecutionResult
Execute access protocol
This is the ONLY way to access the capsule data. Data is never “read” - it is “executed” through this protocol.
§Arguments
context- Execution context with ZKP proof and BFT signature
§Returns
ExecutionResult::Success- Decrypted data (if all checks pass)ExecutionResult::Denied- Access denied with reasonExecutionResult::Lost- Capsule self-destructed
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if capsule is expired
Sourcepub fn state(&self) -> CapsuleState
pub fn state(&self) -> CapsuleState
Get capsule state
Sourcepub fn execution_count(&self) -> u64
pub fn execution_count(&self) -> u64
Get execution count
Auto Trait Implementations§
impl !Freeze for DataCapsule
impl !RefUnwindSafe for DataCapsule
impl Send for DataCapsule
impl Sync for DataCapsule
impl Unpin for DataCapsule
impl !UnwindSafe for DataCapsule
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