Skip to main content

PolicyBuilder

Struct PolicyBuilder 

Source
pub struct PolicyBuilder { /* private fields */ }
Expand description

Build a PolicySnapshot from config + models with validation.

use calybris_core::builder::{PolicyBuilder, ModelBuilder};
use calybris_core::config::EngineConfig;

let snapshot = PolicyBuilder::new(EngineConfig::new())
    .epochs(1, 1)
    .model(ModelBuilder::new(1, 0).quality(9000).cost(250, 1000).build())
    .model(ModelBuilder::new(2, 1).quality(7000).cost(25, 125).build())
    .build()
    .unwrap();

assert_eq!(snapshot.models().len(), 2);

Implementations§

Source§

impl PolicyBuilder

Source

pub fn new(config: EngineConfig) -> Self

Start building a policy from an crate::config::EngineConfig.

Source

pub fn epochs(self, policy: u64, catalog: u64) -> Self

Set policy and catalog epochs.

Source

pub fn model(self, model: KernelModel) -> Self

Add a model to the catalog.

Source

pub fn models(self, models: impl IntoIterator<Item = KernelModel>) -> Self

Add multiple models.

Source

pub fn build(self) -> Result<PolicySnapshot, BuildError>

Build and validate the snapshot.

Validates config, enforces max_catalog_size, then delegates to PolicySnapshot::try_new_trusted for canonical trust-boundary validation.

Source

pub fn build_trusted(self) -> Result<PolicySnapshot, TrustedBuildError>

Build with precise trust-boundary error reporting.

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> 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> Same for T

Source§

type Output = T

Should always be Self
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, <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.