common_game/components/rocket.rs
1use crate::components::energy_cell::EnergyCell;
2/// Represents the rocket in the game, used by the planet.
3#[allow(dead_code)]
4#[derive(Debug)]
5pub struct Rocket {
6 _private: (),
7}
8
9#[allow(dead_code)]
10impl Rocket {
11 /// Creates a new instance of [Rocket].
12 ///
13 /// This method serves as the primary constructor and requires an energy cell
14 /// to initialize the rocket.
15 ///
16 /// # Arguments
17 ///
18 /// * `energy_cell` - An energy cell ([`EnergyCell`]) used to build the rocket.
19 ///
20 /// # Returns
21 ///
22 /// Returns a new instance of [Rocket].
23 ///
24 /// # Errors
25 ///
26 /// Returns an error if `energy_cell` is not charged.
27 pub(crate) fn new(energy_cell: &mut EnergyCell) -> Result<Rocket, String> {
28 energy_cell.discharge().map(|()| Rocket { _private: () })
29 }
30}