Skip to main content

CurveRecipes

Struct CurveRecipes 

pub struct CurveRecipes {
    overlay: HashMap<RecipeKey, CurveRecipe>,
    auto_triangulate: bool,
}
Expand description

A resolver layering user overrides over the immutable default base.

A book holds only the overlay; the defaults are resolved live from the immutable base (recipe_for), so every book shares the one base copy and an override never mutates it. resolve returns overlay ▸ base ▸ absence.

Fields§

§overlay: HashMap<RecipeKey, CurveRecipe>§auto_triangulate: bool

Opt-in: synthesize triangulated recipes for unresolved cross keys whose triangle closes through exactly one hub (see derive_recipe).

Implementations§

§

impl CurveRecipes

pub fn overrides(&self, key: &CollateralSpec) -> bool

Whether the overlay — not the shipped base — holds a recipe for key.

pub fn insert_spec(&mut self, spec: &RecipeSpec) -> Result<(), RecipeSpecError>

Converts spec and inserts it under its key, as insert would a built recipe.

§Errors

RecipeSpecError naming the key, from the builder or the book.

§

impl CurveRecipes

pub fn with_defaults() -> Self

A book seeded from the immutable base: the overlay starts empty and every key falls through to the base until overridden.

pub fn auto_triangulate(&self) -> bool

Whether this book synthesizes triangulated recipes for unresolved cross keys.

pub fn insert( &mut self, key: CollateralSpec, recipe: CurveRecipe, ) -> Result<(), CrossRecipeError>

Adds an overlay entry for key, shadowing any default. The base is untouched: another book created with defaults still resolves key to the original default.

A recipe stored under a cross key (cashflow ≠ collateral) MUST be projection-free (no own-forward entries, no telescoping entries) and policy-free (no policy path, no explicit window) — see CrossRecipeError. Rejection leaves the book unchanged.

§Errors

CrossRecipeError::Projection naming the key and the offending index when a cross-keyed recipe carries a projection entry, and the step variant when it carries a policy path or a window. Either way the book is left as it was.

pub fn resolve(&self, key: &CollateralSpec) -> Option<CurveRecipe>

The effective recipe for key: the overlay entry if present, otherwise the base default, otherwise None (the caller fails loud by key name).

fn validate_triangulated( &self, key: &CollateralSpec, via: &str, recipe: &CurveRecipe, ) -> Result<(), CrossRecipeError>

Validates a triangulated declaration against this book: cross key only, non-degenerate via, no leftover segments, and all three source keys — {collateral, collateral}, {cashflow, via}, {collateral, via} — effective and themselves non-triangulated (one hop only).

pub fn closing_hubs(&self, key: &CollateralSpec) -> Vec<String>

The hubs X whose three source keys — {collateral, collateral}, {cashflow, X}, {collateral, X} — all resolve in this book to non-triangulated recipes: the candidate via currencies for deriving key. Sorted; excludes the key’s own currencies. Independent of the auto_triangulate switch.

pub fn derive_recipe( &self, key: &CollateralSpec, ) -> Result<Option<CurveRecipe>, TriangulatedRecipeError>

The triangulated recipe this book would synthesize for an unresolved cross key: Some when exactly one hub closes the triangle, None when the key is own-collateral, already resolves, or no hub closes it.

§Errors

AmbiguousHub naming the candidates when more than one hub closes the triangle. Choosing between distinct basis markets is the caller’s, so the ambiguity is reported rather than resolved.

pub fn derivable_keys(&self) -> Vec<(CollateralSpec, Vec<String>)>

Every unresolved cross key this book could triangulate, with its closing hubs — one hub means derive_recipe would synthesize it, several mean it needs explicit disambiguation. Enumerates the cross product of currencies appearing in effective keys; derives nothing. Sorted by (cashflow, collateral).

fn effective_currencies(&self) -> Vec<String>

Every currency code appearing in an effective key, deduplicated and unsorted. A key naming no currency pair contributes nothing.

pub fn effective_keys(&self) -> Vec<RecipeKey> ⓘ

The effective collateral keys this book can resolve: the de-duplicated union of the immutable base registry keys (collaterals) and the overlay keys, sorted by (cashflow, collateral) so the order is deterministic. Every returned key resolves (via resolve) to a recipe — including from-scratch overlay keys absent from the base; an overridden base key appears exactly once. The overlay map itself is never exposed, only its keys.

Trait Implementations§

§

impl Clone for CurveRecipes

§

fn clone(&self) -> CurveRecipes

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
§

impl Debug for CurveRecipes

§

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

Formats the value using the given formatter. Read more
§

impl Default for CurveRecipes

§

fn default() -> CurveRecipes

Returns the “default value” for a type. Read more
§

impl Eq for CurveRecipes

§

impl PartialEq for CurveRecipes

§

fn eq(&self, other: &CurveRecipes) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl StructuralPartialEq for CurveRecipes

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, 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.