pub struct Params<'a> { /* private fields */ }Expand description
An owned, finalized OSSL_PARAM array.
Created by ParamBuilder::build(). The lifetime 'a covers any borrowed
byte or string slices stored by pointer (zero-copy push calls).
Implementations§
Source§impl Params<'_>
impl Params<'_>
Sourcepub fn as_ptr(&self) -> *const OSSL_PARAM
pub fn as_ptr(&self) -> *const OSSL_PARAM
Return a const pointer to the first OSSL_PARAM in the array.
Pass this pointer to OpenSSL functions that take const OSSL_PARAM[].
The pointer is valid for the lifetime of self.
Source§impl Params<'_>
impl Params<'_>
Sourcepub unsafe fn from_owned_ptr(ptr: *mut OSSL_PARAM) -> Params<'static>
pub unsafe fn from_owned_ptr(ptr: *mut OSSL_PARAM) -> Params<'static>
Adopt an OpenSSL-allocated OSSL_PARAM array, taking ownership.
The array will be freed with OSSL_PARAM_free on drop. Use this to
wrap arrays returned by functions such as EVP_PKEY_todata.
§Safety
ptr must be a valid, OSSL_PARAM_END-terminated array allocated by
OpenSSL. After this call the caller must not use or free ptr.
Sourcepub fn as_mut_ptr(&mut self) -> *mut OSSL_PARAM
pub fn as_mut_ptr(&mut self) -> *mut OSSL_PARAM
Return a mutable pointer to the first OSSL_PARAM element.
Pass to functions such as EVP_PKEY_get_params that fill a
pre-prepared query array.
Sourcepub fn has_param(&self, key: &CStr) -> bool
pub fn has_param(&self, key: &CStr) -> bool
Return true if a parameter with the given name exists in this array.
Sourcepub fn get_int(&self, key: &CStr) -> Result<i32, ErrorStack>
pub fn get_int(&self, key: &CStr) -> Result<i32, ErrorStack>
Locate key and read its value as an i32.
§Errors
Returns Err if the key is not found or the value cannot be converted.
Sourcepub fn get_uint(&self, key: &CStr) -> Result<u32, ErrorStack>
pub fn get_uint(&self, key: &CStr) -> Result<u32, ErrorStack>
Locate key and read its value as a u32.
§Errors
Sourcepub fn get_size_t(&self, key: &CStr) -> Result<usize, ErrorStack>
pub fn get_size_t(&self, key: &CStr) -> Result<usize, ErrorStack>
Locate key and read its value as a usize.
§Errors
Sourcepub fn get_i64(&self, key: &CStr) -> Result<i64, ErrorStack>
pub fn get_i64(&self, key: &CStr) -> Result<i64, ErrorStack>
Locate key and read its value as an i64.
§Errors
Sourcepub fn get_u64(&self, key: &CStr) -> Result<u64, ErrorStack>
pub fn get_u64(&self, key: &CStr) -> Result<u64, ErrorStack>
Locate key and read its value as a u64.
§Errors
Sourcepub fn get_bn(&self, key: &CStr) -> Result<Vec<u8>, ErrorStack>
pub fn get_bn(&self, key: &CStr) -> Result<Vec<u8>, ErrorStack>
Locate key and read it as BIGNUM, returning big-endian bytes.
§Errors
Returns Err if the key is not found or is not a BIGNUM parameter.
Sourcepub fn get_octet_string(&self, key: &CStr) -> Result<&[u8], ErrorStack>
pub fn get_octet_string(&self, key: &CStr) -> Result<&[u8], ErrorStack>
Locate key and return a borrowed slice of its octet-string data.
The returned slice is valid for the lifetime of self.
§Errors
Sourcepub fn get_utf8_string(&self, key: &CStr) -> Result<&CStr, ErrorStack>
pub fn get_utf8_string(&self, key: &CStr) -> Result<&CStr, ErrorStack>
Locate key and return a borrowed CStr of its UTF-8 string data.
The returned reference is valid for the lifetime of self.
§Errors
Sourcepub fn set_int(&mut self, key: &CStr, val: i32) -> Result<(), ErrorStack>
pub fn set_int(&mut self, key: &CStr, val: i32) -> Result<(), ErrorStack>
Locate key and overwrite its value in place with a new i32.
The Params array must have been built with ParamBuilder::push_int for
this key so that the element already has storage of the right type and size.
This is useful after a get_params call to propagate changes back, or to
update a query template before re-issuing it.
§Errors
Returns Err if the key is not found or the type is incompatible.
Sourcepub fn get_long(&self, key: &CStr) -> Result<i64, ErrorStack>
pub fn get_long(&self, key: &CStr) -> Result<i64, ErrorStack>
Locate key and read its value as an i64.
Wraps OSSL_PARAM_get_long. On LP64 platforms (Linux x86-64) C long
is 64 bits; on LLP64 platforms (Windows) it is 32 bits. The result is
always widened to i64.
§Errors
Returns Err if the key is not found or the value cannot be converted.
Sourcepub fn was_modified(&self, key: &CStr) -> bool
pub fn was_modified(&self, key: &CStr) -> bool
Return true if the parameter named key has been populated by a
get_params call (i.e. OSSL_PARAM_modified returns 1).
Returns false if the key does not exist in the array or has not been
written by OpenSSL yet. This is typically used after passing a query
array to EVP_PKEY_get_params or similar to confirm that a particular
field was actually filled.