Enum pschema_rs::shape::shex::Shape

source ·
pub enum Shape {
    TripleConstraint(TripleConstraint),
    ShapeReference(Box<ShapeReference>),
    ShapeComposite(ShapeComposite),
    ShapeLiteral(ShapeLiteral),
    Cardinality(Box<Cardinality>),
}
Expand description

The above code is defining an enum called Shape in Rust. It has five variants: TripleConstraint, ShapeReference, ShapeComposite, ShapeLiteral, and Cardinality. Each variant can hold different types of data. TripleConstraint holds a TripleConstraint struct, ShapeReference holds a reference to another Shape object, ShapeComposite holds a ShapeComposite struct, ShapeLiteral holds a ShapeLiteral struct, and Cardinality holds a reference to a Cardinality object. The `#derive

Variants§

§

TripleConstraint(TripleConstraint)

§

ShapeReference(Box<ShapeReference>)

§

ShapeComposite(ShapeComposite)

§

ShapeLiteral(ShapeLiteral)

§

Cardinality(Box<Cardinality>)

Implementations§

source§

impl Shape

The above code is implementing a method get_label for the Shape struct. This method returns the label of the shape, which is determined by matching the type of the shape and returning the label of the corresponding shape variant. If the shape is of type Cardinality, the label of the underlying shape is returned.

source

pub fn get_label(&self) -> u8

This function returns the label of a given shape.

Returns:

The function get_label returns an unsigned 8-bit integer, which represents the label of a shape. The label is obtained by matching the shape with one of the five possible variants of the Shape enum, and then returning the label of the corresponding shape. If the shape is a Cardinality shape, the function recursively calls get_label on the inner shape to obtain its

Trait Implementations§

source§

impl Clone for Shape

source§

fn clone(&self) -> Shape

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 Debug for Shape

source§

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

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

impl From<Cardinality> for Shape

This implementation allows a Cardinality struct to be converted into a Shape enum variant using the From trait. It creates a new Shape::Cardinality variant with the Cardinality struct wrapped in a Box. This allows for more flexibility in working with Shape objects, as a Cardinality can be treated as a Shape in certain contexts.

source§

fn from(value: Cardinality) -> Self

Converts to this type from the input type.
source§

impl From<ShapeComposite> for Shape

This is an implementation of the From trait for the ShapeComposite struct. The From trait is a Rust language feature that allows for automatic conversion between types. In this case, it allows a ShapeComposite object to be converted into a Shape enum variant.

source§

fn from(value: ShapeComposite) -> Self

Converts to this type from the input type.
source§

impl From<ShapeLiteral> for Shape

This is an implementation of the From trait for the ShapeLiteral struct, which allows a ShapeLiteral object to be converted into a Shape enum variant. The From trait is a Rust language feature that allows for automatic conversion between types.

source§

fn from(value: ShapeLiteral) -> Self

Converts to this type from the input type.
source§

impl From<ShapeReference> for Shape

The above code is implementing the From trait for the ShapeReference struct, which allows creating a Shape enum variant ShapeReference from a ShapeReference struct. The ShapeReference struct is wrapped in a Box and then converted to the Shape enum variant ShapeReference.

source§

fn from(value: ShapeReference) -> Self

Converts to this type from the input type.
source§

impl From<TripleConstraint> for Shape

The above code is implementing a conversion from a TripleConstraint struct to a Shape enum using the From trait. It creates a new Shape enum variant called TripleConstraint and assigns the value of the TripleConstraint struct to it. This allows for easier conversion between the two types in Rust code.

source§

fn from(value: TripleConstraint) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Shape> for Shape

source§

fn eq(&self, other: &Shape) -> 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 StructuralPartialEq for Shape

Auto Trait Implementations§

§

impl RefUnwindSafe for Shape

§

impl Send for Shape

§

impl Sync for Shape

§

impl Unpin for Shape

§

impl UnwindSafe for Shape

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Allocation for Twhere T: RefUnwindSafe + Send + Sync,