Skip to main content

Types

Trait Types 

Source
pub trait Types: NamedTypeLinks {
Show 16 methods // Required methods fn root(&self) -> u32; fn extends(&self) -> Option<u32>; // Provided methods fn type_of(&mut self, link: u32) -> Option<u32> { ... } fn is_type(&mut self, link: u32) -> bool { ... } fn parents_of(&mut self, type_id: u32) -> Vec<u32> { ... } fn ancestors_of(&mut self, type_id: u32) -> Vec<u32> { ... } fn is_extension(&mut self, link: u32) -> bool { ... } fn is_of(&mut self, link: u32, type_id: u32) -> bool { ... } fn is_of_link(&mut self, link: &Link, type_id: u32) -> bool { ... } fn is_a(&mut self, link: u32, type_id: u32) -> bool { ... } fn is_a_link(&mut self, link: &Link, type_id: u32) -> bool { ... } fn define(&mut self, parent: u32, more: &[u32]) -> Result<u32> { ... } fn define_root(&mut self) -> Result<u32> { ... } fn extend(&mut self, type_id: u32, parent: u32) -> Result<u32> { ... } fn instance(&mut self, type_id: u32) -> Result<u32> { ... } fn instance_with_target(&mut self, type_id: u32, target: u32) -> Result<u32> { ... }
}
Expand description

The queries and writes of a type hierarchy.

Only root and extends are required; everything else is a default method that reads and writes through Self, so a layer that wraps a TypesDecorator – a permission check, say – implements this trait by forwarding the two markers and sees every write the hierarchy makes. Any default can be overridden.

Required Methods§

Source

fn root(&self) -> u32

The root type, (Type: Type Type).

Source

fn extends(&self) -> Option<u32>

The Extends marker, or None when there is none.

Provided Methods§

Source

fn type_of(&mut self, link: u32) -> Option<u32>

The type of a link: its source; None for a missing link.

Source

fn is_type(&mut self, link: u32) -> bool

Whether link is a type: it exists and points at itself.

Source

fn parents_of(&mut self, type_id: u32) -> Vec<u32>

The direct parents of a type: its source (unless it is a point) and what it extends, in the order the extensions were added.

Source

fn ancestors_of(&mut self, type_id: u32) -> Vec<u32>

Every type type_id is, itself first, breadth first, without repeats.

Source

fn is_extension(&mut self, link: u32) -> bool

Whether link is a pair that gives a type one more parent.

Source

fn is_of(&mut self, link: u32, type_id: u32) -> bool

Whether link is strictly of type_id: starting from its source and the types the link itself extends, through any depth of sub-types and parents, cycles included. A type is not of itself; is_a is.

is_of for a link given as (index, source, target), stored or not.

Source

fn is_a(&mut self, link: u32, type_id: u32) -> bool

Whether link is type_id itself or of it.

is_a for a link given as (index, source, target), stored or not.

Source

fn define(&mut self, parent: u32, more: &[u32]) -> Result<u32>

Defines a type (S: parent S) that also extends every type in more.

Source

fn define_root(&mut self) -> Result<u32>

Defines a direct sub-type of root.

Source

fn extend(&mut self, type_id: u32, parent: u32) -> Result<u32>

Makes type_id extend parent: the pair (p: type parent) marked by (m: Extends p). Returns the pair.

Refused when parent is a direct sub-type (parent: type parent) of type_id, whose definition is that very doublet.

Source

fn instance(&mut self, type_id: u32) -> Result<u32>

A value (v: type v) of type_id.

Source

fn instance_with_target(&mut self, type_id: u32, target: u32) -> Result<u32>

A value (v: type target) of type_id.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§