pub struct Scenario {
pub start_time: SimTime,
pub entities: Vec<EntityRef>,
pub world: WorldSnapshot,
pub knowledge: KnowledgeSnapshot,
pub domain_records: Vec<DomainRecord>,
}Fields§
§start_time: SimTime§entities: Vec<EntityRef>§world: WorldSnapshot§knowledge: KnowledgeSnapshot§domain_records: Vec<DomainRecord>Implementations§
Source§impl Scenario
impl Scenario
Sourcepub fn new(start_time: SimTime, entities: Vec<EntityRef>) -> Scenario
pub fn new(start_time: SimTime, entities: Vec<EntityRef>) -> Scenario
Examples found in repository?
examples/governance_transition.rs (line 555)
549fn main() -> Result<(), CanwuError> {
550 let central = CentralPlugin;
551 let treasury = TreasuryPlugin;
552 let county = CountyPlugin;
553 let plugins: [&dyn SimulationPlugin; 3] = [¢ral, &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}pub fn with_domain_records(self, domain_records: Vec<DomainRecord>) -> Scenario
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Scenario
impl<'de> Deserialize<'de> for Scenario
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Scenario, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Scenario, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Scenario
impl Serialize for Scenario
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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
impl StructuralPartialEq for Scenario
Auto Trait Implementations§
impl Freeze for Scenario
impl RefUnwindSafe for Scenario
impl Send for Scenario
impl Sync for Scenario
impl Unpin for Scenario
impl UnsafeUnpin for Scenario
impl UnwindSafe for Scenario
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more