1818namespace viam {
1919namespace sdk {
2020
21- ViamChannel::RustDialData::RustDialData ( const char * path_, void * runtime)
22- : path(path_ ), rust_runtime(runtime) {}
21+ struct ViamChannel ::impl {
22+ impl ( const char * path, void * runtime) : 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 )) {}
24+ impl (const impl&) = delete ;
2725
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 );
26+ impl (impl && other) noexcept
27+ : path( std::exchange(other.path, nullptr )),
28+ rust_runtime ( std::exchange(other.rust_runtime, nullptr )) {}
3129
32- return *this ;
33- }
30+ impl& operator =(const impl&) = delete ;
3431
35- ViamChannel::RustDialData::~RustDialData () {
36- free_string (path);
37- free_rust_runtime (rust_runtime);
38- }
32+ impl& operator =(impl&& other) noexcept {
33+ path = std::exchange (other.path , nullptr );
34+ rust_runtime = std::exchange (other.rust_runtime , nullptr );
35+
36+ return *this ;
37+ }
38+
39+ ~impl () {
40+ free_string (path);
41+ free_rust_runtime (rust_runtime);
42+ }
43+
44+ const char * path;
45+ void * rust_runtime;
46+ };
3947
4048ViamChannel::ViamChannel (std::shared_ptr<grpc::Channel> channel, const char * path, void * runtime)
41- : channel_(std::move(channel)), rust_data_(RustDialData (path, runtime)) {}
49+ : channel_(std::move(channel)), pimpl_(std::make_unique<ViamChannel::impl> (path, runtime)) {}
4250
4351ViamChannel::ViamChannel (std::shared_ptr<grpc::Channel> channel) : channel_(std::move(channel)) {}
4452
@@ -170,7 +178,7 @@ std::shared_ptr<ViamChannel> ViamChannel::dial(const char* uri,
170178 std::string address (" unix://" );
171179 address += socket_path;
172180 const std::shared_ptr<grpc::Channel> channel =
173- impl::create_viam_channel (address, grpc::InsecureChannelCredentials ());
181+ sdk:: impl::create_viam_channel (address, grpc::InsecureChannelCredentials ());
174182 const std::unique_ptr<viam::robot::v1::RobotService::Stub> st =
175183 viam::robot::v1::RobotService::NewStub (channel);
176184 return std::make_shared<ViamChannel>(channel, socket_path, ptr);
@@ -181,7 +189,7 @@ const std::shared_ptr<grpc::Channel>& ViamChannel::channel() const {
181189}
182190
183191void ViamChannel::close () {
184- rust_data_ .reset ();
192+ pimpl_ .reset ();
185193}
186194
187195unsigned int Options::refresh_interval () const {
0 commit comments