pub struct Value { /* private fields */ }
Expand description
A value containing a secret
A #SecretValue contains a password or other secret value.
Use get()
to get the actual secret data, such as a password.
The secret data is not necessarily null-terminated, unless the content type
is “text/plain”.
Each #SecretValue has a content type. For passwords, this is text/plain
.
Use content_type()
to look at the content type.
#SecretValue is reference counted and immutable. The secret data is only
freed when all references have been released via Value::unref()
.
GLib type: Shared boxed type with reference counted clone semantics.
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_ptr(&self) -> *mut SecretValue
pub fn as_ptr(&self) -> *mut SecretValue
Return the inner pointer to the underlying C value.
Sourcepub unsafe fn from_glib_ptr_borrow(ptr: &*mut SecretValue) -> &Self
pub unsafe fn from_glib_ptr_borrow(ptr: &*mut SecretValue) -> &Self
Borrows the underlying C value.
Source§impl Value
impl Value
Sourcepub fn new(secret: &str, content_type: &str) -> Value
pub fn new(secret: &str, content_type: &str) -> Value
Create a #SecretValue for the secret data passed in.
The secret data is copied into non-pageable ‘secure’ memory.
If the length is less than zero, then @secret is assumed to be null-terminated.
§secret
the secret data
§length
the length of the data
§content_type
the content type of the data
§Returns
the new #SecretValue
Sourcepub fn get(&self) -> Vec<u8> ⓘ
pub fn get(&self) -> Vec<u8> ⓘ
Get the secret data in the #SecretValue.
The value is not necessarily null-terminated unless it was created with
Value::new()
or a null-terminated string was passed to
Value::new_full()
.
§Returns
the secret data
Sourcepub fn content_type(&self) -> GString
pub fn content_type(&self) -> GString
Sourcepub fn text(&self) -> Option<GString>
pub fn text(&self) -> Option<GString>
Get the secret data in the #SecretValue if it contains a textual value.
The content type must be text/plain
.
§Returns
the content type