MARS documentation
Rust librariesmars-shard

mars-shard · resolution

Public declarations and documentation for mars-shard::resolution.

Prototype / draft — separate from production registry operations.

Package: mars-shard · Workspace version: 0.1.0 · Module: resolution

Status: prototype / draft. This is not the production registry topology.

This reference follows declared modules and public syntax, including public implementation methods. Function bodies and constant values are omitted. Feature conditions are retained. Private-module re-exports and trait resolution require the compiler; not every declaration is a root import.

resolution::CachedEntry

A cached resolution result for a DID.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CachedEntry {
/// The DID that was resolved.

pub did: String,
/// Content hash of the full entry in the shard.

pub content_hash: String,
/// The shard that holds the full entry.

pub shard_id: String,
/// Unix timestamp (seconds) when this was cached.

pub cached_at: u64,
/// Time-to-live in seconds.

pub ttl: u64
}

Source line: 23.

resolution::CachedEntry::is_expired

Returns true if this cache entry has expired given the current time.

pub fn is_expired(&self, now: u64) -> bool;

Source line: 38.

resolution::ResolutionResult

Outcome of a three-hop resolution.

#[derive(Debug, Clone, PartialEq)]
pub enum ResolutionResult {
    /// Found in the local cache.
    CacheHit(CachedEntry),
    /// Found by querying the primary shard.
    ShardHit {
        shard_id: String,
        content_hash: String,
    },
    /// Found by querying GAL, then the assigned shard.
    GalLookup {
        shard_id: String,
        content_hash: String,
    },
    /// DID not found at any hop.
    NotFound,
    /// DID has been revoked.
    Revoked(RevocationRecord),
}

Source line: 49.

resolution::ResolutionCache

In-memory cache for resolved DIDs with TTL eviction.

pub struct ResolutionCache {

}

Source line: 73.

resolution::ResolutionCache::new

Create a new cache with the given capacity and default TTL.

pub fn new(max_entries: usize, default_ttl: u64) -> Self;

Source line: 81.

resolution::ResolutionCache::get

Look up a DID in the cache. Returns None if missing or expired.

pub fn get(&self, did: &str, now: u64) -> Option<&CachedEntry>;

Source line: 90.

resolution::ResolutionCache::put

Insert an entry into the cache. If the cache is full, evict expired entries first, then the oldest entry if still at capacity.

pub fn put(&mut self, entry: CachedEntry);

Source line: 96.

resolution::ResolutionCache::invalidate

Invalidate (remove) a specific DID from the cache.

pub fn invalidate(&mut self, did: &str);

Source line: 104.

resolution::ResolutionCache::stats

Returns (current_entries, max_entries).

pub fn stats(&self) -> (usize, usize);

Source line: 109.

resolution::ResolutionCache::default_ttl

Returns the default TTL in seconds.

pub fn default_ttl(&self) -> u64;

Source line: 114.

resolution::Resolver

Three-hop DID resolver with cache and topology awareness.

The resolver holds a local cache and a reference to the shard topology. Actual shard I/O is simulated via the registered shard data and GAL data maps.

pub struct Resolver {

}

Source line: 154.

resolution::Resolver::new

Create a new resolver with the given cache parameters.

pub fn new(cache_size: usize, cache_ttl: u64) -> Self;

Source line: 166.

resolution::Resolver::register_shard_entry

Register shard data for testing/simulation.

pub fn register_shard_entry(&mut self, shard_id: &str, did: &str, content_hash: &str);

Source line: 176.

resolution::Resolver::register_gal_entry

Register GAL data for testing/simulation.

pub fn register_gal_entry(&mut self, did: &str, shard_id: &str, content_hash: &str);

Source line: 184.

resolution::Resolver::register_revocation

Register a revocation.

pub fn register_revocation(&mut self, record: RevocationRecord);

Source line: 192.

resolution::Resolver::resolve

Three-hop resolution:

  1. Check local cache -> if found and not expired, return CacheHit.
  2. Query primary shard -> if found, cache and return ShardHit.
  3. Query GAL on-chain -> get shard assignment, query that shard.

At ANY hop: if revocation found, abort immediately with Revoked.

pub fn resolve(&mut self, did: &str, now: u64) -> ResolutionResult;

Source line: 203.

resolution::Resolver::cache_entry

Directly cache an entry (for pre-warming).

pub fn cache_entry(&mut self, entry: CachedEntry);

Source line: 251.

resolution::Resolver::invalidate

Invalidate a cached DID.

pub fn invalidate(&mut self, did: &str);

Source line: 256.

resolution::Resolver::cache_stats

Returns cache statistics.

pub fn cache_stats(&self) -> (usize, usize);

Source line: 261.

Source provenance

Source: mars-shard/src/resolution.rs · SHA-256 1b3e6d2f417b2462ffac928e855ab1a5540beecff337f32908ce613b7f5ef3a3. Package overview.

On this page