pub struct Proposal<State> { /* private fields */ }Expand description
A proposal in a specific lifecycle state.
State transitions:
Proposal<Draft>->Proposal<Validated>viaPromotionGate::validate()Proposal<Validated>->FactviaPromotionGate::promote()
§Example
use converge_core::types::{
Proposal, Draft, ProposalId, ProposedContent, ProposedContentKind,
ObservationProvenance, ObservationId, ContentHash, CaptureContext,
};
// Create a draft proposal (public)
let draft = Proposal::<Draft>::new(
ProposalId::new("proposal-001"),
ProposedContent::new(ProposedContentKind::Claim, "The market is growing"),
ObservationProvenance::new(
ObservationId::new("obs-001"),
ContentHash::zero(),
CaptureContext::default(),
),
);
assert_eq!(draft.id().as_str(), "proposal-001");Implementations§
Source§impl Proposal<Draft>
impl Proposal<Draft>
Sourcepub fn new(
id: ProposalId,
content: ProposedContent,
provenance: ObservationProvenance,
) -> Proposal<Draft>
pub fn new( id: ProposalId, content: ProposedContent, provenance: ObservationProvenance, ) -> Proposal<Draft>
Public constructor for draft proposals.
Anyone can create a draft proposal. It must be validated by a PromotionGate before it can become a Fact.
Source§impl<State> Proposal<State>
impl<State> Proposal<State>
Sourcepub fn id(&self) -> &ProposalId
pub fn id(&self) -> &ProposalId
Get the proposal ID.
Sourcepub fn content(&self) -> &ProposedContent
pub fn content(&self) -> &ProposedContent
Get the proposed content.
Sourcepub fn provenance(&self) -> &ObservationProvenance
pub fn provenance(&self) -> &ObservationProvenance
Get the observation provenance.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Proposal<Draft>
impl<'de> Deserialize<'de> for Proposal<Draft>
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Proposal<Draft>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Proposal<Draft>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<S> Serialize for Proposal<S>
impl<S> Serialize for Proposal<S>
Source§fn serialize<Ser>(
&self,
serializer: Ser,
) -> Result<<Ser as Serializer>::Ok, <Ser as Serializer>::Error>where
Ser: Serializer,
fn serialize<Ser>(
&self,
serializer: Ser,
) -> Result<<Ser as Serializer>::Ok, <Ser as Serializer>::Error>where
Ser: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl<State> Freeze for Proposal<State>
impl<State> RefUnwindSafe for Proposal<State>where
State: RefUnwindSafe,
impl<State> Send for Proposal<State>where
State: Send,
impl<State> Sync for Proposal<State>where
State: Sync,
impl<State> Unpin for Proposal<State>where
State: Unpin,
impl<State> UnsafeUnpin for Proposal<State>
impl<State> UnwindSafe for Proposal<State>where
State: UnwindSafe,
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