BlockRelationMap

Struct BlockRelationMap 

Source
pub struct BlockRelationMap { /* private fields */ }
Expand description

Manages relationships between blocks in a clean, type-safe way

Implementations§

Source§

impl BlockRelationMap

Source

pub fn add_relation_impl( &self, from: BlockId, relation: BlockRelation, to: BlockId, )

Add a relationship between two blocks

Source

pub fn add_relation_impls( &self, from: BlockId, relation: BlockRelation, targets: &[BlockId], )

Add multiple relationships of the same type from one block

Source

pub fn remove_relation_impl( &self, from: BlockId, relation: BlockRelation, to: BlockId, ) -> bool

Remove a specific relationship

Source

pub fn remove_all_relations( &self, from: BlockId, relation: BlockRelation, ) -> Vec<BlockId>

Remove all relationships of a specific type from a block

Source

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

Source

pub fn get_all_relations( &self, from: BlockId, ) -> HashMap<BlockRelation, Vec<BlockId>>

Get all relationships for a specific block

Source

pub fn has_relation( &self, from: BlockId, relation: BlockRelation, to: BlockId, ) -> bool

Check if a specific relationship exists

Source

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)

Source

pub fn add_bidirectional_if_not_exists(&self, caller: BlockId, callee: BlockId)

Add bidirectional relation if it doesn’t already exist (optimized: single borrow)

Source

pub fn has_relation_type(&self, from: BlockId, relation: BlockRelation) -> bool

Check if any relationship of a type exists

Source

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)

Source

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

Source

pub fn stats(&self) -> RelationStats

Get statistics about relationships

Source

pub fn clear(&self)

Clear all relationships

Source

pub fn is_empty(&self) -> bool

Check if the map is empty

Source

pub fn len(&self) -> usize

Get the number of blocks with relationships

Source§

impl BlockRelationMap

Source

pub fn from_block(&self, from: BlockId) -> RelationBuilder<'_>

Create a fluent builder for adding relationships from a block

Source§

impl BlockRelationMap

Source

pub fn add_relation(&self, caller: BlockId, callee: BlockId)

Create a bidirectional call relationship

Source

pub fn remove_relation(&self, caller: BlockId, callee: BlockId)

Remove a bidirectional call relationship

Source

pub fn get_depended(&self, block: BlockId) -> Vec<BlockId>

Source

pub fn get_depends(&self, block: BlockId) -> Vec<BlockId>

Source

pub fn get_children(&self, block: BlockId) -> Vec<BlockId>

Get all children of a block

Source

pub fn get_parent(&self, block: BlockId) -> Option<BlockId>

Get the parent of a block (assumes single parent)

Source

pub fn get_ancestors(&self, block: BlockId) -> Vec<BlockId>

Get all ancestors of a block (walking up the containment hierarchy)

Source

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

Source§

fn clone(&self) -> BlockRelationMap

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BlockRelationMap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BlockRelationMap

Source§

fn default() -> BlockRelationMap

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.