@@ -90,7 +90,8 @@ export send_packet, recv_packet, send, recv, try_recv, peek;
90
90
export select, select2, selecti, select2i, selectable;
91
91
export spawn_service, spawn_service_recv;
92
92
export stream, port, chan, shared_chan, port_set, channel;
93
- export oneshot, recv_one, try_recv_one, send_one, try_send_one;
93
+ export oneshot, chan_one, port_one;
94
+ export recv_one, try_recv_one, send_one, try_send_one;
94
95
95
96
#[ doc( hidden) ]
96
97
const SPIN_COUNT : uint = 0 ;
@@ -1144,23 +1145,27 @@ proto! oneshot {
1144
1145
}
1145
1146
}
1146
1147
1148
+ /// The send end of a oneshot pipe.
1149
+ type chan_one < T : send > = oneshot:: client:: oneshot < T > ;
1150
+ /// The receive end of a oneshot pipe.
1151
+ type port_one < T : send > = oneshot:: server:: oneshot < T > ;
1152
+
1147
1153
/// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair.
1148
- fn oneshot < T : send > ( ) -> ( oneshot:: client:: oneshot < T > ,
1149
- oneshot:: server:: oneshot < T > ) {
1154
+ fn oneshot < T : send > ( ) -> ( chan_one < T > , port_one < T > ) {
1150
1155
oneshot:: init ( )
1151
1156
}
1152
1157
1153
1158
/**
1154
1159
* Receive a message from a oneshot pipe, failing if the connection was
1155
1160
* closed.
1156
1161
*/
1157
- fn recv_one < T : send > ( +port : oneshot :: server :: oneshot < T > ) -> T {
1162
+ fn recv_one < T : send > ( +port : port_one < T > ) -> T {
1158
1163
let oneshot:: send( message) = recv ( port) ;
1159
1164
message
1160
1165
}
1161
1166
1162
1167
/// Receive a message from a oneshot pipe unless the connection was closed.
1163
- fn try_recv_one < T : send > ( +port : oneshot :: server :: oneshot < T > ) -> option < T > {
1168
+ fn try_recv_one < T : send > ( +port : port_one < T > ) -> option < T > {
1164
1169
let message = try_recv ( port) ;
1165
1170
1166
1171
if message == none { none }
@@ -1171,15 +1176,15 @@ fn try_recv_one<T: send> (+port: oneshot::server::oneshot<T>) -> option<T> {
1171
1176
}
1172
1177
1173
1178
/// Send a message on a oneshot pipe, failing if the connection was closed.
1174
- fn send_one < T : send > ( +chan : oneshot :: client :: oneshot < T > , +data : T ) {
1179
+ fn send_one < T : send > ( +chan : chan_one < T > , +data : T ) {
1175
1180
oneshot:: client:: send ( chan, data) ;
1176
1181
}
1177
1182
1178
1183
/**
1179
1184
* Send a message on a oneshot pipe, or return false if the connection was
1180
1185
* closed.
1181
1186
*/
1182
- fn try_send_one < T : send > ( +chan : oneshot :: client :: oneshot < T > , +data : T )
1187
+ fn try_send_one < T : send > ( +chan : chan_one < T > , +data : T )
1183
1188
-> bool {
1184
1189
oneshot:: client:: try_send ( chan, data) . is_some ( )
1185
1190
}
0 commit comments