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: StringParameter name (can be empty for positional params).
flags: ParamFlagsStatus flags.
type_info: TypeInfoType 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
impl RpcParam
Sourcepub fn new(name: impl Into<String>, type_info: TypeInfo, value: Bytes) -> Self
pub fn new(name: impl Into<String>, type_info: TypeInfo, value: Bytes) -> Self
Create a new parameter with a value.
Sourcepub fn encrypted(
name: impl Into<String>,
ciphertext: Bytes,
metadata: EncryptedParamMetadata,
) -> Self
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.
Sourcepub fn encrypted_null(
name: impl Into<String>,
metadata: EncryptedParamMetadata,
) -> Self
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.
Sourcepub fn varchar(name: impl Into<String>, value: &str) -> Self
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.
Sourcepub fn varchar_with_collation(
name: impl Into<String>,
value: &str,
collation: &Collation,
) -> Self
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.