Skip to main content

RpcParam

Struct RpcParam 

Source
pub struct RpcParam {
    pub name: String,
    pub flags: ParamFlags,
    pub type_info: TypeInfo,
    pub value: Option<Bytes>,
    pub crypto_metadata: Option<EncryptedParamMetadata>,
}
Expand description

An RPC parameter.

Fields§

§name: String

Parameter name (can be empty for positional params).

§flags: ParamFlags

Status flags.

§type_info: TypeInfo

Type information.

§value: Option<Bytes>

Parameter value (raw bytes).

§crypto_metadata: Option<EncryptedParamMetadata>

Always Encrypted cipher metadata, written after the value when the parameter is encrypted. None for ordinary parameters.

Implementations§

Source§

impl RpcParam

Source

pub fn new(name: impl Into<String>, type_info: TypeInfo, value: Bytes) -> Self

Create a new parameter with a value.

Source

pub fn null(name: impl Into<String>, type_info: TypeInfo) -> Self

Create a NULL parameter.

Source

pub fn encrypted( name: impl Into<String>, ciphertext: Bytes, metadata: EncryptedParamMetadata, ) -> Self

Create an Always Encrypted parameter.

ciphertext is the AEAD-encrypted, normalized value; metadata is the cipher info the server needs to validate and route it. On the wire the value is carried as BIGVARBINARY(max) with the fEncrypted status bit set and the EncryptedParamMetadata trailer after the value.

Source

pub fn encrypted_null( name: impl Into<String>, metadata: EncryptedParamMetadata, ) -> Self

Create a NULL Always Encrypted parameter.

The server rejects a plaintext parameter bound to an encrypted column, even for NULL, so a NULL value is still sent encrypted: BIGVARBINARY(max) with the fEncrypted status bit, a NULL value, and the cipher metadata.

Source

pub fn int(name: impl Into<String>, value: i32) -> Self

Create an INT parameter.

Source

pub fn bigint(name: impl Into<String>, value: i64) -> Self

Create a BIGINT parameter.

Source

pub fn nvarchar(name: impl Into<String>, value: &str) -> Self

Create an NVARCHAR parameter.

Source

pub fn varchar(name: impl Into<String>, value: &str) -> Self

Create a VARCHAR parameter.

Encodes the string as single-byte characters using Windows-1252 encoding (when the encoding feature is enabled) or Latin-1 fallback. Characters not representable in the target encoding are replaced with ?.

Use this instead of nvarchar when SendStringParametersAsUnicode=false to allow SQL Server to use index seeks on VARCHAR columns.

Source

pub fn varchar_with_collation( name: impl Into<String>, value: &str, collation: &Collation, ) -> Self

Create a VARCHAR parameter using the server’s collation for encoding.

Uses the collation’s character encoding instead of the default Windows-1252. For UTF-8 collations (SQL Server 2019+), the string bytes are used directly.

Source

pub fn as_output(self) -> Self

Mark as output parameter.

Source

pub fn encode(&self, buf: &mut BytesMut)

Encode the parameter to buffer.

Trait Implementations§

Source§

impl Clone for RpcParam

Source§

fn clone(&self) -> RpcParam

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RpcParam

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.