pub trait HasPolicy: Sized {
    type Iterator: Iterator<Item = (AttributeTag, AttributeValue)>;

    // Required methods
    fn identity_provider(&self) -> IdentityProvider;
    fn created_at(&self) -> Timestamp;
    fn valid_to(&self) -> Timestamp;
    fn next_item(&mut self, buf: &mut [u8; 31]) -> Option<(AttributeTag, u8)>;
    fn attributes(&self) -> Self::Iterator;
}
Expand description

A type which has access to a policy of a credential. Since policies can be large this is deliberately written in a relatively low-level style to enable efficient traversal of all the attributes without any allocations.

Required Associated Types§

Required Methods§

source

fn identity_provider(&self) -> IdentityProvider

Identity provider who signed the identity object the credential is derived from.

source

fn created_at(&self) -> Timestamp

Beginning of the month in milliseconds since unix epoch when the credential was created.

source

fn valid_to(&self) -> Timestamp

Beginning of the month where the credential is no longer valid, in milliseconds since unix epoch.

source

fn next_item(&mut self, buf: &mut [u8; 31]) -> Option<(AttributeTag, u8)>

Get the next attribute, storing it in the provided buffer. The return value, if Some, is a pair of an attribute tag, and the length, n of the attribute value. In this case, the attribute value is written in the first n bytes of the provided buffer. The rest of the buffer is unchanged.

The reason this function is added here, and we don’t simply implement an Iterator for this type is that with the supplied buffer we can iterate through the elements more efficiently, without any allocations, the consumer being responsible for allocating the buffer.

source

fn attributes(&self) -> Self::Iterator

Get an iterator over all the attributes of the policy.

Implementors§