pub struct Commit {
    pub header: Option<Header>,
    pub votes: Option<Vec<Vote>>,
    pub round: Option<u32>,
}

Fields§

§header: Option<Header>§votes: Option<Vec<Vote>>§round: Option<u32>

Implementations§

source§

impl Commit

source

pub fn new(header: Header, round: u32) -> Self

Make a new commit using default votes produced from the header.

source

pub fn new_with_votes(header: Header, round: u32, votes: Vec<Vote>) -> Self

Make a new commit using explicit votes.

source

pub fn header(self, header: Header) -> Self

source

pub fn votes(self, votes: Vec<Vote>) -> Self

source

pub fn round(self, round: u32) -> Self

source

pub fn generate_default_votes(self) -> Self

Generate commit votes from all validators in the header. This function will panic if the header is not present

source

pub fn vote_of_validator(&mut self, id: &str) -> &mut Vote

Get a mutable reference to the vote of the given validator. This function will panic if the votes or the validator vote is not present

source

pub fn vote_at_index(&mut self, index: usize) -> &mut Vote

Get a mutable reference to the vote at the given index This function will panic if the votes or the vote at index is not present

Trait Implementations§

source§

impl Clone for Commit

source§

fn clone(&self) -> Commit

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Commit

source§

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

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

impl<'de> Deserialize<'de> for Commit

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl FromStr for Commit

§

type Err = SimpleError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Generator<Commit> for Commit

source§

fn merge_with_default(self, other: Self) -> Self

Merge this companion with the another, default one. The options present in this object will override those in the default one.
source§

fn generate(&self) -> Result<Commit, SimpleError>

Generate the complex object from this companion object.
source§

fn encode(&self) -> Result<String, SimpleError>

Generate and serialize the complex object
source§

impl Options for Commit

source§

fn parse<__S: AsRef<str>>(_parser: &mut Parser<'_, __S>) -> Result<Self, Error>

Parses arguments until the given parser is exhausted or until an error is encountered.
source§

fn command(&self) -> Option<&dyn Options>

Returns the subcommand instance, if present. Read more
source§

fn command_name(&self) -> Option<&'static str>

Returns the name of a parsed command, if present. Read more
source§

fn help_requested(&self) -> bool

Returns whether the user supplied a “help” option to request usage information about the program or any contained subcommands. Read more
source§

fn parse_command<__S: AsRef<str>>( name: &str, _parser: &mut Parser<'_, __S> ) -> Result<Self, Error>

Parses options for the named command.
source§

fn usage() -> &'static str

Returns a string showing usage and help for each supported option. Read more
source§

fn self_usage(&self) -> &'static str

Returns a string showing usage and help for this options instance. Read more
source§

fn command_list() -> Option<&'static str>

Returns a string listing available commands and help text. Read more
source§

fn command_usage(_name: &str) -> Option<&'static str>

Returns a usage string for the named command. Read more
source§

fn self_command_list(&self) -> Option<&'static str>

Returns a listing of available commands and help text. Read more
source§

fn parse_args<S>(args: &[S], style: ParsingStyle) -> Result<Self, Error>
where S: AsRef<str>, Self: Sized,

Parses arguments received from the command line. Read more
source§

fn parse_args_or_exit(style: ParsingStyle) -> Self
where Self: Sized,

Parses arguments from the environment. Read more
source§

fn parse_args_default_or_exit() -> Self
where Self: Sized,

Parses arguments from the environment, using the default parsing style. Read more
source§

fn parse_args_default<S>(args: &[S]) -> Result<Self, Error>
where S: AsRef<str>, Self: Sized,

Parses arguments received from the command line, using the default parsing style. Read more
source§

impl Serialize for Commit

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Commit

§

impl RefUnwindSafe for Commit

§

impl Send for Commit

§

impl Sync for Commit

§

impl Unpin for Commit

§

impl UnwindSafe for Commit

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> 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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,