DiveSegment

Struct DiveSegment 

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

The atomic unit of a dive. Every dive can be represented by a list of DiveSegments.

Implementations§

Source§

impl DiveSegment

Source

pub fn new( segment_type: SegmentType, start_depth: usize, end_depth: usize, time: Duration, ascent_rate: isize, descent_rate: isize, ) -> Result<Self, DiveSegmentError>

Returns a new DiveSegment with the given parameters.

§Arguments
  • segment_type - Type of this segment. See SegmentType.
  • start_depth- Depth at the beginning of the segment.
  • end_depth - Depth at the end of the segment
  • time - Duration of the segment.
  • ascent_rate - Ascent rate of the segment (measured in m min^-1)
  • descent_rate - Descent rate of the segment (measured in m min^-1)
§Errors

This function will return a DiveSegmentError if any of the following are true:

  • segment-type is AscDesc but start and end depths match.
  • segment-type is not AscDesc but start and end depths do not match.
Source

pub fn segment_type(&self) -> SegmentType

Returns the type of the segment.

Source

pub fn start_depth(&self) -> usize

Returns the start depth of the segment.

Source

pub fn end_depth(&self) -> usize

Returns the end depth of the segment.

Source

pub fn time(&self) -> &Duration

Returns the duration of the segment.

Source

pub fn ascent_rate(&self) -> isize

Returns the ascent rate of the segment.

Source

pub fn descent_rate(&self) -> isize

Returns the descent rate of the segment.

Source

pub fn gas_consumed(&self, sac_rate: usize, metres_per_bar: f64) -> usize

Returns the quantity of gas a diver would consume in the segment.

§Arguments
  • sac_rate - Surface Air Consumption (SAC) rate (measured in bar min^-1).
  • metres_per_bar - Depth of water required to induce 1 bar of pressure.

Trait Implementations§

Source§

impl Clone for DiveSegment

Source§

fn clone(&self) -> DiveSegment

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for DiveSegment

Source§

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

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

impl Copy for DiveSegment

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> 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.