Enum hdk::prelude::Op

source ·
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§

source§

impl Op

source

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

Get the AgentPubKey for the author of this op.

source

pub fn timestamp(&self) -> Timestamp

Get the Timestamp for when this op was created.

source

pub fn action_seq(&self) -> u32

Get the action sequence this op.

source

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

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

source

pub fn action_type(&self) -> ActionType

Get the ActionType of this op.

source

pub fn entry_data(&self) -> Option<(&HoloHash<Entry>, &EntryType)>

Get the entry-related data for this op, if applicable

Trait Implementations§

source§

impl Clone for Op

source§

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
source§

impl Debug for Op

source§

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

Formats the value using the given formatter. Read more
source§

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

source§

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 flattened<ET, LT>(&self) -> Result<FlatOp<ET, LT>, WasmError>

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

fn to_type<ET, LT>(&self) -> Result<FlatOp<ET, LT>, WasmError>

👎Deprecated: to_type has been renamed to flattened, please use that name instead
Alias for flattened, for backward compatibility
source§

impl PartialEq for Op

source§

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.
source§

impl Serialize for Op

source§

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
source§

impl TryFrom<&Op> for SerializedBytes

§

type Error = SerializedBytesError

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

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

Performs the conversion.
source§

impl TryFrom<Op> for SerializedBytes

§

type Error = SerializedBytesError

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

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

Performs the conversion.
source§

impl TryFrom<SerializedBytes> for Op

§

type Error = SerializedBytesError

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

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

Performs the conversion.
source§

impl StructuralPartialEq for Op

Auto Trait Implementations§

§

impl Freeze for Op

§

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 T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

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

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 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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

source§

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

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 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> LayoutRaw for T

source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

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

Initializes a with the given initializer. Read more
source§

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

Dereferences the given pointer. Read more
source§

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

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

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

impl<T> Pointee for T

§

type Metadata = ()

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

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where 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 T
where U: Into<T>,

§

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>,

§

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<T> Upcastable for T
where T: Any + Send + Sync + 'static,

source§

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

upcast ref
source§

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

upcast mut ref
source§

fn upcast_any_box(self: Box<T>) -> Box<dyn Any>

upcast boxed dyn
source§

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

source§

fn vzip(self) -> V

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 T
where T: for<'de> Deserialize<'de>,