Struct holochain_types::app::InstalledAppCommon
source · pub struct InstalledAppCommon { /* private fields */ }
Expand description
The common data between apps of any status
Implementations§
source§impl InstalledAppCommon
impl InstalledAppCommon
sourcepub fn new<S: ToString, I: IntoIterator<Item = (RoleName, AppRoleAssignment)>>(
installed_app_id: S,
_agent_key: AgentPubKey,
role_assignments: I
) -> AppResult<Self>
pub fn new<S: ToString, I: IntoIterator<Item = (RoleName, AppRoleAssignment)>>(
installed_app_id: S,
_agent_key: AgentPubKey,
role_assignments: I
) -> AppResult<Self>
Constructor
sourcepub fn id(&self) -> &InstalledAppId
pub fn id(&self) -> &InstalledAppId
Accessor
sourcepub fn provisioned_cells(&self) -> impl Iterator<Item = (&RoleName, &CellId)>
pub fn provisioned_cells(&self) -> impl Iterator<Item = (&RoleName, &CellId)>
Accessor
sourcepub fn into_provisioned_cells(self) -> impl Iterator<Item = (RoleName, CellId)>
pub fn into_provisioned_cells(self) -> impl Iterator<Item = (RoleName, CellId)>
Accessor
sourcepub fn clone_cells(&self) -> impl Iterator<Item = (&CloneId, &CellId)>
pub fn clone_cells(&self) -> impl Iterator<Item = (&CloneId, &CellId)>
Accessor
Examples found in repository?
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586
pub fn clone_cell_ids(&self) -> impl Iterator<Item = &CellId> {
self.clone_cells().map(|(_, cell_id)| cell_id)
}
/// Accessor
pub fn disabled_clone_cell_ids(&self) -> impl Iterator<Item = &CellId> {
self.disabled_clone_cells().map(|(_, cell_id)| cell_id)
}
/// Iterator of all cells, both provisioned and cloned
pub fn all_cells(&self) -> impl Iterator<Item = &CellId> {
self.provisioned_cells()
.map(|(_, c)| c)
.chain(self.clone_cell_ids())
.chain(self.disabled_clone_cell_ids())
}
/// Iterator of all "required" cells, meaning Cells which must be running
/// for this App to be able to run. The notion of "required cells" is not
/// yet solidified, so for now this placeholder equates to "all cells".
pub fn required_cells(&self) -> impl Iterator<Item = &CellId> {
self.all_cells()
}
/// Accessor for particular role
pub fn role(&self, role_name: &RoleName) -> AppResult<&AppRoleAssignment> {
self.role_assignments
.get(role_name)
.ok_or_else(|| AppError::RoleNameMissing(role_name.clone()))
}
fn role_mut(&mut self, role_name: &RoleName) -> AppResult<&mut AppRoleAssignment> {
self.role_assignments
.get_mut(role_name)
.ok_or_else(|| AppError::RoleNameMissing(role_name.clone()))
}
/// Accessor
pub fn roles(&self) -> &HashMap<RoleName, AppRoleAssignment> {
&self.role_assignments
}
/// Add a clone cell.
pub fn add_clone(&mut self, role_name: &RoleName, cell_id: &CellId) -> AppResult<CloneId> {
let app_role_assignment = self.role_mut(role_name)?;
assert_eq!(
cell_id.agent_pubkey(),
app_role_assignment.agent_key(),
"A clone cell must use the same agent key as the role it is added to"
);
if app_role_assignment.is_clone_limit_reached() {
return Err(AppError::CloneLimitExceeded(
app_role_assignment.clone_limit,
app_role_assignment.clone(),
));
}
let clone_id = CloneId::new(role_name, app_role_assignment.next_clone_index);
if app_role_assignment.clones.contains_key(&clone_id) {
return Err(AppError::DuplicateCloneIds(clone_id));
}
// add clone
app_role_assignment
.clones
.insert(clone_id.clone(), cell_id.clone());
// increment next clone index
app_role_assignment.next_clone_index += 1;
Ok(clone_id)
}
/// Get a clone cell id from its clone id.
pub fn get_clone_cell_id(&self, clone_cell_id: &CloneCellId) -> AppResult<CellId> {
let cell_id = match clone_cell_id {
CloneCellId::CellId(cell_id) => cell_id,
CloneCellId::CloneId(clone_id) => self
.role(&clone_id.as_base_role_name())?
.clones
.get(clone_id)
.ok_or_else(|| {
AppError::CloneCellNotFound(CloneCellId::CloneId(clone_id.clone()))
})?,
};
Ok(cell_id.clone())
}
/// Get the clone id from either clone or cell id.
pub fn get_clone_id(&self, clone_cell_id: &CloneCellId) -> AppResult<CloneId> {
let clone_id = match clone_cell_id {
CloneCellId::CloneId(id) => id,
CloneCellId::CellId(id) => {
self.clone_cells()
.find(|(_, cell_id)| *cell_id == id)
.ok_or_else(|| AppError::CloneCellNotFound(CloneCellId::CellId(id.clone())))?
.0
}
};
Ok(clone_id.clone())
}
sourcepub fn disabled_clone_cells(&self) -> impl Iterator<Item = (&CloneId, &CellId)>
pub fn disabled_clone_cells(&self) -> impl Iterator<Item = (&CloneId, &CellId)>
Accessor
sourcepub fn clone_cells_for_role_name(
&self,
role_name: &RoleName
) -> Option<&HashMap<CloneId, CellId>>
pub fn clone_cells_for_role_name(
&self,
role_name: &RoleName
) -> Option<&HashMap<CloneId, CellId>>
Accessor
sourcepub fn disabled_clone_cells_for_role_name(
&self,
role_name: &RoleName
) -> Option<&HashMap<CloneId, CellId>>
pub fn disabled_clone_cells_for_role_name(
&self,
role_name: &RoleName
) -> Option<&HashMap<CloneId, CellId>>
Accessor
sourcepub fn clone_cell_ids(&self) -> impl Iterator<Item = &CellId>
pub fn clone_cell_ids(&self) -> impl Iterator<Item = &CellId>
Accessor
sourcepub fn disabled_clone_cell_ids(&self) -> impl Iterator<Item = &CellId>
pub fn disabled_clone_cell_ids(&self) -> impl Iterator<Item = &CellId>
Accessor
sourcepub fn all_cells(&self) -> impl Iterator<Item = &CellId>
pub fn all_cells(&self) -> impl Iterator<Item = &CellId>
Iterator of all cells, both provisioned and cloned
sourcepub fn required_cells(&self) -> impl Iterator<Item = &CellId>
pub fn required_cells(&self) -> impl Iterator<Item = &CellId>
Iterator of all “required” cells, meaning Cells which must be running for this App to be able to run. The notion of “required cells” is not yet solidified, so for now this placeholder equates to “all cells”.
sourcepub fn role(&self, role_name: &RoleName) -> AppResult<&AppRoleAssignment>
pub fn role(&self, role_name: &RoleName) -> AppResult<&AppRoleAssignment>
Accessor for particular role
Examples found in repository?
560 561 562 563 564 565 566 567 568 569 570 571 572
pub fn get_clone_cell_id(&self, clone_cell_id: &CloneCellId) -> AppResult<CellId> {
let cell_id = match clone_cell_id {
CloneCellId::CellId(cell_id) => cell_id,
CloneCellId::CloneId(clone_id) => self
.role(&clone_id.as_base_role_name())?
.clones
.get(clone_id)
.ok_or_else(|| {
AppError::CloneCellNotFound(CloneCellId::CloneId(clone_id.clone()))
})?,
};
Ok(cell_id.clone())
}
sourcepub fn roles(&self) -> &HashMap<RoleName, AppRoleAssignment>
pub fn roles(&self) -> &HashMap<RoleName, AppRoleAssignment>
Accessor
sourcepub fn add_clone(
&mut self,
role_name: &RoleName,
cell_id: &CellId
) -> AppResult<CloneId>
pub fn add_clone(
&mut self,
role_name: &RoleName,
cell_id: &CellId
) -> AppResult<CloneId>
Add a clone cell.
sourcepub fn get_clone_cell_id(&self, clone_cell_id: &CloneCellId) -> AppResult<CellId>
pub fn get_clone_cell_id(&self, clone_cell_id: &CloneCellId) -> AppResult<CellId>
Get a clone cell id from its clone id.
sourcepub fn get_clone_id(&self, clone_cell_id: &CloneCellId) -> AppResult<CloneId>
pub fn get_clone_id(&self, clone_cell_id: &CloneCellId) -> AppResult<CloneId>
Get the clone id from either clone or cell id.
sourcepub fn get_disabled_clone_id(
&self,
clone_cell_id: &CloneCellId
) -> AppResult<CloneId>
pub fn get_disabled_clone_id(
&self,
clone_cell_id: &CloneCellId
) -> AppResult<CloneId>
Get the clone id from either clone or cell id.
sourcepub fn disable_clone_cell(&mut self, clone_id: &CloneId) -> AppResult<()>
pub fn disable_clone_cell(&mut self, clone_id: &CloneId) -> AppResult<()>
Disable a clone cell.
Removes the cell from the list of clones, and it is not accessible any longer.
sourcepub fn enable_clone_cell(
&mut self,
clone_id: &CloneId
) -> AppResult<InstalledCell>
pub fn enable_clone_cell(
&mut self,
clone_id: &CloneId
) -> AppResult<InstalledCell>
Transformer Enable a disabled clone cell.
The clone cell is added back to the list of clones and can be accessed again.
Returns
The enabled clone cell.
sourcepub fn delete_clone_cell(&mut self, clone_id: &CloneId) -> AppResult<()>
pub fn delete_clone_cell(&mut self, clone_id: &CloneId) -> AppResult<()>
Delete a disabled clone cell.
sourcepub fn _agent_key(&self) -> &AgentPubKey
pub fn _agent_key(&self) -> &AgentPubKey
Accessor
sourcepub fn new_legacy<S: ToString, I: IntoIterator<Item = InstalledCell>>(
installed_app_id: S,
installed_cells: I
) -> AppResult<Self>
pub fn new_legacy<S: ToString, I: IntoIterator<Item = InstalledCell>>(
installed_app_id: S,
installed_cells: I
) -> AppResult<Self>
Constructor for apps not using a manifest. Allows for cloning up to 256 times and implies immediate provisioning.
Trait Implementations§
source§impl AsMut<InstalledAppCommon> for InstalledApp
impl AsMut<InstalledAppCommon> for InstalledApp
source§fn as_mut(&mut self) -> &mut InstalledAppCommon
fn as_mut(&mut self) -> &mut InstalledAppCommon
source§impl AsMut<InstalledAppCommon> for RunningApp
impl AsMut<InstalledAppCommon> for RunningApp
source§fn as_mut(&mut self) -> &mut InstalledAppCommon
fn as_mut(&mut self) -> &mut InstalledAppCommon
source§impl AsMut<InstalledAppCommon> for StoppedApp
impl AsMut<InstalledAppCommon> for StoppedApp
source§fn as_mut(&mut self) -> &mut InstalledAppCommon
fn as_mut(&mut self) -> &mut InstalledAppCommon
source§impl AsRef<InstalledAppCommon> for InstalledApp
impl AsRef<InstalledAppCommon> for InstalledApp
source§fn as_ref(&self) -> &InstalledAppCommon
fn as_ref(&self) -> &InstalledAppCommon
source§impl AsRef<InstalledAppCommon> for RunningApp
impl AsRef<InstalledAppCommon> for RunningApp
source§fn as_ref(&self) -> &InstalledAppCommon
fn as_ref(&self) -> &InstalledAppCommon
source§impl AsRef<InstalledAppCommon> for StoppedApp
impl AsRef<InstalledAppCommon> for StoppedApp
source§fn as_ref(&self) -> &InstalledAppCommon
fn as_ref(&self) -> &InstalledAppCommon
source§impl Borrow<InstalledAppCommon> for InstalledApp
impl Borrow<InstalledAppCommon> for InstalledApp
source§fn borrow(&self) -> &InstalledAppCommon
fn borrow(&self) -> &InstalledAppCommon
source§impl Borrow<InstalledAppCommon> for RunningApp
impl Borrow<InstalledAppCommon> for RunningApp
source§fn borrow(&self) -> &InstalledAppCommon
fn borrow(&self) -> &InstalledAppCommon
source§impl Borrow<InstalledAppCommon> for StoppedApp
impl Borrow<InstalledAppCommon> for StoppedApp
source§fn borrow(&self) -> &InstalledAppCommon
fn borrow(&self) -> &InstalledAppCommon
source§impl BorrowMut<InstalledAppCommon> for InstalledApp
impl BorrowMut<InstalledAppCommon> for InstalledApp
source§fn borrow_mut(&mut self) -> &mut InstalledAppCommon
fn borrow_mut(&mut self) -> &mut InstalledAppCommon
source§impl BorrowMut<InstalledAppCommon> for RunningApp
impl BorrowMut<InstalledAppCommon> for RunningApp
source§fn borrow_mut(&mut self) -> &mut InstalledAppCommon
fn borrow_mut(&mut self) -> &mut InstalledAppCommon
source§impl BorrowMut<InstalledAppCommon> for StoppedApp
impl BorrowMut<InstalledAppCommon> for StoppedApp
source§fn borrow_mut(&mut self) -> &mut InstalledAppCommon
fn borrow_mut(&mut self) -> &mut InstalledAppCommon
source§impl Clone for InstalledAppCommon
impl Clone for InstalledAppCommon
source§fn clone(&self) -> InstalledAppCommon
fn clone(&self) -> InstalledAppCommon
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for InstalledAppCommon
impl Debug for InstalledAppCommon
source§impl<'de> Deserialize<'de> for InstalledAppCommon
impl<'de> Deserialize<'de> for InstalledAppCommon
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl From<InstalledAppCommon> for RunningApp
impl From<InstalledAppCommon> for RunningApp
source§fn from(original: InstalledAppCommon) -> RunningApp
fn from(original: InstalledAppCommon) -> RunningApp
source§impl From<StoppedApp> for InstalledAppCommon
impl From<StoppedApp> for InstalledAppCommon
source§fn from(d: StoppedApp) -> Self
fn from(d: StoppedApp) -> Self
source§impl PartialEq<InstalledAppCommon> for InstalledAppCommon
impl PartialEq<InstalledAppCommon> for InstalledAppCommon
source§fn eq(&self, other: &InstalledAppCommon) -> bool
fn eq(&self, other: &InstalledAppCommon) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for InstalledAppCommon
impl Serialize for InstalledAppCommon
impl Eq for InstalledAppCommon
impl StructuralEq for InstalledAppCommon
impl StructuralPartialEq for InstalledAppCommon
Auto Trait Implementations§
impl RefUnwindSafe for InstalledAppCommon
impl Send for InstalledAppCommon
impl Sync for InstalledAppCommon
impl Unpin for InstalledAppCommon
impl UnwindSafe for InstalledAppCommon
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
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
§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>
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
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>
self
from the equivalent element of its
superset. Read more§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).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.