PlanetToExplorer

Enum PlanetToExplorer 

Source
pub enum PlanetToExplorer {
    SupportedResourceResponse {
        resource_list: HashSet<BasicResourceType>,
    },
    SupportedCombinationResponse {
        combination_list: HashSet<ComplexResourceType>,
    },
    GenerateResourceResponse {
        resource: Option<BasicResource>,
    },
    CombineResourceResponse {
        complex_response: Result<ComplexResource, (String, GenericResource, GenericResource)>,
    },
    AvailableEnergyCellResponse {
        available_cells: ID,
    },
    Stopped,
}
Expand description

This enum describes all possible messages from a Planet to an Explorer.

Variants§

§

SupportedResourceResponse

This variant is used to send the available BasicResourceType list to the Explorer

Response To: ExplorerToPlanet::SupportedResourceRequest

Fields

§resource_list: HashSet<BasicResourceType>

The list of available BasicResourceType

§

SupportedCombinationResponse

This variant is used to send the available ComplexResourceType list to the Explorer

Response To: ExplorerToPlanet::SupportedCombinationRequest

Fields

§combination_list: HashSet<ComplexResourceType>

The list of available ComplexResourceType

§

GenerateResourceResponse

This variant is used to send the generated Basic Resource

Response To: ExplorerToPlanet::GenerateResourceRequest

Fields

§resource: Option<BasicResource>

The optional Basic Resource generated:

[Some(BasicResource)] if resource has been crafted correctly

None if some error occurred

§

CombineResourceResponse

This variant is used to send the ComplexResource generated

Response To: ExplorerToPlanet::CombineResourceRequest

Fields

§complex_response: Result<ComplexResource, (String, GenericResource, GenericResource)>

The complex basic resource generated:

[Ok(ComplexResource)] if complex resource has been crafted correctly

An Err triplet containing an error String and the two resources that were intended to be combined that are given back to the Explorer

§

AvailableEnergyCellResponse

This variant is used to send the number of available energy cells to the Explorer

Response To: ExplorerToPlanet::AvailableEnergyCellRequest

Fields

§available_cells: ID

The number of charged cells available

§

Stopped

This variant is used by planets that are currently in a stopped state to acknowledge any message coming from an explorer

Implementations§

Source§

impl PlanetToExplorer

Source

pub fn is_supported_resource_response(&self) -> bool

Returns true if this is a PlanetToExplorer::SupportedResourceResponse, otherwise false

Source

pub fn as_supported_resource_response_mut( &mut self, ) -> Option<&mut HashSet<BasicResourceType>>

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

Source

pub fn as_supported_resource_response( &self, ) -> Option<&HashSet<BasicResourceType>>

Optionally returns references to the inner fields if this is a PlanetToExplorer::SupportedResourceResponse, otherwise None

Source

pub fn into_supported_resource_response( self, ) -> Result<HashSet<BasicResourceType>, Self>

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

Source

pub fn is_supported_combination_response(&self) -> bool

Returns true if this is a PlanetToExplorer::SupportedCombinationResponse, otherwise false

Source

pub fn as_supported_combination_response_mut( &mut self, ) -> Option<&mut HashSet<ComplexResourceType>>

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

Source

pub fn as_supported_combination_response( &self, ) -> Option<&HashSet<ComplexResourceType>>

Optionally returns references to the inner fields if this is a PlanetToExplorer::SupportedCombinationResponse, otherwise None

Source

pub fn into_supported_combination_response( self, ) -> Result<HashSet<ComplexResourceType>, Self>

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

Source

pub fn is_generate_resource_response(&self) -> bool

Returns true if this is a PlanetToExplorer::GenerateResourceResponse, otherwise false

Source

pub fn as_generate_resource_response_mut( &mut self, ) -> Option<&mut Option<BasicResource>>

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

Source

pub fn as_generate_resource_response(&self) -> Option<&Option<BasicResource>>

Optionally returns references to the inner fields if this is a PlanetToExplorer::GenerateResourceResponse, otherwise None

Source

pub fn into_generate_resource_response( self, ) -> Result<Option<BasicResource>, Self>

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

Source

pub fn is_combine_resource_response(&self) -> bool

Returns true if this is a PlanetToExplorer::CombineResourceResponse, otherwise false

Source

pub fn as_combine_resource_response_mut( &mut self, ) -> Option<&mut Result<ComplexResource, (String, GenericResource, GenericResource)>>

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

Source

pub fn as_combine_resource_response( &self, ) -> Option<&Result<ComplexResource, (String, GenericResource, GenericResource)>>

Optionally returns references to the inner fields if this is a PlanetToExplorer::CombineResourceResponse, otherwise None

Source

pub fn into_combine_resource_response( self, ) -> Result<Result<ComplexResource, (String, GenericResource, GenericResource)>, Self>

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

Source

pub fn is_available_energy_cell_response(&self) -> bool

Returns true if this is a PlanetToExplorer::AvailableEnergyCellResponse, otherwise false

Source

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

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

Source

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

Optionally returns references to the inner fields if this is a PlanetToExplorer::AvailableEnergyCellResponse, otherwise None

Source

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

Returns the inner fields if this is a PlanetToExplorer::AvailableEnergyCellResponse, 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 PlanetToExplorer::Stopped, otherwise false

Trait Implementations§

Source§

impl Debug for PlanetToExplorer

Source§

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

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

impl<'_enum> From<&'_enum PlanetToExplorer> for PlanetToExplorerKind

Source§

fn from(val: &'_enum PlanetToExplorer) -> PlanetToExplorerKind

Converts to this type from the input type.
Source§

impl From<PlanetToExplorer> for PlanetToExplorerKind

Source§

fn from(val: PlanetToExplorer) -> PlanetToExplorerKind

Converts to this type from the input type.
Source§

impl IntoDiscriminant for PlanetToExplorer

Source§

type Discriminant = PlanetToExplorerKind

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.