Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd docs to ipc #153
Add docs to ipc #153
Conversation
|
Opened #154 |
|
Huh, highfive on strike?... Anyway, before I get to take a closer look, just some generic remarks for now:
BTW, I'm not really familiar with rustdoc -- is there some easy way to quickly check how the result looks like? |
|
Good comments. I'll work on incorporating them later.
|
0007a1e
to
9e98dc9
Updated.
I tried to update this, but for most functions I didn't change much. E.g. for
Yes, it doesn't appear to be too strict. I tried to adhere to this, but for functions like |
|
|
ac30d15
to
e3825b1
|
Updated and rebased on master. Is this still something that is worth merging? |
|
Sorry, I was busy with something else when you originally sent this, and didn't remember to check back... Yes, of course this is worth merging! The examples in particular are super valuable :-) Should you feel unable or unwilling to address some of my comments, we can merge it nevertheless -- after all, I can always submit a PR with proposed improvements later on... BTW, I think the commit message for the second commit doesn't really fit any more?... |
| @@ -336,6 +571,9 @@ impl IpcSelectionResult { | |||
| } | |||
| } | |||
|
|
|||
| /// Structure used to represend a readable message from an [IpcSender]. | |||
This comment has been minimized.
This comment has been minimized.
antrik
May 14, 2018
Contributor
I'd call it a raw received message before deserialisation, or something along these lines; and mention that it needs to be processed with the to() method to get a usable message.
(Also, typo: "represend" -> "represent"...)
| @@ -367,6 +605,7 @@ impl OpaqueIpcMessage { | |||
| } | |||
| } | |||
|
|
|||
| /// Cast the data in the contained message to the inferred type. | |||
This comment has been minimized.
This comment has been minimized.
antrik
May 14, 2018
Contributor
I'm not sure it's a good idea to call this a cast... After all, rather than just changing types, it actually deserialises the raw received message into the requested type; thus recreating the original message that was passed into the channel. (Assuming the specified type actually matches the channel type... AIUI, there is not type checking here. Ouch. Definitely should mention that in the documentation...)
Note that I'd call the type "requested" or "specified" or something like that, rather than "inferred": while it's true that it will typically be inferred at the call site, that's not something the method itself cares about AIUI?
| @@ -11,6 +11,33 @@ | |||
| feature(mpsc_select))] | |||
| #![cfg_attr(all(feature = "unstable", test), feature(specialization))] | |||
|
|
|||
| //! An implementation of the Rust channel API (a form of communicating sequential | |||
| //! processes, CSP) over the native OS abstractions. Under the hood, this API uses | |||
This comment has been minimized.
This comment has been minimized.
antrik
May 14, 2018
Contributor
The important aspect IMHO is that ipc-channel implements the channel API across process boundaries. The fact that it abstracts over OS-specific IPC mechanisms is certainly worth mentioning, but more as a side note...
(I do realise that you took that introduction from README.md -- but note that while README.md elaborates on this only in the second paragraph, the create description actually reads "A multiprocess drop-in replacement for Rust channels"...)
Quite frankly, I'm also sceptical about the reference to CSP. While channels can be used as one of the building blocks for CSP, I wouldn't consider them "an implementation of CSP" -- unless I'm more confused about the exact meaning of this term than I thought...
| //! Mach ports on Mac and file descriptor passing over Unix sockets on Linux. The | ||
| //! serde library is used to serialize values for transport over the wire. | ||
| //! | ||
| //! For more detail, see [IpcReceiver], [IpcSender], and [IpcReceiverSet]. |
This comment has been minimized.
This comment has been minimized.
antrik
May 14, 2018
Contributor
Not sure this remark is very helpful...
(Also, I'd say the main entry point is actually channel()?)
| //! # Features | ||
| //! ## `force-inprocess` | ||
| //! | ||
| //! Force the `inprocess` backend to be used instead of the OS specific backend. |
This comment has been minimized.
This comment has been minimized.
antrik
May 14, 2018
Contributor
Since this isn't documented anywhere else as far as I'm aware, I'd say we should explicitly mention here that this is a dummy back-end, that behaves much like the real ones, but doesn't actually work between different processes...
| /// # | ||
| /// # let (tx, rx) = ipc::channel().unwrap(); | ||
| /// # let (embedded_tx, embedded_rx) = ipc::channel().unwrap(); | ||
| /// # let data = vec![0x45, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x00]; |
This comment has been minimized.
This comment has been minimized.
antrik
May 14, 2018
Contributor
I think you could use a simple array here?...
(Applies to other examples too.)
| /// # use ipc_channel::ipc; | ||
| /// # | ||
| /// # let (tx, rx) = ipc::channel().unwrap(); | ||
| /// # let (embedded_tx, embedded_rx) = ipc::channel().unwrap(); |
This comment has been minimized.
This comment has been minimized.
| @@ -158,13 +310,21 @@ impl<T> Clone for IpcSender<T> where T: Serialize { | |||
| } | |||
|
|
|||
| impl<T> IpcSender<T> where T: Serialize { | |||
| /// Create an [IpcSender] connected to a previously defined [IpcOneShotServer]. | |||
This comment has been minimized.
This comment has been minimized.
antrik
May 14, 2018
Contributor
I think it would be clearer to mention that the one-shot server was created elsewhere (typically in a different process), rather than just earlier -- after all, that's the whole point of this mechanism...
Probably should also explain that the connection is established using an identifier string that was also used in the creation of the server, and passed between processes by other means (such as command line arguments or environment variables), in order to bootstrap an initial IPC connection between different processes.
(Arguably part of that rather belongs in the documentation of IpcOneShotServer -- but since you aren't adding any documentation for that one... :-) )
| pub fn connect(name: String) -> Result<IpcSender<T>,Error> { | ||
| Ok(IpcSender { | ||
| os_sender: try!(OsIpcSender::connect(name)), | ||
| phantom: PhantomData, | ||
| }) | ||
| } | ||
|
|
||
| /// Send data to the connected [IpcReceiver] or [IpcOneShotServer]. |
This comment has been minimized.
This comment has been minimized.
antrik
May 14, 2018
Contributor
I suspect bringing up IpcOneShotServer here will only cause confusion. The message is not actually sent to the server: it is sent to a normal receiver -- which just happens to be held by the server, until it is handed out to the actual user as a result of the accept() call. From the sender's point of view, only the connect() call deals with the server at all.
| @@ -191,6 +351,7 @@ impl<T> IpcSender<T> where T: Serialize { | |||
| }) | |||
| } | |||
|
|
|||
| /// Return a wrapper for the OS specific backend. | |||
This comment has been minimized.
This comment has been minimized.
antrik
May 14, 2018
Contributor
Same remark as for IpcReceiver.to_opaque().
(Though frankly I have no idea what OpaqueIpcSender is actually supposed to be useful for... Looks entirely unused to me. Probably should just drop it...)
e3825b1
to
2d520bb
|
|
- Add crate level documentation that discusses the overall goals of the crate and the features it implements. - Add basic documentation to the ipc::channel and ipc::bytes_channel functions. - Add basic documentation to the main structures and their commonly used methods.
|
Updated to address comments... almost two years later |
|
@bors-servo r+ |
|
|
Add docs to ipc Add documentation to the structures in the `ipc` module.
|
|

dlrobertson commentedFeb 26, 2017
Add documentation to the structures in the
ipcmodule.