From 1da6e245ccdd6252490212ebd6fb802571293b75 Mon Sep 17 00:00:00 2001 From: Cecylia Bocovich Date: Mon, 30 Jan 2023 17:05:38 -0500 Subject: [PATCH] Formatting and documentation fixes --- crates/rdsys-backend/src/lib.rs | 16 ++++++++-------- crates/rdsys-backend/src/proto.rs | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/rdsys-backend/src/lib.rs b/crates/rdsys-backend/src/lib.rs index 6ef21a6..b54a67c 100644 --- a/crates/rdsys-backend/src/lib.rs +++ b/crates/rdsys-backend/src/lib.rs @@ -8,7 +8,6 @@ use futures_util::StreamExt; use reqwest::Client; use std::io::{self, BufRead}; use std::sync::mpsc; -use tokio; pub mod proto; @@ -55,15 +54,15 @@ impl Iterator for ResourceStream { Some(b'\r') => match serde_json::from_slice(&self.buf) { Ok(diff) => { self.buf.clear(); - return Ok(Some(diff)); + Ok(Some(diff)) } - Err(e) => return Err(Error::JSON(e)), + Err(e) => Err(Error::JSON(e)), }, Some(n) => { self.buf.push(n); - return Ok(None); + Ok(None) } - None => return Ok(None), + None => Ok(None), }, Err(e) => Err(Error::Io(e)), } @@ -171,9 +170,10 @@ mod tests { /// if successful /// /// # Examples +/// +/// ```ignore /// use rdsys_backend::start_stream; /// -/// ``` /// let endpoint = String::from("http://127.0.0.1:7100/resource-stream"); /// let name = String::from("https"); /// let token = String::from("HttpsApiTokenPlaceholder"); @@ -194,7 +194,7 @@ pub async fn start_stream( let req = proto::ResourceRequest { request_origin: name, - resource_types: resource_types, + resource_types, }; let json = serde_json::to_string(&req)?; @@ -222,7 +222,7 @@ pub async fn start_stream( } }); Ok(ResourceStream { - rx: rx, + rx, buf: vec![], partial: None, }) diff --git a/crates/rdsys-backend/src/proto.rs b/crates/rdsys-backend/src/proto.rs index bb96fb6..f81af42 100644 --- a/crates/rdsys-backend/src/proto.rs +++ b/crates/rdsys-backend/src/proto.rs @@ -10,11 +10,11 @@ pub struct ResourceRequest { } /// Representation of a bridge resource -#[derive(Deserialize, PartialEq, Debug)] +#[derive(Deserialize, PartialEq, Eq, Debug)] pub struct Resource { pub r#type: String, pub blocked_in: HashMap, - pub protocol: String, + pub protocol: String, pub address: String, pub port: u16, pub fingerprint: String, @@ -26,7 +26,7 @@ pub struct Resource { } /// A ResourceDiff holds information about new, changed, or pruned resources -#[derive(Deserialize, PartialEq, Debug)] +#[derive(Deserialize, PartialEq, Eq, Debug)] pub struct ResourceDiff { pub new: Option>>, pub changed: Option>>,