Skip to main content

Route

Struct Route 

Source
pub struct Route { /* private fields */ }
Expand description

A planned passage.

Implementations§

Source§

impl Route

Source

pub fn new(waypoints: Vec<Position>, kind: LegKind) -> Result<Self>

Builds a route from an ordered list of waypoints.

§Errors

Returns NavigationError::InsufficientNodes for fewer than two waypoints, since one position is a destination and not a passage.

Source

pub fn waypoints(&self) -> &[Position]

The waypoints, in order.

Source

pub const fn kind(&self) -> LegKind

What kind of track joins the waypoints.

Source

pub fn leg_count(&self) -> usize

How many legs the route has: one fewer than the waypoints.

Source

pub fn legs(&self) -> Result<Vec<RouteLeg>>

The legs, each with its course and distance.

§Errors

Propagates a sailing failure, notably a rhumb line through a pole.

Source

pub fn total_distance(&self) -> Result<Distance>

Total distance from the first waypoint to the last.

§Errors

As Route::legs.

Source

pub fn passage_time(&self, speed: Speed) -> Result<Duration>

How long the passage takes at a given speed.

§Errors

As Route::legs, plus NavigationError::Indeterminate if the speed is zero or runs the wrong way.

Source

pub fn speed_required(&self, available: Duration) -> Result<Speed>

The speed needed to run the whole route in a given time.

§Errors

As Route::legs, plus NavigationError::Indeterminate if no time is allowed.

Source

pub fn split_legs(&self, interval: Distance) -> Result<Self>

The same route with every leg broken into pieces no longer than interval.

This is how a great-circle route is made steerable: each piece is short enough that holding one course over it costs nothing worth having.

§Errors
  • NavigationError::OutOfRange if interval is not positive, or is so small that the route would not fit in memory.
  • Propagates a sailing failure.
Source

pub fn progress(&self, position: Position) -> Result<Progress>

Where a position is in relation to the route.

The leg chosen is the one the ship is actually on — the first whose along-track distance falls within it. If she is off the end of every leg, the nearest leg is used instead, so the answer is always about something.

§Errors

Propagates a sailing failure, and returns NavigationError::Indeterminate if a leg has no length.

Trait Implementations§

Source§

impl Clone for Route

Source§

fn clone(&self) -> Route

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Route

Source§

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

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

impl PartialEq for Route

Source§

fn eq(&self, other: &Route) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Route

Auto Trait Implementations§

§

impl Freeze for Route

§

impl RefUnwindSafe for Route

§

impl Send for Route

§

impl Sync for Route

§

impl Unpin for Route

§

impl UnsafeUnpin for Route

§

impl UnwindSafe for Route

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.