pub struct Record { /* private fields */ }Expand description
Implementations§
Source§impl Record
impl Record
Sourcepub fn insert(
&mut self,
key: impl Into<String>,
value: impl Into<Value>,
) -> Option<Value>
pub fn insert( &mut self, key: impl Into<String>, value: impl Into<Value>, ) -> Option<Value>
写入字段值并返回被替换的旧值。
Sourcepub fn require<T>(&self, key: &str) -> Result<T, BaseError>where
T: DeserializeOwned,
pub fn require<T>(&self, key: &str) -> Result<T, BaseError>where
T: DeserializeOwned,
读取必需字段并转换为目标类型。
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Record
impl<'de> Deserialize<'de> for Record
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'r> FromRow<'r, MySqlRow> for Record
Available on crate feature mysql only.实现 sqlx::FromRow,支持从 MySQL 查询结果动态解码
impl<'r> FromRow<'r, MySqlRow> for Record
Available on crate feature
mysql only.实现 sqlx::FromRow,支持从 MySQL 查询结果动态解码
按 MySQL 列类型将值映射到对应的 JSON 类型:
- INT/BIGINT → i64
- FLOAT/DOUBLE → f64
- DECIMAL/NUMERIC → String(保留精度)
- VARCHAR/TEXT/CHAR → String
- BOOLEAN/TINYINT(1) → Bool
- DATE/DATETIME/TIMESTAMP → ISO 8601 字符串
- NULL → Null
- BLOB/BINARY → Base64 字符串
- JSON → Object/Array
Source§impl JsonSchema for Record
impl JsonSchema for Record
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreSource§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
impl StructuralPartialEq for Record
Auto Trait Implementations§
impl Freeze for Record
impl RefUnwindSafe for Record
impl Send for Record
impl Sync for Record
impl Unpin for Record
impl UnsafeUnpin for Record
impl UnwindSafe for Record
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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