sys

package
v1.12.6 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sys provides platform-independent interfaces to support webassembly runtime

Index

Constants

This section is empty.

Variables

View Source
var (
	//Files file system implementation on sdk. DiskFS doesn't work on webassembly. it should be initialized with common.NewMemFS()
	Files FS = NewDiskFS()

	//Sleep  pauses the current goroutine for at least the duration.
	//  time.Sleep will stop webassembly main thread. it should be bridged to javascript method on webassembly sdk
	Sleep = time.Sleep

	// Sign sign method. it should be initialized on different platform.
	Sign SignFunc

	// Verify verify method. it should be initialized on different platform.
	Verify VerifyFunc

	// Verify verify method. it should be initialized on different platform.
	VerifyWith VerifyWithFunc

	Authorize AuthorizeFunc
)

Functions

This section is empty.

Types

type AuthorizeFunc added in v1.10.0

type AuthorizeFunc func(msg string) (string, error)

type DiskFS

type DiskFS struct {
}

DiskFS implement file system on disk

func (*DiskFS) MkdirAll

func (dfs *DiskFS) MkdirAll(path string, perm os.FileMode) error

MkdirAll creates a directory named path

func (*DiskFS) Open

func (dfs *DiskFS) Open(name string) (File, error)

Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.

func (*DiskFS) OpenFile

func (dfs *DiskFS) OpenFile(name string, flag int, perm os.FileMode) (File, error)

func (*DiskFS) ReadFile

func (dfs *DiskFS) ReadFile(name string) ([]byte, error)

ReadFile reads the file named by filename and returns the contents.

func (*DiskFS) Remove

func (dfs *DiskFS) Remove(name string) error

Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.

func (*DiskFS) Stat added in v1.8.8

func (dfs *DiskFS) Stat(name string) (fs.FileInfo, error)

Stat returns a FileInfo describing the named file. If there is an error, it will be of type *PathError.

func (*DiskFS) WriteFile

func (dfs *DiskFS) WriteFile(name string, data []byte, perm os.FileMode) error

WriteFile writes data to a file named by filename.

type FS

type FS interface {

	// Open opens the named file for reading. If successful, methods on
	// the returned file can be used for reading; the associated file
	// descriptor has mode O_RDONLY.
	// If there is an error, it will be of type *PathError.
	Open(name string) (File, error)

	// OpenFile open a file
	OpenFile(name string, flag int, perm os.FileMode) (File, error)

	// ReadFile reads the file named by filename and returns the contents.
	ReadFile(name string) ([]byte, error)

	// WriteFile writes data to a file named by filename.
	WriteFile(name string, data []byte, perm fs.FileMode) error

	Stat(name string) (fs.FileInfo, error)

	// Remove removes the named file or (empty) directory.
	// If there is an error, it will be of type *PathError.
	Remove(name string) error

	//MkdirAll creates a directory named path
	MkdirAll(path string, perm os.FileMode) error
}

FS An FS provides access to a hierarchical file system.

func NewDiskFS

func NewDiskFS() FS

NewDiskFS create DiskFS instance

func NewMemChanFS added in v1.8.17

func NewMemChanFS() FS

NewMemFS create MemFS instance

func NewMemFS

func NewMemFS() FS

NewMemFS create MemFS instance

type File

type File interface {
	Stat() (fs.FileInfo, error)
	Read([]byte) (int, error)
	Write(p []byte) (n int, err error)

	Sync() error
	Seek(offset int64, whence int) (ret int64, err error)

	Close() error
}

type KeyPair

type KeyPair struct {
	PublicKey  string `json:"public_key"`
	PrivateKey string `json:"private_key"`
}

KeyPair private and publickey

type MemChanFS added in v1.8.17

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

MemFS implement file system on memory

func (*MemChanFS) MkdirAll added in v1.8.17

func (mfs *MemChanFS) MkdirAll(path string, perm os.FileMode) error

MkdirAll creates a directory named path

func (*MemChanFS) Open added in v1.8.17

func (mfs *MemChanFS) Open(name string) (File, error)

Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.

func (*MemChanFS) OpenFile added in v1.8.17

func (mfs *MemChanFS) OpenFile(name string, flag int, perm os.FileMode) (File, error)

func (*MemChanFS) ReadFile added in v1.8.17

func (mfs *MemChanFS) ReadFile(name string) ([]byte, error)

ReadFile reads the file named by filename and returns the contents.

func (*MemChanFS) Remove added in v1.8.17

func (mfs *MemChanFS) Remove(name string) error

Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.

func (*MemChanFS) Stat added in v1.8.17

func (mfs *MemChanFS) Stat(name string) (fs.FileInfo, error)

Stat returns a FileInfo describing the named file. If there is an error, it will be of type *PathError.

func (*MemChanFS) WriteFile added in v1.8.17

func (mfs *MemChanFS) WriteFile(name string, data []byte, perm os.FileMode) error

WriteFile writes data to a file named by filename.

type MemChanFile added in v1.8.17

type MemChanFile struct {
	Name           string
	Buffer         chan []byte // file content
	Mode           fs.FileMode // FileInfo.Mode
	ModTime        time.Time   // FileInfo.ModTime
	ChunkWriteSize int         //  0 value means no limit
	Sys            interface{} // FileInfo.Sys
	// contains filtered or unexported fields
}

func (*MemChanFile) Close added in v1.8.17

func (f *MemChanFile) Close() error

func (*MemChanFile) Read added in v1.8.17

func (f *MemChanFile) Read(p []byte) (int, error)

func (*MemChanFile) Seek added in v1.8.17

func (f *MemChanFile) Seek(offset int64, whence int) (ret int64, err error)

func (*MemChanFile) Stat added in v1.8.17

func (f *MemChanFile) Stat() (fs.FileInfo, error)

func (*MemChanFile) Sync added in v1.8.17

func (f *MemChanFile) Sync() error

func (*MemChanFile) Write added in v1.8.17

func (f *MemChanFile) Write(p []byte) (n int, err error)

type MemFS

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

MemFS implement file system on memory

func (*MemFS) MkdirAll

func (mfs *MemFS) MkdirAll(path string, perm os.FileMode) error

MkdirAll creates a directory named path

func (*MemFS) Open

func (mfs *MemFS) Open(name string) (File, error)

Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.

func (*MemFS) OpenFile

func (mfs *MemFS) OpenFile(name string, flag int, perm os.FileMode) (File, error)

func (*MemFS) ReadFile

func (mfs *MemFS) ReadFile(name string) ([]byte, error)

ReadFile reads the file named by filename and returns the contents.

func (*MemFS) Remove

func (mfs *MemFS) Remove(name string) error

Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.

func (*MemFS) Stat added in v1.8.8

func (mfs *MemFS) Stat(name string) (fs.FileInfo, error)

Stat returns a FileInfo describing the named file. If there is an error, it will be of type *PathError.

func (*MemFS) WriteFile

func (mfs *MemFS) WriteFile(name string, data []byte, perm os.FileMode) error

WriteFile writes data to a file named by filename.

type MemFile

type MemFile struct {
	Name    string
	Buffer  *bytes.Buffer // file content
	Mode    fs.FileMode   // FileInfo.Mode
	ModTime time.Time     // FileInfo.ModTime
	Sys     interface{}   // FileInfo.Sys
	// contains filtered or unexported fields
}

func (*MemFile) Close

func (f *MemFile) Close() error

func (*MemFile) Read

func (f *MemFile) Read(p []byte) (int, error)

func (*MemFile) Seek

func (f *MemFile) Seek(offset int64, whence int) (ret int64, err error)

func (*MemFile) Stat

func (f *MemFile) Stat() (fs.FileInfo, error)

func (*MemFile) Sync

func (f *MemFile) Sync() error

func (*MemFile) Write

func (f *MemFile) Write(p []byte) (n int, err error)

type MemFileChanInfo added in v1.8.17

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

func (*MemFileChanInfo) Info added in v1.8.17

func (i *MemFileChanInfo) Info() (fs.FileInfo, error)

func (*MemFileChanInfo) IsDir added in v1.8.17

func (i *MemFileChanInfo) IsDir() bool

func (*MemFileChanInfo) ModTime added in v1.8.17

func (i *MemFileChanInfo) ModTime() time.Time

func (*MemFileChanInfo) Mode added in v1.8.17

func (i *MemFileChanInfo) Mode() fs.FileMode

func (*MemFileChanInfo) Name added in v1.8.17

func (i *MemFileChanInfo) Name() string

func (*MemFileChanInfo) Size added in v1.8.17

func (i *MemFileChanInfo) Size() int64

func (*MemFileChanInfo) Sys added in v1.8.17

func (i *MemFileChanInfo) Sys() interface{}

func (*MemFileChanInfo) Type added in v1.8.17

func (i *MemFileChanInfo) Type() fs.FileMode

type MemFileInfo

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

func (*MemFileInfo) Info

func (i *MemFileInfo) Info() (fs.FileInfo, error)

func (*MemFileInfo) IsDir

func (i *MemFileInfo) IsDir() bool

func (*MemFileInfo) ModTime

func (i *MemFileInfo) ModTime() time.Time

func (*MemFileInfo) Mode

func (i *MemFileInfo) Mode() fs.FileMode

func (*MemFileInfo) Name

func (i *MemFileInfo) Name() string

func (*MemFileInfo) Size

func (i *MemFileInfo) Size() int64

func (*MemFileInfo) Sys

func (i *MemFileInfo) Sys() interface{}

func (*MemFileInfo) Type

func (i *MemFileInfo) Type() fs.FileMode

type SignFunc

type SignFunc func(hash string, signatureScheme string, keys []KeyPair) (string, error)

SignFunc sign method for request verification

type VerifyFunc added in v1.8.7

type VerifyFunc func(signature string, msg string) (bool, error)

type VerifyWithFunc added in v1.8.14

type VerifyWithFunc func(pk, signature string, msg string) (bool, error)

Jump to

Keyboard shortcuts

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