pub trait RootResolver: Send + Sync {
// Required methods
fn resolve<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Cid>, ResolverError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn subscribe<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Option<Cid>>, ResolverError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
// Provided methods
fn resolve_shared<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
share_secret: &'life2 [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<Option<Cid>, ResolverError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait { ... }
fn publish<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
cid: &'life2 Cid,
) -> Pin<Box<dyn Future<Output = Result<bool, ResolverError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait { ... }
fn publish_shared<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
key: &'life1 str,
cid: &'life2 Cid,
share_secret: &'life3 [u8; 32],
) -> Pin<Box<dyn Future<Output = Result<bool, ResolverError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Self: 'async_trait { ... }
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ResolverEntry>, ResolverError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
fn subscribe_list<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Vec<ResolverEntry>>, ResolverError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait { ... }
fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), ResolverError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait { ... }
}Expand description
RootResolver - Maps human-readable keys to content identifiers (Cid)
This abstraction allows different backends (Nostr, DNS, HTTP, local storage) to provide mutable pointers to immutable content-addressed data.
The Cid contains:
- hash: content hash (always present)
- key: optional decryption key (for CHK encrypted content)
- size: content size
Unlike the TypeScript version which uses callbacks, this Rust version uses channels which are more idiomatic for async Rust.
Required Methods§
Sourcefn resolve<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Cid>, ResolverError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn resolve<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Cid>, ResolverError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Resolve a key to its current Cid (one-shot)
Returns None if the key doesn’t exist or can’t be resolved. For shared content, pass the share_secret to decrypt the encrypted_key.
Sourcefn subscribe<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Option<Cid>>, ResolverError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn subscribe<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Option<Cid>>, ResolverError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Subscribe to Cid changes for a key.
Returns a channel receiver that will receive the current value immediately, then subsequent updates. The channel is closed when the subscription ends.
To unsubscribe, simply drop the receiver.
Provided Methods§
Resolve with a share secret (for encrypted_key decryption)
Sourcefn publish<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
cid: &'life2 Cid,
) -> Pin<Box<dyn Future<Output = Result<bool, ResolverError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn publish<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
cid: &'life2 Cid,
) -> Pin<Box<dyn Future<Output = Result<bool, ResolverError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Publish/update a Cid (optional - only for writable backends)
Returns true if published successfully.
Publish with encrypted key for sharing
The key is encrypted with share_secret, allowing anyone with the secret to decrypt.
Sourcefn list<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ResolverEntry>, ResolverError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ResolverEntry>, ResolverError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
List all keys matching a prefix (one-shot)
Returns array of matching keys with their current Cids.
Sourcefn subscribe_list<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Vec<ResolverEntry>>, ResolverError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn subscribe_list<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Vec<ResolverEntry>>, ResolverError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Subscribe to list changes for a prefix.
Returns a channel receiver that will receive the current list immediately, then the full updated list on each add/remove/update.