Formatting and documentation fixes

This commit is contained in:
Cecylia Bocovich 2023-01-30 17:05:38 -05:00
parent 46d51315b6
commit 1da6e245cc
2 changed files with 11 additions and 11 deletions

View File

@ -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,
})

View File

@ -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<String, bool>,
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<HashMap<String, Vec<Resource>>>,
pub changed: Option<HashMap<String, Vec<Resource>>>,