Object

Enum Object 

Source
pub enum Object {
    Integer32(i32),
    Long64(i64),
    String(String),
    Float32(f32),
    Double64(f64),
    Boolean(bool),
    Date(NaiveDate),
    DateTime(NaiveDateTime),
    None,
}
Expand description

Basic data objects (including Number, String, bool, none, and time)

Variants§

§

Integer32(i32)

§

Long64(i64)

§

String(String)

§

Float32(f32)

§

Double64(f64)

§

Boolean(bool)

§

Date(NaiveDate)

§

DateTime(NaiveDateTime)

§

None

Implementations§

Source§

impl Object

Source

pub fn is_null(&self) -> bool

Source

pub fn get_string(&self) -> Option<String>

将Object枚举转换为String类型

§参数
  • self - Object枚举的引用
§返回值

返回Option,如果Object为None则返回None,否则返回对应值的字符串表示

Source

pub fn get_integer(&self) -> Option<i32>

将对象转换为整数类型

该函数尝试将当前对象转换为i32类型的整数。根据不同对象类型, 采用相应的转换规则:整数和长整数直接转换,浮点数截断小数部分, 布尔值转换为0或1,其他类型返回None。

§返回值
  • Option<i32> - 转换成功返回Some(整数值),失败返回None
Source

pub fn get_long(&self) -> Option<i64>

将对象转换为64位整数类型

该函数尝试将当前对象转换为i64类型的值。根据不同对象类型, 会进行相应的类型转换或映射。

§返回值
  • Some(i64) - 转换成功时返回对应的64位整数值
  • None - 当前对象无法转换为整数类型时返回None
Source

pub fn get_float32(&self) -> Option<f32>

Convert the current object to 32-bit float-point number

§返回值
  • Option<f32> - 转换成功时返回Some(f32),否则返回None
§转换规则
  • Integer32: 直接转换为f32
  • Long64: 转换为f32(可能丢失精度)
  • Float32: 直接返回
  • Double64: 转换为f32(可能丢失精度)
  • Boolean: true转为1.0,false转为0.0
  • 其他类型: 返回None
Source

pub fn get_double(&self) -> Option<f64>

将对象转换为双精度浮点数

该函数尝试将当前对象转换为f64类型的值。支持的类型包括:

  • 整数类型(Integer32、Long64):直接转换为对应的浮点数
  • 浮点数类型(Float32、Double64):Float32转换为f64,Double64直接返回
  • 布尔类型:true转换为1.0,false转换为0.0
  • 其他类型:返回None
§返回值
  • Option<f64> - 转换成功返回Some(f64值),否则返回None

Trait Implementations§

Source§

impl Debug for Object

Source§

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

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

impl From<&str> for Object

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Object

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Object

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Object

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Object

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Object

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Object

§

impl RefUnwindSafe for Object

§

impl Send for Object

§

impl Sync for Object

§

impl Unpin for Object

§

impl UnwindSafe for Object

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

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

§

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,