pub trait Query {
type QueryIterator: Iterator<Item = Result<Fact, StorageError>>;
// Required methods
fn query(
&self,
name: &str,
keys: &[Box<[u8]>],
) -> Result<Option<Box<[u8]>>, StorageError>;
fn query_prefix(
&self,
name: &str,
prefix: &[Box<[u8]>],
) -> Result<Self::QueryIterator, StorageError>;
}Expand description
Can be queried to look up facts.
Facts are labeled by a name, which are generally a bounded set of human-readable strings determined in advance.
Within a name, facts are an association of compound keys to values. The facts are keyed by a compound key
(k_1, k_2, ..., k_n), where each k is a sequence of bytes. The fact value is also a sequence of bytes.
Required Associated Types§
Sourcetype QueryIterator: Iterator<Item = Result<Fact, StorageError>>
type QueryIterator: Iterator<Item = Result<Fact, StorageError>>
Iterator for Query::query_prefix.
Required Methods§
Sourcefn query(
&self,
name: &str,
keys: &[Box<[u8]>],
) -> Result<Option<Box<[u8]>>, StorageError>
fn query( &self, name: &str, keys: &[Box<[u8]>], ) -> Result<Option<Box<[u8]>>, StorageError>
Look up a named fact by an exact match of the compound key.
Sourcefn query_prefix(
&self,
name: &str,
prefix: &[Box<[u8]>],
) -> Result<Self::QueryIterator, StorageError>
fn query_prefix( &self, name: &str, prefix: &[Box<[u8]>], ) -> Result<Self::QueryIterator, StorageError>
Look up all named facts that begin with the prefix of keys, in sorted key order.
The prefix is a partial compound key (k_1, k_2, ..., k_n), where each k is a sequence of bytes.
This returns all facts under the name with keys such that prefix is equal to a prefix of the fact’s keys.