tokenomics_simulator::engine

Struct Simulation

Source
pub struct Simulation {
    pub id: Uuid,
    pub name: String,
    pub token: Token,
    pub description: Option<String>,
    pub status: SimulationStatus,
    pub options: SimulationOptions,
    pub interval_reports: HashMap<u64, SimulationReport, BuildHasherDefault<XxHash64>>,
    pub report: SimulationReport,
    pub created_at: DateTime<Utc>,
    pub updated_at: DateTime<Utc>,
}

Fields§

§id: Uuid

ID of the simulation.

§name: String

Name of the simulation.

§token: Token

Token used in the simulation.

§description: Option<String>

Description of the simulation.

§status: SimulationStatus

Status of the simulation.

§options: SimulationOptions

Input parameters for the simulation.

§interval_reports: HashMap<u64, SimulationReport, BuildHasherDefault<XxHash64>>

Report of the results for each interval of the simulation.

§report: SimulationReport

Report of the total results of the simulation.

§created_at: DateTime<Utc>

Date and time the simulation was created.

§updated_at: DateTime<Utc>

Date and time the simulation was last updated.

Implementations§

Source§

impl Simulation

Source

pub fn update_status(&mut self, status: SimulationStatus)

Update the status of the simulation.

§Arguments
  • status - The new status of the simulation.
Source

pub fn run(&mut self, token: &mut Token)

Run the simulation.

§Arguments
  • token - The token used in the simulation.
Source

pub fn process_interval( &self, users: &mut [User], interval: u64, ) -> SimulationReport

Simulate trades for a given interval.

§Arguments
  • users - A list of users.
  • interval - Duration of the interval.
§Returns

A report of the simulation results for the interval.

Source

pub fn generate_report(&mut self, users: &[User])

Calculate the total report for the simulation.

§Arguments
  • users - A list of users.
Source

pub fn get_interval(&self) -> u64

Get the interval for the simulation.

§Returns

The duration of the simulation interval.

Trait Implementations§

Source§

impl Debug for Simulation

Source§

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

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

impl<'de> Deserialize<'de> for Simulation

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 Serialize for Simulation

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§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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