Skip to main content

ResolverConfig

Struct ResolverConfig 

Source
pub struct ResolverConfig {
    pub online_enabled: bool,
    pub namespace: Uuid,
    pub fuzzy_min_score: Option<f32>,
}
Expand description

Configuration for the crate::SimbadResolver facade.

Settings are supplied by the caller at construction; the library persists none of them.

use simbad_resolver::ResolverConfig;

// Namespaced by a fixed, application-specific seed so derived target ids
// stay stable across runs. See `SimbadResolver::new` for its full role.
let config = ResolverConfig::new("my-app.targets").with_fuzzy(0.6);
assert!(config.online_enabled);
assert_eq!(config.fuzzy_min_score, Some(0.6));

Fields§

§online_enabled: bool

Whether online resolution is attempted on a cache miss. When false, only the cache is consulted (offline mode).

§namespace: Uuid

The id namespace used to derive stable target ids from designations. Supply your own seed via ResolverConfig::new for id continuity.

§fuzzy_min_score: Option<f32>

Minimum token-set similarity (0.0..=1.0) for a fuzzy typeahead hit in crate::SimbadResolver::search. None (the default) disables fuzzy matching; exact/prefix/substring ranking is unaffected either way.

Implementations§

Source§

impl ResolverConfig

Source

pub fn new(namespace_seed: &str) -> Self

Build a config from an id-namespace seed (e.g. your app’s reverse-DNS name). Online resolution defaults to enabled.

use simbad_resolver::ResolverConfig;

let a = ResolverConfig::new("my-app.targets");
let b = ResolverConfig::new("my-app.targets");
assert!(a.online_enabled);
assert_eq!(a.namespace, b.namespace, "same seed derives the same namespace");
Source

pub fn with_online(self, online_enabled: bool) -> Self

Set whether online resolution is enabled.

use simbad_resolver::ResolverConfig;

let offline = ResolverConfig::new("x").with_online(false);
assert!(!offline.online_enabled);
Source

pub fn with_namespace(self, namespace: Uuid) -> Self

Use an explicit namespace UUID (rather than deriving it from a seed).

use simbad_resolver::ResolverConfig;
use uuid::Uuid;

let explicit = Uuid::from_u128(0x1234_5678_90ab_cdef_1234_5678_90ab_cdef);
let config = ResolverConfig::new("x").with_namespace(explicit);
assert_eq!(config.namespace, explicit);
Source

pub fn with_fuzzy(self, min_score: f32) -> Self

Enable fuzzy typeahead in crate::SimbadResolver::search: after exact/prefix/substring matches, remaining result slots are filled with hits whose token-set similarity to the query is at least min_score (clamped to 0.0..=1.0), in a crate::RANK_FUZZY tier. Off by default. Does not affect crate::SimbadResolver::resolve, which stays exact.

use simbad_resolver::ResolverConfig;

let config = ResolverConfig::new("x").with_fuzzy(2.0); // clamped to 1.0
assert_eq!(config.fuzzy_min_score, Some(1.0));

Trait Implementations§

Source§

impl Clone for ResolverConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResolverConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more