types

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package types represents the imported interface "wasi:filesystem/types@0.2.0".

WASI filesystem is a filesystem API primarily intended to let users run WASI programs that access their files on their existing filesystems, without significant overhead.

It is intended to be roughly portable between Unix-family platforms and Windows, though it does not hide many of the major differences.

Paths are passed as interface-type `string`s, meaning they must consist of a sequence of Unicode Scalar Values (USVs). Some filesystems may contain paths which are not accessible by this API.

The directory separator in WASI is always the forward-slash (`/`).

All paths in WASI are relative paths, and are interpreted relative to a `descriptor` referring to a base directory. If a `path` argument to any WASI function starts with `/`, or if any step of resolving a `path`, including `..` and symbolic link steps, reaches a directory outside of the base directory, or reaches a symlink to an absolute or rooted path in the underlying filesystem, the function fails with `error-code::not-permitted`.

For more information about WASI path resolution and sandboxing, see WASI filesystem path resolution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilesystemErrorCode

func FilesystemErrorCode(err Error) (result cm.Option[ErrorCode])

FilesystemErrorCode represents the imported function "filesystem-error-code".

Attempts to extract a filesystem-related `error-code` from the stream `error` provided.

Stream operations which return `stream-error::last-operation-failed` have a payload with more information about the operation that failed. This payload can be passed through to this function to see if there's filesystem-related information about the error to return.

Note that this function is fallible because not all stream-related errors are filesystem-related errors.

filesystem-error-code: func(err: borrow<error>) -> option<error-code>

Types

type Advice

type Advice uint8

Advice represents the enum "wasi:filesystem/types@0.2.0#advice".

File or memory access pattern advisory information.

enum advice {
	normal,
	sequential,
	random,
	will-need,
	dont-need,
	no-reuse
}
const (
	// The application has no advice to give on its behavior with respect
	// to the specified data.
	AdviceNormal Advice = iota

	// The application expects to access the specified data sequentially
	// from lower offsets to higher offsets.
	AdviceSequential

	// The application expects to access the specified data in a random
	// order.
	AdviceRandom

	// The application expects to access the specified data in the near
	// future.
	AdviceWillNeed

	// The application expects that it will not access the specified data
	// in the near future.
	AdviceDontNeed

	// The application expects to access the specified data once and then
	// not reuse it thereafter.
	AdviceNoReuse
)

func (Advice) MarshalText

func (e Advice) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Advice) String

func (e Advice) String() string

String implements fmt.Stringer, returning the enum case name of e.

func (*Advice) UnmarshalText

func (e *Advice) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler, unmarshaling into an enum case. Returns an error if the supplied text is not one of the enum cases.

type DateTime

type DateTime = wallclock.DateTime

DateTime represents the type alias "wasi:filesystem/types@0.2.0#datetime".

See wallclock.DateTime for more information.

type Descriptor

type Descriptor cm.Resource

Descriptor represents the imported resource "wasi:filesystem/types@0.2.0#descriptor".

A descriptor is a reference to a filesystem object, which may be a file, directory, named pipe, special file, or other object on which filesystem calls may be made.

resource descriptor

func (Descriptor) Advise

func (self Descriptor) Advise(offset FileSize, length FileSize, advice Advice) (result cm.Result[ErrorCode, struct{}, ErrorCode])

Advise represents the imported method "advise".

Provide file advisory information on a descriptor.

This is similar to `posix_fadvise` in POSIX.

advise: func(offset: filesize, length: filesize, advice: advice) -> result<_, error-code>

func (Descriptor) AppendViaStream

func (self Descriptor) AppendViaStream() (result cm.Result[OutputStream, OutputStream, ErrorCode])

AppendViaStream represents the imported method "append-via-stream".

Return a stream for appending to a file, if available.

May fail with an error-code describing why the file cannot be appended.

Note: This allows using `write-stream`, which is similar to `write` with `O_APPEND` in in POSIX.

append-via-stream: func() -> result<output-stream, error-code>

func (Descriptor) CreateDirectoryAt

func (self Descriptor) CreateDirectoryAt(path string) (result cm.Result[ErrorCode, struct{}, ErrorCode])

CreateDirectoryAt represents the imported method "create-directory-at".

Create a directory.

Note: This is similar to `mkdirat` in POSIX.

create-directory-at: func(path: string) -> result<_, error-code>

func (Descriptor) GetFlags

func (self Descriptor) GetFlags() (result cm.Result[DescriptorFlags, DescriptorFlags, ErrorCode])

GetFlags represents the imported method "get-flags".

Get flags associated with a descriptor.

Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX.

Note: This returns the value that was the `fs_flags` value returned from `fdstat_get` in earlier versions of WASI.

get-flags: func() -> result<descriptor-flags, error-code>

func (Descriptor) GetType

func (self Descriptor) GetType() (result cm.Result[DescriptorType, DescriptorType, ErrorCode])

GetType represents the imported method "get-type".

Get the dynamic type of a descriptor.

Note: This returns the same value as the `type` field of the `fd-stat` returned by `stat`, `stat-at` and similar.

Note: This returns similar flags to the `st_mode & S_IFMT` value provided by `fstat` in POSIX.

Note: This returns the value that was the `fs_filetype` value returned from `fdstat_get` in earlier versions of WASI.

get-type: func() -> result<descriptor-type, error-code>

func (Descriptor) IsSameObject

func (self Descriptor) IsSameObject(other Descriptor) (result bool)

IsSameObject represents the imported method "is-same-object".

Test whether two descriptors refer to the same filesystem object.

In POSIX, this corresponds to testing whether the two descriptors have the same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. wasi-filesystem does not expose device and inode numbers, so this function may be used instead.

is-same-object: func(other: borrow<descriptor>) -> bool

func (Descriptor) LinkAt

func (self Descriptor) LinkAt(oldPathFlags PathFlags, oldPath string, newDescriptor Descriptor, newPath string) (result cm.Result[ErrorCode, struct{}, ErrorCode])

LinkAt represents the imported method "link-at".

Create a hard link.

Note: This is similar to `linkat` in POSIX.

link-at: func(old-path-flags: path-flags, old-path: string, new-descriptor: borrow<descriptor>,
new-path: string) -> result<_, error-code>

func (Descriptor) MetadataHash

func (self Descriptor) MetadataHash() (result cm.Result[MetadataHashValueShape, MetadataHashValue, ErrorCode])

MetadataHash represents the imported method "metadata-hash".

Return a hash of the metadata associated with a filesystem object referred to by a descriptor.

This returns a hash of the last-modification timestamp and file size, and may also include the inode number, device number, birth timestamp, and other metadata fields that may change when the file is modified or replaced. It may also include a secret value chosen by the implementation and not otherwise exposed.

Implementations are encourated to provide the following properties:

- If the file is not modified or replaced, the computed hash value should usually not change. - If the object is modified or replaced, the computed hash value should usually change. - The inputs to the hash should not be easily computable from the computed hash.

However, none of these is required.

metadata-hash: func() -> result<metadata-hash-value, error-code>

func (Descriptor) MetadataHashAt

func (self Descriptor) MetadataHashAt(pathFlags PathFlags, path string) (result cm.Result[MetadataHashValueShape, MetadataHashValue, ErrorCode])

MetadataHashAt represents the imported method "metadata-hash-at".

Return a hash of the metadata associated with a filesystem object referred to by a directory descriptor and a relative path.

This performs the same hash computation as `metadata-hash`.

metadata-hash-at: func(path-flags: path-flags, path: string) -> result<metadata-hash-value,
error-code>

func (Descriptor) OpenAt

func (self Descriptor) OpenAt(pathFlags PathFlags, path string, openFlags OpenFlags, flags DescriptorFlags) (result cm.Result[Descriptor, Descriptor, ErrorCode])

OpenAt represents the imported method "open-at".

Open a file or directory.

The returned descriptor is not guaranteed to be the lowest-numbered descriptor not currently open/ it is randomized to prevent applications from depending on making assumptions about indexes, since this is error-prone in multi-threaded contexts. The returned descriptor is guaranteed to be less than 2**31.

If `flags` contains `descriptor-flags::mutate-directory`, and the base descriptor doesn't have `descriptor-flags::mutate-directory` set, `open-at` fails with `error-code::read-only`.

If `flags` contains `write` or `mutate-directory`, or `open-flags` contains `truncate` or `create`, and the base descriptor doesn't have `descriptor-flags::mutate-directory` set, `open-at` fails with `error-code::read-only`.

Note: This is similar to `openat` in POSIX.

open-at: func(path-flags: path-flags, path: string, open-flags: open-flags, %flags:
descriptor-flags) -> result<descriptor, error-code>

func (Descriptor) Read

func (self Descriptor) Read(length FileSize, offset FileSize) (result cm.Result[TupleListU8BoolShape, cm.Tuple[cm.List[uint8], bool], ErrorCode])

Read represents the imported method "read".

Read from a descriptor, without using and updating the descriptor's offset.

This function returns a list of bytes containing the data that was read, along with a bool which, when true, indicates that the end of the file was reached. The returned list will contain up to `length` bytes; it may return fewer than requested, if the end of the file is reached or if the I/O operation is interrupted.

In the future, this may change to return a `stream<u8, error-code>`.

Note: This is similar to `pread` in POSIX.

read: func(length: filesize, offset: filesize) -> result<tuple<list<u8>, bool>,
error-code>

func (Descriptor) ReadDirectory

func (self Descriptor) ReadDirectory() (result cm.Result[DirectoryEntryStream, DirectoryEntryStream, ErrorCode])

ReadDirectory represents the imported method "read-directory".

Read directory entries from a directory.

On filesystems where directories contain entries referring to themselves and their parents, often named `.` and `..` respectively, these entries are omitted.

This always returns a new stream which starts at the beginning of the directory. Multiple streams may be active on the same directory, and they do not interfere with each other.

read-directory: func() -> result<directory-entry-stream, error-code>

func (Descriptor) ReadLinkAt

func (self Descriptor) ReadLinkAt(path string) (result cm.Result[string, string, ErrorCode])

ReadLinkAt represents the imported method "readlink-at".

Read the contents of a symbolic link.

If the contents contain an absolute or rooted path in the underlying filesystem, this function fails with `error-code::not-permitted`.

Note: This is similar to `readlinkat` in POSIX.

readlink-at: func(path: string) -> result<string, error-code>

func (Descriptor) ReadViaStream

func (self Descriptor) ReadViaStream(offset FileSize) (result cm.Result[InputStream, InputStream, ErrorCode])

ReadViaStream represents the imported method "read-via-stream".

Return a stream for reading from a file, if available.

May fail with an error-code describing why the file cannot be read.

Multiple read, write, and append streams may be active on the same open file and they do not interfere with each other.

Note: This allows using `read-stream`, which is similar to `read` in POSIX.

read-via-stream: func(offset: filesize) -> result<input-stream, error-code>

func (Descriptor) RemoveDirectoryAt

func (self Descriptor) RemoveDirectoryAt(path string) (result cm.Result[ErrorCode, struct{}, ErrorCode])

RemoveDirectoryAt represents the imported method "remove-directory-at".

Remove a directory.

Return `error-code::not-empty` if the directory is not empty.

Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.

remove-directory-at: func(path: string) -> result<_, error-code>

func (Descriptor) RenameAt

func (self Descriptor) RenameAt(oldPath string, newDescriptor Descriptor, newPath string) (result cm.Result[ErrorCode, struct{}, ErrorCode])

RenameAt represents the imported method "rename-at".

Rename a filesystem object.

Note: This is similar to `renameat` in POSIX.

rename-at: func(old-path: string, new-descriptor: borrow<descriptor>, new-path:
string) -> result<_, error-code>

func (Descriptor) ResourceDrop

func (self Descriptor) ResourceDrop()

ResourceDrop represents the imported resource-drop for resource "descriptor".

Drops a resource handle.

func (Descriptor) SetSize

func (self Descriptor) SetSize(size FileSize) (result cm.Result[ErrorCode, struct{}, ErrorCode])

SetSize represents the imported method "set-size".

Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros.

Note: This was called `fd_filestat_set_size` in earlier versions of WASI.

set-size: func(size: filesize) -> result<_, error-code>

func (Descriptor) SetTimes

func (self Descriptor) SetTimes(dataAccessTimestamp NewTimestamp, dataModificationTimestamp NewTimestamp) (result cm.Result[ErrorCode, struct{}, ErrorCode])

SetTimes represents the imported method "set-times".

Adjust the timestamps of an open file or directory.

Note: This is similar to `futimens` in POSIX.

Note: This was called `fd_filestat_set_times` in earlier versions of WASI.

set-times: func(data-access-timestamp: new-timestamp, data-modification-timestamp:
new-timestamp) -> result<_, error-code>

func (Descriptor) SetTimesAt

func (self Descriptor) SetTimesAt(pathFlags PathFlags, path string, dataAccessTimestamp NewTimestamp, dataModificationTimestamp NewTimestamp) (result cm.Result[ErrorCode, struct{}, ErrorCode])

SetTimesAt represents the imported method "set-times-at".

Adjust the timestamps of a file or directory.

Note: This is similar to `utimensat` in POSIX.

Note: This was called `path_filestat_set_times` in earlier versions of WASI.

set-times-at: func(path-flags: path-flags, path: string, data-access-timestamp:
new-timestamp, data-modification-timestamp: new-timestamp) -> result<_, error-code>

func (Descriptor) Stat

Stat represents the imported method "stat".

Return the attributes of an open file or directory.

Note: This is similar to `fstat` in POSIX, except that it does not return device and inode information. For testing whether two descriptors refer to the same underlying filesystem object, use `is-same-object`. To obtain additional data that can be used do determine whether a file has been modified, use `metadata-hash`.

Note: This was called `fd_filestat_get` in earlier versions of WASI.

stat: func() -> result<descriptor-stat, error-code>

func (Descriptor) StatAt

func (self Descriptor) StatAt(pathFlags PathFlags, path string) (result cm.Result[DescriptorStatShape, DescriptorStat, ErrorCode])

StatAt represents the imported method "stat-at".

Return the attributes of a file or directory.

Note: This is similar to `fstatat` in POSIX, except that it does not return device and inode information. See the `stat` description for a discussion of alternatives.

Note: This was called `path_filestat_get` in earlier versions of WASI.

stat-at: func(path-flags: path-flags, path: string) -> result<descriptor-stat,
error-code>

func (Descriptor) SymlinkAt

func (self Descriptor) SymlinkAt(oldPath string, newPath string) (result cm.Result[ErrorCode, struct{}, ErrorCode])

SymlinkAt represents the imported method "symlink-at".

Create a symbolic link (also known as a "symlink").

If `old-path` starts with `/`, the function fails with `error-code::not-permitted`.

Note: This is similar to `symlinkat` in POSIX.

symlink-at: func(old-path: string, new-path: string) -> result<_, error-code>

func (Descriptor) Sync

func (self Descriptor) Sync() (result cm.Result[ErrorCode, struct{}, ErrorCode])

Sync represents the imported method "sync".

Synchronize the data and metadata of a file to disk.

This function succeeds with no effect if the file descriptor is not opened for writing.

Note: This is similar to `fsync` in POSIX.

sync: func() -> result<_, error-code>

func (Descriptor) SyncData

func (self Descriptor) SyncData() (result cm.Result[ErrorCode, struct{}, ErrorCode])

SyncData represents the imported method "sync-data".

Synchronize the data of a file to disk.

This function succeeds with no effect if the file descriptor is not opened for writing.

Note: This is similar to `fdatasync` in POSIX.

sync-data: func() -> result<_, error-code>

func (Descriptor) UnlinkFileAt

func (self Descriptor) UnlinkFileAt(path string) (result cm.Result[ErrorCode, struct{}, ErrorCode])

UnlinkFileAt represents the imported method "unlink-file-at".

Unlink a filesystem object that is not a directory.

Return `error-code::is-directory` if the path refers to a directory. Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.

unlink-file-at: func(path: string) -> result<_, error-code>

func (Descriptor) Write

func (self Descriptor) Write(buffer cm.List[uint8], offset FileSize) (result cm.Result[uint64, FileSize, ErrorCode])

Write represents the imported method "write".

Write to a descriptor, without using and updating the descriptor's offset.

It is valid to write past the end of a file; the file is extended to the extent of the write, with bytes between the previous end and the start of the write set to zero.

In the future, this may change to take a `stream<u8, error-code>`.

Note: This is similar to `pwrite` in POSIX.

write: func(buffer: list<u8>, offset: filesize) -> result<filesize, error-code>

func (Descriptor) WriteViaStream

func (self Descriptor) WriteViaStream(offset FileSize) (result cm.Result[OutputStream, OutputStream, ErrorCode])

WriteViaStream represents the imported method "write-via-stream".

Return a stream for writing to a file, if available.

May fail with an error-code describing why the file cannot be written.

Note: This allows using `write-stream`, which is similar to `write` in POSIX.

write-via-stream: func(offset: filesize) -> result<output-stream, error-code>

type DescriptorFlags

type DescriptorFlags uint8

DescriptorFlags represents the flags "wasi:filesystem/types@0.2.0#descriptor-flags".

Descriptor flags.

Note: This was called `fdflags` in earlier versions of WASI.

flags descriptor-flags {
	read,
	write,
	file-integrity-sync,
	data-integrity-sync,
	requested-write-sync,
	mutate-directory,
}
const (
	// Read mode: Data can be read.
	DescriptorFlagsRead DescriptorFlags = 1 << iota

	// Write mode: Data can be written to.
	DescriptorFlagsWrite

	// Request that writes be performed according to synchronized I/O file
	// integrity completion. The data stored in the file and the file's
	// metadata are synchronized. This is similar to `O_SYNC` in POSIX.
	//
	// The precise semantics of this operation have not yet been defined for
	// WASI. At this time, it should be interpreted as a request, and not a
	// requirement.
	DescriptorFlagsFileIntegritySync

	// Request that writes be performed according to synchronized I/O data
	// integrity completion. Only the data stored in the file is
	// synchronized. This is similar to `O_DSYNC` in POSIX.
	//
	// The precise semantics of this operation have not yet been defined for
	// WASI. At this time, it should be interpreted as a request, and not a
	// requirement.
	DescriptorFlagsDataIntegritySync

	// Requests that reads be performed at the same level of integrety
	// requested for writes. This is similar to `O_RSYNC` in POSIX.
	//
	// The precise semantics of this operation have not yet been defined for
	// WASI. At this time, it should be interpreted as a request, and not a
	// requirement.
	DescriptorFlagsRequestedWriteSync

	// Mutating directories mode: Directory contents may be mutated.
	//
	// When this flag is unset on a descriptor, operations using the
	// descriptor which would create, rename, delete, modify the data or
	// metadata of filesystem objects, or obtain another handle which
	// would permit any of those, shall fail with `error-code::read-only` if
	// they would otherwise succeed.
	//
	// This may only be set on directories.
	DescriptorFlagsMutateDirectory
)

type DescriptorStat

type DescriptorStat struct {

	// File type.
	Type DescriptorType `json:"type"`

	// Number of hard links to the file.
	LinkCount LinkCount `json:"link-count"`

	// For regular files, the file size in bytes. For symbolic links, the
	// length in bytes of the pathname contained in the symbolic link.
	Size FileSize `json:"size"`

	// Last data access timestamp.
	//
	// If the `option` is none, the platform doesn't maintain an access
	// timestamp for this file.
	DataAccessTimestamp cm.Option[DateTime] `json:"data-access-timestamp"`

	// Last data modification timestamp.
	//
	// If the `option` is none, the platform doesn't maintain a
	// modification timestamp for this file.
	DataModificationTimestamp cm.Option[DateTime] `json:"data-modification-timestamp"`

	// Last file status-change timestamp.
	//
	// If the `option` is none, the platform doesn't maintain a
	// status-change timestamp for this file.
	StatusChangeTimestamp cm.Option[DateTime] `json:"status-change-timestamp"`
	// contains filtered or unexported fields
}

DescriptorStat represents the record "wasi:filesystem/types@0.2.0#descriptor-stat".

File attributes.

Note: This was called `filestat` in earlier versions of WASI.

record descriptor-stat {
	%type: descriptor-type,
	link-count: link-count,
	size: filesize,
	data-access-timestamp: option<datetime>,
	data-modification-timestamp: option<datetime>,
	status-change-timestamp: option<datetime>,
}

type DescriptorStatShape

type DescriptorStatShape struct {
	// contains filtered or unexported fields
}

DescriptorStatShape is used for storage in variant or result types.

type DescriptorType

type DescriptorType uint8

DescriptorType represents the enum "wasi:filesystem/types@0.2.0#descriptor-type".

The type of a filesystem object referenced by a descriptor.

Note: This was called `filetype` in earlier versions of WASI.

enum descriptor-type {
	unknown,
	block-device,
	character-device,
	directory,
	fifo,
	symbolic-link,
	regular-file,
	socket
}
const (
	// The type of the descriptor or file is unknown or is different from
	// any of the other types specified.
	DescriptorTypeUnknown DescriptorType = iota

	// The descriptor refers to a block device inode.
	DescriptorTypeBlockDevice

	// The descriptor refers to a character device inode.
	DescriptorTypeCharacterDevice

	// The descriptor refers to a directory inode.
	DescriptorTypeDirectory

	// The descriptor refers to a named pipe.
	DescriptorTypeFIFO

	// The file refers to a symbolic link inode.
	DescriptorTypeSymbolicLink

	// The descriptor refers to a regular file inode.
	DescriptorTypeRegularFile

	// The descriptor refers to a socket.
	DescriptorTypeSocket
)

func (DescriptorType) MarshalText

func (e DescriptorType) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (DescriptorType) String

func (e DescriptorType) String() string

String implements fmt.Stringer, returning the enum case name of e.

func (*DescriptorType) UnmarshalText

func (e *DescriptorType) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler, unmarshaling into an enum case. Returns an error if the supplied text is not one of the enum cases.

type DirectoryEntry

type DirectoryEntry struct {

	// The type of the file referred to by this directory entry.
	Type DescriptorType `json:"type"`

	// The name of the object.
	Name string `json:"name"`
	// contains filtered or unexported fields
}

DirectoryEntry represents the record "wasi:filesystem/types@0.2.0#directory-entry".

A directory entry.

record directory-entry {
	%type: descriptor-type,
	name: string,
}

type DirectoryEntryStream

type DirectoryEntryStream cm.Resource

DirectoryEntryStream represents the imported resource "wasi:filesystem/types@0.2.0#directory-entry-stream".

A stream of directory entries.

resource directory-entry-stream

func (DirectoryEntryStream) ReadDirectoryEntry

ReadDirectoryEntry represents the imported method "read-directory-entry".

Read a single directory entry from a `directory-entry-stream`.

read-directory-entry: func() -> result<option<directory-entry>, error-code>

func (DirectoryEntryStream) ResourceDrop

func (self DirectoryEntryStream) ResourceDrop()

ResourceDrop represents the imported resource-drop for resource "directory-entry-stream".

Drops a resource handle.

type Error

type Error = streams.Error

Error represents the imported type alias "wasi:filesystem/types@0.2.0#error".

See streams.Error for more information.

type ErrorCode

type ErrorCode uint8

ErrorCode represents the enum "wasi:filesystem/types@0.2.0#error-code".

Error codes returned by functions, similar to `errno` in POSIX. Not all of these error codes are returned by the functions provided by this API; some are used in higher-level library layers, and others are provided merely for alignment with POSIX.

enum error-code {
	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
}
const (
	// Permission denied, similar to `EACCES` in POSIX.
	ErrorCodeAccess ErrorCode = iota

	// Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK`
	// in POSIX.
	ErrorCodeWouldBlock

	// Connection already in progress, similar to `EALREADY` in POSIX.
	ErrorCodeAlready

	// Bad descriptor, similar to `EBADF` in POSIX.
	ErrorCodeBadDescriptor

	// Device or resource busy, similar to `EBUSY` in POSIX.
	ErrorCodeBusy

	// Resource deadlock would occur, similar to `EDEADLK` in POSIX.
	ErrorCodeDeadlock

	// Storage quota exceeded, similar to `EDQUOT` in POSIX.
	ErrorCodeQuota

	// File exists, similar to `EEXIST` in POSIX.
	ErrorCodeExist

	// File too large, similar to `EFBIG` in POSIX.
	ErrorCodeFileTooLarge

	// Illegal byte sequence, similar to `EILSEQ` in POSIX.
	ErrorCodeIllegalByteSequence

	// Operation in progress, similar to `EINPROGRESS` in POSIX.
	ErrorCodeInProgress

	// Interrupted function, similar to `EINTR` in POSIX.
	ErrorCodeInterrupted

	// Invalid argument, similar to `EINVAL` in POSIX.
	ErrorCodeInvalid

	// I/O error, similar to `EIO` in POSIX.
	ErrorCodeIO

	// Is a directory, similar to `EISDIR` in POSIX.
	ErrorCodeIsDirectory

	// Too many levels of symbolic links, similar to `ELOOP` in POSIX.
	ErrorCodeLoop

	// Too many links, similar to `EMLINK` in POSIX.
	ErrorCodeTooManyLinks

	// Message too large, similar to `EMSGSIZE` in POSIX.
	ErrorCodeMessageSize

	// Filename too long, similar to `ENAMETOOLONG` in POSIX.
	ErrorCodeNameTooLong

	// No such device, similar to `ENODEV` in POSIX.
	ErrorCodeNoDevice

	// No such file or directory, similar to `ENOENT` in POSIX.
	ErrorCodeNoEntry

	// No locks available, similar to `ENOLCK` in POSIX.
	ErrorCodeNoLock

	// Not enough space, similar to `ENOMEM` in POSIX.
	ErrorCodeInsufficientMemory

	// No space left on device, similar to `ENOSPC` in POSIX.
	ErrorCodeInsufficientSpace

	// Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.
	ErrorCodeNotDirectory

	// Directory not empty, similar to `ENOTEMPTY` in POSIX.
	ErrorCodeNotEmpty

	// State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.
	ErrorCodeNotRecoverable

	// Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.
	ErrorCodeUnsupported

	// Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.
	ErrorCodeNoTTY

	// No such device or address, similar to `ENXIO` in POSIX.
	ErrorCodeNoSuchDevice

	// Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX.
	ErrorCodeOverflow

	// Operation not permitted, similar to `EPERM` in POSIX.
	ErrorCodeNotPermitted

	// Broken pipe, similar to `EPIPE` in POSIX.
	ErrorCodePipe

	// Read-only file system, similar to `EROFS` in POSIX.
	ErrorCodeReadOnly

	// Invalid seek, similar to `ESPIPE` in POSIX.
	ErrorCodeInvalidSeek

	// Text file busy, similar to `ETXTBSY` in POSIX.
	ErrorCodeTextFileBusy

	// Cross-device link, similar to `EXDEV` in POSIX.
	ErrorCodeCrossDevice
)

func (ErrorCode) MarshalText

func (e ErrorCode) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (ErrorCode) String

func (e ErrorCode) String() string

String implements fmt.Stringer, returning the enum case name of e.

func (*ErrorCode) UnmarshalText

func (e *ErrorCode) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler, unmarshaling into an enum case. Returns an error if the supplied text is not one of the enum cases.

type FileSize

type FileSize uint64

FileSize represents the u64 "wasi:filesystem/types@0.2.0#filesize".

File size or length of a region within a file.

type filesize = u64

type InputStream

type InputStream = streams.InputStream

InputStream represents the imported type alias "wasi:filesystem/types@0.2.0#input-stream".

See streams.InputStream for more information.

type LinkCount

type LinkCount uint64

LinkCount represents the u64 "wasi:filesystem/types@0.2.0#link-count".

Number of hard links to an inode.

type link-count = u64

type MetadataHashValue

type MetadataHashValue struct {

	// 64 bits of a 128-bit hash value.
	Lower uint64 `json:"lower"`

	// Another 64 bits of a 128-bit hash value.
	Upper uint64 `json:"upper"`
	// contains filtered or unexported fields
}

MetadataHashValue represents the record "wasi:filesystem/types@0.2.0#metadata-hash-value".

A 128-bit hash value, split into parts because wasm doesn't have a 128-bit integer type.

record metadata-hash-value {
	lower: u64,
	upper: u64,
}

type MetadataHashValueShape

type MetadataHashValueShape struct {
	// contains filtered or unexported fields
}

MetadataHashValueShape is used for storage in variant or result types.

type NewTimestamp

type NewTimestamp cm.Variant[uint8, DateTime, DateTime]

NewTimestamp represents the variant "wasi:filesystem/types@0.2.0#new-timestamp".

When setting a timestamp, this gives the value to set it to.

variant new-timestamp {
	no-change,
	now,
	timestamp(datetime),
}

func NewTimestampNoChange

func NewTimestampNoChange() NewTimestamp

NewTimestampNoChange returns a NewTimestamp of case "no-change".

Leave the timestamp set to its previous value.

func NewTimestampNow

func NewTimestampNow() NewTimestamp

NewTimestampNow returns a NewTimestamp of case "now".

Set the timestamp to the current time of the system clock associated with the filesystem.

func NewTimestampTimestamp

func NewTimestampTimestamp(data DateTime) NewTimestamp

NewTimestampTimestamp returns a NewTimestamp of case "timestamp".

Set the timestamp to the given value.

func (*NewTimestamp) NoChange

func (self *NewTimestamp) NoChange() bool

NoChange returns true if NewTimestamp represents the variant case "no-change".

func (*NewTimestamp) Now

func (self *NewTimestamp) Now() bool

Now returns true if NewTimestamp represents the variant case "now".

func (NewTimestamp) String

func (v NewTimestamp) String() string

String implements fmt.Stringer, returning the variant case name of v.

func (*NewTimestamp) Timestamp

func (self *NewTimestamp) Timestamp() *DateTime

Timestamp returns a non-nil *DateTime if NewTimestamp represents the variant case "timestamp".

type OpenFlags

type OpenFlags uint8

OpenFlags represents the flags "wasi:filesystem/types@0.2.0#open-flags".

Open flags used by `open-at`.

flags open-flags {
	create,
	directory,
	exclusive,
	truncate,
}
const (
	// Create file if it does not exist, similar to `O_CREAT` in POSIX.
	OpenFlagsCreate OpenFlags = 1 << iota

	// Fail if not a directory, similar to `O_DIRECTORY` in POSIX.
	OpenFlagsDirectory

	// Fail if file already exists, similar to `O_EXCL` in POSIX.
	OpenFlagsExclusive

	// Truncate file to size 0, similar to `O_TRUNC` in POSIX.
	OpenFlagsTruncate
)

type OptionDirectoryEntryShape

type OptionDirectoryEntryShape struct {
	// contains filtered or unexported fields
}

OptionDirectoryEntryShape is used for storage in variant or result types.

type OutputStream

type OutputStream = streams.OutputStream

OutputStream represents the imported type alias "wasi:filesystem/types@0.2.0#output-stream".

See streams.OutputStream for more information.

type PathFlags

type PathFlags uint8

PathFlags represents the flags "wasi:filesystem/types@0.2.0#path-flags".

Flags determining the method of how paths are resolved.

flags path-flags {
	symlink-follow,
}
const (
	// As long as the resolved path corresponds to a symbolic link, it is
	// expanded.
	PathFlagsSymlinkFollow PathFlags = 1 << iota
)

type TupleListU8BoolShape

type TupleListU8BoolShape struct {
	// contains filtered or unexported fields
}

TupleListU8BoolShape is used for storage in variant or result types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL