pub struct Reader<'a> { /* private fields */ }Expand description
High-level read-only reader for .coi columnar IP databases.
Thread-safe (Send + Sync): share across threads with Arc<Reader<'static>>.
Implementations§
Source§impl Reader<'static>
impl Reader<'static>
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Open a .coi file from disk (uses memory mapping when mmap feature is enabled, else File).
Sourcepub fn open_with_options(
path: impl AsRef<Path>,
options: ReaderOptions,
) -> Result<Self>
pub fn open_with_options( path: impl AsRef<Path>, options: ReaderOptions, ) -> Result<Self>
Open a .coi file with custom cache/verification options.
Sourcepub fn open_file(path: impl AsRef<Path>) -> Result<Self>
pub fn open_file(path: impl AsRef<Path>) -> Result<Self>
Open a .coi file using explicit File positioned I/O (no mmap).
Sourcepub fn open_file_with_options(
path: impl AsRef<Path>,
options: ReaderOptions,
) -> Result<Self>
pub fn open_file_with_options( path: impl AsRef<Path>, options: ReaderOptions, ) -> Result<Self>
Open a .coi file using File I/O with custom options.
Sourcepub fn from_vec(bytes: Vec<u8>) -> Result<Self>
pub fn from_vec(bytes: Vec<u8>) -> Result<Self>
Open a .coi database from an owned byte buffer.
Sourcepub fn from_vec_with_options(
bytes: Vec<u8>,
options: ReaderOptions,
) -> Result<Self>
pub fn from_vec_with_options( bytes: Vec<u8>, options: ReaderOptions, ) -> Result<Self>
Open from an owned Vec<u8> with custom options.
Source§impl<'a> Reader<'a>
impl<'a> Reader<'a>
Sourcepub fn from_bytes(bytes: &'a [u8]) -> Result<Self>
pub fn from_bytes(bytes: &'a [u8]) -> Result<Self>
Open a .coi database directly from a borrowed byte slice (zero-copy).
Sourcepub fn from_bytes_with_options(
bytes: &'a [u8],
options: ReaderOptions,
) -> Result<Self>
pub fn from_bytes_with_options( bytes: &'a [u8], options: ReaderOptions, ) -> Result<Self>
Open from a borrowed byte slice with custom options.
pub fn header(&self) -> &FileHeader
pub fn sections(&self) -> &[SectionEntry]
pub fn metadata(&self) -> &Value
pub fn schema(&self) -> &Schema
pub fn zstd_dict_count(&self) -> usize
pub fn ipv6_aliases(&self) -> &Ipv6Aliases
pub fn ipv6_host_ext(&self) -> &Ipv6HostExt
pub fn ipv4_entry_count(&self) -> u64
pub fn ipv6_entry_count(&self) -> u64
Sourcepub fn ipv4_transitions(&self) -> Result<Vec<(u32, u64)>>
pub fn ipv4_transitions(&self) -> Result<Vec<(u32, u64)>>
Return all IPv4 merged transition points (start_u32, record_id) in ascending order.
Sourcepub fn ipv6_transitions(&self) -> Result<Vec<(u64, u64)>>
pub fn ipv6_transitions(&self) -> Result<Vec<(u64, u64)>>
Return all native IPv6 /64 merged transition points (start_hi64, record_id) in ascending order.
Sourcepub fn ipv4_ranges(&self) -> Result<Vec<(u32, u32, u64)>>
pub fn ipv4_ranges(&self) -> Result<Vec<(u32, u32, u64)>>
Return all populated inclusive IPv4 ranges (start_u32, end_u32, record_id) (record_id > 0).
Sourcepub fn ipv6_ranges(&self) -> Result<Vec<(u64, u64, u64)>>
pub fn ipv6_ranges(&self) -> Result<Vec<(u64, u64, u64)>>
Return all populated inclusive IPv6 /64 ranges (start_hi64, end_hi64, record_id) (record_id > 0).
pub fn dict_entry_counts(&self) -> Vec<(String, u64)>
Sourcepub fn verify_checksums(&self) -> Result<()>
pub fn verify_checksums(&self) -> Result<()>
Verify CRC32C checksums of every section in the .coi file.
Sourcepub fn clear_caches(&self)
pub fn clear_caches(&self)
Clear all LRU caches (useful for benchmarking cold lookups).
Sourcepub fn compile_projection<I, S>(&self, paths: I) -> Result<Projection>
pub fn compile_projection<I, S>(&self, paths: I) -> Result<Projection>
Compile a column projection once at startup for fast projected lookups.
Sourcepub fn lookup_record_id(&self, ip: IpAddr) -> Result<u64>
pub fn lookup_record_id(&self, ip: IpAddr) -> Result<u64>
Resolve an IpAddr to its internal 1-based record_id (0 = NotFound).
pub fn lookup_ipv4_record_id(&self, ip: Ipv4Addr) -> Result<u64>
pub fn lookup_ipv6_record_id(&self, ip: Ipv6Addr) -> Result<u64>
Sourcepub fn get_record_by_id(
&self,
record_id: u64,
projection: Option<&Projection>,
) -> Result<Option<BTreeMap<String, Value>>>
pub fn get_record_by_id( &self, record_id: u64, projection: Option<&Projection>, ) -> Result<Option<BTreeMap<String, Value>>>
Materialize a unique record directly by 1-based record_id (1..=record_count).
Sourcepub fn lookup_value(&self, ip: IpAddr) -> Result<Option<Value>>
pub fn lookup_value(&self, ip: IpAddr) -> Result<Option<Value>>
Look up an IP address and return its full dynamic record (BTreeMap<String, Value>).
Sourcepub fn lookup_projected(
&self,
ip: IpAddr,
projection: &Projection,
) -> Result<Option<Value>>
pub fn lookup_projected( &self, ip: IpAddr, projection: &Projection, ) -> Result<Option<Value>>
Look up an IP address and materialize ONLY the fields selected by projection.
Sourcepub fn lookup<T: for<'de> Deserialize<'de>>(
&self,
ip: IpAddr,
) -> Result<Option<T>>
pub fn lookup<T: for<'de> Deserialize<'de>>( &self, ip: IpAddr, ) -> Result<Option<T>>
Look up an IP address and deserialize the full record directly into a typed serde struct T
without constructing any intermediate BTreeMap or Value.
Sourcepub fn lookup_with_projection<T: for<'de> Deserialize<'de>>(
&self,
ip: IpAddr,
projection: &Projection,
) -> Result<Option<T>>
pub fn lookup_with_projection<T: for<'de> Deserialize<'de>>( &self, ip: IpAddr, projection: &Projection, ) -> Result<Option<T>>
Look up an IP address using a compiled Projection and deserialize directly into T
(zero intermediate BTreeMap / Value allocation).