Struct libhealth::model::ActivityInfo
source · 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
impl ActivityInfo
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
impl Clone for ActivityInfo
source§fn clone(&self) -> ActivityInfo
fn clone(&self) -> ActivityInfo
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ActivityInfo
impl Debug for ActivityInfo
source§impl Default for ActivityInfo
impl Default for ActivityInfo
source§impl From<ActivityType> for ActivityInfo
impl From<ActivityType> for ActivityInfo
source§fn from(activity_type: ActivityType) -> Self
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
impl PartialEq<ActivityInfo> for ActivityInfo
source§fn eq(&self, other: &ActivityInfo) -> bool
fn eq(&self, other: &ActivityInfo) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl TryFrom<&str> for ActivityInfo
impl TryFrom<&str> for ActivityInfo
source§fn try_from(val: &str) -> Result<Self, Self::Error>
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
type Error = ParseError
The type returned in the event of a conversion error.
impl Eq for ActivityInfo
impl StructuralEq for ActivityInfo
impl StructuralPartialEq for ActivityInfo
Auto Trait Implementations§
impl RefUnwindSafe for ActivityInfo
impl Send for ActivityInfo
impl Sync for ActivityInfo
impl Unpin for ActivityInfo
impl UnwindSafe for ActivityInfo
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more