Skip to main content

SchemaGraph

Struct SchemaGraph 

Source
pub struct SchemaGraph {
    pub defs: Vec<SchemaTypeDef>,
    pub root: SchemaType,
}
Expand description

A self-contained schema graph in the recursive in-memory form.

Anywhere a schema travels with a value (typed pair, oplog custom payload, REST/RPC envelope, public oplog rendering), the payload owns its own SchemaGraph — there is no implicit external registry that consumers must look up.

Recursive references between types go through SchemaType::Ref, pointing at named definitions in SchemaGraph::defs.

§Single-root vs multi-root carriers

The common case is single-root: one SchemaGraph describes one payload, with root as the entry type and defs as the named-type registry reachable from it.

Multi-root carriers (today, agent-layer carriers such as [crate::schema::agent::AgentTypeSchema] and [crate::schema::agent::AgentDependencySchema]) use the same shape purely as a definition registry: many roots embedded elsewhere in the carrier reference shared types in defs, and the SchemaGraph::root field is a sentinel (see SchemaGraph::empty). Such carriers must not be passed to root-oriented walkers/renderers as if root were the payload root.

Fields§

§defs: Vec<SchemaTypeDef>

Named type definitions in this graph. The defining set is exactly the types reachable from root (directly or transitively) that need to be named — typically because they participate in a recursive cycle or are referenced multiple times.

§root: SchemaType

Root schema type. Anonymous types appear inline; named types appear as SchemaType::Ref.

Implementations§

Source§

impl SchemaGraph

Source

pub fn anonymous(root: SchemaType) -> SchemaGraph

Convenience: an anonymous root schema with no named definitions.

Source

pub fn empty() -> SchemaGraph

Convenience: an empty graph with no definitions and a sentinel root.

Used as the initial value for multi-root carriers such as [crate::schema::agent::AgentTypeSchema] and [crate::schema::agent::AgentDependencySchema], where the agent’s constructor and methods each act as their own root and only the defs registry is consulted. The root field is a placeholder (empty record) and is not consumed by agent-layer helpers.

Source

pub fn lookup(&self, id: &TypeId) -> Option<&SchemaTypeDef>

Look up a named definition by its TypeId.

Source

pub fn contains_stream_type(&self) -> bool

Whether any type reachable from the root is a stream, including unselected alternatives.

Source

pub fn resolve_ref<'a>( &'a self, ty: &'a SchemaType, ) -> Result<&'a SchemaType, RefResolutionError>

Walk through any number of SchemaType::Ref indirections and return the first non-ref body in this graph. Detects recursive cycles (RefResolutionError::RecursiveRef) and dangling references (RefResolutionError::DanglingRef).

Trait Implementations§

Source§

impl Clone for SchemaGraph

Source§

fn clone(&self) -> SchemaGraph

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 SchemaGraph

Source§

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

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

impl<'de> Deserialize<'de> for SchemaGraph

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<SchemaGraph, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for SchemaGraph

Source§

impl FromSchema for SchemaGraph

Source§

impl IntoSchema for SchemaGraph

Source§

impl PartialEq for SchemaGraph

Source§

fn eq(&self, other: &SchemaGraph) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for SchemaGraph

Source§

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

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SchemaGraph

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> IntoTypedSchemaValue for T
where T: IntoSchema + ?Sized,

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> Resource for T
where T: 'static,

Source§

type Rep = Option<T>

The type which is actually stored in-memory for this resource. 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 = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> TupleOrUnit<()> for T

Source§

fn into(self)