pub struct ExtendedUniverse<'a, U> { /* private fields */ }
Expand description

Extends the universe with dynamic connections. This is intended to be used to allow pathfinding through wormholes and titan bridges.

Example

use std::env;
use neweden::source::sqlite::DatabaseBuilder;
use neweden::navigation::PathBuilder;
use neweden::Navigatable;
use neweden::{Connection, ConnectionType, WormholeType};

let uri = std::env::var("SQLITE_URI").unwrap();
let wormholes = vec![Connection {
    from: 30002718.into(), // Rancer
    to: 30000049.into(),  // Camal
    type_: ConnectionType::Wormhole(WormholeType::VeryLarge),
}];
let universe = DatabaseBuilder::new(&uri).build().unwrap();
let extended = universe.extend(wormholes.into()); // make into an adjacent map and pass into extend()
let path = PathBuilder::new(&extended)
    .waypoint(extended.get_system(&30002718.into()).unwrap()) // from Rancer
    .waypoint(extended.get_system(&30000049.into()).unwrap()) // to Camal
    .build() // returns an iterator
    .collect::<Vec<_>>();
assert_eq!(2, path.len()); // direct jump through our wormhole

Implementations§

source§

impl<'a, U: Galaxy + Navigatable> ExtendedUniverse<'a, U>

source

pub fn new(universe: &'a U, connections: AdjacentMap) -> Self

Trait Implementations§

source§

impl<'a, U: Debug> Debug for ExtendedUniverse<'a, U>

source§

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

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

impl<'a, U: Galaxy> Galaxy for ExtendedUniverse<'a, U>

source§

impl<'b, U: Navigatable> Navigatable for ExtendedUniverse<'b, U>

source§

fn get_system<'a>(&self, id: &SystemId) -> Option<&System>

source§

fn get_connections<'a>(&self, from: &SystemId) -> Option<Vec<Connection>>

source§

fn get_systems_by_range<'a>( &self, from: &SystemId, range: Meters ) -> Option<Vec<&System>>

Auto Trait Implementations§

§

impl<'a, U> RefUnwindSafe for ExtendedUniverse<'a, U>where U: RefUnwindSafe,

§

impl<'a, U> Send for ExtendedUniverse<'a, U>where U: Sync,

§

impl<'a, U> Sync for ExtendedUniverse<'a, U>where U: Sync,

§

impl<'a, U> Unpin for ExtendedUniverse<'a, U>

§

impl<'a, U> UnwindSafe for ExtendedUniverse<'a, U>where U: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.