pub struct Geolocation { /* private fields */ }Expand description
Thread-safe Geolocation controller.
Implementations§
Source§impl Geolocation
impl Geolocation
pub fn new() -> Geolocation
Sourcepub fn register_os_provider(
provider: fn(&GeolocationOptions) -> Option<GeolocationPosition>,
)
pub fn register_os_provider( provider: fn(&GeolocationOptions) -> Option<GeolocationPosition>, )
Registers a process-wide OS geolocation provider consulted whenever no mock position
has been injected on a Geolocation instance.
Sourcepub fn clear_os_provider()
pub fn clear_os_provider()
Clears any registered OS geolocation provider (primarily for test isolation).
Sourcepub fn set_mock_position(&self, coords: GeoCoordinates)
pub fn set_mock_position(&self, coords: GeoCoordinates)
Configures or injects a mock coordinate (e.g. for testing or headless simulation).
Sourcepub fn clear_mock_position(&self)
pub fn clear_mock_position(&self)
Clears any mock coordinate previously injected on this controller.
Sourcepub fn get_current_position(
&self,
) -> Result<GeolocationPosition, GeolocationError>
pub fn get_current_position( &self, ) -> Result<GeolocationPosition, GeolocationError>
Retrieves the current device position snapshot using default GeolocationOptions.
Sourcepub fn get_current_position_with_options(
&self,
options: &GeolocationOptions,
) -> Result<GeolocationPosition, GeolocationError>
pub fn get_current_position_with_options( &self, options: &GeolocationOptions, ) -> Result<GeolocationPosition, GeolocationError>
Retrieves the current device position snapshot respecting options.
Checks instance mock position first, then the registered OS geolocation provider.
Trait Implementations§
Source§impl Clone for Geolocation
impl Clone for Geolocation
Source§fn clone(&self) -> Geolocation
fn clone(&self) -> Geolocation
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for Geolocation
impl Default for Geolocation
Source§fn default() -> Geolocation
fn default() -> Geolocation
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Forget for Geolocation
impl Freeze for Geolocation
impl Move for Geolocation
impl RefUnwindSafe for Geolocation
impl Send for Geolocation
impl Sync for Geolocation
impl Unpin for Geolocation
impl UnsafeUnpin for Geolocation
impl UnwindSafe for Geolocation
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