Skip to main content

BoundaryRequest

Struct BoundaryRequest 

Source
pub struct BoundaryRequest {
    pub at: SimTime,
    pub cadences: Vec<SystemCadence>,
}

Fields§

§at: SimTime§cadences: Vec<SystemCadence>

Implementations§

Source§

impl BoundaryRequest

Source

pub const fn at(at: SimTime) -> BoundaryRequest

Examples found in repository?
examples/phased_boundary.rs (line 155)
149fn main() -> Result<(), CanwuError> {
150    let mut canwu = Canwu::demo(35)?;
151    canwu.register_plugin(&SupplyPlugin)?;
152    canwu.register_plugin(&DemandPlugin)?;
153
154    let receipt = canwu
155        .settle_boundary(BoundaryRequest::at(canwu.time()).with_cadence(SystemCadence::Daily))?;
156    assert_eq!(receipt.allocations[0].granted, 6);
157    assert_eq!(canwu.boundaries()[0].emissions.len(), 2);
158    Ok(())
159}
More examples
Hide additional examples
examples/governance_transition.rs (line 564)
549fn main() -> Result<(), CanwuError> {
550    let central = CentralPlugin;
551    let treasury = TreasuryPlugin;
552    let county = CountyPlugin;
553    let plugins: [&dyn SimulationPlugin; 3] = [&central, &treasury, &county];
554    let mut canwu =
555        Canwu::new_with_plugins(11, Scenario::new(SimTime::EPOCH, Vec::new()), &plugins)?;
556
557    canwu.enqueue_plugin_ingress(canwu_api::PluginIngressRequest::new(
558        CENTRAL_PLUGIN,
559        ISSUE_INGRESS,
560        SimTime::EPOCH,
561        json!({"order_id": ORDER_ID}),
562    ))?;
563
564    let first = canwu.settle_boundary(BoundaryRequest::at(SimTime::EPOCH))?;
565    assert_eq!(first.generated_ingress.len(), 2);
566    assert!(canwu.typed_domain_record(&order_reference()).is_some());
567    assert!(canwu.typed_domain_record(&treasury_reference()).is_none());
568    assert!(canwu.typed_domain_record(&county_reference()).is_none());
569
570    let second = canwu.settle_boundary(BoundaryRequest::at(SimTime::EPOCH))?;
571    assert_eq!(second.record_change_count, 2);
572    assert!(canwu.typed_domain_record(&treasury_reference()).is_some());
573    assert!(canwu.typed_domain_record(&county_reference()).is_some());
574
575    let snapshot = canwu.snapshot_json()?;
576    let restored = Canwu::from_snapshot_json_with_plugins(&snapshot, &plugins)?;
577    let replayed = Canwu::replay_from_journal(&plugins, &canwu.replay_journal())?;
578    assert_eq!(restored.snapshot(), canwu.snapshot());
579    assert_eq!(replayed.snapshot(), canwu.snapshot());
580
581    println!(
582        "relief_order={} treasury_grain={} county_grain={} exact_replay=ok",
583        ORDER_ID, 600, 600
584    );
585    Ok(())
586}
examples/uncertainty_resolution.rs (line 144)
96fn enqueue_ticket(
97    canwu: &mut Canwu,
98    ticket_id: DecisionTicketId,
99    request_offset: u64,
100    controller: DecisionControllerBinding,
101) -> Result<(), CanwuError> {
102    let now = canwu.time();
103    let controller_id = controller.id.clone();
104    canwu.enqueue_decision(
105        now,
106        0,
107        DecisionIngressRequest::new(
108            DecisionRequestId::new(request_offset),
109            canwu.revision(),
110            DecisionMutation::RegisterController { controller },
111        ),
112    )?;
113    canwu.enqueue_decision(
114        now,
115        0,
116        DecisionIngressRequest::new(
117            DecisionRequestId::new(request_offset + 1),
118            canwu.revision(),
119            DecisionMutation::Open {
120                ticket: DecisionTicketDraft {
121                    id: ticket_id,
122                    definition: "example.law-passage".to_owned(),
123                    decision_maker: EntityRef::Person(Canwu::demo_ids().commander),
124                    assigned_controller: controller_id,
125                    summary: "Will the proposed law pass?".to_owned(),
126                    context: DecisionContext::new(
127                        "example.law-passage.v1",
128                        json!({
129                            "supporting_seats": 72,
130                            "opposing_seats": 28,
131                            "public_pressure": "high"
132                        }),
133                    ),
134                    options: vec![
135                        DecisionOption::new("pass", "Pass the law"),
136                        DecisionOption::new("fail", "Reject the law"),
137                    ],
138                    deadline: None,
139                    parent_ticket: None,
140                },
141            },
142        ),
143    )?;
144    canwu.settle_boundary(canwu_api::BoundaryRequest::at(now))?;
145    Ok(())
146}
Source

pub fn with_cadence(self, cadence: SystemCadence) -> BoundaryRequest

Examples found in repository?
examples/phased_boundary.rs (line 155)
149fn main() -> Result<(), CanwuError> {
150    let mut canwu = Canwu::demo(35)?;
151    canwu.register_plugin(&SupplyPlugin)?;
152    canwu.register_plugin(&DemandPlugin)?;
153
154    let receipt = canwu
155        .settle_boundary(BoundaryRequest::at(canwu.time()).with_cadence(SystemCadence::Daily))?;
156    assert_eq!(receipt.allocations[0].granted, 6);
157    assert_eq!(canwu.boundaries()[0].emissions.len(), 2);
158    Ok(())
159}

Trait Implementations§

Source§

impl Clone for BoundaryRequest

Source§

fn clone(&self) -> BoundaryRequest

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 BoundaryRequest

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BoundaryRequest

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<BoundaryRequest, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for BoundaryRequest

Source§

impl PartialEq for BoundaryRequest

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for BoundaryRequest

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for BoundaryRequest

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> 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.