pub use inventory;
pub use api_parity_rs_macros::{parity, parity_impl};
#[cfg(feature = "walker")]
pub mod walk;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Status {
Implemented,
Partial,
Unimplemented,
}
impl Status {
pub fn as_str(&self) -> &'static str {
match self {
Status::Implemented => "implemented",
Status::Partial => "partial",
Status::Unimplemented => "unimplemented",
}
}
}
#[derive(Debug)]
pub struct ParityEntry {
pub path: &'static str,
pub implementation: &'static str,
pub status: Status,
pub since: Option<&'static str>,
pub comment: Option<&'static str>,
pub issue: Option<u32>,
}
inventory::collect!(ParityEntry);
#[cfg(feature = "serde")]
mod dump {
use super::*;
use serde::Serialize;
use std::io::Write;
#[derive(Serialize)]
struct EntryDto<'a> {
path: &'a str,
implementation: &'a str,
status: &'a str,
since: Option<&'a str>,
issue: Option<u32>,
comment: Option<&'a str>,
}
#[derive(Serialize)]
struct Envelope<'a> {
schema_version: u32,
kind: &'a str,
language: &'a str,
version: &'a str,
source: &'a str,
entries: Vec<EntryDto<'a>>,
}
pub fn dump_to_writer<W: Write>(
source: &str,
version: &str,
mut out: W,
) -> Result<(), std::io::Error> {
let mut entries: Vec<&ParityEntry> = inventory::iter::<ParityEntry>.into_iter().collect();
entries.sort_by_key(|e| e.path);
let envelope = Envelope {
schema_version: 1,
kind: "port",
language: "rust",
version,
source,
entries: entries
.iter()
.map(|e| EntryDto {
path: e.path,
implementation: e.implementation,
status: e.status.as_str(),
since: e.since,
issue: e.issue,
comment: e.comment,
})
.collect(),
};
let s = serde_json::to_string_pretty(&envelope)
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
writeln!(out, "{s}")
}
}
#[cfg(feature = "serde")]
pub use dump::dump_to_writer;