pub enum CacheValue {
Number(String),
Json(String),
}Expand description
缓存值(区分 is_numeric 短路与 JSON 序列化)
对齐 PHP think\cache\Driver::serialize/unserialize 行为:
Number(s):对齐is_numeric($data) === true,存储为字符串Json(s):对齐serialize($data),存储为 JSON 字符串
PHP bug 复刻:unserialize 对 is_numeric 返回 string,而非 int。
本枚举通过 Number(String) 携带原始字符串,反序列化时直接返回 string,
不还原为 int 类型。
Variants§
Number(String)
数值型缓存值(对齐 PHP is_numeric 短路)
存储为字符串形式,反序列化时直接返回 string。
Json(String)
JSON 序列化缓存值(对齐 PHP serialize)
存储为 JSON 字符串,反序列化时通过 serde_json::from_str 还原。
Implementations§
Source§impl CacheValue
impl CacheValue
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<CacheValue, CacheError>
pub fn from_bytes(bytes: &[u8]) -> Result<CacheValue, CacheError>
从存储字节反序列化缓存值
对齐 PHP Driver::unserialize($data):
- 若
is_numeric→ 返回Number(s)(保留原始字符串) - 否则 → 返回
Json(s)
Trait Implementations§
Source§impl Clone for CacheValue
impl Clone for CacheValue
Source§fn clone(&self) -> CacheValue
fn clone(&self) -> CacheValue
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CacheValue
impl Debug for CacheValue
Source§impl PartialEq for CacheValue
impl PartialEq for CacheValue
impl StructuralPartialEq for CacheValue
Auto Trait Implementations§
impl Freeze for CacheValue
impl RefUnwindSafe for CacheValue
impl Send for CacheValue
impl Sync for CacheValue
impl Unpin for CacheValue
impl UnsafeUnpin for CacheValue
impl UnwindSafe for CacheValue
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
Converts
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> ⓘ
Converts
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