pub enum Op {
    StoreRecord(StoreRecord),
    StoreEntry(StoreEntry),
    RegisterUpdate(RegisterUpdate),
    RegisterDelete(RegisterDelete),
    RegisterAgentActivity(RegisterAgentActivity),
    RegisterCreateLink(RegisterCreateLink),
    RegisterDeleteLink(RegisterDeleteLink),
}
Expand description

These are the operations that can be applied to Holochain data. Every Action produces a set of operations. These operations are each sent to an authority for validation.

Examples

Validate a new entry: https://github.com/holochain/holochain/blob/develop/crates/test_utils/wasm/wasm_workspace/validate/src/integrity.rs

Producing Operations

The following is a list of the operations that can be produced by each Action:

Authorities

There are three types of authorities in Holochain:

The Action Authority

This set of authorities receives the Op::StoreRecord. This is where you can implement your own logic for checking that it is valid to store any of the Action variants according to your own applications rules.

The Entry Authority

This set of authorities receives the Op::StoreEntry. This is where you can implement your own logic for checking that it is valid to store an Entry. You can think of this as the “Create” from the CRUD acronym.

Metadata

The entry authority is also responsible for storing the metadata for each entry. They receive the Op::RegisterUpdate and Op::RegisterDelete. This is where you can implement your own logic for checking that it is valid to update or delete any of the Entry types defined in your application. You can think of this as the “Update” and “Delete” from the CRUD acronym.

They receive the Op::RegisterCreateLink and Op::RegisterDeleteLink. This is where you can implement your own logic for checking that it is valid to place a link on a base Entry.

The Chain Authority

This set of authorities receives the Op::RegisterAgentActivity. This is where you can implement your own logic for checking that it is valid to add a new Action to an agent source chain. You are not validating the individual record but the entire agents source chain.

Author

When authoring a new Action to your source chain, the validation will be run from the perspective of every authority.

A note on metadata for the Action authority.

Technically speaking the Action authority also receives and validates the Op::RegisterUpdate and Op::RegisterDelete but they run the same callback as the Entry authority because it would be inconsistent to have two separate validation outcomes for these ops.

Running Validation

When the fn validate(op: Op) -> ExternResult<ValidateCallbackResult> is called it will be passed the operation variant for the authority that is actually running the validation.

For example the entry authority will be passed the Op::StoreEntry operation. The operations that can be applied to Holochain data. Operations beginning with Store are concerned with creating and storing data. Operations beginning with Register are concerned with registering metadata about the data.

Variants§

§

StoreRecord(StoreRecord)

Stores a new Record in the DHT. This is the act of creating a new Action and publishing it to the DHT. Note that not all Actions contain an Entry.

§

StoreEntry(StoreEntry)

Stores a new Entry in the DHT. This is the act of creating a either a Action::Create or a Action::Update and publishing it to the DHT. These actions create a new instance of an Entry.

§

RegisterUpdate(RegisterUpdate)

Registers an update from an instance of an Entry in the DHT. This is the act of creating a Action::Update and publishing it to the DHT. Note that the Action::Update stores an new instance of an Entry and registers it as an update to the original Entry. This operation is only concerned with registering the update.

§

RegisterDelete(RegisterDelete)

Registers a deletion of an instance of an Entry in the DHT. This is the act of creating a Action::Delete and publishing it to the DHT.

§

RegisterAgentActivity(RegisterAgentActivity)

Registers a new Action on an agent source chain. This is the act of creating any Action and publishing it to the DHT.

Registers a link between two Entrys. This is the act of creating a Action::CreateLink and publishing it to the DHT. The authority is the entry authority for the base Entry.

Deletes a link between two Entrys. This is the act of creating a Action::DeleteLink and publishing it to the DHT. The delete always references a specific Action::CreateLink.

Implementations§

§

impl Op

pub fn author(&self) -> &HoloHash<Agent>

Get the AgentPubKey for the author of this op.

pub fn timestamp(&self) -> Timestamp

Get the Timestamp for when this op was created.

pub fn action_seq(&self) -> u32

Get the action sequence this op.

pub fn prev_action(&self) -> Option<&HoloHash<Action>>

Get the ActionHash for the the previous action from this op if there is one.

pub fn action_type(&self) -> ActionType

Get the ActionType of this op.

Trait Implementations§

§

impl Clone for Op

§

fn clone(&self) -> Op

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Op

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for Op

§

fn deserialize<__D>(
    __deserializer: __D
) -> Result<Op, <__D as Deserializer<'de>>::Error>where
    __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl OpHelper for Op

source§

fn to_type<ET, LT>(&self) -> Result<OpType<ET, LT>, WasmError>where
    ET: EntryTypesHelper + UnitEnum,
    <ET as UnitEnum>::Unit: Into<ZomeTypesKey<EntryDefIndex>>,
    LT: LinkTypesHelper,
    WasmError: From<<ET as EntryTypesHelper>::Error> + From<<LT as LinkTypesHelper>::Error>,

Converts an Op to an OpType without consuming it. This will clone the required internal data.
§

impl PartialEq<Op> for Op

§

fn eq(&self, other: &Op) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Serialize for Op

§

fn serialize<__S>(
    &self,
    __serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
    __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl TryFrom<&Op> for SerializedBytes

§

type Error = SerializedBytesError

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

fn try_from(t: &Op) -> Result<SerializedBytes, SerializedBytesError>

Performs the conversion.
§

impl TryFrom<Op> for SerializedBytes

§

type Error = SerializedBytesError

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

fn try_from(t: Op) -> Result<SerializedBytes, SerializedBytesError>

Performs the conversion.
§

impl TryFrom<SerializedBytes> for Op

§

type Error = SerializedBytesError

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

fn try_from(sb: SerializedBytes) -> Result<Op, SerializedBytesError>

Performs the conversion.
§

impl StructuralPartialEq for Op

Auto Trait Implementations§

§

impl RefUnwindSafe for Op

§

impl Send for Op

§

impl Sync for Op

§

impl Unpin for Op

§

impl UnwindSafe for Op

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata(
    _: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
§

impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
    W: DeserializeWith<F, T, D>,
    D: Fallible + ?Sized,
    F: ?Sized,

§

fn deserialize(
    &self,
    deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

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

const: unstable · 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T> ToOwned for Twhere
    T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<T> Upcastable for Twhere
    T: Any + Send + Sync + 'static,

§

fn upcast_any_ref(&self) -> &(dyn Any + 'static)

upcast ref
§

fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)

upcast mut ref
§

fn upcast_any_box(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

upcast boxed dyn
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
    S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for Twhere
    T: for<'de> Deserialize<'de>,