summaryrefslogtreecommitdiff
path: root/rust/proto/src
diff options
context:
space:
mode:
Diffstat (limited to 'rust/proto/src')
-rw-r--r--rust/proto/src/lib.rs49
1 files changed, 4 insertions, 45 deletions
diff --git a/rust/proto/src/lib.rs b/rust/proto/src/lib.rs
index 1a16c15..1a8199b 100644
--- a/rust/proto/src/lib.rs
+++ b/rust/proto/src/lib.rs
@@ -1,55 +1,12 @@
-use chrono::{DateTime, TimeZone, Utc};
+use chrono::{DateTime, Utc};
use std::ops::{Deref, DerefMut};
include!("gen/mod.rs");
-impl From<&str> for touchpad::common::v1::Gender {
- fn from(s: &str) -> Self {
- match s {
- "Male" => Self::Male,
- "Female" => Self::Female,
- _ => Self::Unspecified,
- }
- }
-}
-
-impl From<&str> for touchpad::common::v1::Stroke {
- fn from(s: &str) -> Self {
- match s {
- "Fly" => Self::Fly,
- "Back" => Self::Back,
- "Breast" => Self::Breast,
- "Free" => Self::Free,
- "Medley" => Self::Medley,
- _ => Self::Unspecified,
- }
- }
-}
-
-impl From<&str> for touchpad::common::v1::EventTimeResult {
- fn from(s: &str) -> Self {
- match s {
- "DQ" => Self::Dq,
- "DNS" => Self::Dns,
- "SCR" => Self::Scr,
- _ => Self::Unspecified,
- }
- }
-}
+//region ProtoTimestamp
pub struct ProtoTimestamp(pbjson_types::Timestamp);
-impl ProtoTimestamp {
- const TOUCHPAD_DATE_FORMAT: &'static str = "%Y-%m-%d";
-
- pub fn from_touchpad(str: &str) -> Result<Self, chrono::format::ParseError> {
- let date = chrono::NaiveDate::parse_from_str(str, ProtoTimestamp::TOUCHPAD_DATE_FORMAT)?;
- let datetime = chrono::NaiveDateTime::new(date, chrono::NaiveTime::from_hms(0, 0, 0));
-
- Ok(Utc.from_utc_datetime(&datetime).into())
- }
-}
-
impl Into<pbjson_types::Timestamp> for ProtoTimestamp {
fn into(self) -> pbjson_types::Timestamp {
self.0
@@ -75,3 +32,5 @@ impl DerefMut for ProtoTimestamp {
&mut self.0
}
}
+
+//endregion
'13' height='13' alt='Gravatar' /> Anshul Gupta 1-1/+1 2024-03-13style(clippy): fixes `module_inception` lintGravatar Anshul Gupta 2-2/+2 2024-03-02feat: switches from `smol_str` to `compact_str`Gravatar Anshul Gupta 5-22/+22 2024-02-28fix: fixes new `non_local_definitions` lintGravatar Anshul Gupta 3-9/+13 2024-02-20ci: caches clippyGravatar Anshul Gupta 1-0/+3 2024-02-20fix: incorrect display message in errorGravatar Anshul Gupta 1-1/+1 2024-02-20feat(api): adds scrobble endpointsGravatar Anshul Gupta 2-0/+363 2024-02-20refactor: replaces requests with `construct_req`Gravatar Anshul Gupta 4-121/+14 2024-02-20refactor(request): changes to use `construct_req`Gravatar Anshul Gupta 1-24/+5 2024-02-20feat: adds `construct_req` functionGravatar Anshul Gupta 1-1/+114 2024-02-20feat(api): adds search endpointsGravatar Anshul Gupta 5-14/+290 2024-02-20docs: adds codecov to docs/readmeGravatar Anshul Gupta 2-0/+2 2024-02-20docs: updates README.mdGravatar Anshul Gupta 1-2/+2