Skip to main content

FieldExtractor

Struct FieldExtractor 

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

字段提取器:通过闭包从数据中提取字段

闭包签名 Fn() -> String,由调用方在闭包内捕获对数据源的访问方式。 extract 收到的 data: &dyn Any 参数被忽略(由闭包自行决定如何取值), 这种设计让用户可以灵活地把外部状态(如 Arc<T>、数据库行等)捕获进闭包。

Implementations§

Source§

impl FieldExtractor

Source

pub fn new<F>(f: F) -> Self
where F: Fn() -> String + Send + Sync + 'static,

创建字段提取器

§参数
  • f: 闭包,捕获字段访问逻辑,返回字段值字符串

Trait Implementations§

Source§

impl Debug for FieldExtractor

Source§

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

Formats the value using the given formatter. Read more
Source§

impl ShardKeyExtractor for FieldExtractor

Source§

fn extract(&self, _data: &dyn Any) -> Result<String, ShardingError>

从数据中提取分片键 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, 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.