pub struct DecisionOptionWeight {
pub option_id: String,
pub weight: u64,
}Fields§
§option_id: String§weight: u64Implementations§
Source§impl DecisionOptionWeight
impl DecisionOptionWeight
Sourcepub fn new(option_id: impl Into<String>, weight: u64) -> DecisionOptionWeight
pub fn new(option_id: impl Into<String>, weight: u64) -> DecisionOptionWeight
Examples found in repository?
examples/uncertainty_resolution.rs (line 35)
22fn random_resolution_system(
23 view: &SimulationView<'_>,
24 context: &BoundaryContext,
25) -> Result<BoundaryProposal, CanwuError> {
26 let ticket = view
27 .decision_ticket(RANDOM_TICKET)?
28 .expect("the example opens the ticket before the daily boundary");
29 let calendar_ingress = context
30 .admitted_ingress
31 .first()
32 .copied()
33 .expect("the example runs this system from calendar ingress");
34 let option_weights = vec![
35 DecisionOptionWeight::new("fail", 25),
36 DecisionOptionWeight::new("pass", 75),
37 ];
38 let sample = view.random_sample_for_operation(
39 &decision_stream(),
40 EvidenceRef::Ingress(calendar_ingress),
41 "decision_selection",
42 "law-proposal-42",
43 RandomOperationTarget::DecisionTicket {
44 ticket_id: ticket.id,
45 ticket_version: ticket.version,
46 },
47 0,
48 100,
49 "select whether the law passes from configured weights",
50 )?;
51 Ok(BoundaryProposal {
52 directives: vec![BoundaryDirective::ResolveDecisionRandomly {
53 resolution: RandomDecisionResolution {
54 priority: 0,
55 decision_request_id: DecisionRequestId::new(3),
56 command_request_id: None,
57 ticket_id: ticket.id,
58 expected_version: ticket.version,
59 controller_id: ticket.assigned_controller.clone(),
60 sample,
61 option_weights,
62 },
63 }],
64 ..BoundaryProposal::default()
65 })
66}Trait Implementations§
Source§impl Clone for DecisionOptionWeight
impl Clone for DecisionOptionWeight
Source§fn clone(&self) -> DecisionOptionWeight
fn clone(&self) -> DecisionOptionWeight
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 DecisionOptionWeight
impl Debug for DecisionOptionWeight
Source§impl<'de> Deserialize<'de> for DecisionOptionWeight
impl<'de> Deserialize<'de> for DecisionOptionWeight
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DecisionOptionWeight, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DecisionOptionWeight, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for DecisionOptionWeight
Source§impl Ord for DecisionOptionWeight
impl Ord for DecisionOptionWeight
Source§fn cmp(&self, other: &DecisionOptionWeight) -> Ordering
fn cmp(&self, other: &DecisionOptionWeight) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for DecisionOptionWeight
impl PartialEq for DecisionOptionWeight
Source§impl PartialOrd for DecisionOptionWeight
impl PartialOrd for DecisionOptionWeight
Source§impl Serialize for DecisionOptionWeight
impl Serialize for DecisionOptionWeight
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 DecisionOptionWeight
Auto Trait Implementations§
impl Freeze for DecisionOptionWeight
impl RefUnwindSafe for DecisionOptionWeight
impl Send for DecisionOptionWeight
impl Sync for DecisionOptionWeight
impl Unpin for DecisionOptionWeight
impl UnsafeUnpin for DecisionOptionWeight
impl UnwindSafe for DecisionOptionWeight
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