DataCapsule

Struct DataCapsule 

Source
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

Source

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 identifier
  • data - Raw data to encapsulate
  • predicate - Access control predicate
  • max_executions - Max allowed executions (0 = unlimited)
  • ttl_seconds - Time to live (0 = forever)
Source

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 reason
  • ExecutionResult::Lost - Capsule self-destructed
Source

pub fn is_expired(&self) -> bool

Check if capsule is expired

Source

pub fn state(&self) -> CapsuleState

Get capsule state

Source

pub fn id(&self) -> &str

Get capsule ID

Source

pub fn execution_count(&self) -> u64

Get execution count

Source

pub fn destroy(&self)

Manually destroy capsule (authorized destruction)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V