Comments (3)
Let's wait on @wojcik91 update in #12
from wireguard-rs.
I'd like to bring a little update regarding this matter.
I tried to somewhat play with the librairy, adding the clone trait and I also tried to bring the Copy trait (The copy trait is a way more complicated thing to implement because you need to add the copy trait for a lot of things and you can't because of a vector that can't be copied bit to bit.
For the main concern :
The clone is not mandatory for 99% of the use cases because you can borrow a Host and make it mutable if it's still not enough, you can make the Host type
a type reference
and you can also reference to the object host
itself, so you can give it to multiple functions. (This way you can avoid the borrow / value moved problem)
However, there are some really particular cases that might need the clone trait (you want to perform a very particular operation on the host, or on the peer, and it's irreversible, or it's a side operation that doesn't need to continue with the structure afterward, then the clone trait can be interesting. You can also use a to_owned on the struct but it performs actually a .clone().
It's not related to the library but you have to keep in mind that if you have a Host A, then you clone to a Host B, you'll be able to modify both in parallel but every changes that are made to Host A won't be mirrored to the Host B. And vice & versa. Which means that you can't clone Host A to give Host B to another function and expect to use the Host A with the changes. (for instance, peer creation)
Finally, I think adding the clone trait (and copy trait when possible) is a must because it can save a lot of time and allows to pull the library from crates.io with the changes already made instead of modifying it locally.
Can I have your feedback on the possibility of doing the integration of the clone trait to the structures ?
Best,
Ange
from wireguard-rs.
Hi.
I added the Clone
trait to Host
struct and specific interface implementations in #20.
When it comes to the WGApi struct itself, making it Clone
would require a more significant refactor or pulling in an additional crate (like dyn-clone
) due to the need for object-safety, so I don't think we'll add it at this point in time.
from wireguard-rs.
Related Issues (20)
- Add Windows support for defguard client HOT 4
- Wireguard-rs on crates.io HOT 1
- Presharedkey support HOT 8
- How work write and delete peer ? HOT 3
- OS Error 19 with defguard_wireguard_rs 0.2.0 from crates.io for the server example HOT 1
- Unable to change existing WireGuard interface address on Linux HOT 1
- Sequence of creating peers and host blurry HOT 3
- Mutiple allowed ips not working in peer (wg show) HOT 1
- Enrich example with how to use preshared key inside the server.rs
- Route adding when creating the interface not working
- Mandatory steps for configuring the peer ?
- Clone trait for the WGApi ? HOT 1
- Release wireguard-rs 0.3
- After disconnecting DNS rules are not removed
- Release wireguard_rs 0.3.1
- Provide Example for presharedkey implementation HOT 1
- Update README Wireguard-RS with Windows
- Remove sensitive info from debug logs on Windows
- Add option to set MTU
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wireguard-rs.