holochain_zome_types/
clone.rs

1//! Cells can be cloned to create new cells with the different properties.
2
3use crate::cell::{CellId, CloneId};
4use derive_more::Display;
5use holo_hash::DnaHash;
6use holochain_integrity_types::DnaModifiers;
7
8/// The arguments to create a clone of an existing cell.
9#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
10pub struct CreateCloneCellInput {
11    /// The id of the cell to clone.
12    pub cell_id: CellId,
13    /// Modifiers to set for the new cell.
14    /// At least one of the modifiers must be set to obtain a distinct hash for
15    /// the clone cell's DNA.
16    #[cfg(feature = "properties")]
17    pub modifiers: holochain_integrity_types::DnaModifiersOpt<crate::properties::YamlProperties>,
18    /// Optionally set a proof of membership for the clone cell
19    pub membrane_proof: Option<holochain_integrity_types::MembraneProof>,
20    /// Optionally a name for the DNA clone
21    pub name: Option<String>,
22}
23
24/// Cloned cell that was created from a provisioned cell at runtime.
25#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
26pub struct ClonedCell {
27    /// The cell's identifying data
28    pub cell_id: CellId,
29    /// A conductor-local clone identifier
30    pub clone_id: CloneId,
31    /// The hash of the DNA that this cell was instantiated from
32    pub original_dna_hash: DnaHash,
33    /// The DNA modifiers that were used to instantiate this clone cell
34    pub dna_modifiers: DnaModifiers,
35    /// The name the cell was instantiated with
36    pub name: String,
37    /// Whether or not the cell is running
38    pub enabled: bool,
39}
40
41/// Ways of specifying a clone cell in the context of an app.
42#[derive(Clone, Debug, Display, serde::Serialize, serde::Deserialize)]
43#[serde(tag = "type", content = "value", rename_all = "snake_case")]
44pub enum CloneCellId {
45    /// Clone id consisting of role name and clone index.
46    CloneId(CloneId),
47    /// The DNA hash of the clone to use within an app.
48    DnaHash(DnaHash),
49}
50
51/// Arguments to specify the clone cell to be disabled.
52#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
53pub struct DisableCloneCellInput {
54    /// The clone id or cell id of the clone cell
55    pub clone_cell_id: CloneCellId,
56}
57
58/// Arguments to specify the clone cell to be enabled.
59pub type EnableCloneCellInput = DisableCloneCellInput;
60
61/// Arguments to delete a disabled clone cell of an app.
62pub type DeleteCloneCellInput = DisableCloneCellInput;