cynic_parser/schema_coordinates/
directive_argument.rs1use core::fmt;
2
3use crate::Span;
4
5use super::{DirectiveCoordinate, Name};
6
7#[derive(Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd)]
8pub struct DirectiveArgumentCoordinate {
9 pub(super) directive: DirectiveCoordinate,
10 pub(super) name: Name,
11}
12
13impl DirectiveArgumentCoordinate {
14 pub(crate) fn new(name: impl Into<String>, argument: impl Into<String>) -> Self {
15 Self {
16 directive: DirectiveCoordinate::new(name),
17 name: Name::new(argument.into()),
18 }
19 }
20
21 pub fn directive(&self) -> &DirectiveCoordinate {
22 &self.directive
23 }
24
25 pub fn span(&self) -> Span {
26 self.name.span
27 }
28
29 pub fn name(&self) -> &str {
30 &self.name.value
31 }
32}
33
34impl fmt::Display for DirectiveArgumentCoordinate {
35 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
36 write!(f, "{}({}:)", self.directive, self.name.value)
37 }
38}