pub struct GraphNode {
pub name: &'static str,
pub dependencies: &'static [&'static str],
pub scope: &'static str,
}Expand description
A node in the dependency graph representing an injectable type.
Each node corresponds to a type annotated with #[derive(Injectable)]
and records its direct dependencies and scope.
§Construction
Nodes are created by the proc macro from constructor parameter analysis:
ⓘ
// From:
#[injectable(ctor)]
pub async fn new(db: Inject<Database>, cache: Inject<Cache>) -> Self
// The macro generates:
GraphNode {
name: "UserService",
dependencies: &["Database", "Cache"],
scope: "singleton",
}Fields§
§name: &'static strThe fully qualified type name of this injectable.
dependencies: &'static [&'static str]The type names of direct dependencies.
scope: &'static strThe scope of this injectable (“singleton” or “transient”).
Implementations§
Source§impl GraphNode
impl GraphNode
Sourcepub const fn new(
name: &'static str,
dependencies: &'static [&'static str],
) -> GraphNode
pub const fn new( name: &'static str, dependencies: &'static [&'static str], ) -> GraphNode
Create a new graph node with default singleton scope.
Sourcepub const fn leaf(name: &'static str) -> GraphNode
pub const fn leaf(name: &'static str) -> GraphNode
Create a graph node with no dependencies (singleton scope by default).
Sourcepub const fn with_scope(
name: &'static str,
dependencies: &'static [&'static str],
scope: &'static str,
) -> GraphNode
pub const fn with_scope( name: &'static str, dependencies: &'static [&'static str], scope: &'static str, ) -> GraphNode
Create a graph node with an explicit scope.
Sourcepub const fn leaf_with_scope(
name: &'static str,
scope: &'static str,
) -> GraphNode
pub const fn leaf_with_scope( name: &'static str, scope: &'static str, ) -> GraphNode
Create a leaf graph node with an explicit scope.
Sourcepub fn dependency_count(&self) -> usize
pub fn dependency_count(&self) -> usize
Returns the number of direct dependencies.
Sourcepub fn is_singleton(&self) -> bool
pub fn is_singleton(&self) -> bool
Returns true if this node is in singleton scope.
Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
Returns true if this node is in transient scope.
Trait Implementations§
impl Collect for GraphNode
impl Eq for GraphNode
impl StructuralPartialEq for GraphNode
Auto Trait Implementations§
impl Freeze for GraphNode
impl RefUnwindSafe for GraphNode
impl Send for GraphNode
impl Sync for GraphNode
impl Unpin for GraphNode
impl UnsafeUnpin for GraphNode
impl UnwindSafe for GraphNode
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
Mutably borrows from an owned value. Read more