pub struct BlockRelationMap { /* private fields */ }Expand description
Manages relationships between blocks in a clean, type-safe way
Implementations§
Source§impl BlockRelationMap
impl BlockRelationMap
Sourcepub fn add_relation_impl(
&self,
from: BlockId,
relation: BlockRelation,
to: BlockId,
)
pub fn add_relation_impl( &self, from: BlockId, relation: BlockRelation, to: BlockId, )
Add a relationship between two blocks
Sourcepub fn add_relation_impls(
&self,
from: BlockId,
relation: BlockRelation,
targets: &[BlockId],
)
pub fn add_relation_impls( &self, from: BlockId, relation: BlockRelation, targets: &[BlockId], )
Add multiple relationships of the same type from one block
Sourcepub fn remove_relation_impl(
&self,
from: BlockId,
relation: BlockRelation,
to: BlockId,
) -> bool
pub fn remove_relation_impl( &self, from: BlockId, relation: BlockRelation, to: BlockId, ) -> bool
Remove a specific relationship
Sourcepub fn remove_all_relations(
&self,
from: BlockId,
relation: BlockRelation,
) -> Vec<BlockId>
pub fn remove_all_relations( &self, from: BlockId, relation: BlockRelation, ) -> Vec<BlockId>
Remove all relationships of a specific type from a block
Sourcepub fn remove_block_relations(&self, block_id: BlockId)
pub fn remove_block_relations(&self, block_id: BlockId)
Remove all relationships for a block (useful when deleting a block)
Get all blocks related to a given block with a specific relationship
Sourcepub fn get_all_relations(
&self,
from: BlockId,
) -> HashMap<BlockRelation, Vec<BlockId>>
pub fn get_all_relations( &self, from: BlockId, ) -> HashMap<BlockRelation, Vec<BlockId>>
Get all relationships for a specific block
Sourcepub fn has_relation(
&self,
from: BlockId,
relation: BlockRelation,
to: BlockId,
) -> bool
pub fn has_relation( &self, from: BlockId, relation: BlockRelation, to: BlockId, ) -> bool
Check if a specific relationship exists
Sourcepub fn add_relation_if_not_exists(
&self,
from: BlockId,
relation: BlockRelation,
to: BlockId,
)
pub fn add_relation_if_not_exists( &self, from: BlockId, relation: BlockRelation, to: BlockId, )
Add a relation if it doesn’t already exist (optimized: single borrow)
Sourcepub fn add_bidirectional_if_not_exists(&self, caller: BlockId, callee: BlockId)
pub fn add_bidirectional_if_not_exists(&self, caller: BlockId, callee: BlockId)
Add bidirectional relation if it doesn’t already exist (optimized: single borrow)
Sourcepub fn has_relation_type(&self, from: BlockId, relation: BlockRelation) -> bool
pub fn has_relation_type(&self, from: BlockId, relation: BlockRelation) -> bool
Check if any relationship of a type exists
Sourcepub fn get_connected_blocks(&self) -> Vec<BlockId>
pub fn get_connected_blocks(&self) -> Vec<BlockId>
Get all blocks that have any relationships
Get all blocks related to a given block (regardless of relationship type)
Sourcepub fn find_reverse_relations(
&self,
to: BlockId,
relation: BlockRelation,
) -> Vec<BlockId>
pub fn find_reverse_relations( &self, to: BlockId, relation: BlockRelation, ) -> Vec<BlockId>
Find all blocks that point to a given block with a specific relationship
Sourcepub fn stats(&self) -> RelationStats
pub fn stats(&self) -> RelationStats
Get statistics about relationships
Source§impl BlockRelationMap
impl BlockRelationMap
Sourcepub fn from_block(&self, from: BlockId) -> RelationBuilder<'_>
pub fn from_block(&self, from: BlockId) -> RelationBuilder<'_>
Create a fluent builder for adding relationships from a block
Source§impl BlockRelationMap
impl BlockRelationMap
Sourcepub fn add_relation(&self, caller: BlockId, callee: BlockId)
pub fn add_relation(&self, caller: BlockId, callee: BlockId)
Create a bidirectional call relationship
Sourcepub fn remove_relation(&self, caller: BlockId, callee: BlockId)
pub fn remove_relation(&self, caller: BlockId, callee: BlockId)
Remove a bidirectional call relationship
pub fn get_depended(&self, block: BlockId) -> Vec<BlockId>
pub fn get_depends(&self, block: BlockId) -> Vec<BlockId>
Sourcepub fn get_children(&self, block: BlockId) -> Vec<BlockId>
pub fn get_children(&self, block: BlockId) -> Vec<BlockId>
Get all children of a block
Sourcepub fn get_parent(&self, block: BlockId) -> Option<BlockId>
pub fn get_parent(&self, block: BlockId) -> Option<BlockId>
Get the parent of a block (assumes single parent)
Sourcepub fn get_ancestors(&self, block: BlockId) -> Vec<BlockId>
pub fn get_ancestors(&self, block: BlockId) -> Vec<BlockId>
Get all ancestors of a block (walking up the containment hierarchy)
Sourcepub fn get_descendants(&self, block: BlockId) -> Vec<BlockId>
pub fn get_descendants(&self, block: BlockId) -> Vec<BlockId>
Get all descendants of a block (walking down the containment hierarchy)
Trait Implementations§
Source§impl Clone for BlockRelationMap
impl Clone for BlockRelationMap
Source§fn clone(&self) -> BlockRelationMap
fn clone(&self) -> BlockRelationMap
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BlockRelationMap
impl Debug for BlockRelationMap
Source§impl Default for BlockRelationMap
impl Default for BlockRelationMap
Source§fn default() -> BlockRelationMap
fn default() -> BlockRelationMap
Auto Trait Implementations§
impl !Freeze for BlockRelationMap
impl !RefUnwindSafe for BlockRelationMap
impl Send for BlockRelationMap
impl !Sync for BlockRelationMap
impl Unpin for BlockRelationMap
impl UnwindSafe for BlockRelationMap
Blanket Implementations§
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<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 more