Debian Codegraph @

src/json_schema_impls/decimal.rs

raw symbols SCIP
1 use craterust-analyzer cargo schemars 1.2.2 crate/::_alloc_preluderust-analyzer cargo schemars 1.2.2 _alloc_prelude/::*;
2 use craterust-analyzer cargo schemars 1.2.2 crate/::generaterust-analyzer cargo schemars 1.2.2 generate/::Contractrust-analyzer cargo schemars 1.2.2 generate/Contract#;
3 use craterust-analyzer cargo schemars 1.2.2 crate/::{JsonSchemarust-analyzer cargo schemars 1.2.2 JsonSchema#, Schemarust-analyzer cargo schemars 1.2.2 schema/Schema#, SchemaGeneratorrust-analyzer cargo schemars 1.2.2 generate/SchemaGenerator#};
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 use serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::Valuerust-analyzer cargo serde_json 1.0.151 value/Value#;
6
7 macro_rules! decimal_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/decimal/decimal_impl! {
8 ($type:ty) => {
9 impl JsonSchema for $type {
10 inline_schema!();
11
12 fn schema_name() -> Cow<'static, str> {
13 "Decimal".into()
14 }
15
16 fn json_schema(generator: &mut SchemaGenerator) -> Schema {
17 let (ty, pattern) = match generator.contract() {
18 Contract::Deserialize => (
19 Value::Array(vec!["string".into(), "number".into()]),
20 r"^-?\d+(\.\d+)?([eE]\d+)?$".into(),
21 ),
22 Contract::Serialize => ("string".into(), r"^-?\d+(\.\d+)?$".into()),
23 };
24
25 let mut result = Schema::default();
26 result.insert("type".to_owned(), ty);
27 result.insert("pattern".to_owned(), pattern);
28 result
29 }
30 }
31 };
32 }
33
34 #[cfg(feature = "rust_decimal1")]
35 decimal_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/decimal/decimal_impl!!(rust_decimal1rust-analyzer cargo rust_decimal 1.42.1 crate/::Decimalrust-analyzer cargo rust_decimal 1.42.1 decimal/Decimal#);
36 #[cfg(feature = "bigdecimal04")]
37 decimal_implrust-analyzer cargo schemars 1.2.2 json_schema_impls/decimal/decimal_impl!!(bigdecimal04rust-analyzer cargo bigdecimal 0.4.10 crate/::BigDecimalrust-analyzer cargo bigdecimal 0.4.10 BigDecimal#);