Skip to content

Commit 57a9221

Browse files
committed
rule of 3 rust data
1 parent c1f3d55 commit 57a9221

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/viam/sdk/rpc/dial.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ namespace sdk {
2121
ViamChannel::RustDialData::RustDialData(const char* path_, void* runtime)
2222
: path(path_), rust_runtime(runtime) {}
2323

24+
ViamChannel::RustDialData::RustDialData(RustDialData&& other) noexcept
25+
: path(std::exchange(other.path, nullptr)),
26+
rust_runtime(std::exchange(other.rust_runtime, nullptr)) {}
27+
28+
ViamChannel::RustDialData& ViamChannel::RustDialData::operator=(RustDialData&& other) noexcept {
29+
path = std::exchange(other.path, nullptr);
30+
rust_runtime = std::exchange(other.rust_runtime, nullptr);
31+
32+
return *this;
33+
}
34+
2435
ViamChannel::RustDialData::~RustDialData() {
2536
free_string(path);
2637
free_rust_runtime(rust_runtime);

src/viam/sdk/rpc/dial.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ class ViamChannel {
4646
private:
4747
struct RustDialData {
4848
RustDialData(const char* path_, void* runtime);
49+
50+
RustDialData(const RustDialData&) = delete;
51+
RustDialData(RustDialData&&) noexcept;
52+
53+
RustDialData& operator=(const RustDialData&) = delete;
54+
RustDialData& operator=(RustDialData&&) noexcept;
55+
4956
~RustDialData();
5057

5158
const char* path;

0 commit comments

Comments
 (0)