Skip to main content

abi_definitions/file_system/
socket.rs

1use crate::{XilaFileSystemFile, abi_unsafe_function};
2
3use virtual_file_system::Error;
4
5abi_unsafe_function! {
6    /// This function is used to send data through a socket.
7    ///
8    /// # Safety
9    ///
10    /// This function is unsafe because it dereferences raw pointers.
11    fn xila_network_send(
12        _socket:  XilaFileSystemFile,
13        buffer: *const u8,
14        size: usize,
15    ) -> XilaFileSystemResult {
16        if buffer.is_null() {
17            return Err(Error::InvalidParameter);
18        }
19
20        let _buffer = core::slice::from_raw_parts(buffer, size);
21
22        Ok(())
23    }
24}
25
26abi_unsafe_function! {
27    /// This function is used to receive data through a socket.
28    ///
29    /// # Safety
30    ///
31    /// This function is unsafe because it dereferences raw pointers.
32    ///
33    /// # Errors
34    ///
35    /// This function may return an error if the file system fails to receive the data.
36    fn xila_network_receive(
37        _socket: XilaFileSystemFile,
38        buffer: *mut u8,
39        size: usize,
40    ) -> XilaFileSystemResult {
41        if buffer.is_null() {
42            return Err(Error::InvalidParameter);
43        }
44
45        let _buffer = core::slice::from_raw_parts_mut(buffer, size);
46
47        Ok(())
48    }
49}