pub trait IpData:
Copy
+ Clone
+ PartialEq {
// Required method
fn from_record(record: &StringRecord) -> Result<Option<Self>, FromCsvError>;
}
Expand description
Data associated with an ip address, derived from a CountryCode
.
In general, the fewer the possibilities, the more compressed the data structure will be. For Example, if you mapped a country code to a boolean, the data structure will store very large ranges of true/false, consisting of multiple consecutive ranges in the original dataset.
Required Methods§
Sourcefn from_record(record: &StringRecord) -> Result<Option<Self>, FromCsvError>
fn from_record(record: &StringRecord) -> Result<Option<Self>, FromCsvError>
db-ip data consists of csv records, any data must be derived from then.
Should return [Err(Error::InvalidRecord)
] if the fields are insufficient and the loading should
be aborted, and [Ok(None)
] if the field is fine, but the data is irrelevant.
§Notes
- The first two indices are the begin and end of the ip range, respectively.
- You don’t have to implement this if you disable the
csv
feature. - If you do implement it, you are responsible for knowing which indices correspond to which data.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.