pub struct TvpEncoder<'a> {
pub schema: &'a str,
pub type_name: &'a str,
pub columns: &'a [TvpColumnDef],
}Expand description
TVP value encoder.
This provides the complete TVP encoding logic for RPC parameters.
Fields§
§schema: &'a strDatabase schema (e.g., “dbo”). Empty for default.
type_name: &'a strType name as defined in the database.
columns: &'a [TvpColumnDef]Column definitions.
Implementations§
Source§impl<'a> TvpEncoder<'a>
impl<'a> TvpEncoder<'a>
Sourcepub const fn new(
schema: &'a str,
type_name: &'a str,
columns: &'a [TvpColumnDef],
) -> Self
pub const fn new( schema: &'a str, type_name: &'a str, columns: &'a [TvpColumnDef], ) -> Self
Create a new TVP encoder.
Sourcepub fn encode_metadata(&self, buf: &mut BytesMut)
pub fn encode_metadata(&self, buf: &mut BytesMut)
Encode the complete TVP type info and metadata.
This encodes:
- TVP type ID (0xF3)
- TVP_TYPENAME (DbName, OwningSchema, TypeName)
- TVP_COLMETADATA
- TVP_END_TOKEN (marks end of column metadata)
After calling this, use Self::encode_row for each row, then
Self::encode_end to finish.
Sourcepub fn encode_row<F>(&self, buf: &mut BytesMut, encode_values: F)
pub fn encode_row<F>(&self, buf: &mut BytesMut, encode_values: F)
Encode a TVP row.
§Arguments
encode_values- A closure that encodes the column values into the buffer. Each value should be encoded according to its type (similar to RPC param encoding).
Sourcepub fn encode_end(&self, buf: &mut BytesMut)
pub fn encode_end(&self, buf: &mut BytesMut)
Encode the TVP end marker.
This must be called after all rows have been encoded.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for TvpEncoder<'a>
impl<'a> RefUnwindSafe for TvpEncoder<'a>
impl<'a> Send for TvpEncoder<'a>
impl<'a> Sync for TvpEncoder<'a>
impl<'a> Unpin for TvpEncoder<'a>
impl<'a> UnwindSafe for TvpEncoder<'a>
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