pub struct TypeFlowGraphV2 {
pub definitions: Vec<DefinitionData>,
pub usages: Vec<UsageData>,
pub generic_args: Vec<GenericArgData>,
pub trait_bounds: Vec<TraitBoundData>,
pub usage_to_args: Vec<SmallVec<[u32; 4]>>,
pub node_to_bounds: HashMap<TypeNodeId, SmallVec<[u32; 2]>>,
pub lookup: LookupTable,
}Expand description
Type relationship graph (V2 - Data-Oriented Design).
NOTE: Deserialize is NOT derived because TypeFlowGraphV2 contains SecondaryMap<SymbolId, …> and HashMap<SymbolId, …>. SymbolId is process-specific. Serialize is kept for debugging/inspection.
Fields§
§definitions: Vec<DefinitionData>Definition nodes.
usages: Vec<UsageData>Usage nodes.
generic_args: Vec<GenericArgData>Generic argument nodes.
trait_bounds: Vec<TraitBoundData>Trait bound nodes.
usage_to_args: Vec<SmallVec<[u32; 4]>>Usage → generic args (1:N).
node_to_bounds: HashMap<TypeNodeId, SmallVec<[u32; 2]>>Node → trait bounds (1:N).
lookup: LookupTableReverse-lookup tables (SymbolId → node indices, etc.) used for
fast querying.
Implementations§
Source§impl TypeFlowGraphV2
impl TypeFlowGraphV2
Sourcepub fn with_capacity(defs: usize, usages: usize) -> Self
pub fn with_capacity(defs: usize, usages: usize) -> Self
Create with pre-allocated capacity.
Sourcepub fn add_definition(
&mut self,
symbol_id: SymbolId,
kind: TypeDefKind,
) -> TypeNodeId
pub fn add_definition( &mut self, symbol_id: SymbolId, kind: TypeDefKind, ) -> TypeNodeId
Add a type definition node.
Sourcepub fn add_usage(
&mut self,
context: UsageContext,
ref_kind: RefKind,
resolved: Option<SymbolId>,
container: Option<SymbolId>,
) -> TypeNodeId
pub fn add_usage( &mut self, context: UsageContext, ref_kind: RefKind, resolved: Option<SymbolId>, container: Option<SymbolId>, ) -> TypeNodeId
Add a type usage node.
Sourcepub fn add_generic_arg(
&mut self,
parent: TypeNodeId,
arg_index: u8,
resolved: Option<SymbolId>,
) -> TypeNodeId
pub fn add_generic_arg( &mut self, parent: TypeNodeId, arg_index: u8, resolved: Option<SymbolId>, ) -> TypeNodeId
Add a generic argument node.
Sourcepub fn add_trait_bound(
&mut self,
target: TypeNodeId,
trait_id: Option<SymbolId>,
) -> TypeNodeId
pub fn add_trait_bound( &mut self, target: TypeNodeId, trait_id: Option<SymbolId>, ) -> TypeNodeId
Add a trait bound node.
Sourcepub fn add_contains(&mut self, container: SymbolId, field_type: SymbolId)
pub fn add_contains(&mut self, container: SymbolId, field_type: SymbolId)
Register a container-field relationship.
Sourcepub fn definition(&self, id: SymbolId) -> Option<TypeNodeId>
pub fn definition(&self, id: SymbolId) -> Option<TypeNodeId>
Get the definition node for a symbol (O(1)).
Sourcepub fn usages(&self, id: SymbolId) -> impl Iterator<Item = TypeNodeId> + '_
pub fn usages(&self, id: SymbolId) -> impl Iterator<Item = TypeNodeId> + '_
Get all usage indices for a type (O(1)).
Sourcepub fn usage_count(&self, id: SymbolId) -> usize
pub fn usage_count(&self, id: SymbolId) -> usize
Get the number of usages for a type (O(1)).
Sourcepub fn types_used_by(
&self,
container: SymbolId,
) -> impl Iterator<Item = SymbolId> + '_
pub fn types_used_by( &self, container: SymbolId, ) -> impl Iterator<Item = SymbolId> + '_
Forward lookup: what types does this container use? (O(1) + result count)
Returns resolved SymbolIds of types referenced by the container.
Includes both directly resolved types and types referenced via generic arguments
(e.g., Foo in Vec<Foo>).
Sourcepub fn type_users(
&self,
type_id: SymbolId,
) -> impl Iterator<Item = SymbolId> + '_
pub fn type_users( &self, type_id: SymbolId, ) -> impl Iterator<Item = SymbolId> + '_
Reverse lookup: what containers use this type? (O(1) + result count)
Returns SymbolIds of containers that reference the given type.
Sourcepub fn type_users_chain(
&self,
start: SymbolId,
max_depth: usize,
) -> Vec<ChainNode>
pub fn type_users_chain( &self, start: SymbolId, max_depth: usize, ) -> Vec<ChainNode>
BFS traversal: find all containers that use this type, transitively.
“Type A is used by container B; B (as a type) is used by container C” etc.
Sourcepub fn types_used_by_chain(
&self,
start: SymbolId,
max_depth: usize,
) -> Vec<ChainNode>
pub fn types_used_by_chain( &self, start: SymbolId, max_depth: usize, ) -> Vec<ChainNode>
BFS traversal: find all types used by this container, transitively.
“Container A uses type B; B (as a container) uses type C” etc.
Sourcepub fn analyze_type_chain(
&self,
start: SymbolId,
max_depth: usize,
direction: ChainDirection,
) -> ChainResult
pub fn analyze_type_chain( &self, start: SymbolId, max_depth: usize, direction: ChainDirection, ) -> ChainResult
Full chain analysis with statistics.
Returns ChainResult compatible with CodeGraphV2’s analyze_chain().
Sourcepub fn generic_args(
&self,
node: TypeNodeId,
) -> impl Iterator<Item = TypeNodeId> + '_
pub fn generic_args( &self, node: TypeNodeId, ) -> impl Iterator<Item = TypeNodeId> + '_
Get generic arguments for a usage node (O(1)).
Sourcepub fn trait_bounds(
&self,
node: TypeNodeId,
) -> impl Iterator<Item = TypeNodeId> + '_
pub fn trait_bounds( &self, node: TypeNodeId, ) -> impl Iterator<Item = TypeNodeId> + '_
Get trait bounds for a node (O(1)).
Sourcepub fn get_definition(&self, id: TypeNodeId) -> Option<&DefinitionData>
pub fn get_definition(&self, id: TypeNodeId) -> Option<&DefinitionData>
Get definition data by ID.
Sourcepub fn get_usage(&self, id: TypeNodeId) -> Option<&UsageData>
pub fn get_usage(&self, id: TypeNodeId) -> Option<&UsageData>
Get usage data by ID.
Sourcepub fn get_generic_arg(&self, id: TypeNodeId) -> Option<&GenericArgData>
pub fn get_generic_arg(&self, id: TypeNodeId) -> Option<&GenericArgData>
Get generic arg data by ID.
Sourcepub fn get_trait_bound(&self, id: TypeNodeId) -> Option<&TraitBoundData>
pub fn get_trait_bound(&self, id: TypeNodeId) -> Option<&TraitBoundData>
Get trait bound data by ID.
Sourcepub fn impact(&self, id: SymbolId) -> TypeImpactV2
pub fn impact(&self, id: SymbolId) -> TypeImpactV2
Analyze the impact of changing a type (O(1) + result count).
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Total number of nodes.
Sourcepub fn definition_count(&self) -> usize
pub fn definition_count(&self) -> usize
Number of definitions.
Sourcepub fn usages_count(&self) -> usize
pub fn usages_count(&self) -> usize
Number of usages.
Trait Implementations§
Source§impl Clone for TypeFlowGraphV2
impl Clone for TypeFlowGraphV2
Source§fn clone(&self) -> TypeFlowGraphV2
fn clone(&self) -> TypeFlowGraphV2
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TypeFlowGraphV2
impl Debug for TypeFlowGraphV2
Source§impl Default for TypeFlowGraphV2
impl Default for TypeFlowGraphV2
Source§fn default() -> TypeFlowGraphV2
fn default() -> TypeFlowGraphV2
Auto Trait Implementations§
impl Freeze for TypeFlowGraphV2
impl RefUnwindSafe for TypeFlowGraphV2
impl Send for TypeFlowGraphV2
impl Sync for TypeFlowGraphV2
impl Unpin for TypeFlowGraphV2
impl UnsafeUnpin for TypeFlowGraphV2
impl UnwindSafe for TypeFlowGraphV2
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