diff --git a/src/data/mod.rs b/src/data/mod.rs index c62797e..0b2734d 100644 --- a/src/data/mod.rs +++ b/src/data/mod.rs @@ -4,12 +4,12 @@ pub mod id; mod record; pub mod table; +use super::Message; use std::{ collections::BTreeMap, - sync::mpsc::{Receiver, Sender, channel}, + sync::mpsc::{channel, Receiver, Sender}, thread::spawn, }; -use super::Message; use uuid::Uuid; #[derive(PartialEq, Eq, Hash, PartialOrd, Ord, Clone, Debug)] diff --git a/src/lib.rs b/src/lib.rs index 0c8c0e1..a6e2fa7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,47 @@ use std::sync::mpsc::{channel, Sender}; struct Request; +enum Field { + Static(String), +} + +impl From for Field { + fn from(value: String) -> Self { + Field::Static(value) + } +} + +impl From<&str> for Field { + fn from(value: &str) -> Self { + Field::Static(value.to_string()) + } +} + +#[cfg(test)] +mod fields { + use super::*; + + #[test] + fn string_to_field() { + let entries = ["test1".to_string(), "test2".to_string()]; + for data in entries { + match data.clone().into() { + Field::Static(result) => assert_eq!(result, data), + } + } + } + + #[test] + fn str_to_field() { + let entries = ["test1", "test2"]; + for data in entries { + match data.into() { + Field::Static(result) => assert_eq!(result, data), + } + } + } +} + struct Record; struct Response { @@ -32,7 +73,10 @@ impl Response { 0 } - fn add_header(&mut self, name: S) where S: Into { + fn add_header(&mut self, name: S) + where + S: Into, + { self.headers.push(name.into()); } }