pub struct Manager { /* private fields */ }Expand description
A manager for dealing with location data and handling location updates.
All functions must be called from the main thread, except on Linux, where any thread works (including from inside a handler callback).
As soon as the handler is registered, it may receive updates immediately,
even if update_once or start_updates are not called.
When the manager is dropped, the handler is no longer guaranteed to receive updates.
Implementations§
Source§impl Manager
impl Manager
Sourcepub fn new<T>(handler: T) -> Result<Self>where
T: Handler,
pub fn new<T>(handler: T) -> Result<Self>where
T: Handler,
Creates a new location manager with the given handler.
Must be called from the main thread, except on Linux.
Sourcepub fn new_with_desktop_id<T>(handler: T, desktop_id: &str) -> Result<Self>where
T: Handler,
pub fn new_with_desktop_id<T>(handler: T, desktop_id: &str) -> Result<Self>where
T: Handler,
Like Manager::new, but with an explicit GeoClue desktop ID.
Prefer Manager::new, which works this out itself. This is an escape hatch for odd or
legacy GeoClue setups. Pass an installed desktop-file ID without the .desktop suffix
(ASCII letters, digits, ., _, -); it’s validated either way.
Available everywhere so cross-platform code can call it unconditionally; off Linux the ID is ignored.
Requests authorization to access location data.
Linux (portal), iOS, and Android return immediately; a request made beforehand waits for the
user, and a denial goes to Handler::error. Linux (GeoClue) and Windows block and return
the result.
Sourcepub fn update_once(&self) -> Result<()>
pub fn update_once(&self) -> Result<()>
Requests the device’s current location, delivered to the handler. May deliver a cached fix
immediately, then a fresher one once acquired. On Linux, gives up after 60 seconds with
Error::TemporarilyUnavailable if nothing arrives.
Sourcepub fn start_updates(&mut self) -> Result<()>
pub fn start_updates(&mut self) -> Result<()>
Begins delivering continuous updates to the handler.
Sourcepub fn stop_updates(&mut self) -> Result<()>
pub fn stop_updates(&mut self) -> Result<()>
Stops delivering continuous updates to the handler.