Skip to content

Commit

Permalink
cosmetic changes to clean up some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
evomimic committed Dec 18, 2024
1 parent d09e83f commit 8ac1537
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 78 deletions.
35 changes: 0 additions & 35 deletions crates/coordinator/holons/src/query_manager.rs

This file was deleted.

61 changes: 18 additions & 43 deletions zomes/coordinator/holons/src/space_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,7 @@ pub trait HolonCacheBehavior {
fn add_to_cache(&self, holons: Vec<Holon>) -> Result<(), HolonError>;
}


///direct access to holons
pub trait HolonStageQuery {
/// holon from a StageReference
fn get_holon(&self, reference: &StagedReference) -> Result<Rc<RefCell<Holon>>, HolonError>;
/// holon from a Stage index
fn get_holon_by_index(&self, index: usize) -> Result<Rc<RefCell<Holon>>, HolonError>;
fn get_all_holons(&self) -> Vec<Rc<RefCell<Holon>>>;
}

///comon stage operations
///common stage operations
///direct access to holons
pub trait HolonStageQuery {
/// holon from a StageReference
Expand All @@ -64,7 +54,7 @@ pub trait HolonStageQuery {
fn get_staged_holons(&self) -> Vec<Rc<RefCell<Holon>>>;
}

///comon stage operations
///common stage operations
pub trait HolonStagingBehavior {
/// Stages the provided holon and returns a reference-counted reference to it
/// If the holon has a key, update the keyed_index to allow the staged holon
Expand All @@ -74,15 +64,15 @@ pub trait HolonStagingBehavior {
/// This function converts a StagedIndex into a StagedReference
/// Returns HolonError::IndexOutOfRange if index is out range for staged_holons vector
/// Returns HolonError::NotAccessible if the staged holon is in an Abandoned state
fn to_staged_reference(&self,staged_index: StagedIndex) -> Result<StagedReference, HolonError>;
/// Returns a dictionary indexed by key of all staged holons
fn to_staged_reference(&self, staged_index: StagedIndex)
-> Result<StagedReference, HolonError>;
/// Returns a dictionary indexed by key of all staged holons
fn get_stage_key_index(&self) -> BTreeMap<MapString, usize>;

///holon reference from a key name
fn get_holon_by_key(&self, key: MapString) -> Result<StagedReference, HolonError>;
//fn get_mut_holon_by_index(&self, holon_index: StagedIndex) -> Result<RefMut<Holon>, HolonError>

/// Returns a dictionary indexed by key of all staged holons
fn get_stage_key_index(&self) -> BTreeMap<MapString, usize>;
}

impl HolonSpaceManager {
Expand Down Expand Up @@ -135,11 +125,11 @@ impl HolonSpaceManager {
Some(space_reference) => Ok(space_reference),
None => {
debug!("No Local Space Holon found in session, fetching it.");
let spaceholon = holon_service::get_holon_by_path(
let space_holon = holon_service::get_holon_by_path(
"local_holon_space".to_string(),
LinkTypes::LocalHolonSpace,
);
match spaceholon {
return match space_holon {
Ok(spaceholon) => {
match spaceholon {
Some(spaceholon) => {
Expand All @@ -149,7 +139,7 @@ impl HolonSpaceManager {
HolonReference::smartreference_from_holon_id(holon_id);
self.set_space_holon(spaceholon);
self.set_space_holon_ref(ref_spaceholon.clone());
return Ok(ref_spaceholon);
Ok(ref_spaceholon)
}
None => {
info!(
Expand Down Expand Up @@ -186,25 +176,23 @@ impl HolonSpaceManager {
holon_id,
);
self.set_space_holon_ref(space_reference.clone());
return Ok(space_reference);
}
Err(_) => {
return Err(HolonError::CommitFailure(
"Unable to crate path to the LocalHolonSpace"
.to_string(),
));
Ok(space_reference)
}
Err(_) => Err(HolonError::CommitFailure(
"Unable to crate path to the LocalHolonSpace"
.to_string(),
)),
}
} else {
return Err(HolonError::CommitFailure(
Err(HolonError::CommitFailure(
"Unable to commit LocalHolonSpace".to_string(),
));
))
}
}
}
}
Err(fetch_error) => return Err(fetch_error),
}
Err(fetch_error) => Err(fetch_error),
};
}
};
}
Expand Down Expand Up @@ -260,19 +248,6 @@ impl HolonStageQuery for HolonSpaceManager {
}
}


impl HolonStageQuery for HolonSpaceManager {
fn get_holon(&self, reference: &StagedReference) -> Result<Rc<RefCell<Holon>>, HolonError> {
self.nursery.borrow().get_holon_by_index(reference.holon_index)
}
fn get_holon_by_index(&self, index: usize) -> Result<Rc<RefCell<Holon>>, HolonError>{
self.nursery.borrow().get_holon_by_index(index)
}
fn get_all_holons(&self) -> Vec<Rc<RefCell<Holon>>> {
self.nursery.borrow().get_all_holons()
}
}

impl HolonStagingBehavior for HolonSpaceManager {
fn stage_new_holon(&self, mut holon: Holon) -> Result<StagedReference, HolonError> {
//let mut cloned_holon = holon.clone();
Expand Down

0 comments on commit 8ac1537

Please sign in to comment.