pub struct Leg<'a> { /* private fields */ }Expand description
A session for Writer::leg to start: its sport, the pool of a pool
swim, the name of its profile, and whether the wearer moved to it by hand.
use fit_encoder::{Leg, Pool, Sport, SubSport};
let run = Leg::new(Sport::RUNNING, SubSport::TRAIL).named("Trail Run");
let swim = Leg::pool_swim(Pool::meters(25.0)).by_hand();Implementations§
Source§impl Leg<'_>
impl Leg<'_>
Sourcepub fn check(&self) -> Result<(), Error>
pub fn check(&self) -> Result<(), Error>
Refuses a leg that Writer::leg could never start, whatever the activity: one of
lap_swimming without a pool, a pool of no length or too long, a sport or sub-sport of
FIT’s “none”, or a name too long or holding a NUL. What it refuses, leg refuses the
same way whenever it could otherwise start one, so a recorder that writes an activity
later can refuse a leg when it is chosen.
use fit_encoder::{Error, Leg, Sport, SubSport};
assert_eq!(Leg::new(Sport::RUNNING, SubSport::TRAIL).check(), Ok(()));
let pool_swim = Leg::new(Sport::SWIMMING, SubSport::LAP_SWIMMING);
assert_eq!(pool_swim.check(), Err(Error::OutOfRange));§Errors
Source§impl<'a> Leg<'a>
impl<'a> Leg<'a>
Sourcepub const fn new(sport: Sport, sub_sport: SubSport) -> Self
pub const fn new(sport: Sport, sub_sport: SubSport) -> Self
A session of sport; not lap_swimming, which Leg::pool_swim starts.
Sourcepub const fn pool_swim(pool: Pool) -> Self
pub const fn pool_swim(pool: Pool) -> Self
A pool swim in pool, whose lengths give its distance.
Sourcepub const fn named(self, name: &'a str) -> Self
pub const fn named(self, name: &'a str) -> Self
The name of the sport’s profile on the device, such as “Open Water”, up to
SPORT_NAME_MAX bytes.
Sourcepub const fn by_hand(self) -> Self
pub const fn by_hand(self) -> Self
The wearer moved to it by hand, in an activity whose profile otherwise moves on by
itself (Options::auto_multisport): the session
before it was ended manual. Without that option every session is. Not a first leg.