added csp_socket_close
This commit is contained in:
parent
d49d0affe2
commit
0b075e5a97
@ -343,9 +343,9 @@ pub const CSP_DBG_ETH_ERR_RX_OUT: u32 = 3;
|
||||
pub const CSP_DBG_ETH_ERR_SHORT_BEGIN: u32 = 4;
|
||||
pub const CSP_DBG_ETH_ERR_INCOMPLETE: u32 = 5;
|
||||
pub const CSP_DBG_ETH_ERR_UNKNOWN: u32 = 6;
|
||||
pub const __bool_true_false_are_defined: u32 = 1;
|
||||
pub const true_: u32 = 1;
|
||||
pub const false_: u32 = 0;
|
||||
pub const __bool_true_false_are_defined: u32 = 1;
|
||||
pub const CSP_QUEUE_OK: u32 = 0;
|
||||
pub const CSP_QUEUE_ERROR: i32 = -1;
|
||||
pub const CSP_ANY: u32 = 255;
|
||||
@ -2411,7 +2411,11 @@ extern "C" {
|
||||
) -> ::core::ffi::c_int;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn bcopy(__src: *const ::core::ffi::c_void, __dest: *mut ::core::ffi::c_void, __n: usize);
|
||||
pub fn bcopy(
|
||||
__src: *const ::core::ffi::c_void,
|
||||
__dest: *mut ::core::ffi::c_void,
|
||||
__n: ::core::ffi::c_ulong,
|
||||
);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn bzero(__s: *mut ::core::ffi::c_void, __n: ::core::ffi::c_ulong);
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
git clone https://github.com/us-irs/libcsp.git
|
||||
cd libcsp
|
||||
git checkout const-correctness
|
||||
|
15
src/lib.rs
15
src/lib.rs
@ -398,6 +398,21 @@ pub fn csp_accept(socket: &mut CspSocket, timeout: Duration) -> Option<CspConnRe
|
||||
}))
|
||||
}
|
||||
|
||||
/// Rust wrapper for [ffi::csp_socket_close] which returns the result code directly.
|
||||
pub fn csp_socket_close_raw(sock: &mut CspSocket) -> i32 {
|
||||
unsafe { ffi::csp_socket_close(&mut sock.0) }
|
||||
}
|
||||
|
||||
/// Rust wrapper for [ffi::csp_socket_close].
|
||||
///
|
||||
/// This function will panic if the error code returned from [ffi::csp_socket_close] is not one of
|
||||
/// [CspError]. [csp_socket_close_raw] can be used if this is not acceptable.
|
||||
pub fn csp_socket_close(sock: &mut CspSocket) -> Result<(), CspError> {
|
||||
let result = unsafe { ffi::csp_socket_close(&mut sock.0) };
|
||||
Err(CspError::try_from(result)
|
||||
.unwrap_or_else(|_| panic!("unexpected error value {} from csp_socket_close", result)))
|
||||
}
|
||||
|
||||
/// Rust wrapper for [ffi::csp_read].
|
||||
pub fn csp_read(conn: &mut CspConnRef, timeout: Duration) -> Option<CspPacketRef> {
|
||||
let timeout_millis = timeout.as_millis();
|
||||
|
Loading…
Reference in New Issue
Block a user