Implement JsonSchema for CStr/CString

This commit is contained in:
Graham Esau 2019-10-27 19:41:25 +00:00
parent 437b38dd8b
commit be59422c13
3 changed files with 26 additions and 2 deletions

View file

@ -1,7 +1,7 @@
use crate::gen::SchemaGenerator; use crate::gen::SchemaGenerator;
use crate::schema::*; use crate::schema::*;
use crate::JsonSchema; use crate::JsonSchema;
use std::ffi::{OsStr, OsString}; use std::ffi::{CStr, CString, OsStr, OsString};
impl JsonSchema for OsString { impl JsonSchema for OsString {
fn schema_name() -> String { fn schema_name() -> String {
@ -40,3 +40,27 @@ impl JsonSchema for OsStr {
<OsString>::json_schema(gen) <OsString>::json_schema(gen)
} }
} }
impl JsonSchema for CString {
no_ref_schema!();
fn schema_name() -> String {
<Vec<u8>>::schema_name()
}
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
<Vec<u8>>::json_schema(gen)
}
}
impl JsonSchema for CStr {
no_ref_schema!();
fn schema_name() -> String {
<Vec<u8>>::schema_name()
}
fn json_schema(gen: &mut SchemaGenerator) -> Schema {
<Vec<u8>>::json_schema(gen)
}
}

View file

@ -10,8 +10,8 @@ mod array;
#[cfg(feature = "chrono")] #[cfg(feature = "chrono")]
mod chrono; mod chrono;
mod core; mod core;
mod ffi;
mod maps; mod maps;
mod os;
mod primitives; mod primitives;
mod sequences; mod sequences;
mod serdejson; mod serdejson;