@bytecodealliance/jco
Version:
JavaScript tooling for working with WebAssembly Components
167 lines (164 loc) • 4.04 kB
TypeScript
/** @module Interface wasi:filesystem/types@0.2.3 **/
export function filesystemErrorCode(err: Error): ErrorCode | undefined;
/**
* # Variants
*
* ## `"unknown"`
*
* ## `"block-device"`
*
* ## `"character-device"`
*
* ## `"directory"`
*
* ## `"fifo"`
*
* ## `"symbolic-link"`
*
* ## `"regular-file"`
*
* ## `"socket"`
*/
export type DescriptorType = 'unknown' | 'block-device' | 'character-device' | 'directory' | 'fifo' | 'symbolic-link' | 'regular-file' | 'socket';
/**
* # Variants
*
* ## `"access"`
*
* ## `"would-block"`
*
* ## `"already"`
*
* ## `"bad-descriptor"`
*
* ## `"busy"`
*
* ## `"deadlock"`
*
* ## `"quota"`
*
* ## `"exist"`
*
* ## `"file-too-large"`
*
* ## `"illegal-byte-sequence"`
*
* ## `"in-progress"`
*
* ## `"interrupted"`
*
* ## `"invalid"`
*
* ## `"io"`
*
* ## `"is-directory"`
*
* ## `"loop"`
*
* ## `"too-many-links"`
*
* ## `"message-size"`
*
* ## `"name-too-long"`
*
* ## `"no-device"`
*
* ## `"no-entry"`
*
* ## `"no-lock"`
*
* ## `"insufficient-memory"`
*
* ## `"insufficient-space"`
*
* ## `"not-directory"`
*
* ## `"not-empty"`
*
* ## `"not-recoverable"`
*
* ## `"unsupported"`
*
* ## `"no-tty"`
*
* ## `"no-such-device"`
*
* ## `"overflow"`
*
* ## `"not-permitted"`
*
* ## `"pipe"`
*
* ## `"read-only"`
*
* ## `"invalid-seek"`
*
* ## `"text-file-busy"`
*
* ## `"cross-device"`
*/
export type ErrorCode = 'access' | 'would-block' | 'already' | 'bad-descriptor' | 'busy' | 'deadlock' | 'quota' | 'exist' | 'file-too-large' | 'illegal-byte-sequence' | 'in-progress' | 'interrupted' | 'invalid' | 'io' | 'is-directory' | 'loop' | 'too-many-links' | 'message-size' | 'name-too-long' | 'no-device' | 'no-entry' | 'no-lock' | 'insufficient-memory' | 'insufficient-space' | 'not-directory' | 'not-empty' | 'not-recoverable' | 'unsupported' | 'no-tty' | 'no-such-device' | 'overflow' | 'not-permitted' | 'pipe' | 'read-only' | 'invalid-seek' | 'text-file-busy' | 'cross-device';
export interface MetadataHashValue {
lower: bigint,
upper: bigint,
}
export type Error = import('./wasi-io-streams.js').Error;
export interface PathFlags {
symlinkFollow?: boolean,
}
export type Filesize = bigint;
export type InputStream = import('./wasi-io-streams.js').InputStream;
export type OutputStream = import('./wasi-io-streams.js').OutputStream;
export type LinkCount = bigint;
export type Datetime = import('./wasi-clocks-wall-clock.js').Datetime;
export interface DescriptorStat {
type: DescriptorType,
linkCount: LinkCount,
size: Filesize,
dataAccessTimestamp?: Datetime,
dataModificationTimestamp?: Datetime,
statusChangeTimestamp?: Datetime,
}
export interface OpenFlags {
create?: boolean,
directory?: boolean,
exclusive?: boolean,
truncate?: boolean,
}
export interface DescriptorFlags {
read?: boolean,
write?: boolean,
fileIntegritySync?: boolean,
dataIntegritySync?: boolean,
requestedWriteSync?: boolean,
mutateDirectory?: boolean,
}
export interface DirectoryEntry {
type: DescriptorType,
name: string,
}
export class Descriptor implements Partial<Disposable> {
/**
* This type does not have a public constructor.
*/
private constructor();
readViaStream(offset: Filesize): InputStream;
writeViaStream(offset: Filesize): OutputStream;
appendViaStream(): OutputStream;
getType(): DescriptorType;
readDirectory(): DirectoryEntryStream;
stat(): DescriptorStat;
statAt(pathFlags: PathFlags, path: string): DescriptorStat;
openAt(pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags): Descriptor;
metadataHash(): MetadataHashValue;
metadataHashAt(pathFlags: PathFlags, path: string): MetadataHashValue;
[Symbol.dispose]?: () => void;
}
export class DirectoryEntryStream implements Partial<Disposable> {
/**
* This type does not have a public constructor.
*/
private constructor();
readDirectoryEntry(): DirectoryEntry | undefined;
[Symbol.dispose]?: () => void;
}