Conversation
|
I remember this exact issue when writing Maybe a slightly cleaner work-around is making it an associated constant, since it should never change. |
|
Ultimately, it's the caller of the trait that has to make sure that the message is offset by the correct amount of bytes, so the associated constant approach also feels slightly cumbersome. Then again, I'm ok with having the changes. |
|
How about making the
Yeah, but this can be forced with the type system rather than having them do it manually. By having the method only accept a custom type that only expose an offset buffer slice on the platforms that need it. |
The tunnel reader trait as used on macOS (#18) forces a copy of the received traffic since macOS's
utunrequires extra header to be passed into the tunnel interface when receiving tunnel traffic. Since theWriter::writemethod takes a single parameter that is the slice of bytes that should be written to theutundevice, and the slice doesn't contain the headersutunexpects, the slice has to be copied and a buffer needs to be allocated. Since the header on macOS are always 4 bytes long, it will always be smaller than the wireguard header that's preceding the payload in the buffer that's originally backing the slice.This seems like a bit of a hack, and I'm open to better suggestions to reducing the amount of copying required.