@@ -1144,16 +1144,22 @@ proto! oneshot {
1144
1144
}
1145
1145
}
1146
1146
1147
- /// Receive a message from a oneshot pipe.
1147
+ /// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair.
1148
+ fn oneshot < T : send > ( ) -> ( oneshot:: client:: oneshot < T > ,
1149
+ oneshot:: server:: oneshot < T > ) {
1150
+ oneshot:: init ( )
1151
+ }
1152
+
1153
+ /**
1154
+ * Receive a message from a oneshot pipe, failing if the connection was
1155
+ * closed.
1156
+ */
1148
1157
fn recv_one < T : send > ( +port : oneshot:: server:: oneshot < T > ) -> T {
1149
1158
let oneshot:: send( message) = recv ( port) ;
1150
1159
message
1151
1160
}
1152
1161
1153
- /** Receive a message from a oneshot pipe, or fail if the connection
1154
- is closed.
1155
-
1156
- */
1162
+ /// Receive a message from a oneshot pipe unless the connection was closed.
1157
1163
fn try_recv_one < T : send > ( +port : oneshot:: server:: oneshot < T > ) -> option < T > {
1158
1164
let message = try_recv ( port) ;
1159
1165
@@ -1164,6 +1170,20 @@ fn try_recv_one<T: send> (+port: oneshot::server::oneshot<T>) -> option<T> {
1164
1170
}
1165
1171
}
1166
1172
1173
+ /// 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 ) {
1175
+ oneshot:: client:: send ( chan, data) ;
1176
+ }
1177
+
1178
+ /**
1179
+ * Send a message on a oneshot pipe, or return false if the connection was
1180
+ * closed.
1181
+ */
1182
+ fn try_send_one < T : send > ( +chan : oneshot:: client:: oneshot < T > , +data : T )
1183
+ -> bool {
1184
+ oneshot:: client:: try_send ( chan, data) . is_some ( )
1185
+ }
1186
+
1167
1187
#[ cfg( test) ]
1168
1188
mod test {
1169
1189
#[ test]
0 commit comments