| 1 | //! Error types for MaxMind DB operations. |
| 2 | |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#; |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/; |
| 5 | |
| 6 | use ipnetworkrust-analyzer cargo ipnetwork 0.21.1 crate/::IpNetworkErrorrust-analyzer cargo ipnetwork 0.21.1 error/IpNetworkError#; |
| 7 | use serderust-analyzer cargo serde 1.0.229 crate/::derust-analyzer cargo serde_core 1.0.229 de/; |
| 8 | use thiserrorrust-analyzer cargo thiserror 2.0.19 crate/::Errorrust-analyzer cargo thiserror-impl 2.0.19 Error:; |
| 9 | |
| 10 | /// Error returned by MaxMind DB operations. |
| 11 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Errorrust-analyzer cargo thiserror-impl 2.0.19 Error:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 12 | #[non_exhaustive] |
| 13 | pub enum MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError# { |
| 14 | /// The database file is invalid or corrupted. |
| 15 | #[errorrust-analyzer cargo thiserror-impl 2.0.19 error:("{}", format_invalid_databaserust-analyzer cargo maxminddb 0.30.0 error/format_invalid_database().(.message, .offset))] |
| 16 | InvalidDatabaserust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidDatabase# { |
| 17 | /// Description of what is invalid. |
| 18 | messagerust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidDatabase#message.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 19 | /// Byte offset in the database where the error was detected. |
| 20 | offsetrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidDatabase#offset.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, |
| 21 | }, |
| 22 | |
| 23 | /// An I/O error occurred while reading the database. |
| 24 | #[errorrust-analyzer cargo thiserror-impl 2.0.19 error:("i/o error: {0}")] |
| 25 | Iorust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Io#( |
| 26 | #[from] |
| 27 | #[source] |
| 28 | iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#, |
| 29 | ), |
| 30 | |
| 31 | /// Memory mapping failed. |
| 32 | #[cfg(feature = "mmap")] |
| 33 | #[errorrust-analyzer cargo thiserror-impl 2.0.19 error:("memory map error: {0}")] |
| 34 | Mmaprust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Mmap#(#[source] iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#), |
| 35 | |
| 36 | /// Error decoding data from the database. |
| 37 | #[errorrust-analyzer cargo thiserror-impl 2.0.19 error:("{}", format_decoding_errorrust-analyzer cargo maxminddb 0.30.0 error/format_decoding_error().(.message, .offset, .path.as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().()))] |
| 38 | Decodingrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding# { |
| 39 | /// Description of the decoding error. |
| 40 | messagerust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding#message.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 41 | /// Byte offset in the data section where the error occurred. |
| 42 | offsetrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding#offset.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, |
| 43 | /// JSON-pointer-like path to the field (e.g., "/city/names/en"). |
| 44 | pathrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding#path.: 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#>, |
| 45 | }, |
| 46 | |
| 47 | /// The provided network/CIDR is invalid. |
| 48 | #[errorrust-analyzer cargo thiserror-impl 2.0.19 error:("invalid network: {0}")] |
| 49 | InvalidNetworkrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidNetwork#( |
| 50 | #[from] |
| 51 | #[source] |
| 52 | IpNetworkErrorrust-analyzer cargo ipnetwork 0.21.1 error/IpNetworkError#, |
| 53 | ), |
| 54 | |
| 55 | /// The provided input is invalid for this operation. |
| 56 | #[errorrust-analyzer cargo thiserror-impl 2.0.19 error:("invalid input: {message}")] |
| 57 | InvalidInputrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidInput# { |
| 58 | /// Description of what is invalid about the input. |
| 59 | messagerust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidInput#message.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 60 | }, |
| 61 | } |
| 62 | |
| 63 | fn format_invalid_databaserust-analyzer cargo maxminddb 0.30.0 error/format_invalid_database().(message: &str, offset: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 64 | match offset { |
| 65 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(off) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("invalid database at offset {off}: {message}"), |
| 66 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("invalid database: {message}"), |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | fn format_decoding_errorrust-analyzer cargo maxminddb 0.30.0 error/format_decoding_error().(message: &str, offset: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>, path: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 71 | match (offset, path) { |
| 72 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(off), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(p)) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("decoding error at offset {off} (path: {p}): {message}"), |
| 73 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(off), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("decoding error at offset {off}: {message}"), |
| 74 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(p)) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("decoding error (path: {p}): {message}"), |
| 75 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("decoding error: {message}"), |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | impl MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError# { |
| 80 | /// Creates an InvalidDatabase error with just a message. |
| 81 | pub fn invalid_databaserust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError]invalid_database().(message: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) -> Selfrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError] { |
| 82 | MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::InvalidDatabaserust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidDatabase# { |
| 83 | messagerust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidDatabase#message.: message.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), |
| 84 | offsetrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidDatabase#offset.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | /// Creates an InvalidDatabase error with message and offset. |
| 89 | pub fn invalid_database_atrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError]invalid_database_at().(message: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, offset: usize) -> Selfrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError] { |
| 90 | MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::InvalidDatabaserust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidDatabase# { |
| 91 | messagerust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidDatabase#message.: message.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), |
| 92 | offsetrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidDatabase#offset.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(offset), |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | /// Creates a Decoding error with just a message. |
| 97 | pub fn decodingrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError]decoding().(message: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) -> Selfrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError] { |
| 98 | MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::Decodingrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding# { |
| 99 | messagerust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding#message.: message.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), |
| 100 | offsetrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding#offset.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 101 | pathrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding#path.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | /// Creates a Decoding error with message and offset. |
| 106 | pub fn decoding_atrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError]decoding_at().(message: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, offset: usize) -> Selfrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError] { |
| 107 | MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::Decodingrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding# { |
| 108 | messagerust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding#message.: message.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), |
| 109 | offsetrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding#offset.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(offset), |
| 110 | pathrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding#path.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | /// Creates a Decoding error with message, offset, and path. |
| 115 | pub fn decoding_at_pathrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError]decoding_at_path().( |
| 116 | message: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 117 | offset: usize, |
| 118 | path: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, |
| 119 | ) -> Selfrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError] { |
| 120 | MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::Decodingrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding# { |
| 121 | messagerust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding#message.: message.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), |
| 122 | offsetrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding#offset.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(offset), |
| 123 | pathrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Decoding#path.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()), |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | /// Creates an InvalidInput error. |
| 128 | pub fn invalid_inputrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError]invalid_input().(message: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) -> Selfrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError] { |
| 129 | MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::InvalidInputrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidInput# { |
| 130 | messagerust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#InvalidInput#message.: message.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(), |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | impl derust-analyzer cargo serde_core 1.0.229 de/::Errorrust-analyzer cargo serde_core 1.0.229 de/Error# for MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError# { |
| 136 | fn customrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError][Error]custom().<T: Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#>(msg: T) -> Selfrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError][Error] { |
| 137 | MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::decodingrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError]decoding().(msg.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | #[cfg(test)] |
| 142 | mod testsrust-analyzer cargo maxminddb 0.30.0 error/tests/ { |
| 143 | use superrust-analyzer cargo maxminddb 0.30.0 error/::*; |
| 144 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#, ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#}; |
| 145 | |
| 146 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 147 | fn test_error_displayrust-analyzer cargo maxminddb 0.30.0 error/tests/test_error_display().() { |
| 148 | // Error without offset |
| 149 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 150 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 151 | "{}", |
| 152 | MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::invalid_databaserust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError]invalid_database().("something went wrong") |
| 153 | ), |
| 154 | "invalid database: something went wrong".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 155 | ); |
| 156 | // Error with offset |
| 157 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 158 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 159 | "{}", |
| 160 | MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::invalid_database_atrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError]invalid_database_at().("something went wrong", 42) |
| 161 | ), |
| 162 | "invalid database at offset 42: something went wrong".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 163 | ); |
| 164 | let io_err = Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::NotFoundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#NotFound#, "file not found"); |
| 165 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 166 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::fromrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError][`From<io::Error>`]from().(io_err)), |
| 167 | "i/o error: file not found".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 168 | ); |
| 169 | |
| 170 | #[cfg(feature = "mmap")] |
| 171 | { |
| 172 | let mmap_io_err = Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::PermissionDeniedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#PermissionDenied#, "mmap failed"); |
| 173 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 174 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::Mmaprust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#Mmap#(mmap_io_err)), |
| 175 | "memory map error: mmap failed".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 176 | ); |
| 177 | } |
| 178 | |
| 179 | // Decoding error without offset |
| 180 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 181 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::decodingrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError]decoding().("unexpected type")), |
| 182 | "decoding error: unexpected type".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 183 | ); |
| 184 | // Decoding error with offset |
| 185 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 186 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::decoding_atrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError]decoding_at().("unexpected type", 100)), |
| 187 | "decoding error at offset 100: unexpected type".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 188 | ); |
| 189 | // Decoding error with offset and path |
| 190 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 191 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 192 | "{}", |
| 193 | MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::decoding_at_pathrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError]decoding_at_path().("unexpected type", 100, "/city/names/en") |
| 194 | ), |
| 195 | "decoding error at offset 100 (path: /city/names/en): unexpected type".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 196 | ); |
| 197 | |
| 198 | let net_err = IpNetworkErrorrust-analyzer cargo ipnetwork 0.21.1 error/IpNetworkError#::InvalidPrefixrust-analyzer cargo ipnetwork 0.21.1 error/IpNetworkError#InvalidPrefix#; |
| 199 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 200 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::fromrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError][`From<IpNetworkError>`]from().(net_err)), |
| 201 | "invalid network: invalid prefix".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 202 | ); |
| 203 | |
| 204 | // InvalidInput error |
| 205 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 206 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", MaxMindDbErrorrust-analyzer cargo maxminddb 0.30.0 error/MaxMindDbError#::invalid_inputrust-analyzer cargo maxminddb 0.30.0 error/impl#[MaxMindDbError]invalid_input().("bad address")), |
| 207 | "invalid input: bad address".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 208 | ); |
| 209 | } |
| 210 | } |