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: boolOpt-in: synthesize triangulated recipes for unresolved cross keys whose
triangle closes through exactly one hub (see derive_recipe).
Implementations§
§impl CurveRecipes
impl CurveRecipes
pub fn overrides(&self, key: &CollateralSpec) -> bool
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>
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
impl CurveRecipes
pub fn with_defaults() -> Self
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
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>
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>
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>
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>
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>
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>)>
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>
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> ⓘ
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
impl Clone for CurveRecipes
§fn clone(&self) -> CurveRecipes
fn clone(&self) -> CurveRecipes
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more