pub struct Schema { /* private fields */ }
Expand description
Represents a set of attributes that are stored with an item.
These schemas are used for interoperability between various services storing the same types of items.
Each schema has a name like org.gnome.keyring.NetworkPassword
, and defines a
set of attributes, and types (string, integer, boolean) for those attributes.
Attributes are stored as strings in the Secret Service, and the attribute types
simply define standard ways to store integer and boolean values as strings.
Attributes are represented in libsecret via a [glib::HashTable
][crate::glib::HashTable] with
string keys and values. Even for values that defined as an integer or boolean in
the schema, the attribute values in the [glib::HashTable
][crate::glib::HashTable] are strings.
Boolean values are stored as the strings ‘true’ and ‘false’. Integer values are
stored in decimal, with a preceding negative sign for negative integers.
Schemas are handled entirely on the client side by this library. The name of the schema is automatically stored as an attribute on the item.
Normally when looking up passwords only those with matching schema names are
returned. If the schema @flags contain the SECRET_SCHEMA_DONT_MATCH_NAME
flag,
then lookups will not check that the schema name matches that on the item, only
the schema’s attributes are matched. This is useful when you are looking up
items that are not stored by the libsecret library. Other libraries such as
libgnome-keyring don’t store the schema name.
Additional schemas can be defined via the Schema
structure like this:
⚠️ The following code is in c ⚠️
// in a header:
const SecretSchema * example_get_schema (void) G_GNUC_CONST;
#define EXAMPLE_SCHEMA example_get_schema ()
// in a .c file
const SecretSchema *
example_get_schema (void)
{
static const SecretSchema the_schema = {
"org.example.Password", SECRET_SCHEMA_NONE,
{
{ "number", SECRET_SCHEMA_ATTRIBUTE_INTEGER },
{ "string", SECRET_SCHEMA_ATTRIBUTE_STRING },
{ "even", SECRET_SCHEMA_ATTRIBUTE_BOOLEAN },
{ NULL, 0 },
}
};
return &the_schema;
}
GLib type: Shared boxed type with reference counted clone semantics.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn as_ptr(&self) -> *mut SecretSchema
pub fn as_ptr(&self) -> *mut SecretSchema
Return the inner pointer to the underlying C value.
Sourcepub unsafe fn from_glib_ptr_borrow(ptr: &*mut SecretSchema) -> &Self
pub unsafe fn from_glib_ptr_borrow(ptr: &*mut SecretSchema) -> &Self
Borrows the underlying C value.
Source§impl Schema
impl Schema
Sourcepub fn new(
name: &str,
flags: SchemaFlags,
attribute_names_and_types: HashMap<&str, SchemaAttributeType>,
) -> Self
pub fn new( name: &str, flags: SchemaFlags, attribute_names_and_types: HashMap<&str, SchemaAttributeType>, ) -> Self
Using this function is not normally necessary from C code. This is useful for constructing #SecretSchema structures in bindings.
A schema represents a set of attributes that are stored with an item. These schemas are used for interoperability between various services storing the same types of items.
Each schema has an @name like org.gnome.keyring.NetworkPassword
, and
defines a set of attributes names, and types (string, integer, boolean) for
those attributes.
Each key in the @attributes table should be a attribute name strings, and
the values in the table should be integers from the SchemaAttributeType
enumeration, representing the attribute type for each attribute name.
Normally when looking up passwords only those with matching schema names are
returned. If the schema @flags contain the SchemaFlags::DONT_MATCH_NAME
flag,
then lookups will not check that the schema name matches that on the item, only
the schema’s attributes are matched. This is useful when you are looking up items
that are not stored by the libsecret library. Other libraries such as libgnome-keyring
don’t store the schema name.
§name
the dotted name of the schema
§flags
the flags for the schema
§attribute_names_and_types
the attribute names and types of those attributes
§Returns
the new schema, which should be unreferenced with
Schema::unref()
when done
Trait Implementations§
Source§impl Ord for Schema
impl Ord for Schema
Source§impl PartialOrd for Schema
impl PartialOrd for Schema
Source§impl StaticType for Schema
impl StaticType for Schema
Source§fn static_type() -> Type
fn static_type() -> Type
Self
.