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:
- Every
Actionproduces aOp::RegisterAgentActivityand aOp::StoreRecord. Action::Createalso produces aOp::StoreEntry.Action::Updatealso produces aOp::StoreEntryand aOp::RegisterUpdate.Action::Deletealso produces aOp::RegisterDelete.Action::CreateLinkalso produces aOp::RegisterCreateLink.Action::DeleteLinkalso produces aOp::RegisterDeleteLink.
§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.
RegisterCreateLink(RegisterCreateLink)
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.
RegisterDeleteLink(RegisterDeleteLink)
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
impl Op
Get the AgentPubKey for the author of this op.
Sourcepub fn action_seq(&self) -> u32
pub fn action_seq(&self) -> u32
Get the action sequence this op.
Sourcepub fn prev_action(&self) -> Option<&HoloHash<Action>>
pub fn prev_action(&self) -> Option<&HoloHash<Action>>
Get the ActionHash for the the previous action from this op if there is one.
Sourcepub fn action_type(&self) -> ActionType
pub fn action_type(&self) -> ActionType
Get the ActionType of this op.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Op
impl<'de> Deserialize<'de> for Op
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Op, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Op, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl OpHelper for Op
impl OpHelper for Op
Source§fn flattened<ET, LT>(&self) -> Result<FlatOp<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>,
fn flattened<ET, LT>(&self) -> Result<FlatOp<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>,
Source§fn to_type<ET, LT>(&self) -> Result<FlatOp<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>,
fn to_type<ET, LT>(&self) -> Result<FlatOp<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>,
to_type has been renamed to flattened, please use that name insteadflattened, for backward compatibilitySource§impl Serialize for Op
impl Serialize for Op
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl TryFrom<&Op> for SerializedBytes
impl TryFrom<&Op> for SerializedBytes
Source§type Error = SerializedBytesError
type Error = SerializedBytesError
Source§fn try_from(t: &Op) -> Result<SerializedBytes, SerializedBytesError>
fn try_from(t: &Op) -> Result<SerializedBytes, SerializedBytesError>
Source§impl TryFrom<Op> for SerializedBytes
impl TryFrom<Op> for SerializedBytes
Source§type Error = SerializedBytesError
type Error = SerializedBytesError
Source§fn try_from(t: Op) -> Result<SerializedBytes, SerializedBytesError>
fn try_from(t: Op) -> Result<SerializedBytes, SerializedBytesError>
Source§impl TryFrom<SerializedBytes> for Op
impl TryFrom<SerializedBytes> for Op
Source§type Error = SerializedBytesError
type Error = SerializedBytesError
Source§fn try_from(sb: SerializedBytes) -> Result<Op, SerializedBytesError>
fn try_from(sb: SerializedBytes) -> Result<Op, SerializedBytesError>
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> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.