Skip to main content

TypeFlowGraphV2

Struct TypeFlowGraphV2 

Source
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: LookupTable

Reverse-lookup tables (SymbolId → node indices, etc.) used for fast querying.

Implementations§

Source§

impl TypeFlowGraphV2

Source

pub fn new() -> Self

Create a new empty graph.

Source

pub fn with_capacity(defs: usize, usages: usize) -> Self

Create with pre-allocated capacity.

Source

pub fn add_definition( &mut self, symbol_id: SymbolId, kind: TypeDefKind, ) -> TypeNodeId

Add a type definition node.

Source

pub fn add_usage( &mut self, context: UsageContext, ref_kind: RefKind, resolved: Option<SymbolId>, container: Option<SymbolId>, ) -> TypeNodeId

Add a type usage node.

Source

pub fn add_generic_arg( &mut self, parent: TypeNodeId, arg_index: u8, resolved: Option<SymbolId>, ) -> TypeNodeId

Add a generic argument node.

Source

pub fn add_trait_bound( &mut self, target: TypeNodeId, trait_id: Option<SymbolId>, ) -> TypeNodeId

Add a trait bound node.

Source

pub fn add_contains(&mut self, container: SymbolId, field_type: SymbolId)

Register a container-field relationship.

Source

pub fn definition(&self, id: SymbolId) -> Option<TypeNodeId>

Get the definition node for a symbol (O(1)).

Source

pub fn usages(&self, id: SymbolId) -> impl Iterator<Item = TypeNodeId> + '_

Get all usage indices for a type (O(1)).

Source

pub fn usage_count(&self, id: SymbolId) -> usize

Get the number of usages for a type (O(1)).

Source

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>).

Source

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.

Source

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.

Source

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.

Source

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().

Source

pub fn generic_args( &self, node: TypeNodeId, ) -> impl Iterator<Item = TypeNodeId> + '_

Get generic arguments for a usage node (O(1)).

Source

pub fn trait_bounds( &self, node: TypeNodeId, ) -> impl Iterator<Item = TypeNodeId> + '_

Get trait bounds for a node (O(1)).

Source

pub fn get_definition(&self, id: TypeNodeId) -> Option<&DefinitionData>

Get definition data by ID.

Source

pub fn get_usage(&self, id: TypeNodeId) -> Option<&UsageData>

Get usage data by ID.

Source

pub fn get_generic_arg(&self, id: TypeNodeId) -> Option<&GenericArgData>

Get generic arg data by ID.

Source

pub fn get_trait_bound(&self, id: TypeNodeId) -> Option<&TraitBoundData>

Get trait bound data by ID.

Source

pub fn impact(&self, id: SymbolId) -> TypeImpactV2

Analyze the impact of changing a type (O(1) + result count).

Source

pub fn node_count(&self) -> usize

Total number of nodes.

Source

pub fn definition_count(&self) -> usize

Number of definitions.

Source

pub fn usages_count(&self) -> usize

Number of usages.

Source

pub fn is_empty(&self) -> bool

Check if empty.

Trait Implementations§

Source§

impl Clone for TypeFlowGraphV2

Source§

fn clone(&self) -> TypeFlowGraphV2

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TypeFlowGraphV2

Source§

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

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

impl Default for TypeFlowGraphV2

Source§

fn default() -> TypeFlowGraphV2

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

impl Serialize for TypeFlowGraphV2

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> Same for T

Source§

type Output = T

Should always be Self
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.