From 5cd801a6d0183cf185ad999e388b8ea68b592970 Mon Sep 17 00:00:00 2001 From: Xander Bil Date: Wed, 13 Mar 2024 16:16:26 +0100 Subject: [PATCH] format --- src/api.rs | 10 +++++++--- src/db/lib.rs | 1 - src/db/mod.rs | 2 +- src/parser.rs | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/api.rs b/src/api.rs index 8206653..6120ba7 100644 --- a/src/api.rs +++ b/src/api.rs @@ -36,7 +36,7 @@ async fn create_record(req: Request) -> Result { let rdata = record ._type - .to_bytes(&record.data) + .to_data(&record.data) .map_err(|e| e.to_string())?; match insert_into_database(RR { name: record.name, @@ -67,9 +67,13 @@ async fn create_record(req: Request) -> Result) -> Result> { if let Some(q) = req.uri().query() { - let params = form_urlencoded::parse(q.as_bytes()).into_owned().collect::>(); + let params = form_urlencoded::parse(q.as_bytes()) + .into_owned() + .collect::>(); if let Some(domain) = params.get("domain_name") { - return Ok(Response::builder().status(StatusCode::OK).body(full(domain.to_owned()))?) + return Ok(Response::builder() + .status(StatusCode::OK) + .body(full(domain.to_owned()))?); } } diff --git a/src/db/lib.rs b/src/db/lib.rs index 9f2d667..41fe994 100644 --- a/src/db/lib.rs +++ b/src/db/lib.rs @@ -3,7 +3,6 @@ use diesel::sqlite::SqliteConnection; use dotenvy::dotenv; use std::env; - pub fn establish_connection() -> SqliteConnection { dotenv().ok(); diff --git a/src/db/mod.rs b/src/db/mod.rs index 5253185..9ea4d54 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -1,2 +1,2 @@ -pub mod models; pub mod lib; +pub mod models; diff --git a/src/parser.rs b/src/parser.rs index e23b030..f5dc4fa 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -39,7 +39,7 @@ pub trait FromBytes { } impl Type { - pub fn to_bytes(&self, text: &String) -> Result> { + pub fn to_data(&self, text: &String) -> Result> { match self { Type::A => { let arr: Vec = text @@ -57,7 +57,7 @@ impl Type { } } } - pub fn from_bytes(&self, bytes: &[u8]) -> Result { + pub fn from_data(&self, bytes: &[u8]) -> Result { match self { Type::A => { if bytes.len() == 4 {