pub struct KeyHint {
pub pubkey: Option<PublicKey>,
pub name: Option<String>,
pub is_global: bool,
}Expand description
Key hint for resolving the signer
Contains explicit fields for each hint type. Exactly one hint field should be set. The hint is used to look up the actual public key in AuthSettings for signature verification.
Fields§
§pubkey: Option<PublicKey>Public key hint (e.g. Ed25519 verifying key)
name: Option<String>Name hint: “alice_laptop” - searches keys where name matches
is_global: boolWhether this hint refers to the global permission
Implementations§
Source§impl KeyHint
impl KeyHint
Sourcepub fn from_pubkey(pubkey: &PublicKey) -> Self
pub fn from_pubkey(pubkey: &PublicKey) -> Self
Create a hint from a public key
Sourcepub fn global(actual_pubkey: &PublicKey) -> Self
pub fn global(actual_pubkey: &PublicKey) -> Self
Create a global permission hint with actual signer pubkey
Sourcepub fn is_set(&self) -> bool
pub fn is_set(&self) -> bool
Check if any hint field is set
Returns true if at least one of pubkey, name, or is_global is set.
§Unsigned Entry Detection
This method is primarily used to detect unsigned entries during validation. An entry is considered unsigned when:
- The
SigKeyisDirectwith an empty hint (!hint.is_set()) - The signature field is
None
This allows databases to operate without authentication when no auth keys are configured, supporting both authenticated and unauthenticated use cases.
// Empty hint - represents an unsigned entry when combined with no signature
let empty = KeyHint::default();
assert!(!empty.is_set());
// Hint with pubkey - this entry requires signature verification
let pubkey = PrivateKey::generate().public_key();
let with_pubkey = KeyHint::from_pubkey(&pubkey);
assert!(with_pubkey.is_set());
// Hint with name only - also requires signature verification
let with_name = KeyHint::from_name("alice_laptop");
assert!(with_name.is_set());Trait Implementations§
Source§impl<'de> Deserialize<'de> for KeyHint
impl<'de> Deserialize<'de> for KeyHint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for KeyHint
impl StructuralPartialEq for KeyHint
Auto Trait Implementations§
impl Freeze for KeyHint
impl RefUnwindSafe for KeyHint
impl Send for KeyHint
impl Sync for KeyHint
impl Unpin for KeyHint
impl UnwindSafe for KeyHint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more