Skip to content

Commit 46adb84

Browse files
committed
Expose build info
Allows client to access the version specified in Cargo.toml
1 parent 5ebca79 commit 46adb84

File tree

7 files changed

+95
-0
lines changed

7 files changed

+95
-0
lines changed

livekit-uniffi/generated/kotlin/uniffi/livekit_uniffi/livekit_uniffi.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,8 @@ internal object IntegrityCheckingUniffiLib {
640640
uniffiCheckContractApiVersion(this)
641641
uniffiCheckApiChecksums(this)
642642
}
643+
external fun uniffi_livekit_uniffi_checksum_func_build_version(
644+
): Short
643645
external fun uniffi_livekit_uniffi_checksum_func_generate_token(
644646
): Short
645647
external fun uniffi_livekit_uniffi_checksum_func_log_forward_bootstrap(
@@ -661,6 +663,8 @@ internal object UniffiLib {
661663
Native.register(UniffiLib::class.java, findLibraryName(componentName = "livekit_uniffi"))
662664

663665
}
666+
external fun uniffi_livekit_uniffi_fn_func_build_version(uniffi_out_err: UniffiRustCallStatus,
667+
): RustBuffer.ByValue
664668
external fun uniffi_livekit_uniffi_fn_func_generate_token(`options`: RustBuffer.ByValue,`credentials`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
665669
): RustBuffer.ByValue
666670
external fun uniffi_livekit_uniffi_fn_func_log_forward_bootstrap(`level`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
@@ -788,6 +792,9 @@ private fun uniffiCheckContractApiVersion(lib: IntegrityCheckingUniffiLib) {
788792
}
789793
@Suppress("UNUSED_PARAMETER")
790794
private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {
795+
if (lib.uniffi_livekit_uniffi_checksum_func_build_version() != 45072.toShort()) {
796+
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
797+
}
791798
if (lib.uniffi_livekit_uniffi_checksum_func_generate_token() != 29823.toShort()) {
792799
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
793800
}
@@ -1962,6 +1969,19 @@ public object FfiConverterMapStringString: FfiConverterRustBuffer<Map<kotlin.Str
19621969

19631970

19641971

1972+
/**
1973+
* Returns the version specified in the crate's Cargo.toml.
1974+
*/ fun `buildVersion`(): kotlin.String {
1975+
return FfiConverterString.lift(
1976+
uniffiRustCall() { _status ->
1977+
UniffiLib.uniffi_livekit_uniffi_fn_func_build_version(
1978+
1979+
_status)
1980+
}
1981+
)
1982+
}
1983+
1984+
19651985
/**
19661986
* Generates an access token.
19671987
*

livekit-uniffi/generated/python/livekit_uniffi.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,8 @@ def _uniffi_check_contract_api_version(lib):
479479
raise InternalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")
480480

481481
def _uniffi_check_api_checksums(lib):
482+
if lib.uniffi_livekit_uniffi_checksum_func_build_version() != 45072:
483+
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
482484
if lib.uniffi_livekit_uniffi_checksum_func_generate_token() != 29823:
483485
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
484486
if lib.uniffi_livekit_uniffi_checksum_func_log_forward_bootstrap() != 14091:
@@ -750,6 +752,10 @@ class _UniffiForeignFutureDroppedCallbackStruct(ctypes.Structure):
750752
ctypes.c_uint64,
751753
)
752754
_UniffiLib.ffi_livekit_uniffi_rust_future_free_void.restype = None
755+
_UniffiLib.uniffi_livekit_uniffi_fn_func_build_version.argtypes = (
756+
ctypes.POINTER(_UniffiRustCallStatus),
757+
)
758+
_UniffiLib.uniffi_livekit_uniffi_fn_func_build_version.restype = _UniffiRustBuffer
753759
_UniffiLib.uniffi_livekit_uniffi_fn_func_generate_token.argtypes = (
754760
_UniffiRustBuffer,
755761
_UniffiRustBuffer,
@@ -773,6 +779,9 @@ class _UniffiForeignFutureDroppedCallbackStruct(ctypes.Structure):
773779
_UniffiLib.ffi_livekit_uniffi_uniffi_contract_version.argtypes = (
774780
)
775781
_UniffiLib.ffi_livekit_uniffi_uniffi_contract_version.restype = ctypes.c_uint32
782+
_UniffiLib.uniffi_livekit_uniffi_checksum_func_build_version.argtypes = (
783+
)
784+
_UniffiLib.uniffi_livekit_uniffi_checksum_func_build_version.restype = ctypes.c_uint16
776785
_UniffiLib.uniffi_livekit_uniffi_checksum_func_generate_token.argtypes = (
777786
)
778787
_UniffiLib.uniffi_livekit_uniffi_checksum_func_generate_token.restype = ctypes.c_uint16
@@ -1880,6 +1889,20 @@ def read(buf):
18801889
@staticmethod
18811890
def write(value, buf):
18821891
buf.write_u8(value)
1892+
def build_version() -> str:
1893+
"""
1894+
Returns the version specified in the crate's Cargo.toml.
1895+
"""
1896+
_uniffi_lowered_args = (
1897+
)
1898+
_uniffi_lift_return = _UniffiFfiConverterString.lift
1899+
_uniffi_error_converter = None
1900+
_uniffi_ffi_result = _uniffi_rust_call_with_error(
1901+
_uniffi_error_converter,
1902+
_UniffiLib.uniffi_livekit_uniffi_fn_func_build_version,
1903+
*_uniffi_lowered_args,
1904+
)
1905+
return _uniffi_lift_return(_uniffi_ffi_result)
18831906
def generate_token(options: TokenOptions,credentials: typing.Optional[ApiCredentials]) -> str:
18841907
"""
18851908
Generates an access token.
@@ -1984,6 +2007,7 @@ def verify_token(token: str,credentials: typing.Optional[ApiCredentials]) -> Cla
19842007
"Claims",
19852008
"LogForwardEntry",
19862009
"TokenOptions",
2010+
"build_version",
19872011
"generate_token",
19882012
"log_forward_bootstrap",
19892013
"log_forward_receive",

livekit-uniffi/generated/swift/livekit_uniffi.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,15 @@ fileprivate func uniffiFutureContinuationCallback(handle: UInt64, pollResult: In
15721572
print("uniffiFutureContinuationCallback invalid handle")
15731573
}
15741574
}
1575+
/**
1576+
* Returns the version specified in the crate's Cargo.toml.
1577+
*/
1578+
public func buildVersion() -> String {
1579+
return try! FfiConverterString.lift(try! rustCall() {
1580+
uniffi_livekit_uniffi_fn_func_build_version($0
1581+
)
1582+
})
1583+
}
15751584
/**
15761585
* Generates an access token.
15771586
*
@@ -1656,6 +1665,9 @@ private let initializationResult: InitializationResult = {
16561665
if bindings_contract_version != scaffolding_contract_version {
16571666
return InitializationResult.contractVersionMismatch
16581667
}
1668+
if (uniffi_livekit_uniffi_checksum_func_build_version() != 45072) {
1669+
return InitializationResult.apiChecksumMismatch
1670+
}
16591671
if (uniffi_livekit_uniffi_checksum_func_generate_token() != 29823) {
16601672
return InitializationResult.apiChecksumMismatch
16611673
}

livekit-uniffi/generated/swift/livekit_uniffiFFI.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ typedef struct UniffiForeignFutureResultVoid {
242242
typedef void (*UniffiForeignFutureCompleteVoid)(uint64_t, UniffiForeignFutureResultVoid
243243
);
244244

245+
#endif
246+
#ifndef UNIFFI_FFIDEF_UNIFFI_LIVEKIT_UNIFFI_FN_FUNC_BUILD_VERSION
247+
#define UNIFFI_FFIDEF_UNIFFI_LIVEKIT_UNIFFI_FN_FUNC_BUILD_VERSION
248+
RustBuffer uniffi_livekit_uniffi_fn_func_build_version(RustCallStatus *_Nonnull out_status
249+
250+
);
245251
#endif
246252
#ifndef UNIFFI_FFIDEF_UNIFFI_LIVEKIT_UNIFFI_FN_FUNC_GENERATE_TOKEN
247253
#define UNIFFI_FFIDEF_UNIFFI_LIVEKIT_UNIFFI_FN_FUNC_GENERATE_TOKEN
@@ -522,6 +528,12 @@ void ffi_livekit_uniffi_rust_future_free_void(uint64_t handle
522528
#ifndef UNIFFI_FFIDEF_FFI_LIVEKIT_UNIFFI_RUST_FUTURE_COMPLETE_VOID
523529
#define UNIFFI_FFIDEF_FFI_LIVEKIT_UNIFFI_RUST_FUTURE_COMPLETE_VOID
524530
void ffi_livekit_uniffi_rust_future_complete_void(uint64_t handle, RustCallStatus *_Nonnull out_status
531+
);
532+
#endif
533+
#ifndef UNIFFI_FFIDEF_UNIFFI_LIVEKIT_UNIFFI_CHECKSUM_FUNC_BUILD_VERSION
534+
#define UNIFFI_FFIDEF_UNIFFI_LIVEKIT_UNIFFI_CHECKSUM_FUNC_BUILD_VERSION
535+
uint16_t uniffi_livekit_uniffi_checksum_func_build_version(void
536+
525537
);
526538
#endif
527539
#ifndef UNIFFI_FFIDEF_UNIFFI_LIVEKIT_UNIFFI_CHECKSUM_FUNC_GENERATE_TOKEN

livekit-uniffi/python_test/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ def main():
1010
# Receive log messages from Rust
1111
log_forward_bootstrap(level=LogForwardFilter.INFO)
1212

13+
# Print FFI version
14+
print(f"FFI version: v{build_version()}")
15+
1316
credentials = ApiCredentials(key="devkey", secret="secret")
1417

1518
jwt = generate_token(

livekit-uniffi/src/build_info.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2025 LiveKit, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/// Returns the version specified in the crate's Cargo.toml.
16+
#[uniffi::export]
17+
pub fn build_version() -> String {
18+
env!("CARGO_PKG_VERSION").to_string()
19+
}
20+
21+
// TODO: consider adding other info such as timestamp and Git hash.

livekit-uniffi/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ pub mod access_token;
1818
/// Forward log messages from Rust.
1919
pub mod log_forward;
2020

21+
/// Information about the build such as version.
22+
pub mod build_info;
23+
2124
// TODO: expose more modules...
2225

2326
uniffi::setup_scaffolding!();

0 commit comments

Comments
 (0)