Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UUID type fix #251

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if useLocalFramework {
path: "./common/target/ios/libferrostar-rs.xcframework"
)
} else {
let releaseTag = "0.10.1"
let releaseTag = "0.11.0"
let releaseChecksum = "cc959191f3d066f628264c103e5ea0c3544664ffd0e61907e082d7f1a4d8c5d2"
binaryTarget = .binaryTarget(
name: "FerrostarCoreRS",
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ plugins {

allprojects {
group = "com.stadiamaps.ferrostar"
version = "0.10.1"
version = "0.11.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import uniffi.ferrostar.RouteDeviation
import uniffi.ferrostar.RouteRequest
import uniffi.ferrostar.TripState
import uniffi.ferrostar.UserLocation
import uniffi.ferrostar.Uuid
import uniffi.ferrostar.Waypoint

/** Represents the complete state of the navigation session provided by FerrostarCore-RS. */
Expand Down Expand Up @@ -109,7 +110,7 @@ class FerrostarCore(

// Maintains a set of utterance IDs which have been seen previously.
// This helps us maintain the guarantee that the observer won't see the same one twice.
private val _queuedUtteranceIds: MutableSet<String> = mutableSetOf()
private val _queuedUtteranceIds: MutableSet<Uuid> = mutableSetOf()

var isCalculatingNewRoute: Boolean = false
private set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,13 @@ class AndroidTtsObserver(
// Amazon Polly is generally the intended target for SSML on Android though.
val status =
tts.speak(
spokenInstruction.text, TextToSpeech.QUEUE_ADD, null, spokenInstruction.utteranceId)
spokenInstruction.text,
TextToSpeech.QUEUE_ADD,
null,
spokenInstruction.utteranceId.toString())
if (status != TextToSpeech.SUCCESS) {
android.util.Log.e(TAG, "Unable to speak instruction: code $status")
statusObserver?.onTtsSpeakError(spokenInstruction.utteranceId, status)
statusObserver?.onTtsSpeakError(spokenInstruction.utteranceId.toString(), status)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion apple/Sources/FerrostarCore/FerrostarCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public protocol FerrostarCoreDelegate: AnyObject {
private var lastAutomaticRecalculation: Date? = nil
private var lastLocation: UserLocation? = nil
private var recalculationTask: Task<Void, Never>?
private var queuedUtteranceIDs: Set<String> = Set()
private var queuedUtteranceIDs: Set<UUID> = Set()

private var config: SwiftNavigationControllerConfig

Expand Down
17 changes: 11 additions & 6 deletions apple/Sources/UniFFI/ferrostar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3880,25 +3880,30 @@ private struct FfiConverterDictionaryStringString: FfiConverterRustBuffer {
}

/**
* Typealias from the type name used in the UDL file to the builtin type. This
* Typealias from the type name used in the UDL file to the custom type. This
* is needed because the UDL type name is used in function/method signatures.
*/
public typealias Uuid = String
public typealias Uuid = UUID

public struct FfiConverterTypeUuid: FfiConverter {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Uuid {
try FfiConverterString.read(from: &buf)
let builtinValue = try FfiConverterString.read(from: &buf)
return UUID(uuidString: builtinValue)!
}

public static func write(_ value: Uuid, into buf: inout [UInt8]) {
FfiConverterString.write(value, into: &buf)
let builtinValue = value.uuidString
return FfiConverterString.write(builtinValue, into: &buf)
}

public static func lift(_ value: RustBuffer) throws -> Uuid {
try FfiConverterString.lift(value)
let builtinValue = try FfiConverterString.lift(value)
return UUID(uuidString: builtinValue)!
}

public static func lower(_ value: Uuid) -> RustBuffer {
FfiConverterString.lower(value)
let builtinValue = value.uuidString
return FfiConverterString.lower(builtinValue)
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/ferrostar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ lints.workspace = true

[package]
name = "ferrostar"
version = "0.10.1"
version = "0.11.0"
readme = "README.md"
description = "The core of modern turn-by-turn navigation."
keywords = ["navigation", "routing", "valhalla", "osrm"]
Expand Down
12 changes: 12 additions & 0 deletions common/ferrostar/uniffi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[bindings.swift.custom_types.Uuid]
type_name = "UUID"
into_custom = "UUID(uuidString: {})!"
from_custom = "{}.uuidString"

[bindings.kotlin.custom_types.Uuid]
# Eventually we can transition to the Kotlin stdlib type,
# but this was only just added in Kotlin 2.0.20 (Aug 2024) and is marked experimental.
# See https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.uuid/-uuid/.
type_name = "java.util.UUID"
into_custom = "java.util.UUID.fromString({})"
from_custom = "{}.toString()"
6 changes: 3 additions & 3 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"CatMe0w <[email protected]> (https://github.com/CatMe0w)",
"Luke Seelenbinder <[email protected]>"
],
"version": "0.10.1",
"version": "0.11.0",
"license": "BSD-3-Clause",
"type": "module",
"main": "./dist/ferrostar-webcomponents.js",
Expand Down
Loading