Add some additional code comments
This commit is contained in:
parent
73bf56810e
commit
ad6ee5b42d
9 changed files with 21 additions and 7 deletions
|
@ -52,6 +52,7 @@ impl Deref for Datetime {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Datetime {
|
impl Datetime {
|
||||||
|
/// Convert the Datetime to a raw String
|
||||||
pub fn to_raw(&self) -> String {
|
pub fn to_raw(&self) -> String {
|
||||||
self.0.to_rfc3339_opts(SecondsFormat::AutoSi, true)
|
self.0.to_rfc3339_opts(SecondsFormat::AutoSi, true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,38 +52,39 @@ impl Deref for Duration {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Duration {
|
impl Duration {
|
||||||
|
/// Convert the Duration to a raw String
|
||||||
pub fn to_raw(&self) -> String {
|
pub fn to_raw(&self) -> String {
|
||||||
self.to_string()
|
self.to_string()
|
||||||
}
|
}
|
||||||
|
/// Get the total number of seconds
|
||||||
pub fn secs(&self) -> Value {
|
pub fn secs(&self) -> Value {
|
||||||
self.0.as_secs().into()
|
self.0.as_secs().into()
|
||||||
}
|
}
|
||||||
|
/// Get the total number of minutes
|
||||||
pub fn mins(&self) -> Value {
|
pub fn mins(&self) -> Value {
|
||||||
let secs = self.0.as_secs();
|
let secs = self.0.as_secs();
|
||||||
let mins = secs / SECONDS_PER_MINUTE;
|
let mins = secs / SECONDS_PER_MINUTE;
|
||||||
mins.into()
|
mins.into()
|
||||||
}
|
}
|
||||||
|
/// Get the total number of hours
|
||||||
pub fn hours(&self) -> Value {
|
pub fn hours(&self) -> Value {
|
||||||
let secs = self.0.as_secs();
|
let secs = self.0.as_secs();
|
||||||
let hours = secs / SECONDS_PER_HOUR;
|
let hours = secs / SECONDS_PER_HOUR;
|
||||||
hours.into()
|
hours.into()
|
||||||
}
|
}
|
||||||
|
/// Get the total number of dats
|
||||||
pub fn days(&self) -> Value {
|
pub fn days(&self) -> Value {
|
||||||
let secs = self.0.as_secs();
|
let secs = self.0.as_secs();
|
||||||
let days = secs / SECONDS_PER_DAY;
|
let days = secs / SECONDS_PER_DAY;
|
||||||
days.into()
|
days.into()
|
||||||
}
|
}
|
||||||
|
/// Get the total number of months
|
||||||
pub fn weeks(&self) -> Value {
|
pub fn weeks(&self) -> Value {
|
||||||
let secs = self.0.as_secs();
|
let secs = self.0.as_secs();
|
||||||
let weeks = secs / SECONDS_PER_WEEK;
|
let weeks = secs / SECONDS_PER_WEEK;
|
||||||
weeks.into()
|
weeks.into()
|
||||||
}
|
}
|
||||||
|
/// Get the total number of years
|
||||||
pub fn years(&self) -> Value {
|
pub fn years(&self) -> Value {
|
||||||
let secs = self.0.as_secs();
|
let secs = self.0.as_secs();
|
||||||
let years = secs / SECONDS_PER_YEAR;
|
let years = secs / SECONDS_PER_YEAR;
|
||||||
|
|
|
@ -22,6 +22,7 @@ pub struct Graph {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Graph {
|
impl Graph {
|
||||||
|
/// Convert the graph edge to a raw String
|
||||||
pub fn to_raw(&self) -> String {
|
pub fn to_raw(&self) -> String {
|
||||||
self.to_string()
|
self.to_string()
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,9 +83,11 @@ impl From<Vec<Value>> for Id {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Id {
|
impl Id {
|
||||||
|
/// Generate a new random ID
|
||||||
pub fn rand() -> Self {
|
pub fn rand() -> Self {
|
||||||
Self::String(nanoid!(20, &ID_CHARS))
|
Self::String(nanoid!(20, &ID_CHARS))
|
||||||
}
|
}
|
||||||
|
/// Convert the Id to a raw String
|
||||||
pub fn to_raw(&self) -> String {
|
pub fn to_raw(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Self::Number(v) => v.to_string(),
|
Self::Number(v) => v.to_string(),
|
||||||
|
|
|
@ -44,6 +44,7 @@ impl Deref for Ident {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ident {
|
impl Ident {
|
||||||
|
/// Convert the Ident to a raw String
|
||||||
pub fn to_raw(&self) -> String {
|
pub fn to_raw(&self) -> String {
|
||||||
self.0.to_string()
|
self.0.to_string()
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ impl From<&str> for Part {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Part {
|
impl Part {
|
||||||
// Returns a yield if an alias is specified
|
/// Returns a yield if an alias is specified
|
||||||
pub(crate) fn alias(&self) -> Option<&Idiom> {
|
pub(crate) fn alias(&self) -> Option<&Idiom> {
|
||||||
match self {
|
match self {
|
||||||
Part::Graph(v) => v.alias.as_ref(),
|
Part::Graph(v) => v.alias.as_ref(),
|
||||||
|
|
|
@ -44,12 +44,15 @@ impl Deref for Strand {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Strand {
|
impl Strand {
|
||||||
|
/// Get the underlying String slice
|
||||||
pub fn as_str(&self) -> &str {
|
pub fn as_str(&self) -> &str {
|
||||||
self.0.as_str()
|
self.0.as_str()
|
||||||
}
|
}
|
||||||
|
/// Returns the underlying String
|
||||||
pub fn as_string(self) -> String {
|
pub fn as_string(self) -> String {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
/// Convert the Strand to a raw String
|
||||||
pub fn to_raw(self) -> String {
|
pub fn to_raw(self) -> String {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ impl From<(&str, &str)> for Thing {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Thing {
|
impl Thing {
|
||||||
|
/// Convert the Thing to a raw String
|
||||||
pub fn to_raw(&self) -> String {
|
pub fn to_raw(&self) -> String {
|
||||||
self.to_string()
|
self.to_string()
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,15 +36,19 @@ impl Deref for Uuid {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Uuid {
|
impl Uuid {
|
||||||
|
/// Generate a new V4 UUID
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self(uuid::Uuid::new_v4())
|
Self(uuid::Uuid::new_v4())
|
||||||
}
|
}
|
||||||
|
/// Generate a new V4 UUID
|
||||||
pub fn new_v4() -> Self {
|
pub fn new_v4() -> Self {
|
||||||
Self(uuid::Uuid::new_v4())
|
Self(uuid::Uuid::new_v4())
|
||||||
}
|
}
|
||||||
|
/// Generate a new V7 UUID
|
||||||
pub fn new_v7() -> Self {
|
pub fn new_v7() -> Self {
|
||||||
Self(uuid::Uuid::now_v7())
|
Self(uuid::Uuid::now_v7())
|
||||||
}
|
}
|
||||||
|
/// Convert the Uuid to a raw String
|
||||||
pub fn to_raw(&self) -> String {
|
pub fn to_raw(&self) -> String {
|
||||||
self.0.to_string()
|
self.0.to_string()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue