pub struct EnumDefinition {
pub name: String,
pub values: Vec<EnumValueDefinition>,
pub description: Option<String>,
}Expand description
A GraphQL enum type definition.
Enums represent a finite set of possible values, useful for categorization fields like status, role, or priority.
§Example
use fraiseql_core::schema::{EnumDefinition, EnumValueDefinition};
let status_enum = EnumDefinition {
name: "OrderStatus".to_string(),
values: vec![
EnumValueDefinition::new("PENDING"),
EnumValueDefinition::new("PROCESSING"),
EnumValueDefinition::new("SHIPPED"),
EnumValueDefinition::new("DELIVERED"),
],
description: Some("Possible states of an order".to_string()),
};Fields§
§name: StringEnum type name (e.g., “OrderStatus”).
values: Vec<EnumValueDefinition>Possible values for this enum.
description: Option<String>Description of the enum type.
Implementations§
Source§impl EnumDefinition
impl EnumDefinition
Sourcepub fn with_value(self, value: EnumValueDefinition) -> Self
pub fn with_value(self, value: EnumValueDefinition) -> Self
Add a value to this enum.
Sourcepub fn with_values(self, values: Vec<EnumValueDefinition>) -> Self
pub fn with_values(self, values: Vec<EnumValueDefinition>) -> Self
Add multiple values to this enum.
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set description.
Sourcepub fn find_value(&self, name: &str) -> Option<&EnumValueDefinition>
pub fn find_value(&self, name: &str) -> Option<&EnumValueDefinition>
Find a value by name.
Trait Implementations§
Source§impl Clone for EnumDefinition
impl Clone for EnumDefinition
Source§fn clone(&self) -> EnumDefinition
fn clone(&self) -> EnumDefinition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EnumDefinition
impl Debug for EnumDefinition
Source§impl<'de> Deserialize<'de> for EnumDefinition
impl<'de> Deserialize<'de> for EnumDefinition
Source§fn 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
Source§impl PartialEq for EnumDefinition
impl PartialEq for EnumDefinition
Source§impl Serialize for EnumDefinition
impl Serialize for EnumDefinition
impl StructuralPartialEq for EnumDefinition
Auto Trait Implementations§
impl Freeze for EnumDefinition
impl RefUnwindSafe for EnumDefinition
impl Send for EnumDefinition
impl Sync for EnumDefinition
impl Unpin for EnumDefinition
impl UnsafeUnpin for EnumDefinition
impl UnwindSafe for EnumDefinition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more