wireguard-uapi-rs
                                
                                
                                
                                    wireguard-uapi-rs copied to clipboard
                            
                            
                            
                        get: Make device peer vector a map
Currently, peers in a device are stored as a vector, which requires iterating to find a peer by its public key, so this commit changes it to be a hash map.
I've had a bit of difficulty deciding whether the types returned from this library should be easy to use or reflective of the raw Netlink responses. Although a map is certainly more useful, the original intention was to mimic the raw response.
I think there's good arguments both ways. Is the primary advantage of returning a map directly to avoid a O(n) passthrough on the Vec<Peers> after the response is serialized? Or are there other advantages I'm forgetting?
I guess you do have a point here, because my use case is holding a map of peers at runtime for constant-time access. Serialization and deserialization is more a happy accident. The peculiarity of largely reimplementing the data structures with one field having a different type (and, of course, the reimplemented serialization code) made me want to propose this.