Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive Debug on Context and Socket #349

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ pub fn version() -> (i32, i32, i32) {
(major as i32, minor as i32, patch as i32)
}

#[derive(Debug)]
struct RawContext {
ctx: *mut c_void,
}
Expand Down Expand Up @@ -417,7 +418,7 @@ impl Drop for RawContext {
/// other threads, see `zmq_ctx_destroy`(3)) by explicitly calling
/// `Context::destroy`.
///
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct Context {
raw: Arc<RawContext>,
}
Expand Down Expand Up @@ -480,6 +481,7 @@ impl Default for Context {
}

/// A socket, the central object in 0MQ.
#[derive(Debug)]
pub struct Socket {
sock: *mut c_void,
// The `context` field is never accessed, but implicitly does
Expand Down Expand Up @@ -1348,3 +1350,16 @@ pub fn z85_decode(data: &str) -> result::Result<Vec<u8>, DecodeError> {

Ok(dest)
}


#[cfg(test)]
mod tests {
use crate::Context;
use crate::SocketType;

#[test]
fn debug_works() {
println!("{:?}", Context::new());
println!("{:?}", Context::new().socket(SocketType::REQ));
}
}