<commit_before>//! Module: czmq-zsock

use {czmq_sys, Error, ErrorKind, Result, ZMonitor};
use std::{error, fmt, mem, ptr, result};
use std::ffi::{CStr, CString};
use std::os::raw::c_void;
use std::str::{Utf8Error};
use zmsg::ZMsgable;

// Duplicate this from rust-zmq to avoid users having to depend on
// both libs.
#[derive(Clone, Debug, PartialEq)]
pub enum ZSockType {
    PAIR   = 0,
    PUB    = 1,
    SUB    = 2,
    REQ    = 3,
    REP    = 4,
    DEALER = 5,
    ROUTER = 6,
    PULL   = 7,
    PUSH   = 8,
    XPUB   = 9,
    XSUB   = 10,
}

// Duplicate this from rust-zmq to avoid users having to depend on
// both libs.
#[allow(non_camel_case_types)]
#[derive(Clone, Debug, PartialEq)]
pub enum ZSockMechanism {
    ZMQ_NULL   = 0,
    ZMQ_PLAIN  = 1,
    ZMQ_CURVE  = 2,
    ZMQ_GSSAPI = 3,
}

impl Copy for ZSockMechanism {}

pub struct ZSock {
    zsock: *mut czmq_sys::zsock_t,
    owned: bool,
}

unsafe impl Send for ZSock {}

impl Drop for ZSock {
    fn drop(&mut self) {
        if self.owned {
            unsafe { czmq_sys::zsock_destroy(&mut self.zsock) };
        }
    }
}

impl ZSock {
    pub fn new(sock_type: ZSockType) -> ZSock {
        ZSock {
            zsock: unsafe { czmq_sys::zsock_new(sock_type as i32) },
            owned: true,
        }
    }
<commit_msg>Implemented PartialEq for ZSock<commit_after>//! Module: czmq-zsock

use {czmq_sys, Error, ErrorKind, Result, ZMonitor};
use std::{error, fmt, mem, ptr, result};
use std::ffi::{CStr, CString};
use std::os::raw::c_void;
use std::str::{Utf8Error};
use zmsg::ZMsgable;

// Duplicate this from rust-zmq to avoid users having to depend on
// both libs.
#[derive(Clone, Debug, PartialEq)]
pub enum ZSockType {
    PAIR   = 0,
    PUB    = 1,
    SUB    = 2,
    REQ    = 3,
    REP    = 4,
    DEALER = 5,
    ROUTER = 6,
    PULL   = 7,
    PUSH   = 8,
    XPUB   = 9,
    XSUB   = 10,
}

// Duplicate this from rust-zmq to avoid users having to depend on
// both libs.
#[allow(non_camel_case_types)]
#[derive(Clone, Debug, PartialEq)]
pub enum ZSockMechanism {
    ZMQ_NULL   = 0,
    ZMQ_PLAIN  = 1,
    ZMQ_CURVE  = 2,
    ZMQ_GSSAPI = 3,
}

impl Copy for ZSockMechanism {}

pub struct ZSock {
    zsock: *mut czmq_sys::zsock_t,
    owned: bool,
}

impl Drop for ZSock {
    fn drop(&mut self) {
        if self.owned {
            unsafe { czmq_sys::zsock_destroy(&mut self.zsock) };
        }
    }
}

impl PartialEq for ZSock {
    fn eq(&self, other: &ZSock) -> bool {
        self.zsock == other.zsock
    }
}

unsafe impl Send for ZSock {}

impl ZSock {
    pub fn new(sock_type: ZSockType) -> ZSock {
        ZSock {
            zsock: unsafe { czmq_sys::zsock_new(sock_type as i32) },
            owned: true,
        }
    }

{'fraction_non_alphanumeric': 0.12728602779809803, 'fraction_numerical': 0.013899049012435992, 'mean_word_length': 2.380716934487021, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3982539', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1065, 'n_words': 288}