| 1 | use craterust-analyzer cargo schemars 1.2.2 crate/::SchemaGeneratorrust-analyzer cargo schemars 1.2.2 generate/SchemaGenerator#; |
| 2 | use craterust-analyzer cargo schemars 1.2.2 crate/::_alloc_preluderust-analyzer cargo schemars 1.2.2 _alloc_prelude/::*; |
| 3 | use craterust-analyzer cargo schemars 1.2.2 crate/::{json_schemarust-analyzer cargo schemars 1.2.2 macros/json_schema!, JsonSchemarust-analyzer cargo schemars 1.2.2 JsonSchema#, Schemarust-analyzer cargo schemars 1.2.2 schema/Schema#}; |
| 4 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#; |
| 5 | |
| 6 | macro_rules! simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl! { |
| 7 | ($type:ty => $instance_type:literal) => { |
| 8 | impl JsonSchema for $type { |
| 9 | inline_schema!(); |
| 10 | |
| 11 | fn schema_name() -> Cow<'static, str> { |
| 12 | $instance_type.into() |
| 13 | } |
| 14 | |
| 15 | fn json_schema(_: &mut SchemaGenerator) -> Schema { |
| 16 | json_schema!({ |
| 17 | "type": $instance_type |
| 18 | }) |
| 19 | } |
| 20 | } |
| 21 | }; |
| 22 | ($type:ty => $instance_type:literal, $format:literal) => { |
| 23 | impl JsonSchema for $type { |
| 24 | inline_schema!(); |
| 25 | |
| 26 | fn schema_name() -> Cow<'static, str> { |
| 27 | $format.into() |
| 28 | } |
| 29 | |
| 30 | fn json_schema(_: &mut SchemaGenerator) -> Schema { |
| 31 | json_schema!({ |
| 32 | "type": $instance_type, |
| 33 | "format": $format |
| 34 | }) |
| 35 | } |
| 36 | } |
| 37 | }; |
| 38 | } |
| 39 | |
| 40 | macro_rules! ranged_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/ranged_impl! { |
| 41 | ($type:ty => $instance_type:literal, $format:literal) => { |
| 42 | impl JsonSchema for $type { |
| 43 | inline_schema!(); |
| 44 | |
| 45 | fn schema_name() -> Cow<'static, str> { |
| 46 | $format.into() |
| 47 | } |
| 48 | |
| 49 | fn json_schema(_: &mut SchemaGenerator) -> Schema { |
| 50 | json_schema!({ |
| 51 | "type": $instance_type, |
| 52 | "format": $format, |
| 53 | "minimum": <$type>::MIN, |
| 54 | "maximum": <$type>::MAX |
| 55 | }) |
| 56 | } |
| 57 | } |
| 58 | }; |
| 59 | } |
| 60 | |
| 61 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(str => "string"); |
| 62 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# => "string"); |
| 63 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(bool => "boolean"); |
| 64 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(f32 => "number", "float"); |
| 65 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(f64 => "number", "double"); |
| 66 | ranged_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/ranged_impl!!(i8 => "integer", "int8"); |
| 67 | ranged_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/ranged_impl!!(i16 => "integer", "int16"); |
| 68 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(i32 => "integer", "int32"); |
| 69 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(i64 => "integer", "int64"); |
| 70 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(i128 => "integer", "int128"); |
| 71 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(isize => "integer", "int"); |
| 72 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(() => "null"); |
| 73 | |
| 74 | #[cfg(feature = "std")] |
| 75 | mod std_typesrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/std_types/ { |
| 76 | use superrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/::*; |
| 77 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::netrust-analyzer cargo std https://github.com/rust-lang/rust/library/std net/::{IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr#, Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr#, Ipv6Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv6Addr#, SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr#, SocketAddrV4rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddrV4#, SocketAddrV6rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddrV6#}; |
| 78 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::{Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#}; |
| 79 | |
| 80 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path# => "string"); |
| 81 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf# => "string"); |
| 82 | |
| 83 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(Ipv4Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv4Addr# => "string", "ipv4"); |
| 84 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(Ipv6Addrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/Ipv6Addr# => "string", "ipv6"); |
| 85 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(IpAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/ip_addr/IpAddr# => "string", "ip"); |
| 86 | |
| 87 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(SocketAddrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddr# => "string"); |
| 88 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(SocketAddrV4rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddrV4# => "string"); |
| 89 | simple_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/simple_impl!!(SocketAddrV6rust-analyzer cargo core https://github.com/rust-lang/rust/library/core net/socket_addr/SocketAddrV6# => "string"); |
| 90 | } |
| 91 | |
| 92 | macro_rules! unsigned_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/unsigned_impl! { |
| 93 | ($type:ty => $instance_type:literal, $format:literal) => { |
| 94 | impl JsonSchema for $type { |
| 95 | inline_schema!(); |
| 96 | |
| 97 | fn schema_name() -> Cow<'static, str> { |
| 98 | $format.into() |
| 99 | } |
| 100 | |
| 101 | fn json_schema(_: &mut SchemaGenerator) -> Schema { |
| 102 | json_schema!({ |
| 103 | "type": $instance_type, |
| 104 | "format": $format, |
| 105 | "minimum": 0 |
| 106 | }) |
| 107 | } |
| 108 | } |
| 109 | }; |
| 110 | } |
| 111 | |
| 112 | ranged_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/ranged_impl!!(u8 => "integer", "uint8"); |
| 113 | ranged_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/ranged_impl!!(u16 => "integer", "uint16"); |
| 114 | unsigned_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/unsigned_impl!!(u32 => "integer", "uint32"); |
| 115 | unsigned_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/unsigned_impl!!(u64 => "integer", "uint64"); |
| 116 | unsigned_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/unsigned_impl!!(u128 => "integer", "uint128"); |
| 117 | unsigned_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/unsigned_impl!!(usize => "integer", "uint"); |
| 118 | |
| 119 | impl JsonSchemarust-analyzer cargo schemars 1.2.2 JsonSchema# for char { |
| 120 | inline_schemarust-analyzer cargo schemars 1.2.2 json_schema_impls/inline_schema!!(); |
| 121 | |
| 122 | fn schema_namerust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/impl#[char][JsonSchema]schema_name().() -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str> { |
| 123 | "Character".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 124 | } |
| 125 | |
| 126 | fn schema_idrust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/impl#[char][JsonSchema]schema_id().() -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str> { |
| 127 | "char".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 128 | } |
| 129 | |
| 130 | fn json_schemarust-analyzer cargo schemars 1.2.2 json_schema_impls/primitives/impl#[char][JsonSchema]json_schema().(_: &mut SchemaGeneratorrust-analyzer cargo schemars 1.2.2 generate/SchemaGenerator#) -> Schemarust-analyzer cargo schemars 1.2.2 schema/Schema# { |
| 131 | json_schemarust-analyzer cargo schemars 1.2.2 macros/json_schema!!({ |
| 132 | "type": "string", |
| 133 | "minLength": 1, |
| 134 | "maxLength": 1, |
| 135 | }) |
| 136 | } |
| 137 | } |