|
2 | 2 |
|
3 | 3 | use mach2::port::{mach_port_right_t, mach_port_t};
|
4 | 4 |
|
5 |
| -/// A trait for everything that wraps a raw Mach port name (aka `mach_port_t`) and can be converted |
6 |
| -/// into it. |
| 5 | +/// A trait to get a raw Mach port name (`mach_port_t`) from an object. |
7 | 6 | pub trait AsRawName {
|
8 | 7 | /// Specifies the disposition value to be set in a port descriptor when the represented right
|
9 | 8 | /// reference has to be moved to the receiver's IPC space.
|
10 | 9 | ///
|
11 | 10 | /// This should be one of the `MACH_MSG_TYPE_MOVE_*` constants.
|
12 | 11 | const MSG_TYPE: mach_port_right_t;
|
13 | 12 |
|
14 |
| - /// Converts a type into a raw Mach port name. This function should not alter reference counts |
15 |
| - /// of any port rights. |
| 13 | + /// Extracts the raw Mach port name. |
| 14 | + /// |
| 15 | + /// This function is intended to **borrow** a Mach port right reference. That is, the ownership |
| 16 | + /// of the reference isn't passed to the caller, and the name is only guaranteed to represent |
| 17 | + /// the corresponding port right only during the lifetime of the original object. |
| 18 | + /// |
| 19 | + /// This function should not alter reference counts of the port right represented by the name. |
16 | 20 | fn as_raw_name(&self) -> mach_port_t;
|
17 | 21 | }
|
18 | 22 |
|
19 |
| -/// A trait for everything that wraps a raw Mach port name (aka `mach_port_t`) and can be converted |
20 |
| -/// into it. |
| 23 | +/// A trait to convert an object into a raw Mach port name (`mach_port_t`) while taking ownership |
| 24 | +/// of the port right reference represented by the name. |
21 | 25 | pub trait IntoRawName: AsRawName {
|
22 |
| - /// Converts a type into a raw Mach port name. This function should not alter reference counts |
23 |
| - /// of any port rights. |
| 26 | + /// Converts an object into a raw Mach port name. |
| 27 | + /// |
| 28 | + /// This function is intended to **pass** a Mach port right reference from a destructed object |
| 29 | + /// to the caller. That means the caller will be responsible for properly dropping the reference |
| 30 | + /// when it is no longer needed. |
| 31 | + /// |
| 32 | + /// This function should not alter reference counts of the port right represented by the name. |
24 | 33 | fn into_raw_name(self) -> mach_port_t;
|
25 | 34 | }
|
0 commit comments