Formatting and documentation fixes
This commit is contained in:
parent
46d51315b6
commit
1da6e245cc
|
@ -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,
|
||||
})
|
||||
|
|
|
@ -10,7 +10,7 @@ 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>,
|
||||
|
@ -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>>>,
|
||||
|
|
Loading…
Reference in New Issue