This repository has been archived by the owner on Oct 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is based on @npmccullum's [wasi-snapshot-preview2 draft] which is in turn based on the [wasi-sockets proposal], though for simplify for now it omits UDP sockets and some other features. It's also based on the [pseudo-streams PR]; so that should proceed first before this. [draft wasi-snapshot-preview2]: https://github.com/npmccallum/wasi-snapshot-preview2 [wasi-sockets proposal]: https://github.com/WebAssembly/wasi-sockets [pseudo-streams PR]: #29
- Loading branch information
1 parent
018ca43
commit a17f1c2
Showing
3 changed files
with
606 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,136 @@ | ||
#![allow(unused_variables)] | ||
|
||
use crate::{ | ||
wasi_tcp::{self, BytesResult, Socket, WasiTcp}, | ||
HostResult, WasiCtx, | ||
wasi_tcp::{ | ||
self, ConnectionFlags, Errno, IpSocketAddress, ListenerFlags, Network, Size, TcpConnection, | ||
TcpListener, WasiTcp, | ||
}, | ||
HostResult, WasiCtx, WasiStream, | ||
}; | ||
|
||
#[async_trait::async_trait] | ||
impl WasiTcp for WasiCtx { | ||
async fn bytes_readable(&mut self, socket: Socket) -> HostResult<BytesResult, wasi_tcp::Error> { | ||
async fn listen( | ||
&mut self, | ||
network: Network, | ||
address: IpSocketAddress, | ||
backlog: Option<Size>, | ||
flags: ListenerFlags, | ||
) -> HostResult<TcpListener, Errno> { | ||
todo!() | ||
} | ||
|
||
async fn accept( | ||
&mut self, | ||
listener: TcpListener, | ||
flags: ConnectionFlags, | ||
) -> HostResult<(TcpConnection, IpSocketAddress), Errno> { | ||
todo!() | ||
} | ||
|
||
async fn connect( | ||
&mut self, | ||
network: Network, | ||
local_address: IpSocketAddress, | ||
remote_address: IpSocketAddress, | ||
flags: ConnectionFlags, | ||
) -> HostResult<TcpConnection, Errno> { | ||
todo!() | ||
} | ||
|
||
async fn send(&mut self, connection: TcpConnection, bytes: Vec<u8>) -> HostResult<Size, Errno> { | ||
todo!() | ||
} | ||
|
||
async fn receive( | ||
&mut self, | ||
connection: TcpConnection, | ||
length: Size, | ||
) -> HostResult<(Vec<u8>, bool), Errno> { | ||
todo!() | ||
} | ||
|
||
async fn get_listener_local_address( | ||
&mut self, | ||
listener: TcpListener, | ||
) -> HostResult<IpSocketAddress, Errno> { | ||
todo!() | ||
} | ||
|
||
async fn get_tcp_connection_local_address( | ||
&mut self, | ||
connection: TcpConnection, | ||
) -> HostResult<IpSocketAddress, Errno> { | ||
todo!() | ||
} | ||
|
||
async fn get_remote_address( | ||
&mut self, | ||
connection: TcpConnection, | ||
) -> HostResult<IpSocketAddress, Errno> { | ||
todo!() | ||
} | ||
|
||
async fn get_flags(&mut self, connection: TcpConnection) -> HostResult<ConnectionFlags, Errno> { | ||
todo!() | ||
} | ||
|
||
async fn set_flags( | ||
&mut self, | ||
connection: TcpConnection, | ||
flags: ConnectionFlags, | ||
) -> HostResult<(), Errno> { | ||
todo!() | ||
} | ||
|
||
async fn get_receive_buffer_size( | ||
&mut self, | ||
connection: TcpConnection, | ||
) -> HostResult<Size, Errno> { | ||
todo!() | ||
} | ||
|
||
async fn set_receive_buffer_size( | ||
&mut self, | ||
connection: TcpConnection, | ||
value: Size, | ||
) -> HostResult<(), Errno> { | ||
todo!() | ||
} | ||
|
||
async fn get_send_buffer_size(&mut self, connection: TcpConnection) -> HostResult<Size, Errno> { | ||
todo!() | ||
} | ||
|
||
async fn set_send_buffer_size( | ||
&mut self, | ||
connection: TcpConnection, | ||
value: Size, | ||
) -> HostResult<(), Errno> { | ||
todo!() | ||
} | ||
|
||
async fn bytes_readable(&mut self, socket: TcpConnection) -> HostResult<Size, Errno> { | ||
drop(socket); | ||
todo!() | ||
} | ||
|
||
async fn bytes_writable(&mut self, socket: Socket) -> HostResult<BytesResult, wasi_tcp::Error> { | ||
async fn bytes_writable(&mut self, socket: TcpConnection) -> HostResult<Size, Errno> { | ||
drop(socket); | ||
todo!() | ||
} | ||
|
||
async fn read_via_stream( | ||
&mut self, | ||
fd: wasi_tcp::TcpConnection, | ||
) -> HostResult<WasiStream, wasi_tcp::Errno> { | ||
todo!() | ||
} | ||
|
||
async fn write_via_stream( | ||
&mut self, | ||
fd: wasi_tcp::TcpConnection, | ||
) -> HostResult<WasiStream, wasi_tcp::Errno> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.