Skip to content

Instantly share code, notes, and snippets.

@smvv
Last active December 20, 2015 00:19
Show Gist options
  • Save smvv/6040719 to your computer and use it in GitHub Desktop.
Save smvv/6040719 to your computer and use it in GitHub Desktop.
/* Fix: add `#[deriving(Clone]' to the enum.
zmq.rc:200:8: 215:9 error: failed to find an implementation of trait std::clone::Clone for Error
zmq.rc:200 do getsockopt_int(self.sock, constants::ZMQ_TYPE).map |ty| {
zmq.rc:201 match *ty {
zmq.rc:202 0 => PAIR,
zmq.rc:203 1 => PUB,
zmq.rc:204 2 => SUB,
zmq.rc:205 3 => REQ,
*/
/// Socket types
pub enum SocketType {
PAIR = 0,
PUB = 1,
SUB = 2,
REQ = 3,
REP = 4,
DEALER = 5,
ROUTER = 6,
PULL = 7,
PUSH = 8,
XPUB = 9,
XSUB = 10,
}
impl Socket {
pub fn get_socket_type(&self) -> Result<SocketType, Error> {
do getsockopt_int(self.sock, constants::ZMQ_TYPE).map |ty| {
match *ty {
0 => PAIR,
1 => PUB,
2 => SUB,
3 => REQ,
4 => REP,
5 => DEALER,
6 => ROUTER,
7 => PULL,
8 => PUSH,
9 => XPUB,
10 => XSUB,
_ => fail!(~"socket type is out of range!")
}
}
}
// [...]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment