avalanche_types/choices/decidable.rs
1//! The Decidable trait.
2use crate::errors::Result;
3use crate::{choices::status::Status, ids::Id};
4
5/// Represents an element that can be decided.
6/// Decidable objects are transactions, blocks, or vertices.
7/// ref. <https://pkg.go.dev/github.com/ava-labs/avalanchego/snow/choices#Decidable>
8pub trait Decidable {
9 /// Returns the ID of this block's parent.
10 fn id(&self) -> Id;
11
12 /// Returns the current status.
13 fn status(&self) -> Status;
14
15 /// Accepts this element.
16 /// TODO: use <https://docs.rs/tokio-context/latest/tokio_context>?
17 fn accept(&mut self) -> Result<()>;
18 /// Rejects this element.
19 /// TODO: use <https://docs.rs/tokio-context/latest/tokio_context>?
20 fn reject(&mut self) -> Result<()>;
21}