CzdbMemory

Struct CzdbMemory 

Source
pub struct CzdbMemory { /* private fields */ }
Expand description

In-memory CZDB searcher with a prebuilt index and string pool.

预构建索引与字符串池的内存 CZDB 查询器。

Implementations§

Source§

impl CzdbMemory

Source

pub fn open(db_path: &str, key: &str) -> Result<Self, CzError>

Open a database file and build in-memory indices.

打开数据库文件并构建内存索引。

Source

pub fn from_bytes(data: Vec<u8>, key: &str) -> Result<Self, CzError>

Build from raw bytes and construct in-memory indices.

从原始字节构建并生成内存索引。

Source

pub fn search(&self, ip: IpAddr) -> Option<String>

Search a single IP address.

查询指定 IP 地址。

Source

pub fn search_ref(&self, ip: IpAddr) -> Option<&str>

Search a single IP address and return a borrowed string.

查询指定 IP 并返回借用字符串。

Source

pub fn search_many(&self, ips: &[IpAddr]) -> Vec<Option<String>>

Search a small batch of IP addresses.

批量查询 IP(小批量)。

Source

pub fn search_many_ref<'a>(&'a self, ips: &[IpAddr]) -> Vec<Option<&'a str>>

Search a batch of IP addresses and return borrowed strings.

批量查询 IP 并返回借用字符串。

Source

pub fn search_many_scan<'a>(&'a self, ips: &[IpAddr]) -> Vec<Option<&'a str>>

Search a large batch by sorting and scanning.

对大批量 IP 进行排序后扫描查询。

Source

pub fn db_type(&self) -> DbType

Returns the database IP version.

返回数据库类型(IPv4 或 IPv6)。

Trait Implementations§

Source§

impl Debug for CzdbMemory

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.