{"action":"created","issue":{"url":"https://api.github.com/repos/dcuddeback/serial-rs/issues/16","repository_url":"https://api.github.com/repos/dcuddeback/serial-rs","labels_url":"https://api.github.com/repos/dcuddeback/serial-rs/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/dcuddeback/serial-rs/issues/16/comments","events_url":"https://api.github.com/repos/dcuddeback/serial-rs/issues/16/events","html_url":"https://github.com/dcuddeback/serial-rs/issues/16","id":153092543,"number":16,"title":"serial::windows::com::COMPort does not implement Send trait","user":{"login":"apoloval","id":738507,"avatar_url":"https://avatars.githubusercontent.com/u/738507?v=3","gravatar_id":"","url":"https://api.github.com/users/apoloval","html_url":"https://github.com/apoloval","followers_url":"https://api.github.com/users/apoloval/followers","following_url":"https://api.github.com/users/apoloval/following{/other_user}","gists_url":"https://api.github.com/users/apoloval/gists{/gist_id}","starred_url":"https://api.github.com/users/apoloval/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apoloval/subscriptions","organizations_url":"https://api.github.com/users/apoloval/orgs","repos_url":"https://api.github.com/users/apoloval/repos","events_url":"https://api.github.com/users/apoloval/events{/privacy}","received_events_url":"https://api.github.com/users/apoloval/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-04T19:15:42Z","updated_at":"2016-05-13T15:46:46Z","closed_at":null,"body":"I'm writing an application using `serial-rs`, and I've found an obstacle trying to use it in a multithreading context. \r\n\r\nThe point is that I'm make a sort of serial port scanner. A _listener_ thread will scan serial ports until a new device is connected. Then it creates a new thread and passes the `SerialPort` instance to it using move semantics. \r\n\r\nIn order to do that, `SerialPort` implementations must implement `Send` trait. The native implementation for Windows, `serial::windows::com::COMPort` if I'm not wrong, does not according to the following compilation error:\r\n\r\n```\r\nsrc\\port\\serial.rs:43:9: 43:18 error: the trait `core::marker::Send` is not implemented for the type `*mut *mut libc::c_void` [E0277]\r\nsrc\\port\\serial.rs:43         Self::new(domain, proto::oacsp())\r\n                              ^~~~~~~~~\r\nsrc\\port\\serial.rs:43:9: 43:18 help: run `rustc --explain E0277` to see a detailed explanation\r\nsrc\\port\\serial.rs:43:9: 43:18 note: `*mut *mut libc::c_void` cannot be sent between threads safely\r\nsrc\\port\\serial.rs:43:9: 43:18 note: required because it appears within the type `serial::windows::com::COMPort`\r\nsrc\\port\\serial.rs:43:9: 43:18 note: required because it appears within the type `proto::oacsp::output::MessageConsumer<serial::windows::com::COMPort>`\r\nsrc\\port\\serial.rs:43:9: 43:18 note: required because it appears within the type `proto::oacsp::writer::EventWriter<proto::oacsp::output::MessageConsumer<serial::windows::com::COMPort>>`\r\nsrc\\port\\serial.rs:43:9: 43:18 note: required by `port::serial::SerialPort::new` \r\n```\r\n\r\nMoving the `SerialPort` instance from one thread to another should not be forbidden. Sharing it perhaps should not. Thus, `Send` + `'static` should be implemented but `Sync` should not. \r\n"},"comment":{"url":"https://api.github.com/repos/dcuddeback/serial-rs/issues/comments/219082173","html_url":"https://github.com/dcuddeback/serial-rs/issues/16#issuecomment-219082173","issue_url":"https://api.github.com/repos/dcuddeback/serial-rs/issues/16","id":219082173,"user":{"login":"apoloval","id":738507,"avatar_url":"https://avatars.githubusercontent.com/u/738507?v=3","gravatar_id":"","url":"https://api.github.com/users/apoloval","html_url":"https://github.com/apoloval","followers_url":"https://api.github.com/users/apoloval/followers","following_url":"https://api.github.com/users/apoloval/following{/other_user}","gists_url":"https://api.github.com/users/apoloval/gists{/gist_id}","starred_url":"https://api.github.com/users/apoloval/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apoloval/subscriptions","organizations_url":"https://api.github.com/users/apoloval/orgs","repos_url":"https://api.github.com/users/apoloval/repos","events_url":"https://api.github.com/users/apoloval/events{/privacy}","received_events_url":"https://api.github.com/users/apoloval/received_events","type":"User","site_admin":false},"created_at":"2016-05-13T15:46:46Z","updated_at":"2016-05-13T15:46:46Z","body":"No, I didn't. But I guess there should be no problem. In Unix, file descriptors are integer values, which are `Send` by default in Rust. In Windows, resource handles are pointers, which are not `Send`. \r\n"}}