@@ -173,21 +173,21 @@ impl SocketRef {
173
173
Socket :: new ( family, kind) . into_ref_with_type ( vm, cls)
174
174
}
175
175
176
- fn connect ( self , address : PyTupleRef , vm : & VirtualMachine ) -> PyResult {
176
+ fn connect ( self , address : PyTupleRef , vm : & VirtualMachine ) -> PyResult < ( ) > {
177
177
let address_string = get_address_string ( vm, address) ?;
178
178
179
179
match self . socket_kind {
180
180
SocketKind :: Stream => match TcpStream :: connect ( address_string) {
181
181
Ok ( stream) => {
182
182
self . con . borrow_mut ( ) . replace ( Connection :: TcpStream ( stream) ) ;
183
- Ok ( vm . get_none ( ) )
183
+ Ok ( ( ) )
184
184
}
185
185
Err ( s) => Err ( vm. new_os_error ( s. to_string ( ) ) ) ,
186
186
} ,
187
187
SocketKind :: Dgram => {
188
188
if let Some ( Connection :: UdpSocket ( con) ) = self . con . borrow ( ) . as_ref ( ) {
189
189
match con. connect ( address_string) {
190
- Ok ( _) => Ok ( vm . get_none ( ) ) ,
190
+ Ok ( _) => Ok ( ( ) ) ,
191
191
Err ( s) => Err ( vm. new_os_error ( s. to_string ( ) ) ) ,
192
192
}
193
193
} else {
@@ -197,7 +197,7 @@ impl SocketRef {
197
197
}
198
198
}
199
199
200
- fn bind ( self , address : PyTupleRef , vm : & VirtualMachine ) -> PyResult {
200
+ fn bind ( self , address : PyTupleRef , vm : & VirtualMachine ) -> PyResult < ( ) > {
201
201
let address_string = get_address_string ( vm, address) ?;
202
202
203
203
match self . socket_kind {
@@ -206,14 +206,14 @@ impl SocketRef {
206
206
self . con
207
207
. borrow_mut ( )
208
208
. replace ( Connection :: TcpListener ( stream) ) ;
209
- Ok ( vm . get_none ( ) )
209
+ Ok ( ( ) )
210
210
}
211
211
Err ( s) => Err ( vm. new_os_error ( s. to_string ( ) ) ) ,
212
212
} ,
213
213
SocketKind :: Dgram => match UdpSocket :: bind ( address_string) {
214
214
Ok ( dgram) => {
215
215
self . con . borrow_mut ( ) . replace ( Connection :: UdpSocket ( dgram) ) ;
216
- Ok ( vm . get_none ( ) )
216
+ Ok ( ( ) )
217
217
}
218
218
Err ( s) => Err ( vm. new_os_error ( s. to_string ( ) ) ) ,
219
219
} ,
@@ -274,25 +274,25 @@ impl SocketRef {
274
274
Ok ( vm. ctx . new_tuple ( vec ! [ vm. ctx. new_bytes( buffer) , addr_tuple] ) )
275
275
}
276
276
277
- fn send ( self , bytes : PyBytesRef , vm : & VirtualMachine ) -> PyResult {
277
+ fn send ( self , bytes : PyBytesRef , vm : & VirtualMachine ) -> PyResult < ( ) > {
278
278
match self . con . borrow_mut ( ) . as_mut ( ) {
279
279
Some ( v) => match v. write ( & bytes) {
280
280
Ok ( _) => ( ) ,
281
281
Err ( s) => return Err ( vm. new_os_error ( s. to_string ( ) ) ) ,
282
282
} ,
283
283
None => return Err ( vm. new_type_error ( "" . to_string ( ) ) ) ,
284
284
} ;
285
- Ok ( vm . get_none ( ) )
285
+ Ok ( ( ) )
286
286
}
287
287
288
- fn sendto ( self , bytes : PyBytesRef , address : PyTupleRef , vm : & VirtualMachine ) -> PyResult {
288
+ fn sendto ( self , bytes : PyBytesRef , address : PyTupleRef , vm : & VirtualMachine ) -> PyResult < ( ) > {
289
289
let address_string = get_address_string ( vm, address) ?;
290
290
291
291
match self . socket_kind {
292
292
SocketKind :: Dgram => {
293
293
if let Some ( v) = self . con . borrow ( ) . as_ref ( ) {
294
294
return match v. send_to ( & bytes, address_string) {
295
- Ok ( _) => Ok ( vm . get_none ( ) ) ,
295
+ Ok ( _) => Ok ( ( ) ) ,
296
296
Err ( s) => Err ( vm. new_os_error ( s. to_string ( ) ) ) ,
297
297
} ;
298
298
}
@@ -301,7 +301,7 @@ impl SocketRef {
301
301
Ok ( dgram) => match dgram. send_to ( & bytes, address_string) {
302
302
Ok ( _) => {
303
303
self . con . borrow_mut ( ) . replace ( Connection :: UdpSocket ( dgram) ) ;
304
- Ok ( vm . get_none ( ) )
304
+ Ok ( ( ) )
305
305
}
306
306
Err ( s) => Err ( vm. new_os_error ( s. to_string ( ) ) ) ,
307
307
} ,
@@ -312,9 +312,8 @@ impl SocketRef {
312
312
}
313
313
}
314
314
315
- fn close ( self , vm : & VirtualMachine ) -> PyResult {
315
+ fn close ( self , _vm : & VirtualMachine ) -> ( ) {
316
316
self . con . borrow_mut ( ) . take ( ) ;
317
- Ok ( vm. get_none ( ) )
318
317
}
319
318
320
319
fn fileno ( self , vm : & VirtualMachine ) -> PyResult {
0 commit comments