-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from rylev/wasi-scaffold
Scaffold wasi support
- Loading branch information
Showing
6 changed files
with
296 additions
and
20 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::os::wasi::io::{FromRawFd, AsRawFd}; | ||
|
||
use {TcpBuilder, UdpBuilder, FromInner, AsInner}; | ||
use socket::Socket; | ||
use sys::{self, c::__wasi_fd_t}; | ||
|
||
impl FromRawFd for TcpBuilder { | ||
unsafe fn from_raw_fd(fd: __wasi_fd_t) -> TcpBuilder { | ||
let sock = sys::Socket::from_inner(fd); | ||
TcpBuilder::from_inner(Socket::from_inner(sock)) | ||
} | ||
} | ||
|
||
impl AsRawFd for TcpBuilder { | ||
fn as_raw_fd(&self) -> __wasi_fd_t { | ||
// TODO: this unwrap() is very bad | ||
self.as_inner().borrow().as_ref().unwrap().as_inner().raw() as __wasi_fd_t | ||
} | ||
} | ||
|
||
impl FromRawFd for UdpBuilder { | ||
unsafe fn from_raw_fd(fd: __wasi_fd_t) -> UdpBuilder { | ||
let sock = sys::Socket::from_inner(fd); | ||
UdpBuilder::from_inner(Socket::from_inner(sock)) | ||
} | ||
} | ||
|
||
impl AsRawFd for UdpBuilder { | ||
fn as_raw_fd(&self) -> __wasi_fd_t { | ||
// TODO: this unwrap() is very bad | ||
self.as_inner().borrow().as_ref().unwrap().as_inner().raw() as __wasi_fd_t | ||
} | ||
} |
Oops, something went wrong.