pub struct Location { /* private fields */ }Expand description
A geographic location with coordinates and metadata.
All fields are private to allow future API evolution without breaking changes. Use the accessor methods to retrieve location data.
Implementations§
Source§impl Location
impl Location
Sourcepub const fn new(
latitude: Latitude,
longitude: Longitude,
timestamp: Timestamp,
) -> Location
pub const fn new( latitude: Latitude, longitude: Longitude, timestamp: Timestamp, ) -> Location
Creates a new Location with validated coordinates.
§Arguments
latitude- Latitude in degrees (-90 to 90).longitude- Longitude in degrees (-180 to 180).timestamp- When this location was recorded
Sourcepub fn from_degrees(
latitude: f64,
longitude: f64,
timestamp: Timestamp,
) -> Result<Location, LocationError>
pub fn from_degrees( latitude: f64, longitude: f64, timestamp: Timestamp, ) -> Result<Location, LocationError>
Creates a new Location from raw coordinate degrees.
§Errors
Returns LocationError::InvalidCoordinate if either coordinate is
NaN or outside its valid range.
Sourcepub async fn get() -> Result<Location, LocationError>
pub async fn get() -> Result<Location, LocationError>
Returns the current device location.
Precondition: callers must ensure Permission::Location is
granted; this function does not trigger the runtime prompt.
Use waterkit_permission::request(Permission::Location) first.
§Errors
Returns LocationError::PermissionDenied when access is denied,
LocationError::ServiceDisabled when location services are off,
LocationError::Timeout when the request times out,
LocationError::InvalidCoordinate when the OS returns invalid
coordinates, or LocationError::Platform for other OS failures.
Sourcepub const fn with_altitude(self, altitude: f64) -> Location
pub const fn with_altitude(self, altitude: f64) -> Location
Sets the altitude in meters above sea level.
with_* prefix is preserved here because Location also has
getters with bare field names (altitude() returns the current
value); the workspace-wide naming rule is “bare method name =
setter unless a getter already takes that name.”
Sourcepub const fn with_horizontal_accuracy(self, accuracy: f64) -> Location
pub const fn with_horizontal_accuracy(self, accuracy: f64) -> Location
Sets the horizontal accuracy in meters.
Sourcepub const fn with_vertical_accuracy(self, accuracy: f64) -> Location
pub const fn with_vertical_accuracy(self, accuracy: f64) -> Location
Sets the vertical accuracy in meters.
Sourcepub const fn altitude(&self) -> Option<f64>
pub const fn altitude(&self) -> Option<f64>
Returns the altitude in meters above sea level, if available.
Sourcepub const fn horizontal_accuracy(&self) -> Option<f64>
pub const fn horizontal_accuracy(&self) -> Option<f64>
Returns the horizontal accuracy in meters, if available.
Lower values indicate more precise location data.
Sourcepub const fn vertical_accuracy(&self) -> Option<f64>
pub const fn vertical_accuracy(&self) -> Option<f64>
Returns the vertical accuracy in meters, if available.
Lower values indicate more precise altitude data.