pub struct ActivityInfo {
    pub activity_type: ActivityType,
    pub available_data_points: ActivityDataPoints,
    pub average_calories_burned_per_minute: u32,
    pub id: &'static str,
    pub name: String,
    pub color: RGBA,
}
Expand description

A struct containing informations about a certain activity type.

Fields§

§activity_type: ActivityType§available_data_points: ActivityDataPoints§average_calories_burned_per_minute: u32§id: &'static str

An ID that can be used for saving things to the DB.

§name: String

The localised name of the ActivityType.

§color: RGBA

Implementations§

source§

impl ActivityInfo

source

pub fn new( activity_type: ActivityType, available_data_points: ActivityDataPoints, average_calories_burned_per_minute: u32, name: String, color: RGBA ) -> Self

Trait Implementations§

source§

impl Clone for ActivityInfo

source§

fn clone(&self) -> ActivityInfo

Returns a copy 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 ActivityInfo

source§

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

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

impl Default for ActivityInfo

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<ActivityType> for ActivityInfo

source§

fn from(activity_type: ActivityType) -> Self

Converts an ActivityType into an ActivityInfo that contains infos like a localised name.

Returns

The respective ActivityInfo

Examples
use libhealth::model::{ActivityInfo, ActivityType, ActivityDataPoints};

let info = ActivityInfo::from(ActivityType::Basketball);
assert_eq!(info.activity_type, ActivityType::Basketball);
assert_eq!(info.available_data_points, ActivityDataPoints::CALORIES_BURNED | ActivityDataPoints::DURATION | ActivityDataPoints::HEART_RATE);
assert_eq!(info.id, "basketball");
// assert_eq!(info.name, "Basketball") Assuming your language is set to English, this would work too.
source§

impl PartialEq<ActivityInfo> for ActivityInfo

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<&str> for ActivityInfo

source§

fn try_from(val: &str) -> Result<Self, Self::Error>

Try converting from an ActivityInfo ID to an ActivityInfo.

Examples
use libhealth::model::{ActivityInfo, ActivityType, ActivityDataPoints};
use std::convert::TryFrom;

let info = ActivityInfo::try_from("basketball").unwrap();
assert_eq!(info.activity_type, ActivityType::Basketball);
assert_eq!(info.available_data_points, ActivityDataPoints::CALORIES_BURNED | ActivityDataPoints::DURATION | ActivityDataPoints::HEART_RATE);
assert_eq!(info.id, "basketball");
// assert_eq!(info.name, "Basketball") Assuming your language is set to English, this would work too.

assert!(ActivityInfo::try_from("unknown").is_err());
§

type Error = ParseError

The type returned in the event of a conversion error.
source§

impl Eq for ActivityInfo

source§

impl StructuralEq for ActivityInfo

source§

impl StructuralPartialEq for ActivityInfo

Auto Trait Implementations§

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> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V