pub struct PluginIngressRequest {
pub plugin: String,
pub packet_type: String,
pub due_at: SimTime,
pub priority: i32,
pub payload: Value,
pub affected_entities: Vec<EntityRef>,
pub cause: Option<CauseRef>,
pub archive_retention: Vec<PluginArchiveRetention>,
}Fields§
§plugin: String§packet_type: String§due_at: SimTime§priority: i32§payload: Value§affected_entities: Vec<EntityRef>§cause: Option<CauseRef>§archive_retention: Vec<PluginArchiveRetention>Implementations§
Source§impl PluginIngressRequest
impl PluginIngressRequest
Sourcepub fn new(
plugin: impl Into<String>,
packet_type: impl Into<String>,
due_at: SimTime,
payload: Value,
) -> PluginIngressRequest
pub fn new( plugin: impl Into<String>, packet_type: impl Into<String>, due_at: SimTime, payload: Value, ) -> PluginIngressRequest
Examples found in repository?
examples/governance_transition.rs (lines 557-562)
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 const fn with_priority(self, priority: i32) -> PluginIngressRequest
pub fn with_entity(self, entity: EntityRef) -> PluginIngressRequest
pub fn caused_by(self, cause: CauseRef) -> PluginIngressRequest
pub fn with_archive_retention( self, retention: impl IntoIterator<Item = PluginArchiveRetention>, ) -> PluginIngressRequest
Trait Implementations§
Source§impl Clone for PluginIngressRequest
impl Clone for PluginIngressRequest
Source§fn clone(&self) -> PluginIngressRequest
fn clone(&self) -> PluginIngressRequest
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PluginIngressRequest
impl Debug for PluginIngressRequest
Source§impl<'de> Deserialize<'de> for PluginIngressRequest
impl<'de> Deserialize<'de> for PluginIngressRequest
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PluginIngressRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PluginIngressRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for PluginIngressRequest
impl PartialEq for PluginIngressRequest
Source§impl Serialize for PluginIngressRequest
impl Serialize for PluginIngressRequest
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 PluginIngressRequest
Auto Trait Implementations§
impl Freeze for PluginIngressRequest
impl RefUnwindSafe for PluginIngressRequest
impl Send for PluginIngressRequest
impl Sync for PluginIngressRequest
impl Unpin for PluginIngressRequest
impl UnsafeUnpin for PluginIngressRequest
impl UnwindSafe for PluginIngressRequest
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