| 1 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::errorrust-analyzer cargo jsonschema 0.37.4 error/::ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#; |
| 2 | use ahashrust-analyzer cargo ahash 0.8.12 crate/::AHashMaprust-analyzer cargo ahash 0.8.12 hash_map/AHashMap#; |
| 3 | use data_encodingrust-analyzer cargo data-encoding 2.9.0 crate/::{BASE32rust-analyzer cargo data-encoding 2.9.0 BASE32., BASE32HEXrust-analyzer cargo data-encoding 2.9.0 BASE32HEX., BASE64rust-analyzer cargo data-encoding 2.9.0 BASE64., BASE64URLrust-analyzer cargo data-encoding 2.9.0 BASE64URL., HEXUPPERrust-analyzer cargo data-encoding 2.9.0 HEXUPPER.}; |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::LazyLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/lazy_lock/LazyLock#; |
| 5 | |
| 6 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) type ContentEncodingCheckTyperust-analyzer cargo jsonschema 0.37.4 content_encoding/ContentEncodingCheckType# = fn(&str) -> bool; |
| 7 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) type ContentEncodingConverterTyperust-analyzer cargo jsonschema 0.37.4 content_encoding/ContentEncodingConverterType# = |
| 8 | fn(&str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'static>>; |
| 9 | |
| 10 | // RFC 4648 §4: Base 64 Encoding |
| 11 | // https://datatracker.ietf.org/doc/html/rfc4648#section-4 |
| 12 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn is_base64rust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base64().(instance_string: &str) -> bool { |
| 13 | BASE64rust-analyzer cargo data-encoding 2.9.0 BASE64..decoderust-analyzer cargo data-encoding 2.9.0 impl#[Encoding]decode().(instance_string.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 14 | } |
| 15 | |
| 16 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn from_base64rust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base64().( |
| 17 | instance_string: &str, |
| 18 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'static>> { |
| 19 | match BASE64rust-analyzer cargo data-encoding 2.9.0 BASE64..decoderust-analyzer cargo data-encoding 2.9.0 impl#[Encoding]decode().(instance_string.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()) { |
| 20 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)), |
| 21 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | // RFC 4648 §5: Base 64 Encoding with URL and Filename Safe Alphabet |
| 26 | // https://datatracker.ietf.org/doc/html/rfc4648#section-5 |
| 27 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn is_base64urlrust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base64url().(instance_string: &str) -> bool { |
| 28 | BASE64URLrust-analyzer cargo data-encoding 2.9.0 BASE64URL..decoderust-analyzer cargo data-encoding 2.9.0 impl#[Encoding]decode().(instance_string.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 29 | } |
| 30 | |
| 31 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn from_base64urlrust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base64url().( |
| 32 | instance_string: &str, |
| 33 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'static>> { |
| 34 | match BASE64URLrust-analyzer cargo data-encoding 2.9.0 BASE64URL..decoderust-analyzer cargo data-encoding 2.9.0 impl#[Encoding]decode().(instance_string.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()) { |
| 35 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)), |
| 36 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // RFC 4648 §6: Base 32 Encoding |
| 41 | // https://datatracker.ietf.org/doc/html/rfc4648#section-6 |
| 42 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn is_base32rust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base32().(instance_string: &str) -> bool { |
| 43 | BASE32rust-analyzer cargo data-encoding 2.9.0 BASE32..decoderust-analyzer cargo data-encoding 2.9.0 impl#[Encoding]decode().(instance_string.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 44 | } |
| 45 | |
| 46 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn from_base32rust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base32().( |
| 47 | instance_string: &str, |
| 48 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'static>> { |
| 49 | match BASE32rust-analyzer cargo data-encoding 2.9.0 BASE32..decoderust-analyzer cargo data-encoding 2.9.0 impl#[Encoding]decode().(instance_string.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()) { |
| 50 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)), |
| 51 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | // RFC 4648 §7: Base 32 Encoding with Extended Hex Alphabet |
| 56 | // https://datatracker.ietf.org/doc/html/rfc4648#section-7 |
| 57 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn is_base32hexrust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base32hex().(instance_string: &str) -> bool { |
| 58 | BASE32HEXrust-analyzer cargo data-encoding 2.9.0 BASE32HEX..decoderust-analyzer cargo data-encoding 2.9.0 impl#[Encoding]decode().(instance_string.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 59 | } |
| 60 | |
| 61 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn from_base32hexrust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base32hex().( |
| 62 | instance_string: &str, |
| 63 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'static>> { |
| 64 | match BASE32HEXrust-analyzer cargo data-encoding 2.9.0 BASE32HEX..decoderust-analyzer cargo data-encoding 2.9.0 impl#[Encoding]decode().(instance_string.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()) { |
| 65 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)), |
| 66 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | // RFC 4648 §8: Base 16 Encoding |
| 71 | // https://datatracker.ietf.org/doc/html/rfc4648#section-8 |
| 72 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn is_base16rust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base16().(instance_string: &str) -> bool { |
| 73 | HEXUPPERrust-analyzer cargo data-encoding 2.9.0 HEXUPPER..decoderust-analyzer cargo data-encoding 2.9.0 impl#[Encoding]decode().(instance_string.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()).is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 74 | || HEXUPPERrust-analyzer cargo data-encoding 2.9.0 HEXUPPER. |
| 75 | .decoderust-analyzer cargo data-encoding 2.9.0 impl#[Encoding]decode().(instance_string.to_uppercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_uppercase().().as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().()) |
| 76 | .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() |
| 77 | } |
| 78 | |
| 79 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn from_base16rust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base16().( |
| 80 | instance_string: &str, |
| 81 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'static>> { |
| 82 | // Base16 is case-insensitive per RFC 4648 |
| 83 | let result = HEXUPPERrust-analyzer cargo data-encoding 2.9.0 HEXUPPER. |
| 84 | .decoderust-analyzer cargo data-encoding 2.9.0 impl#[Encoding]decode().(instance_string.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()) |
| 85 | .or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]or_else().(|_| HEXUPPERrust-analyzer cargo data-encoding 2.9.0 HEXUPPER..decoderust-analyzer cargo data-encoding 2.9.0 impl#[Encoding]decode().(instance_string.to_uppercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_uppercase().().as_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_bytes().())); |
| 86 | match result { |
| 87 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8().(value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)), |
| 88 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // Supported in JSON Schema Draft 6, 7, 2019-09, and 2020-12 |
| 93 | // Per JSON Schema Validation spec §8.3, encoding values are defined in: |
| 94 | // - RFC 4648 (base16, base32, base32hex, base64, base64url) |
| 95 | // - RFC 2045 §6.7-6.8 (quoted-printable, 7bit, 8bit, binary) |
| 96 | // We implement the RFC 4648 encodings as they are transformation encodings. |
| 97 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) static DEFAULT_CONTENT_ENCODING_CHECKS_AND_CONVERTERSrust-analyzer cargo jsonschema 0.37.4 content_encoding/DEFAULT_CONTENT_ENCODING_CHECKS_AND_CONVERTERS.: LazyLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/lazy_lock/LazyLock#< |
| 98 | AHashMaprust-analyzer cargo ahash 0.8.12 hash_map/AHashMap#<&'static str, (ContentEncodingCheckTyperust-analyzer cargo jsonschema 0.37.4 content_encoding/ContentEncodingCheckType#, ContentEncodingConverterTyperust-analyzer cargo jsonschema 0.37.4 content_encoding/ContentEncodingConverterType#)>, |
| 99 | > = LazyLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/lazy_lock/LazyLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/lazy_lock/impl#[`LazyLock<T, F>`]new().(|| { |
| 100 | let mut map: AHashMaprust-analyzer cargo ahash 0.8.12 hash_map/AHashMap#<&'static str, (ContentEncodingCheckTyperust-analyzer cargo jsonschema 0.37.4 content_encoding/ContentEncodingCheckType#, ContentEncodingConverterTyperust-analyzer cargo jsonschema 0.37.4 content_encoding/ContentEncodingConverterType#)> = |
| 101 | AHashMaprust-analyzer cargo ahash 0.8.12 hash_map/AHashMap#::with_capacityrust-analyzer cargo ahash 0.8.12 hash_map/impl#[`AHashMap<K, V>`]with_capacity().(5); |
| 102 | map.insertrust-analyzer cargo ahash 0.8.12 hash_map/impl#[`AHashMap<K, V, S>`]insert().("base64", (is_base64rust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base64()., from_base64rust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base64().)); |
| 103 | map.insertrust-analyzer cargo ahash 0.8.12 hash_map/impl#[`AHashMap<K, V, S>`]insert().("base64url", (is_base64urlrust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base64url()., from_base64urlrust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base64url().)); |
| 104 | map.insertrust-analyzer cargo ahash 0.8.12 hash_map/impl#[`AHashMap<K, V, S>`]insert().("base32", (is_base32rust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base32()., from_base32rust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base32().)); |
| 105 | map.insertrust-analyzer cargo ahash 0.8.12 hash_map/impl#[`AHashMap<K, V, S>`]insert().("base32hex", (is_base32hexrust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base32hex()., from_base32hexrust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base32hex().)); |
| 106 | map.insertrust-analyzer cargo ahash 0.8.12 hash_map/impl#[`AHashMap<K, V, S>`]insert().("base16", (is_base16rust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base16()., from_base16rust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base16().)); |
| 107 | map |
| 108 | }); |
| 109 | |
| 110 | #[cfg(test)] |
| 111 | mod testsrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/ { |
| 112 | use superrust-analyzer cargo jsonschema 0.37.4 content_encoding/::*; |
| 113 | use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:; |
| 114 | |
| 115 | // Test string: "foobar" |
| 116 | const TEST_STRINGrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_STRING.: &str = "foobar"; |
| 117 | const TEST_BASE64rust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE64.: &str = "Zm9vYmFy"; |
| 118 | const TEST_BASE64URLrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE64URL.: &str = "Zm9vYmFy"; // same as base64 for "foobar" (no +/) |
| 119 | const TEST_BASE32rust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE32.: &str = "MZXW6YTBOI======"; |
| 120 | const TEST_BASE32HEXrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE32HEX.: &str = "CPNMUOJ1E8======"; |
| 121 | const TEST_BASE16_UPPERrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE16_UPPER.: &str = "666F6F626172"; |
| 122 | const TEST_BASE16_LOWERrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE16_LOWER.: &str = "666f6f626172"; |
| 123 | const TEST_BASE16_MIXEDrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE16_MIXED.: &str = "666F6f626172"; |
| 124 | |
| 125 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE64rust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE64., true ; "valid base64")] |
| 126 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("not valid base64!!!", false ; "invalid base64 with special chars")] |
| 127 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("Zm9v====", false ; "invalid base64 padding")] |
| 128 | fn test_is_base64rust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/test_is_base64().(input: &str, expected: bool) { |
| 129 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_base64rust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base64().(input), expected); |
| 130 | } |
| 131 | |
| 132 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE64rust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE64., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TEST_STRINGrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_STRING.) ; "decode valid base64")] |
| 133 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("invalid!", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# ; "decode invalid base64")] |
| 134 | fn test_from_base64rust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/test_from_base64().(input: &str, expected: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>) { |
| 135 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 136 | from_base64rust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base64().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 137 | expected.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#::to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().) |
| 138 | ); |
| 139 | } |
| 140 | |
| 141 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE64URLrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE64URL., true ; "valid base64url")] |
| 142 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("PDw_Pz4-", true ; "base64url with url safe chars")] |
| 143 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("Zm9v+YmFy", false ; "base64 plus char invalid in base64url")] |
| 144 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("Zm9v/YmFy", false ; "base64 slash char invalid in base64url")] |
| 145 | fn test_is_base64urlrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/test_is_base64url().(input: &str, expected: bool) { |
| 146 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_base64urlrust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base64url().(input), expected); |
| 147 | } |
| 148 | |
| 149 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE64URLrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE64URL., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TEST_STRINGrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_STRING.) ; "decode valid base64url")] |
| 150 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("invalid!", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# ; "decode invalid base64url")] |
| 151 | fn test_from_base64urlrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/test_from_base64url().(input: &str, expected: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>) { |
| 152 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 153 | from_base64urlrust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base64url().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 154 | expected.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#::to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().) |
| 155 | ); |
| 156 | } |
| 157 | |
| 158 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE32rust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE32., true ; "valid base32")] |
| 159 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("not valid", false ; "invalid base32 text")] |
| 160 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("189", false ; "base32 invalid chars 1,8,9")] |
| 161 | fn test_is_base32rust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/test_is_base32().(input: &str, expected: bool) { |
| 162 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_base32rust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base32().(input), expected); |
| 163 | } |
| 164 | |
| 165 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE32rust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE32., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TEST_STRINGrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_STRING.) ; "decode valid base32")] |
| 166 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("189!!!", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# ; "decode invalid base32")] |
| 167 | fn test_from_base32rust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/test_from_base32().(input: &str, expected: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>) { |
| 168 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 169 | from_base32rust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base32().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 170 | expected.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#::to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().) |
| 171 | ); |
| 172 | } |
| 173 | |
| 174 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE32HEXrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE32HEX., true ; "valid base32hex")] |
| 175 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("not valid", false ; "invalid base32hex text")] |
| 176 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("XYZ", false ; "base32hex invalid chars X,Y,Z")] |
| 177 | fn test_is_base32hexrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/test_is_base32hex().(input: &str, expected: bool) { |
| 178 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_base32hexrust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base32hex().(input), expected); |
| 179 | } |
| 180 | |
| 181 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE32HEXrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE32HEX., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TEST_STRINGrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_STRING.) ; "decode valid base32hex")] |
| 182 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("XYZ!!!", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# ; "decode invalid base32hex")] |
| 183 | fn test_from_base32hexrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/test_from_base32hex().(input: &str, expected: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>) { |
| 184 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 185 | from_base32hexrust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base32hex().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 186 | expected.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#::to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().) |
| 187 | ); |
| 188 | } |
| 189 | |
| 190 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE16_UPPERrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE16_UPPER., true ; "valid base16 uppercase")] |
| 191 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE16_LOWERrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE16_LOWER., true ; "valid base16 lowercase")] |
| 192 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE16_MIXEDrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE16_MIXED., true ; "valid base16 mixed case")] |
| 193 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("not valid", false ; "invalid base16 text")] |
| 194 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("GHIJ", false ; "base16 invalid chars G-J")] |
| 195 | fn test_is_base16rust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/test_is_base16().(input: &str, expected: bool) { |
| 196 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(is_base16rust-analyzer cargo jsonschema 0.37.4 content_encoding/is_base16().(input), expected); |
| 197 | } |
| 198 | |
| 199 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE16_UPPERrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE16_UPPER., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TEST_STRINGrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_STRING.) ; "decode base16 uppercase")] |
| 200 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE16_LOWERrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE16_LOWER., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TEST_STRINGrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_STRING.) ; "decode base16 lowercase")] |
| 201 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(TEST_BASE16_MIXEDrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_BASE16_MIXED., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TEST_STRINGrust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/TEST_STRING.) ; "decode base16 mixed")] |
| 202 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:("GHIJ", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# ; "decode invalid base16")] |
| 203 | fn test_from_base16rust-analyzer cargo jsonschema 0.37.4 content_encoding/tests/test_from_base16().(input: &str, expected: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>) { |
| 204 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 205 | from_base16rust-analyzer cargo jsonschema 0.37.4 content_encoding/from_base16().(input).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 206 | expected.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#::to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().) |
| 207 | ); |
| 208 | } |
| 209 | } |