pub struct Type { /* private fields */ }
Expand description
Configuration item for a GraphQL type. In back-end storage, the type is recorded in a label attached to the graph node.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(),
true, false, None, None),
Property::new("role".to_string(), UsesFilter::all(), "String".to_string(),
true, false, None, None)),
vec!(),
EndpointsFilter::all()
);
Implementations
sourceimpl Type
impl Type
sourcepub fn new(
name: String,
props: Vec<Property>,
rels: Vec<Relationship>,
endpoints: EndpointsFilter
) -> Type
pub fn new(
name: String,
props: Vec<Property>,
rels: Vec<Relationship>,
endpoints: EndpointsFilter
) -> Type
Creates a new Type struct.
Arguments
- name - the name of the type, which will be recorded as the label on a node in the graph back-end
- props - a vector of
Property
structs describing the properties on the node - rels - a vector of
Relationship
structs describing the outgoing relationships from this node type - endpoints - an
EndpointsFilter
struct describing which CRUD operations should be generated automatically for this node type.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(),
true, false, None, None),
Property::new("role".to_string(), UsesFilter::all(), "String".to_string(),
true, false, None, None)),
vec!(),
EndpointsFilter::all()
);
sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the name of the type. This type name is used as the label on nodes of this type in the graph database storage back-end.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(), true, false, None, None),
Property::new("role".to_string(), UsesFilter::all(), "String".to_string(), true, false, None, None)),
vec!(),
EndpointsFilter::all()
);
assert_eq!("User", t.name());
sourcepub fn endpoints(&self) -> &EndpointsFilter
pub fn endpoints(&self) -> &EndpointsFilter
Returns the EndpointsFilter
struct associate with this type, determining which CRUD
operations should be auto-generated for this node type.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(), true, false, None, None),
Property::new("role".to_string(), UsesFilter::all(), "String".to_string(), true, false, None, None)),
vec!(),
EndpointsFilter::all()
);
assert_eq!(&EndpointsFilter::all(), t.endpoints());
sourcepub fn props(&self) -> Iter<'_, Property>
pub fn props(&self) -> Iter<'_, Property>
Returns an iterator over the Property
structs defining properties on this node type.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(),
true, false, None, None)), vec!(), EndpointsFilter::all());
assert_eq!("name", t.props().next().expect("Expected property").name());
pub fn mut_props(&mut self) -> &mut Vec<Property>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourcepub fn props_as_slice(&self) -> &[Property]
pub fn props_as_slice(&self) -> &[Property]
Returns a slice of the Property
structs defining properties on this node type.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(), true, false, None, None)),
vec!(),
EndpointsFilter::all()
);
assert_eq!("name", t.props_as_slice()[0].name());
sourcepub fn rels(&self) -> Iter<'_, Relationship>
pub fn rels(&self) -> Iter<'_, Relationship>
Returns an iterator over the Relationship
structs defining relationships originating
from this node type.
Examples
let t = Type::new(
"User".to_string(),
vec!(Property::new("name".to_string(), UsesFilter::all(), "String".to_string(), true,
false, None, None)),
vec!(Relationship::new("rel_name".to_string(), false, vec!("Role".to_string()), vec!(
Property::new("rel_prop".to_string(), UsesFilter::all(), "String".to_string(), true, false, None, None)
), EndpointsFilter::all(), None)),
EndpointsFilter::all()
);
assert_eq!("rel_name", t.rels().next().expect("Expected relationship").name());
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Type
impl<'de> Deserialize<'de> for Type
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for Type
impl Ord for Type
sourceimpl PartialOrd<Type> for Type
impl PartialOrd<Type> for Type
sourcefn partial_cmp(&self, other: &Type) -> Option<Ordering>
fn partial_cmp(&self, other: &Type) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl TryFrom<&'_ str> for Type
impl TryFrom<&'_ str> for Type
sourcefn try_from(yaml: &str) -> Result<Type, Error>
fn try_from(yaml: &str) -> Result<Type, Error>
Creates a new Type struct from a yaml-formatted string.
Errors
Returns an Error
variant YamlDeserializationFailed
if the yaml-formatted
string is improperly formatted.
Examples
use warpgrapher::engine::config::{Type};
use std::convert::TryFrom;
let t = Type::try_from("
name: User
props:
- name: name
type: String
").unwrap();
impl Eq for Type
impl StructuralEq for Type
impl StructuralPartialEq for Type
Auto Trait Implementations
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnwindSafe for Type
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more