Struct MmdbBuilder
pub struct MmdbBuilder { /* private fields */ }net only.Expand description
A builder for MaxMind DB byte images.
Implementations§
§impl MmdbBuilder
impl MmdbBuilder
pub fn insert(
&mut self,
net: IpNet,
location: &GeoLocation,
) -> Result<(), MmdbWriteError>
pub fn insert( &mut self, net: IpNet, location: &GeoLocation, ) -> Result<(), MmdbWriteError>
Insert a typed GeoLocation for a network into the database.
For an IPv6 database an IPv4 net is placed in the ::/96 range so the
reader’s IPv4-in-IPv6 traversal finds it.
§Errors
Returns MmdbWriteError if net’s family does not match the
database, it overlaps an existing entry, or the data section grows
beyond 4 GiB.
§impl MmdbBuilder
impl MmdbBuilder
pub fn new(
ip_version: IpVersion,
database_type: impl Into<String>,
) -> MmdbBuilder
pub fn new( ip_version: IpVersion, database_type: impl Into<String>, ) -> MmdbBuilder
Create a builder for a database of the given IpVersion and
database_type string (e.g. "GeoLite2-City"). Records are emitted at
32 bits.
pub fn with_languages<I, S>(self, langs: I) -> MmdbBuilder
pub fn with_languages<I, S>(self, langs: I) -> MmdbBuilder
Declare the locale codes for which localised data is present.
pub fn with_build_epoch(self, epoch: u64) -> MmdbBuilder
pub fn with_build_epoch(self, epoch: u64) -> MmdbBuilder
Set the build timestamp (Unix epoch seconds).
pub fn build(&self) -> Result<Vec<u8>, MmdbWriteError>
pub fn build(&self) -> Result<Vec<u8>, MmdbWriteError>
Serialise the database to a byte vector.
§Errors
Returns MmdbWriteError::TooLarge if the resulting tree/data layout
exceeds the format’s u32 addressing limit. follow_or_create already
bounds the node count, so node_count as u32 here is always exact.
pub fn write_to<W>(&self, w: W) -> Result<(), MmdbWriteError>where
W: Write,
pub fn write_to<W>(&self, w: W) -> Result<(), MmdbWriteError>where
W: Write,
Serialise the database to any writer.
The tree is emitted one 4-byte record at a time, so the writer is internally buffered — callers need not (and should not double-) wrap it.
§Errors
Returns MmdbWriteError if the database is too large to encode or the
underlying write fails.
pub fn write_to_file(
&self,
path: impl AsRef<Path>,
) -> Result<(), MmdbWriteError>
pub fn write_to_file( &self, path: impl AsRef<Path>, ) -> Result<(), MmdbWriteError>
Serialise the database to a file at path.
§Errors
Returns MmdbWriteError if the database is too large to encode or the
file cannot be written.
Trait Implementations§
§impl Clone for MmdbBuilder
impl Clone for MmdbBuilder
§fn clone(&self) -> MmdbBuilder
fn clone(&self) -> MmdbBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for MmdbBuilder
impl RefUnwindSafe for MmdbBuilder
impl Send for MmdbBuilder
impl Sync for MmdbBuilder
impl Unpin for MmdbBuilder
impl UnsafeUnpin for MmdbBuilder
impl UnwindSafe for MmdbBuilder
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>
§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writer§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writer§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writer§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writer§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer