pub trait KeyVisitor {
    // Required methods
    fn visit_type(&mut self, kind: KeyKind);
    fn visit_composite(&mut self, kind: CompositeKind, count: usize);
    fn visit_composite_attribute(
        &mut self,
        key: impl Into<Cow<'static, str>>,
        value: impl Into<KeyAttibuteValue>
    );
}
Expand description

A Visitor for information about a KeyEncoding.

This trait is used in KeyEncoding::describe to report information about the type of data contained within the key. Using this information, generically interpreting the bytes of a key type can be possible as long as the key type uses CompositeKeyEncoder.

This trait is not something that most users will ever need to implement. Instead, KeyDescription::for_key()/KeyDescription::for_encoding() are built-in functions to retrieve the information reported by this trait in an easier-to-use interface.

Required Methods§

source

fn visit_type(&mut self, kind: KeyKind)

Report that a basic key type is encoded next in this key.

source

fn visit_composite(&mut self, kind: CompositeKind, count: usize)

Report that a composite type made up of count fields is encoded next in this key.

KeyVisitor implementations may panic if there are less than or more than count fields reported by either visit_type() or visit_composite().

source

fn visit_composite_attribute( &mut self, key: impl Into<Cow<'static, str>>, value: impl Into<KeyAttibuteValue> )

Report that the current composite type has extra metadata.

This can be used to encode const generic parameters that are helpful in interpretting the contents of a type. For example, LimitedResolutionTimestamp uses this function to report the TimeEpoch’s nanoseconds since the Unix epoch.

Implementors§