Skip to main content

Params

Struct Params 

Source
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<'_>

Source

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<'_>

Source

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.

Source

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.

Source

pub fn has_param(&self, key: &CStr) -> bool

Return true if a parameter with the given name exists in this array.

Source

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.

Source

pub fn get_uint(&self, key: &CStr) -> Result<u32, ErrorStack>

Locate key and read its value as a u32.

§Errors
Source

pub fn get_size_t(&self, key: &CStr) -> Result<usize, ErrorStack>

Locate key and read its value as a usize.

§Errors
Source

pub fn get_i64(&self, key: &CStr) -> Result<i64, ErrorStack>

Locate key and read its value as an i64.

§Errors
Source

pub fn get_u64(&self, key: &CStr) -> Result<u64, ErrorStack>

Locate key and read its value as a u64.

§Errors
Source

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.

Source

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
Source

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
Source

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.

Source

pub fn set_uint(&mut self, key: &CStr, val: u32) -> Result<(), ErrorStack>

Locate key and overwrite its value in place with a new u32.

See set_int for usage notes.

§Errors

Returns Err if the key is not found or the type is incompatible.

Source

pub fn set_size(&mut self, key: &CStr, val: usize) -> Result<(), ErrorStack>

Locate key and overwrite its value in place with a new usize.

See set_int for usage notes.

§Errors

Returns Err if the key is not found or the type is incompatible.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Drop for Params<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Params<'_>

Source§

impl Sync for Params<'_>

Auto Trait Implementations§

§

impl<'a> Freeze for Params<'a>

§

impl<'a> RefUnwindSafe for Params<'a>

§

impl<'a> Unpin for Params<'a>

§

impl<'a> UnsafeUnpin for Params<'a>

§

impl<'a> UnwindSafe for Params<'a>

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> 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, 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.