Implement JsonSchema for CStr/CString
This commit is contained in:
		
							parent
							
								
									437b38dd8b
								
							
						
					
					
						commit
						be59422c13
					
				
					 3 changed files with 26 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
use crate::gen::SchemaGenerator;
 | 
			
		||||
use crate::schema::*;
 | 
			
		||||
use crate::JsonSchema;
 | 
			
		||||
use std::ffi::{OsStr, OsString};
 | 
			
		||||
use std::ffi::{CStr, CString, OsStr, OsString};
 | 
			
		||||
 | 
			
		||||
impl JsonSchema for OsString {
 | 
			
		||||
    fn schema_name() -> String {
 | 
			
		||||
| 
						 | 
				
			
			@ -40,3 +40,27 @@ impl JsonSchema for OsStr {
 | 
			
		|||
        <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)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -10,8 +10,8 @@ mod array;
 | 
			
		|||
#[cfg(feature = "chrono")]
 | 
			
		||||
mod chrono;
 | 
			
		||||
mod core;
 | 
			
		||||
mod ffi;
 | 
			
		||||
mod maps;
 | 
			
		||||
mod os;
 | 
			
		||||
mod primitives;
 | 
			
		||||
mod sequences;
 | 
			
		||||
mod serdejson;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue