Skip to main content

PluginIngressRequest

Struct PluginIngressRequest 

Source
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

Source

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] = [&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}
Source

pub const fn with_priority(self, priority: i32) -> PluginIngressRequest

Source

pub fn with_entity(self, entity: EntityRef) -> PluginIngressRequest

Source

pub fn caused_by(self, cause: CauseRef) -> PluginIngressRequest

Source

pub fn with_archive_retention( self, retention: impl IntoIterator<Item = PluginArchiveRetention>, ) -> PluginIngressRequest

Trait Implementations§

Source§

impl Clone for PluginIngressRequest

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for PluginIngressRequest

Source§

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

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

impl<'de> Deserialize<'de> for PluginIngressRequest

Source§

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

Source§

fn eq(&self, other: &PluginIngressRequest) -> 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 PluginIngressRequest

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 PluginIngressRequest

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.