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§
source§impl ScalarDefinition
impl ScalarDefinition
sourcepub fn description(&mut self, description: String)
pub fn description(&mut self, description: String)
Set the ScalarDef’s description.
Trait Implementations§
source§impl Clone for ScalarDefinition
impl Clone for ScalarDefinition
source§fn clone(&self) -> ScalarDefinition
fn clone(&self) -> ScalarDefinition
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ScalarDefinition
impl Debug for ScalarDefinition
source§impl Display for ScalarDefinition
impl Display for ScalarDefinition
source§impl PartialEq<ScalarDefinition> for ScalarDefinition
impl PartialEq<ScalarDefinition> for ScalarDefinition
source§fn eq(&self, other: &ScalarDefinition) -> bool
fn eq(&self, other: &ScalarDefinition) -> bool
source§impl TryFrom<ScalarTypeDefinition> for ScalarDefinition
impl TryFrom<ScalarTypeDefinition> for ScalarDefinition
source§fn 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.
source§impl TryFrom<ScalarTypeExtension> for ScalarDefinition
impl TryFrom<ScalarTypeExtension> for ScalarDefinition
source§fn 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.