Open collosi opened 6 years ago
I think that it safe to have all methods take an immutable reference to self
, as long as there is no way to obtain a reference to some state within the socket which would be invalidated by some method. I might be mistaken, though, and will try to solicit a second opinion.
I've now renamed this issue. If it is indeed safe and sound to use &Socket
for socket setters, it should be safe for other methods as well. This should be resolved with a rationale documented somewhere, and will require an API change.
Functions like set_subscribe() logically change the state in a Socket. Doesn't that mean that it should be declared like "fn set_subscribe(&mut self, value: &[u8]) -> Result<()>"? I understand that the rust type checker might not force you to do that because you're mutating state behind a native pointer, but logically shouldn't it? More importantly, are there optimizations that the compiler might make that are incorrect, because it's assuming nothing related to the socket is changing?