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
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.
sourcepub fn get_label(&self) -> u8
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 From<Cardinality> for Shape
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
fn from(value: Cardinality) -> Self
source§impl From<ShapeComposite> for Shape
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
fn from(value: ShapeComposite) -> Self
source§impl From<ShapeLiteral> for Shape
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
fn from(value: ShapeLiteral) -> Self
source§impl From<ShapeReference> for Shape
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
fn from(value: ShapeReference) -> Self
source§impl From<TripleConstraint> for Shape
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.