LiveKit C++ SDK
Real-time audio/video SDK for C++
Loading...
Searching...
No Matches
ffi_handle.h
1
/*
2
* Copyright 2025 LiveKit
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an “AS IS” BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#pragma once
18
19
#include <cstdint>
20
21
namespace
livekit {
22
29
class
FfiHandle
{
30
public
:
31
explicit
FfiHandle
(uintptr_t h = 0)
noexcept
;
32
~FfiHandle
();
33
34
// Non-copyable
35
FfiHandle
(
const
FfiHandle
&) =
delete
;
36
FfiHandle
&operator=(
const
FfiHandle
&) =
delete
;
37
38
// Movable
39
FfiHandle
(
FfiHandle
&&other)
noexcept
;
40
FfiHandle
&operator=(
FfiHandle
&&other)
noexcept
;
41
42
// Replace the current handle with a new one, dropping the old if needed
43
void
reset(uintptr_t new_handle = 0)
noexcept
;
44
45
// Release ownership of the handle without dropping it
46
[[nodiscard]] uintptr_t release()
noexcept
;
47
48
// Whether the handle is valid (non-zero)
49
[[nodiscard]]
bool
valid()
const
noexcept
;
50
51
// Get the raw handle value
52
[[nodiscard]] uintptr_t get()
const
noexcept
;
53
54
// Allow `if (handle)` syntax
55
explicit
operator
bool()
const
noexcept
{
return
valid(); }
56
57
private
:
58
uintptr_t handle_{0};
59
};
60
61
}
// namespace livekit
livekit::FfiHandle
RAII wrapper for an FFI handle (uintptr_t) coming from Rust.
Definition
ffi_handle.h:29
include
livekit
ffi_handle.h
Generated by
1.9.8