use serde::Serialize;
use crate::output::Render;
#[derive(Debug, Serialize)]
pub struct HostEntry {
pub host: String,
}
#[derive(Debug, Serialize)]
#[serde(transparent)]
pub struct HostRows(pub Vec<HostEntry>);
impl Render for HostRows {
fn headers() -> &'static [&'static str] {
&["HOST"]
}
fn rows(&self) -> Vec<Vec<String>> {
self.0
.iter()
.map(|entry| vec![entry.host.clone()])
.collect()
}
const PRIORITIES: &'static [u8] = &[0];
}
#[cfg(test)]
mod tests {
use super::super::tests::assert_no_drift;
use super::*;
#[test]
fn host_rows_match_their_json_keys() {
let rows = HostRows(vec![
HostEntry {
host: "amp2".to_string(),
},
HostEntry {
host: "deploy@build".to_string(),
},
]);
assert_no_drift(&rows, |json| &json[0], &[]);
}
}