From e07bd5a52ec26672d01102dac001abc5cc83f79d Mon Sep 17 00:00:00 2001 From: Miaxos Date: Mon, 20 Sep 2021 13:54:30 +0000 Subject: [PATCH] misc: add documentations for naive_time url and uuid --- src/types/external/naive_time.rs | 19 +++++++++++++++++++ src/types/external/url.rs | 1 + src/types/external/uuid.rs | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/src/types/external/naive_time.rs b/src/types/external/naive_time.rs index 406e9480..ee82b3a2 100644 --- a/src/types/external/naive_time.rs +++ b/src/types/external/naive_time.rs @@ -3,6 +3,13 @@ use chrono::{NaiveDate, NaiveDateTime, NaiveTime}; use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value}; #[Scalar(internal)] +/// ISO 8601 calendar date without timezone. +/// Format: %Y-%m-%d +/// +/// # Examples +/// +/// * `1994-11-13` +/// * `2000-02-24` impl ScalarType for NaiveDate { fn parse(value: Value) -> InputValueResult { match value { @@ -17,6 +24,13 @@ impl ScalarType for NaiveDate { } #[Scalar(internal)] +/// ISO 8601 time without timezone. +/// Allows for the nanosecond precision and optional leap second representation. +/// Format: %H:%M:%S%.f +/// +/// # Examples +/// +/// * `08:59:60.123` impl ScalarType for NaiveTime { fn parse(value: Value) -> InputValueResult { match value { @@ -31,6 +45,11 @@ impl ScalarType for NaiveTime { } #[Scalar(internal)] +/// ISO 8601 combined date and time without timezone. +/// +/// # Examples +/// +/// * `2015-07-01T08:59:60.123`, impl ScalarType for NaiveDateTime { fn parse(value: Value) -> InputValueResult { match value { diff --git a/src/types/external/url.rs b/src/types/external/url.rs index 6ae704e2..b9a8dda8 100644 --- a/src/types/external/url.rs +++ b/src/types/external/url.rs @@ -3,6 +3,7 @@ use url::Url; use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value}; #[Scalar(internal)] +/// URL is a String implementing the [URL Standard](http://url.spec.whatwg.org/) impl ScalarType for Url { fn parse(value: Value) -> InputValueResult { match value { diff --git a/src/types/external/uuid.rs b/src/types/external/uuid.rs index 8d73c90f..917d4cd2 100644 --- a/src/types/external/uuid.rs +++ b/src/types/external/uuid.rs @@ -3,6 +3,14 @@ use uuid::Uuid; use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value}; #[Scalar(internal, name = "UUID")] +/// A UUID is a unique 128-bit number, stored as 16 octets. UUIDs are parsed as Strings +/// within GraphQL. UUIDs are used to assign unique identifiers to entities without requiring a central +/// allocating authority. +/// +/// # References +/// +/// * [Wikipedia: Universally Unique Identifier](http://en.wikipedia.org/wiki/Universally_unique_identifier) +/// * [RFC4122: A Universally Unique IDentifier (UUID) URN Namespace](http://tools.ietf.org/html/rfc4122) impl ScalarType for Uuid { fn parse(value: Value) -> InputValueResult { match value {