Struct holochain_types::app::AppRoleResolution
source · pub struct AppRoleResolution {
pub agent: AgentPubKey,
pub dnas_to_register: Vec<(DnaFile, Option<MembraneProof>)>,
pub role_assignments: Vec<(RoleName, AppRoleAssignment)>,
}
Expand description
The answer to the question: “how do we concretely assign DNAs to the open roles of this App?” Includes the DNAs selected to fill the roles and the details of the role assignments.
Fields§
§agent: AgentPubKey
§dnas_to_register: Vec<(DnaFile, Option<MembraneProof>)>
§role_assignments: Vec<(RoleName, AppRoleAssignment)>
Implementations§
source§impl AppRoleResolution
impl AppRoleResolution
sourcepub fn new(agent: AgentPubKey) -> Self
pub fn new(agent: AgentPubKey) -> Self
Examples found in repository?
src/app/app_bundle.rs (line 68)
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
pub async fn resolve_cells(
self,
agent: AgentPubKey,
_gamut: DnaGamut,
membrane_proofs: HashMap<RoleName, MembraneProof>,
) -> AppBundleResult<AppRoleResolution> {
let AppManifestValidated { name: _, roles } = self.manifest().clone().validate()?;
let bundle = Arc::new(self);
let tasks = roles.into_iter().map(|(role_name, role)| async {
let bundle = bundle.clone();
Ok((role_name, bundle.resolve_cell(role).await?))
});
let resolution = futures::future::join_all(tasks)
.await
.into_iter()
.collect::<AppBundleResult<Vec<_>>>()?
.into_iter()
.fold(
Ok(AppRoleResolution::new(agent.clone())),
|acc: AppBundleResult<AppRoleResolution>, (role_name, op)| {
if let Ok(mut resolution) = acc {
match op {
CellProvisioningOp::Create(dna, clone_limit) => {
let agent = resolution.agent.clone();
let dna_hash = dna.dna_hash().clone();
let cell_id = CellId::new(dna_hash, agent);
let role = AppRoleAssignment::new(cell_id, true, clone_limit);
// TODO: could sequentialize this to remove the clone
let proof = membrane_proofs.get(&role_name).cloned();
resolution.dnas_to_register.push((dna, proof));
resolution.role_assignments.push((role_name, role));
}
CellProvisioningOp::Existing(cell_id, clone_limit) => {
let role = AppRoleAssignment::new(cell_id, true, clone_limit);
resolution.role_assignments.push((role_name, role));
}
CellProvisioningOp::Noop(cell_id, clone_limit) => {
resolution.role_assignments.push((
role_name,
AppRoleAssignment::new(cell_id, false, clone_limit),
));
}
other => {
tracing::error!(
"Encountered unexpected CellProvisioningOp: {:?}",
other
);
unimplemented!()
}
}
Ok(resolution)
} else {
acc
}
},
)?;
// let resolution = cells.into_iter();
Ok(resolution)
}
sourcepub fn cells_to_create(&self) -> Vec<(CellId, Option<MembraneProof>)> ⓘ
pub fn cells_to_create(&self) -> Vec<(CellId, Option<MembraneProof>)> ⓘ
Return the IDs of new cells to be created as part of the resolution. Does not return existing cells to be reused.
Trait Implementations§
source§impl Debug for AppRoleResolution
impl Debug for AppRoleResolution
source§impl PartialEq<AppRoleResolution> for AppRoleResolution
impl PartialEq<AppRoleResolution> for AppRoleResolution
source§fn eq(&self, other: &AppRoleResolution) -> bool
fn eq(&self, other: &AppRoleResolution) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for AppRoleResolution
impl StructuralEq for AppRoleResolution
impl StructuralPartialEq for AppRoleResolution
Auto Trait Implementations§
impl !RefUnwindSafe for AppRoleResolution
impl Send for AppRoleResolution
impl Sync for AppRoleResolution
impl Unpin for AppRoleResolution
impl !UnwindSafe for AppRoleResolution
Blanket Implementations§
§impl<T> Any for Twhere
T: Any + ?Sized,
impl<T> Any for Twhere
T: Any + ?Sized,
§fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
TODO: once 1.33.0 is the minimum supported compiler version, remove
Any::type_id_compat and use StdAny::type_id instead.
https://github.com/rust-lang/rust/issues/27745
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
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>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> 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>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.§impl<T> Upcastable for Twhere
T: 'static + Any + Send + Sync,
impl<T> Upcastable for Twhere
T: 'static + Any + Send + Sync,
§fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
§fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref