pub struct Component<T> {
    pub origin: ComponentOrigin,
    pub node: Node<T>,
}
Expand description

A component of a type or schema, for example a field of an object type.

Wraps a Node<T> and adds its origin: either a (schema or type) definition or a specific extension.

Implements Deref and DerefMut so that methods and fields of Node<T> and T can be accessed directly.

Fields§

§origin: ComponentOrigin§node: Node<T>

Implementations§

source§

impl<T> Component<T>

source

pub fn new(node: T) -> Self

Mark node as coming from a synthetic (no source location) definition (not an extension)

Methods from Deref<Target = Node<T>>§

source

pub fn location(&self) -> Option<NodeLocation>

source

pub fn is_built_in(&self) -> bool

Whether this node is located in FileId::BUILT_IN, which defines built-in directives, built-in scalars, and introspection types.

source

pub fn same_location<U>(&self, node: U) -> Node<U>

Returns the given node at the same location as self (e.g. for a type conversion).

source

pub fn to_component(&self, origin: ComponentOrigin) -> Component<T>

source

pub fn ptr_eq(&self, other: &Self) -> bool

Returns whether two Nodes point to the same memory allocation

source

pub fn make_mut(&mut self) -> &mut T
where T: Clone,

Returns a mutable reference to T, cloning it if necessary

This is functionally equivalent to Arc::make_mut from the standard library.

If this Node is uniquely owned, make_mut() will provide a mutable reference to the contents. If not, make_mut() will create a new Node with a clone of the contents, update self to point to it, and provide a mutable reference to its contents.

This is useful for implementing copy-on-write schemes where you wish to avoid copying things if your Node is not shared.

source

pub fn get_mut(&mut self) -> Option<&mut T>

Returns a mutable reference to T if this Node is uniquely owned

Trait Implementations§

source§

impl<T> AsRef<T> for Component<T>

source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T: Clone> Clone for Component<T>

source§

fn clone(&self) -> Component<T>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: Debug> Debug for Component<T>

source§

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

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

impl<T> Deref for Component<T>

§

type Target = Node<T>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> DerefMut for Component<T>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<T> From<T> for Component<T>

source§

fn from(node: T) -> Self

Converts to this type from the input type.
source§

impl<T: Hash> Hash for Component<T>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T: PartialEq> PartialEq for Component<T>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Eq> Eq for Component<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Component<T>
where T: RefUnwindSafe,

§

impl<T> Send for Component<T>
where T: Send + Sync,

§

impl<T> Sync for Component<T>
where T: Send + Sync,

§

impl<T> Unpin for Component<T>
where T: Unpin,

§

impl<T> UnwindSafe for Component<T>

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromFd for T
where T: From<OwnedFd>,

§

fn from_fd(owned_fd: OwnedFd) -> T

👎Deprecated since 1.0.0: FromFd::from_fd is replaced by From<OwnedFd>::from
Constructs a new instance of Self from the given file descriptor. Read more
§

fn from_into_fd<Owned>(into_owned: Owned) -> Self
where Owned: Into<OwnedFd>, Self: Sized + From<OwnedFd>,

Constructs a new instance of Self from the given file descriptor converted from into_owned. Read more
§

impl<T> FromFilelike for T
where T: From<OwnedFd>,

§

fn from_filelike(owned: OwnedFd) -> T

Constructs a new instance of Self from the given filelike object. Read more
§

fn from_into_filelike<Owned>(owned: Owned) -> T
where Owned: IntoFilelike,

Constructs a new instance of Self from the given filelike object converted from into_owned. Read more
§

impl<T> FromSocketlike for T
where T: From<OwnedFd>,

§

fn from_socketlike(owned: OwnedFd) -> T

Constructs a new instance of Self from the given socketlike object.
§

fn from_into_socketlike<Owned>(owned: Owned) -> T
where Owned: IntoSocketlike,

Constructs a new instance of Self from the given socketlike object converted from into_owned.
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> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.