Struct apollo_encoder::ScalarDefinition
source · [−]pub struct ScalarDefinition { /* private fields */ }
Expand description
Represents scalar types such as Int, String, and Boolean. Scalars cannot have fields.
ScalarTypeDefinition: Description? scalar Name Directives?
Detailed documentation can be found in GraphQL spec.
Example
use apollo_encoder::ScalarDefinition;
let mut scalar = ScalarDefinition::new("NumberOfTreatsPerDay".to_string());
scalar.description(
"Int representing number of treats received.".to_string(),
);
assert_eq!(
scalar.to_string(),
r#""Int representing number of treats received."
scalar NumberOfTreatsPerDay
"#
);
Implementations
sourceimpl ScalarDefinition
impl ScalarDefinition
sourcepub fn description(&mut self, description: String)
pub fn description(&mut self, description: String)
Set the ScalarDef’s description.
Trait Implementations
sourceimpl Clone for ScalarDefinition
impl Clone for ScalarDefinition
sourcefn clone(&self) -> ScalarDefinition
fn clone(&self) -> ScalarDefinition
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for ScalarDefinition
impl Debug for ScalarDefinition
sourceimpl Display for ScalarDefinition
impl Display for ScalarDefinition
sourceimpl PartialEq<ScalarDefinition> for ScalarDefinition
impl PartialEq<ScalarDefinition> for ScalarDefinition
sourcefn eq(&self, other: &ScalarDefinition) -> bool
fn eq(&self, other: &ScalarDefinition) -> bool
sourceimpl TryFrom<ScalarTypeDefinition> for ScalarDefinition
impl TryFrom<ScalarTypeDefinition> for ScalarDefinition
sourcefn try_from(node: ScalarTypeDefinition) -> Result<Self, Self::Error>
fn try_from(node: ScalarTypeDefinition) -> Result<Self, Self::Error>
Create an apollo-encoder node from an apollo-parser one.
Errors
This returns an error if the apollo-parser tree is not valid. The error doesn’t have much context due to TryFrom API constraints: validate the parse tree before using TryFrom if granular errors are important to you.
type Error = FromError
type Error = FromError
sourceimpl TryFrom<ScalarTypeExtension> for ScalarDefinition
impl TryFrom<ScalarTypeExtension> for ScalarDefinition
sourcefn try_from(node: ScalarTypeExtension) -> Result<Self, Self::Error>
fn try_from(node: ScalarTypeExtension) -> Result<Self, Self::Error>
Create an apollo-encoder node from an apollo-parser one.
Errors
This returns an error if the apollo-parser tree is not valid. The error doesn’t have much context due to TryFrom API constraints: validate the parse tree before using TryFrom if granular errors are important to you.