1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-01 09:24:20 -04:00
denoland-deno/src/msg.fbs
Ryan Dahl bcbbee7399 Adds basic File I/O and FD table.
Adds deno.stdin, deno.stdout, deno.stderr, deno.open(), deno.write(),
deno.read(), deno.Reader, deno.Writer, deno.copy().

Fixes #721. tests/cat.ts works.
2018-09-28 20:53:33 -04:00

288 lines
3.7 KiB
Text

union Any {
Start,
StartRes,
CodeFetch,
CodeFetchRes,
CodeCache,
SetTimeout,
Exit,
TimerStart,
TimerReady,
TimerClear,
Environ,
EnvironRes,
FetchReq,
FetchRes,
MakeTempDir,
MakeTempDirRes,
Mkdir,
Remove,
ReadFile,
ReadFileRes,
WriteFile,
Rename,
Readlink,
ReadlinkRes,
Symlink,
Stat,
StatRes,
SetEnv,
Open,
OpenRes,
Read,
ReadRes,
Write,
WriteRes,
Close,
}
enum ErrorKind: byte {
NoError = 0,
// io errors
NotFound,
PermissionDenied,
ConnectionRefused,
ConnectionReset,
ConnectionAborted,
NotConnected,
AddrInUse,
AddrNotAvailable,
BrokenPipe,
AlreadyExists,
WouldBlock,
InvalidInput,
InvalidData,
TimedOut,
Interrupted,
WriteZero,
Other,
UnexpectedEof,
BadFileDescriptor,
// url errors
EmptyHost,
IdnaError,
InvalidPort,
InvalidIpv4Address,
InvalidIpv6Address,
InvalidDomainCharacter,
RelativeUrlWithoutBase,
RelativeUrlWithCannotBeABaseBase,
SetHostOnCannotBeABaseUrl,
Overflow,
// hyper errors
HttpUser,
HttpClosed,
HttpCanceled,
HttpParse,
HttpOther,
}
table Base {
cmd_id: uint32;
sync: bool = true; // TODO(ry) Change default to false.
error_kind: ErrorKind = NoError;
error: string;
msg: Any;
}
table Start {
unused: int8;
}
table StartRes {
cwd: string;
argv: [string];
debug_flag: bool;
deps_flag: bool;
recompile_flag: bool;
}
table CodeFetch {
module_specifier: string;
containing_file: string;
}
table CodeFetchRes {
// If it's a non-http module, moduleName and filename will be the same.
// For http modules, moduleName is its resolved http URL, and filename
// is the location of the locally downloaded source code.
module_name: string;
filename: string;
source_code: string;
output_code: string; // Non-empty only if cached.
}
table CodeCache {
filename: string;
source_code: string;
output_code: string;
}
table SetTimeout {
timeout: int;
}
table Exit {
code: int;
}
table TimerStart {
id: uint;
delay: uint;
}
table TimerReady {
id: uint;
canceled: bool;
}
table TimerClear {
id: uint;
}
table Environ {}
table SetEnv {
key: string;
value: string;
}
table EnvironRes {
map: [EnvPair];
}
table EnvPair {
key: string;
value: string;
}
table FetchReq {
id: uint;
url: string;
// header_line: [string];
}
table FetchRes {
id: uint;
status: int;
header_key: [string];
header_value: [string];
body: [ubyte];
}
table MakeTempDir {
dir: string;
prefix: string;
suffix: string;
}
table MakeTempDirRes {
path: string;
}
table Mkdir {
path: string;
mode: uint;
// mode specified by https://godoc.org/os#FileMode
}
table Remove {
path: string;
recursive: bool;
}
table ReadFile {
filename: string;
}
table ReadFileRes {
data: [ubyte];
}
table WriteFile {
filename: string;
data: [ubyte];
perm: uint;
// perm specified by https://godoc.org/os#FileMode
}
table Rename {
oldpath: string;
newpath: string;
}
table Readlink {
name: string;
}
table ReadlinkRes {
path: string;
}
table Symlink {
oldname: string;
newname: string;
}
table Stat {
filename: string;
lstat: bool;
}
table StatRes {
is_file: bool;
is_symlink: bool;
len: ulong;
modified:ulong;
accessed:ulong;
created:ulong;
mode: uint;
has_mode: bool; // false on windows
}
table WriteFileSync {
filename: string;
data: [ubyte];
perm: uint;
// perm specified by https://godoc.org/os#FileMode
}
table Open {
filename: string;
perm: uint;
}
table OpenRes {
fd: int;
}
table Read {
fd: int;
// (ptr, len) is passed as second parameter to libdeno.send().
}
table ReadRes {
nread: uint;
eof: bool;
}
table Write {
fd: int;
}
table WriteRes {
nbyte: uint;
}
table Close {
fd: int;
}
root_type Base;