PlanetToOrchestrator

Enum PlanetToOrchestrator 

Source
pub enum PlanetToOrchestrator {
    SunrayAck {
        planet_id: ID,
    },
    AsteroidAck {
        planet_id: ID,
        rocket: Option<Rocket>,
    },
    StartPlanetAIResult {
        planet_id: ID,
    },
    StopPlanetAIResult {
        planet_id: ID,
    },
    KillPlanetResult {
        planet_id: ID,
    },
    InternalStateResponse {
        planet_id: ID,
        planet_state: DummyPlanetState,
    },
    IncomingExplorerResponse {
        planet_id: ID,
        explorer_id: ID,
        res: Result<(), String>,
    },
    OutgoingExplorerResponse {
        planet_id: ID,
        explorer_id: ID,
        res: Result<(), String>,
    },
    Stopped {
        planet_id: ID,
    },
}
Expand description

This enum describes all possible messages from a Planet to the Orchestrator

Variants§

§

SunrayAck

This variant is used to acknowledge the obtained Sunray

Response to: OrchestratorToPlanet::Sunray

Fields

§planet_id: ID

ID of the planet sending the message

§

AsteroidAck

This variant is used to acknowledge the obtained Asteroid and notify the orchestrator if the planet has a rocket to defend itself

Response to: OrchestratorToPlanet::Asteroid

Fields

§planet_id: ID

ID of the planet sending the message

§rocket: Option<Rocket>

Optional rocket returned to the Orchestrator to decide if planet can deflect the asteroid

§

StartPlanetAIResult

This variant is used to acknowledge the starting of the Planet Ai

Response to: OrchestratorToPlanet::StartPlanetAI

Fields

§planet_id: ID

ID of the planet sending the message

§

StopPlanetAIResult

This variant is used to acknowledge the stopping of the Planet Ai, in this state a planet will only respond to incoming messages with a PlanetToOrchestrator::Stopped

Response to: OrchestratorToPlanet::StopPlanetAI

Fields

§planet_id: ID

ID of the planet sending the message

§

KillPlanetResult

This variant is used to acknowledge the killing of a planet, in this case the planet thread will be terminated and the planet will be deleted from the galaxy

Response to: OrchestratorToPlanet::KillPlanet

Fields

§planet_id: ID
§

InternalStateResponse

This variant is used to send back the Planet State

Response to OrchestratorToPlanet::InternalStateRequest

Fields

§planet_id: ID

ID of the planet sending the message

§planet_state: DummyPlanetState

A struct containing the relevant information of a Planet to be shown by the GUI

§

IncomingExplorerResponse

This variant is used to acknowledge the incoming explorer reception

Response to OrchestratorToPlanet::IncomingExplorerRequest

Fields

§planet_id: ID

ID of the planet sending the message

§explorer_id: ID

Incoming explorer’s ID

§res: Result<(), String>

Result of the operation:

Ok if the Sender to the incoming explorer has been correctly set up

[Err(String)] if an error occurred

§

OutgoingExplorerResponse

This variant is used to acknowledge that an explorer is leaving the planet

Response to: OrchestratorToPlanet::OutgoingExplorerRequest

Fields

§planet_id: ID

ID of the planet sending the message

§explorer_id: ID

Incoming explorer’s ID

§res: Result<(), String>

Result of the operation:

Ok if the Sender to the outgoing explorer has been correctly deleted

[Err(String)] if an error occurred

§

Stopped

This variant is used by planets that are currently in a stopped state to acknowledge any message coming from the Orchestrator (except for OrchestratorToPlanet::StartPlanetAI)

Fields

§planet_id: ID

ID of the planet sending the message

Implementations§

Source§

impl PlanetToOrchestrator

Source

pub fn is_sunray_ack(&self) -> bool

Returns true if this is a PlanetToOrchestrator::SunrayAck, otherwise false

Source

pub fn as_sunray_ack_mut(&mut self) -> Option<&mut ID>

Optionally returns mutable references to the inner fields if this is a PlanetToOrchestrator::SunrayAck, otherwise None

Source

pub fn as_sunray_ack(&self) -> Option<&ID>

Optionally returns references to the inner fields if this is a PlanetToOrchestrator::SunrayAck, otherwise None

Source

pub fn into_sunray_ack(self) -> Result<ID, Self>

Returns the inner fields if this is a PlanetToOrchestrator::SunrayAck, otherwise returns back the enum in the Err case of the result

Source

pub fn is_asteroid_ack(&self) -> bool

Returns true if this is a PlanetToOrchestrator::AsteroidAck, otherwise false

Source

pub fn as_asteroid_ack_mut(&mut self) -> Option<(&mut ID, &mut Option<Rocket>)>

Optionally returns mutable references to the inner fields if this is a PlanetToOrchestrator::AsteroidAck, otherwise None

Source

pub fn as_asteroid_ack(&self) -> Option<(&ID, &Option<Rocket>)>

Optionally returns references to the inner fields if this is a PlanetToOrchestrator::AsteroidAck, otherwise None

Source

pub fn into_asteroid_ack(self) -> Result<(ID, Option<Rocket>), Self>

Returns the inner fields if this is a PlanetToOrchestrator::AsteroidAck, otherwise returns back the enum in the Err case of the result

Source

pub fn is_start_planet_ai_result(&self) -> bool

Returns true if this is a PlanetToOrchestrator::StartPlanetAIResult, otherwise false

Source

pub fn as_start_planet_ai_result_mut(&mut self) -> Option<&mut ID>

Optionally returns mutable references to the inner fields if this is a PlanetToOrchestrator::StartPlanetAIResult, otherwise None

Source

pub fn as_start_planet_ai_result(&self) -> Option<&ID>

Optionally returns references to the inner fields if this is a PlanetToOrchestrator::StartPlanetAIResult, otherwise None

Source

pub fn into_start_planet_ai_result(self) -> Result<ID, Self>

Returns the inner fields if this is a PlanetToOrchestrator::StartPlanetAIResult, otherwise returns back the enum in the Err case of the result

Source

pub fn is_stop_planet_ai_result(&self) -> bool

Returns true if this is a PlanetToOrchestrator::StopPlanetAIResult, otherwise false

Source

pub fn as_stop_planet_ai_result_mut(&mut self) -> Option<&mut ID>

Optionally returns mutable references to the inner fields if this is a PlanetToOrchestrator::StopPlanetAIResult, otherwise None

Source

pub fn as_stop_planet_ai_result(&self) -> Option<&ID>

Optionally returns references to the inner fields if this is a PlanetToOrchestrator::StopPlanetAIResult, otherwise None

Source

pub fn into_stop_planet_ai_result(self) -> Result<ID, Self>

Returns the inner fields if this is a PlanetToOrchestrator::StopPlanetAIResult, otherwise returns back the enum in the Err case of the result

Source

pub fn is_kill_planet_result(&self) -> bool

Returns true if this is a PlanetToOrchestrator::KillPlanetResult, otherwise false

Source

pub fn as_kill_planet_result_mut(&mut self) -> Option<&mut ID>

Optionally returns mutable references to the inner fields if this is a PlanetToOrchestrator::KillPlanetResult, otherwise None

Source

pub fn as_kill_planet_result(&self) -> Option<&ID>

Optionally returns references to the inner fields if this is a PlanetToOrchestrator::KillPlanetResult, otherwise None

Source

pub fn into_kill_planet_result(self) -> Result<ID, Self>

Returns the inner fields if this is a PlanetToOrchestrator::KillPlanetResult, otherwise returns back the enum in the Err case of the result

Source

pub fn is_internal_state_response(&self) -> bool

Returns true if this is a PlanetToOrchestrator::InternalStateResponse, otherwise false

Source

pub fn as_internal_state_response_mut( &mut self, ) -> Option<(&mut ID, &mut DummyPlanetState)>

Optionally returns mutable references to the inner fields if this is a PlanetToOrchestrator::InternalStateResponse, otherwise None

Source

pub fn as_internal_state_response(&self) -> Option<(&ID, &DummyPlanetState)>

Optionally returns references to the inner fields if this is a PlanetToOrchestrator::InternalStateResponse, otherwise None

Source

pub fn into_internal_state_response( self, ) -> Result<(ID, DummyPlanetState), Self>

Returns the inner fields if this is a PlanetToOrchestrator::InternalStateResponse, otherwise returns back the enum in the Err case of the result

Source

pub fn is_incoming_explorer_response(&self) -> bool

Returns true if this is a PlanetToOrchestrator::IncomingExplorerResponse, otherwise false

Source

pub fn as_incoming_explorer_response_mut( &mut self, ) -> Option<(&mut ID, &mut ID, &mut Result<(), String>)>

Optionally returns mutable references to the inner fields if this is a PlanetToOrchestrator::IncomingExplorerResponse, otherwise None

Source

pub fn as_incoming_explorer_response( &self, ) -> Option<(&ID, &ID, &Result<(), String>)>

Optionally returns references to the inner fields if this is a PlanetToOrchestrator::IncomingExplorerResponse, otherwise None

Source

pub fn into_incoming_explorer_response( self, ) -> Result<(ID, ID, Result<(), String>), Self>

Returns the inner fields if this is a PlanetToOrchestrator::IncomingExplorerResponse, otherwise returns back the enum in the Err case of the result

Source

pub fn is_outgoing_explorer_response(&self) -> bool

Returns true if this is a PlanetToOrchestrator::OutgoingExplorerResponse, otherwise false

Source

pub fn as_outgoing_explorer_response_mut( &mut self, ) -> Option<(&mut ID, &mut ID, &mut Result<(), String>)>

Optionally returns mutable references to the inner fields if this is a PlanetToOrchestrator::OutgoingExplorerResponse, otherwise None

Source

pub fn as_outgoing_explorer_response( &self, ) -> Option<(&ID, &ID, &Result<(), String>)>

Optionally returns references to the inner fields if this is a PlanetToOrchestrator::OutgoingExplorerResponse, otherwise None

Source

pub fn into_outgoing_explorer_response( self, ) -> Result<(ID, ID, Result<(), String>), Self>

Returns the inner fields if this is a PlanetToOrchestrator::OutgoingExplorerResponse, otherwise returns back the enum in the Err case of the result

Source

pub fn is_stopped(&self) -> bool

Returns true if this is a PlanetToOrchestrator::Stopped, otherwise false

Source

pub fn as_stopped_mut(&mut self) -> Option<&mut ID>

Optionally returns mutable references to the inner fields if this is a PlanetToOrchestrator::Stopped, otherwise None

Source

pub fn as_stopped(&self) -> Option<&ID>

Optionally returns references to the inner fields if this is a PlanetToOrchestrator::Stopped, otherwise None

Source

pub fn into_stopped(self) -> Result<ID, Self>

Returns the inner fields if this is a PlanetToOrchestrator::Stopped, otherwise returns back the enum in the Err case of the result

Source§

impl PlanetToOrchestrator

Source

pub fn planet_id(&self) -> ID

Helper method to extract the planet_id field from any message variant without needing to match a specific one.

Trait Implementations§

Source§

impl Debug for PlanetToOrchestrator

Source§

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

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

impl<'_enum> From<&'_enum PlanetToOrchestrator> for PlanetToOrchestratorKind

Source§

fn from(val: &'_enum PlanetToOrchestrator) -> PlanetToOrchestratorKind

Converts to this type from the input type.
Source§

impl From<PlanetToOrchestrator> for PlanetToOrchestratorKind

Source§

fn from(val: PlanetToOrchestrator) -> PlanetToOrchestratorKind

Converts to this type from the input type.
Source§

impl IntoDiscriminant for PlanetToOrchestrator

Source§

type Discriminant = PlanetToOrchestratorKind

Enum listing the same variants as this enum but without any data fields
Source§

fn discriminant(&self) -> Self::Discriminant

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.