diff --git a/apple/Sources/UniFFI/ferrostar.swift b/apple/Sources/UniFFI/ferrostar.swift index 770393a8..f7625da1 100644 --- a/apple/Sources/UniFFI/ferrostar.swift +++ b/apple/Sources/UniFFI/ferrostar.swift @@ -587,10 +587,10 @@ public func FfiConverterTypeNavigationController_lower(_ value: NavigationContro * over a generic request/response flow (typically over a network; * local/offline routers **do not use this object** as the interaction patterns are different). * - * This is essentially the composite of the [RouteRequestGenerator] and [RouteResponseParser] + * This is essentially the composite of the [`RouteRequestGenerator`] and [`RouteResponseParser`] * traits, but it provides one further level of abstraction which is helpful to consumers. * As there is no way to signal compatibility between request generators and response parsers, - * the [RouteAdapter] provides convenience constructors which take the guesswork out of it, + * the [`RouteAdapter`] provides convenience constructors which take the guesswork out of it, * while still leaving consumers free to implement one or both halves. * * In the future, we may provide additional methods or conveniences, and this @@ -615,10 +615,10 @@ public protocol RouteAdapterProtocol: AnyObject { * over a generic request/response flow (typically over a network; * local/offline routers **do not use this object** as the interaction patterns are different). * - * This is essentially the composite of the [RouteRequestGenerator] and [RouteResponseParser] + * This is essentially the composite of the [`RouteRequestGenerator`] and [`RouteResponseParser`] * traits, but it provides one further level of abstraction which is helpful to consumers. * As there is no way to signal compatibility between request generators and response parsers, - * the [RouteAdapter] provides convenience constructors which take the guesswork out of it, + * the [`RouteAdapter`] provides convenience constructors which take the guesswork out of it, * while still leaving consumers free to implement one or both halves. * * In the future, we may provide additional methods or conveniences, and this @@ -965,7 +965,7 @@ public func FfiConverterTypeRouteDeviationDetector_lower(_ value: RouteDeviation } /** - * A trait describing any object capable of generating [RouteRequest]s. + * A trait describing any object capable of generating [`RouteRequest`]s. * * The interface is intentionally generic. Every routing backend has its own set of * parameters, including a "profile," max travel speed, units of speed and distance, and more. @@ -986,7 +986,7 @@ public protocol RouteRequestGenerator: AnyObject { } /** - * A trait describing any object capable of generating [RouteRequest]s. + * A trait describing any object capable of generating [`RouteRequest`]s. * * The interface is intentionally generic. Every routing backend has its own set of * parameters, including a "profile," max travel speed, units of speed and distance, and more. @@ -2406,9 +2406,9 @@ public func FfiConverterTypeVisualInstructionContent_lower(_ value: VisualInstru /** * A waypoint along a route. * - * Within the context of Ferrostar, a route request consists of exactly one [UserLocation] + * Within the context of Ferrostar, a route request consists of exactly one [`UserLocation`] * and at least one [Waypoint]. The route starts from the user's location (which may - * contain other useful information like their current course for the [crate::routing_adapters::RouteRequestGenerator] + * contain other useful information like their current course for the [`crate::routing_adapters::RouteRequestGenerator`] * to use) and proceeds through one or more waypoints. * * Waypoints are used during route calculation, are tracked throughout the lifecycle of a trip, @@ -2473,7 +2473,7 @@ public func FfiConverterTypeWaypoint_lower(_ value: Waypoint) -> RustBuffer { // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. /** - * Specifies additional information about a [ManeuverType] + * Specifies additional information about a [`ManeuverType`] */ public enum ManeuverModifier { case uTurn @@ -2556,7 +2556,7 @@ extension ManeuverModifier: Equatable, Hashable {} /** * Indicates the type of maneuver to perform. * - * Frequently used in conjunction with [ManeuverModifier]. + * Frequently used in conjunction with [`ManeuverModifier`]. */ public enum ManeuverType { case turn @@ -2865,7 +2865,7 @@ public func FfiConverterTypeRouteDeviationTracking_lower(_ value: RouteDeviation // Note that we don't yet support `indirect` for enums. // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. /** - * A route request generated by a [RouteRequestGenerator]. + * A route request generated by a [`RouteRequestGenerator`]. */ public enum RouteRequest { case httpPost( @@ -3071,7 +3071,7 @@ public enum StepAdvanceMode { minimumHorizontalAccuracy: UInt16, /** * At this (optional) distance, navigation should advance to the next step regardless - * of which LineString appears closer. + * of which `LineString` appears closer. */ automaticAdvanceDistance: UInt16? ) @@ -3704,7 +3704,7 @@ public func advanceLocationSimulation(state: LocationSimulationState) -> Locatio } /** - * Creates a [RouteResponseParser] capable of parsing OSRM responses. + * Creates a [`RouteResponseParser`] capable of parsing OSRM responses. * * This response parser is designed to be fairly flexible, * supporting both vanilla OSRM and enhanced Valhalla (ex: from Stadia Maps and Mapbox) outputs @@ -3721,10 +3721,10 @@ public func createOsrmResponseParser(polylinePrecision: UInt32) -> RouteResponse } /** - * Creates a [RouteRequestGenerator] + * Creates a [`RouteRequestGenerator`] * which generates requests to an arbitrary Valhalla server (using the OSRM response format). * - * This is provided as a convenience for use from foreign code when creating your own [routing_adapters::RouteAdapter]. + * This is provided as a convenience for use from foreign code when creating your own [`routing_adapters::RouteAdapter`]. */ public func createValhallaRequestGenerator(endpointUrl: String, profile: String) -> RouteRequestGenerator { try! FfiConverterTypeRouteRequestGenerator.lift( @@ -3825,10 +3825,10 @@ private var initializationResult: InitializationResult { if uniffi_ferrostar_checksum_func_advance_location_simulation() != 62608 { return InitializationResult.apiChecksumMismatch } - if uniffi_ferrostar_checksum_func_create_osrm_response_parser() != 28097 { + if uniffi_ferrostar_checksum_func_create_osrm_response_parser() != 46856 { return InitializationResult.apiChecksumMismatch } - if uniffi_ferrostar_checksum_func_create_valhalla_request_generator() != 35701 { + if uniffi_ferrostar_checksum_func_create_valhalla_request_generator() != 27528 { return InitializationResult.apiChecksumMismatch } if uniffi_ferrostar_checksum_func_get_route_polyline() != 53320 { diff --git a/common/Cargo.lock b/common/Cargo.lock index 03cba9c4..09399534 100644 --- a/common/Cargo.lock +++ b/common/Cargo.lock @@ -1172,7 +1172,7 @@ dependencies = [ [[package]] name = "uniffi-bindgen" -version = "0.1.0" +version = "0.0.0" dependencies = [ "uniffi", ] diff --git a/common/Cargo.toml b/common/Cargo.toml index 3fa69e37..da664f4b 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -1,5 +1,4 @@ [workspace] - members = [ "uniffi-bindgen", "ferrostar", @@ -11,7 +10,7 @@ authors = ["Ian Wagner ", "Jacob Fielding /// /// The `decimal_digits` parameter refers to the number of digits after the point. pub(crate) fn trunc_float(value: f64, decimal_digits: u32) -> f64 { - let factor = 10i64.pow(decimal_digits) as f64; + let factor = 10_i64.pow(decimal_digits) as f64; (value * factor).round() / factor } @@ -60,7 +60,7 @@ fn snap_point_to_line(point: &Point, line: &LineString) -> Option { // Bail early when we have two essentially identical points. // This can cause some issues with edge cases (captured in proptest regressions) // with the underlying libraries. - if line.euclidean_distance(point) < 0.000001 { + if line.euclidean_distance(point) < 0.000_001 { return Some(*point); } @@ -113,7 +113,7 @@ fn is_close_enough_to_end_of_linestring( /// Determines whether the navigation controller should complete the current route step /// and move to the next. /// -/// NOTE: The [UserLocation] should *not* be snapped. +/// NOTE: The [`UserLocation`] should *not* be snapped. pub fn should_advance_to_next_step( current_step_linestring: &LineString, next_route_step: Option<&RouteStep>, @@ -134,7 +134,7 @@ pub fn should_advance_to_next_step( is_close_enough_to_end_of_linestring( ¤t_position, current_step_linestring, - distance as f64, + f64::from(distance), ) } } @@ -150,7 +150,7 @@ pub fn should_advance_to_next_step( if is_close_enough_to_end_of_linestring( ¤t_position, current_step_linestring, - distance as f64, + f64::from(distance), ) { return true; } diff --git a/common/ferrostar/src/deviation_detection.rs b/common/ferrostar/src/deviation_detection.rs index 016457ba..b9ef3338 100644 --- a/common/ferrostar/src/deviation_detection.rs +++ b/common/ferrostar/src/deviation_detection.rs @@ -50,7 +50,7 @@ impl RouteDeviationTracking { minimum_horizontal_accuracy, max_acceptable_deviation, } => { - if location.horizontal_accuracy < *minimum_horizontal_accuracy as f64 { + if location.horizontal_accuracy < f64::from(*minimum_horizontal_accuracy) { // Check if the deviation from the route line is within tolerance, // after sanity checking that the positioning signal is within accuracy tolerance. deviation_from_line( diff --git a/common/ferrostar/src/lib.rs b/common/ferrostar/src/lib.rs index 5ebaa03d..6bb50d17 100644 --- a/common/ferrostar/src/lib.rs +++ b/common/ferrostar/src/lib.rs @@ -31,7 +31,7 @@ impl UniffiCustomTypeConverter for Uuid { type Builtin = String; fn into_custom(val: Self::Builtin) -> uniffi::Result { - Uuid::from_str(&val).map_err(|e| e.into()) + Ok(Uuid::from_str(&val)?) } fn from_custom(obj: Self) -> Self::Builtin { @@ -47,10 +47,10 @@ impl UniffiCustomTypeConverter for Uuid { // Instead, we use top-level functions to return dynamic objects conforming to the trait. // -/// Creates a [RouteRequestGenerator] +/// Creates a [`RouteRequestGenerator`] /// which generates requests to an arbitrary Valhalla server (using the OSRM response format). /// -/// This is provided as a convenience for use from foreign code when creating your own [routing_adapters::RouteAdapter]. +/// This is provided as a convenience for use from foreign code when creating your own [`routing_adapters::RouteAdapter`]. #[uniffi::export] fn create_valhalla_request_generator( endpoint_url: String, @@ -59,7 +59,7 @@ fn create_valhalla_request_generator( Arc::new(ValhallaHttpRequestGenerator::new(endpoint_url, profile)) } -/// Creates a [RouteResponseParser] capable of parsing OSRM responses. +/// Creates a [`RouteResponseParser`] capable of parsing OSRM responses. /// /// This response parser is designed to be fairly flexible, /// supporting both vanilla OSRM and enhanced Valhalla (ex: from Stadia Maps and Mapbox) outputs diff --git a/common/ferrostar/src/models.rs b/common/ferrostar/src/models.rs index 03cfe0b5..6f81532d 100644 --- a/common/ferrostar/src/models.rs +++ b/common/ferrostar/src/models.rs @@ -56,9 +56,9 @@ impl From for Point { /// A waypoint along a route. /// -/// Within the context of Ferrostar, a route request consists of exactly one [UserLocation] +/// Within the context of Ferrostar, a route request consists of exactly one [`UserLocation`] /// and at least one [Waypoint]. The route starts from the user's location (which may -/// contain other useful information like their current course for the [crate::routing_adapters::RouteRequestGenerator] +/// contain other useful information like their current course for the [`crate::routing_adapters::RouteRequestGenerator`] /// to use) and proceeds through one or more waypoints. /// /// Waypoints are used during route calculation, are tracked throughout the lifecycle of a trip, @@ -215,10 +215,13 @@ pub struct RouteStep { impl RouteStep { // TODO: Memoize or something later pub(crate) fn get_linestring(&self) -> LineString { - LineString::from_iter(self.geometry.iter().map(|coord| Coord { - x: coord.lng, - y: coord.lat, - })) + self.geometry + .iter() + .map(|coord| Coord { + x: coord.lng, + y: coord.lat, + }) + .collect() } /// Gets the active visual instruction given the user's progress along the step. @@ -276,7 +279,7 @@ pub struct SpokenInstruction { /// Indicates the type of maneuver to perform. /// -/// Frequently used in conjunction with [ManeuverModifier]. +/// Frequently used in conjunction with [`ManeuverModifier`]. #[derive(Deserialize, Debug, Copy, Clone, Eq, PartialEq, uniffi::Enum)] #[cfg_attr(test, derive(Serialize))] #[serde(rename_all = "lowercase")] @@ -306,7 +309,7 @@ pub enum ManeuverType { ExitRotary, } -/// Specifies additional information about a [ManeuverType] +/// Specifies additional information about a [`ManeuverType`] #[derive(Deserialize, Debug, Copy, Clone, Eq, PartialEq, uniffi::Enum)] #[cfg_attr(test, derive(Serialize))] #[serde(rename_all = "lowercase")] diff --git a/common/ferrostar/src/navigation_controller/mod.rs b/common/ferrostar/src/navigation_controller/mod.rs index 259f0e9f..1fc1e106 100644 --- a/common/ferrostar/src/navigation_controller/mod.rs +++ b/common/ferrostar/src/navigation_controller/mod.rs @@ -11,7 +11,7 @@ use crate::{ models::{Route, UserLocation}, }; use geo::{HaversineDistance, Point}; -use models::*; +use models::{NavigationControllerConfig, StepAdvanceStatus, TripState}; /// Manages the navigation lifecycle of a route, reacting to inputs like user location updates /// and returning a new state. @@ -30,7 +30,7 @@ pub struct NavigationController { impl NavigationController { #[uniffi::constructor] pub fn new(route: Route, config: NavigationControllerConfig) -> Self { - Self { config, route } + Self { route, config } } /// Returns initial trip state as if the user had just started the route with no progress. diff --git a/common/ferrostar/src/navigation_controller/models.rs b/common/ferrostar/src/navigation_controller/models.rs index 303917c6..83ee19a4 100644 --- a/common/ferrostar/src/navigation_controller/models.rs +++ b/common/ferrostar/src/navigation_controller/models.rs @@ -78,7 +78,7 @@ pub enum StepAdvanceMode { /// Values larger than this cannot trigger a step advance. minimum_horizontal_accuracy: u16, /// At this (optional) distance, navigation should advance to the next step regardless - /// of which LineString appears closer. + /// of which `LineString` appears closer. automatic_advance_distance: Option, }, } diff --git a/common/ferrostar/src/routing_adapters/mod.rs b/common/ferrostar/src/routing_adapters/mod.rs index 346b5bd1..52ae0985 100644 --- a/common/ferrostar/src/routing_adapters/mod.rs +++ b/common/ferrostar/src/routing_adapters/mod.rs @@ -12,7 +12,7 @@ pub mod error; pub mod osrm; pub mod valhalla; -/// A route request generated by a [RouteRequestGenerator]. +/// A route request generated by a [`RouteRequestGenerator`]. #[derive(PartialEq, Debug, uniffi::Enum)] pub enum RouteRequest { HttpPost { @@ -22,7 +22,7 @@ pub enum RouteRequest { }, } -/// A trait describing any object capable of generating [RouteRequest]s. +/// A trait describing any object capable of generating [`RouteRequest`]s. /// /// The interface is intentionally generic. Every routing backend has its own set of /// parameters, including a "profile," max travel speed, units of speed and distance, and more. @@ -63,10 +63,10 @@ pub trait RouteResponseParser: Send + Sync { /// over a generic request/response flow (typically over a network; /// local/offline routers **do not use this object** as the interaction patterns are different). /// -/// This is essentially the composite of the [RouteRequestGenerator] and [RouteResponseParser] +/// This is essentially the composite of the [`RouteRequestGenerator`] and [`RouteResponseParser`] /// traits, but it provides one further level of abstraction which is helpful to consumers. /// As there is no way to signal compatibility between request generators and response parsers, -/// the [RouteAdapter] provides convenience constructors which take the guesswork out of it, +/// the [`RouteAdapter`] provides convenience constructors which take the guesswork out of it, /// while still leaving consumers free to implement one or both halves. /// /// In the future, we may provide additional methods or conveniences, and this diff --git a/common/ferrostar/src/routing_adapters/osrm/mod.rs b/common/ferrostar/src/routing_adapters/osrm/mod.rs index c9d19578..8b0c17cd 100644 --- a/common/ferrostar/src/routing_adapters/osrm/mod.rs +++ b/common/ferrostar/src/routing_adapters/osrm/mod.rs @@ -86,7 +86,7 @@ impl RouteResponseParser for OsrmResponseParser { distance: route.distance, waypoints: waypoints.clone(), steps, - }) + }); } } diff --git a/common/ferrostar/src/routing_adapters/osrm/models.rs b/common/ferrostar/src/routing_adapters/osrm/models.rs index 8a7f5ce3..06f5b205 100644 --- a/common/ferrostar/src/routing_adapters/osrm/models.rs +++ b/common/ferrostar/src/routing_adapters/osrm/models.rs @@ -44,7 +44,7 @@ pub struct Route { /// /// NOTE: This library assumes that 1) an overview geometry will always be requested, and /// 2) that it will be a polyline (whether it is a polyline5 or polyline6 can be determined - /// by the [crate::routing_adapters::RouteResponseParser]). + /// by the [`crate::routing_adapters::RouteResponseParser`]). pub geometry: String, /// The legs between the given waypoints. pub legs: Vec, @@ -85,6 +85,7 @@ pub struct Annotation { /// NOTE: This annotation is not in the official spec, but is a common extension used by Mapbox /// and Valhalla. #[serde(default, rename = "maxspeed")] + #[allow(dead_code)] max_speed: Vec, } @@ -185,7 +186,7 @@ pub struct StepManeuver { /// A string indicating the type of maneuver. /// /// Note that even though there are `new name` and `notification` instructions, the - /// `mode` and `name` (of the parent [RouteStep]) can change between *any* pair of instructions. + /// `mode` and `name` (of the parent [`RouteStep`]) can change between *any* pair of instructions. /// They only offer a fallback in case there is nothing else to report. /// TODO: Model this as an enum. Note that new types may be introduced, and anything unknown to the client should be handled like a turn. #[serde(rename = "type")] @@ -202,7 +203,7 @@ impl StepManeuver { // Most commercial offerings offer server-side synthesis of voice instructions. // However, we might consider synthesizing these locally too. // This will be rather cumbersome with localization though. - fn synthesize_instruction(&self, locale: &str) -> String { + fn synthesize_instruction(&self, _locale: &str) -> String { String::from("TODO: OSRM instruction synthesis") } @@ -269,7 +270,7 @@ pub struct Lane { #[derive(Deserialize, Debug)] pub struct Waypoint { - /// THe name of the street that the waypoint snapped to. + /// The name of the street that the waypoint snapped to. pub name: Option, /// The distance (in meters) between the snapped point and the input coordinate. pub distance: Option, diff --git a/common/ferrostar/src/routing_adapters/valhalla.rs b/common/ferrostar/src/routing_adapters/valhalla.rs index 96803f67..35a043ef 100644 --- a/common/ferrostar/src/routing_adapters/valhalla.rs +++ b/common/ferrostar/src/routing_adapters/valhalla.rs @@ -6,7 +6,7 @@ use std::collections::HashMap; /// A route request generator for Valhalla backends operating over HTTP. /// -/// Valhalla supports the [WaypointKind] field of [Waypoint]s. Variants have the same meaning as their +/// Valhalla supports the [`WaypointKind`] field of [Waypoint]s. Variants have the same meaning as their /// [`type` strings in Valhalla API](https://valhalla.github.io/valhalla/api/turn-by-turn/api-reference/#locations) /// having the same name. #[derive(Debug)] diff --git a/common/uniffi-bindgen/Cargo.toml b/common/uniffi-bindgen/Cargo.toml index 66ac3fc6..0befce7c 100644 --- a/common/uniffi-bindgen/Cargo.toml +++ b/common/uniffi-bindgen/Cargo.toml @@ -1,13 +1,13 @@ +lints.workspace = true + [package] name = "uniffi-bindgen" -version = "0.1.0" authors.workspace = true license.workspace = true edition.workspace = true repository.workspace = true rust-version.workspace = true - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +publish = false [dependencies] uniffi = { workspace = true, features = ["cli"] } diff --git a/common/uniffi-bindgen/src/main.rs b/common/uniffi-bindgen/src/main.rs index f6cff6cf..a01b5470 100644 --- a/common/uniffi-bindgen/src/main.rs +++ b/common/uniffi-bindgen/src/main.rs @@ -1,3 +1,3 @@ fn main() { - uniffi::uniffi_bindgen_main() + uniffi::uniffi_bindgen_main(); }