Struct apollo_encoder::EnumDefinition
source · [−]pub struct EnumDefinition { /* private fields */ }
Expand description
Enums are special scalars that can only have a defined set of values.
EnumTypeDefinition: Description? enum Name Directives? EnumValuesDefinition?
Detailed documentation can be found in GraphQL spec.
Example
use apollo_encoder::{Argument, Directive, EnumValue, EnumDefinition, Value};
let mut enum_ty_1 = EnumValue::new("CAT_TREE".to_string());
enum_ty_1.description(Some("Top bunk of a cat tree.".to_string()));
let enum_ty_2 = EnumValue::new("BED".to_string());
let mut deprecated_directive = Directive::new(String::from("deprecated"));
deprecated_directive.arg(Argument::new(String::from("reason"), Value::String(String::from("Box was recycled."))));
let mut enum_ty_3 = EnumValue::new("CARDBOARD_BOX".to_string());
enum_ty_3.directive(deprecated_directive);
let mut enum_ = EnumDefinition::new("NapSpots".to_string());
enum_.description(Some("Favourite cat nap spots.".to_string()));
enum_.value(enum_ty_1);
enum_.value(enum_ty_2);
enum_.value(enum_ty_3);
assert_eq!(
enum_.to_string(),
r#""Favourite cat nap spots."
enum NapSpots {
"Top bunk of a cat tree."
CAT_TREE
BED
CARDBOARD_BOX @deprecated(reason: "Box was recycled.")
}
"#
);
Implementations
sourceimpl EnumDefinition
impl EnumDefinition
sourcepub fn description(&mut self, description: Option<String>)
pub fn description(&mut self, description: Option<String>)
Set the Enum Definition’s description.
Trait Implementations
sourceimpl Clone for EnumDefinition
impl Clone for EnumDefinition
sourcefn clone(&self) -> EnumDefinition
fn clone(&self) -> EnumDefinition
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for EnumDefinition
impl Debug for EnumDefinition
sourceimpl Display for EnumDefinition
impl Display for EnumDefinition
sourceimpl PartialEq<EnumDefinition> for EnumDefinition
impl PartialEq<EnumDefinition> for EnumDefinition
sourcefn eq(&self, other: &EnumDefinition) -> bool
fn eq(&self, other: &EnumDefinition) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &EnumDefinition) -> bool
fn ne(&self, other: &EnumDefinition) -> bool
This method tests for !=
.
impl StructuralPartialEq for EnumDefinition
Auto Trait Implementations
impl RefUnwindSafe for EnumDefinition
impl Send for EnumDefinition
impl Sync for EnumDefinition
impl Unpin for EnumDefinition
impl UnwindSafe for EnumDefinition
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
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.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more