file

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ProtocolId = "/fx/file/0.2.0"

Variables

View Source
var (
	ActionType_name = map[int32]string{
		0: "READ",
		1: "WRITE",
		2: "MKDIR",
		3: "LS",
		4: "DELETE",
	}
	ActionType_value = map[string]int32{
		"READ":   0,
		"WRITE":  1,
		"MKDIR":  2,
		"LS":     3,
		"DELETE": 4,
	}
)

Enum value maps for ActionType.

View Source
var (
	EntryType_name = map[int32]string{
		0: "FILE",
		1: "DIRECTORY",
	}
	EntryType_value = map[string]int32{
		"FILE":      0,
		"DIRECTORY": 1,
	}
)

Enum value maps for EntryType.

Functions

func Handle added in v0.4.7

Handle implement root handler for newFile protocol It reads 2 bytes from the stream which determines the size of the request message It then reads the request message and passes the stream to the appropriate handler

func HandleDelete added in v0.4.7

func HandleDelete(ctx context.Context, api fxiface.CoreAPI, ds drive.DriveStore, path string, userDID string, s network.Stream) error

HandleDelete handle FSRequest with Delete action, delete a Node at a given location in the user's drive

func HandleLs added in v0.4.7

func HandleLs(ctx context.Context, api fxiface.CoreAPI, ds drive.DriveStore, path string, userDID string, s network.Stream) error

HandleLs handle FSRequest with Ls action, list entries existing in a given path in a user's drive

func HandleMkDir added in v0.4.7

func HandleMkDir(ctx context.Context, api fxiface.CoreAPI, ds drive.DriveStore, path string, userDID string, s network.Stream) error

HandleMkDir create a new directory at a given location in the user's drive

func HandleRead added in v0.4.7

func HandleRead(ctx context.Context, api fxiface.CoreAPI, ds drive.DriveStore, path string, userDID string, s network.Stream) error

HandleRead read a file at a given path from the user's drive

func HandleWrite added in v0.4.7

func HandleWrite(ctx context.Context, api fxiface.CoreAPI, ds drive.DriveStore, path string, userDID string, s network.Stream) error

HandleWrite handle FSRequest with Write action, write a file at a given location in the user's drive

func RequestDelete added in v0.4.7

func RequestDelete(ctx context.Context, s network.Stream, path string, userDID string) error

Send and FSRequest for Delete action, wait until receiving an ack (a one byte)

func RequestMkDir added in v0.4.7

func RequestMkDir(ctx context.Context, s network.Stream, path string, userDID string) (string, error)

RequestMkDir send an FSRequest for MkDir action, wait until receiving a cid for the directory

func RequestRead added in v0.4.7

func RequestRead(ctx context.Context, s network.Stream, path string, userDID string) (io.Reader, error)

RequestRead Send an FSRequest for Read action, return a io.Reader to read file from the stream

func RequestWrite added in v0.4.7

func RequestWrite(ctx context.Context, s network.Stream, path string, userDID string, f io.Reader) (string, error)

RequestWrite send an FSRequest for Write action, wait until receiving a cid for the file

Types

type ActionType added in v0.4.7

type ActionType int32
const (
	ActionType_READ   ActionType = 0
	ActionType_WRITE  ActionType = 1
	ActionType_MKDIR  ActionType = 2
	ActionType_LS     ActionType = 3
	ActionType_DELETE ActionType = 4
)

func (ActionType) Descriptor added in v0.4.7

func (ActionType) Descriptor() protoreflect.EnumDescriptor

func (ActionType) Enum added in v0.4.7

func (x ActionType) Enum() *ActionType

func (ActionType) EnumDescriptor deprecated added in v0.4.7

func (ActionType) EnumDescriptor() ([]byte, []int)

Deprecated: Use ActionType.Descriptor instead.

func (ActionType) Number added in v0.4.7

func (x ActionType) Number() protoreflect.EnumNumber

func (ActionType) String added in v0.4.7

func (x ActionType) String() string

func (ActionType) Type added in v0.4.7

type DirEntries added in v0.4.7

type DirEntries struct {
	Items []*DirEntry `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
	// contains filtered or unexported fields
}

func RequestLs added in v0.4.7

func RequestLs(ctx context.Context, s network.Stream, path string, userDID string) (*DirEntries, error)

Send and FSRequest for Ls action, wait until receiving a list of DirEntries

func (*DirEntries) Descriptor deprecated added in v0.4.7

func (*DirEntries) Descriptor() ([]byte, []int)

Deprecated: Use DirEntries.ProtoReflect.Descriptor instead.

func (*DirEntries) GetItems added in v0.4.7

func (x *DirEntries) GetItems() []*DirEntry

func (*DirEntries) ProtoMessage added in v0.4.7

func (*DirEntries) ProtoMessage()

func (*DirEntries) ProtoReflect added in v0.4.7

func (x *DirEntries) ProtoReflect() protoreflect.Message

func (*DirEntries) Reset added in v0.4.7

func (x *DirEntries) Reset()

func (*DirEntries) String added in v0.4.7

func (x *DirEntries) String() string

type DirEntry added in v0.4.7

type DirEntry struct {
	Name string    `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Type EntryType `protobuf:"varint,2,opt,name=type,proto3,enum=file.EntryType" json:"type,omitempty"`
	Size int32     `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"`
	Cid  string    `protobuf:"bytes,4,opt,name=cid,proto3" json:"cid,omitempty"`
	// contains filtered or unexported fields
}

func (*DirEntry) Descriptor deprecated added in v0.4.7

func (*DirEntry) Descriptor() ([]byte, []int)

Deprecated: Use DirEntry.ProtoReflect.Descriptor instead.

func (*DirEntry) GetCid added in v0.4.7

func (x *DirEntry) GetCid() string

func (*DirEntry) GetName added in v0.4.7

func (x *DirEntry) GetName() string

func (*DirEntry) GetSize added in v0.4.7

func (x *DirEntry) GetSize() int32

func (*DirEntry) GetType added in v0.4.7

func (x *DirEntry) GetType() EntryType

func (*DirEntry) ProtoMessage added in v0.4.7

func (*DirEntry) ProtoMessage()

func (*DirEntry) ProtoReflect added in v0.4.7

func (x *DirEntry) ProtoReflect() protoreflect.Message

func (*DirEntry) Reset added in v0.4.7

func (x *DirEntry) Reset()

func (*DirEntry) String added in v0.4.7

func (x *DirEntry) String() string

type EntryType added in v0.4.7

type EntryType int32
const (
	EntryType_FILE      EntryType = 0
	EntryType_DIRECTORY EntryType = 1
)

func (EntryType) Descriptor added in v0.4.7

func (EntryType) Descriptor() protoreflect.EnumDescriptor

func (EntryType) Enum added in v0.4.7

func (x EntryType) Enum() *EntryType

func (EntryType) EnumDescriptor deprecated added in v0.4.7

func (EntryType) EnumDescriptor() ([]byte, []int)

Deprecated: Use EntryType.Descriptor instead.

func (EntryType) Number added in v0.4.7

func (x EntryType) Number() protoreflect.EnumNumber

func (EntryType) String added in v0.4.7

func (x EntryType) String() string

func (EntryType) Type added in v0.4.7

type FSRequest added in v0.4.7

type FSRequest struct {
	DID       string     `protobuf:"bytes,1,opt,name=DID,proto3" json:"DID,omitempty"`
	Path      string     `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
	Signature []byte     `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"`
	Action    ActionType `protobuf:"varint,4,opt,name=action,proto3,enum=file.ActionType" json:"action,omitempty"`
	// contains filtered or unexported fields
}

func (*FSRequest) Descriptor deprecated added in v0.4.7

func (*FSRequest) Descriptor() ([]byte, []int)

Deprecated: Use FSRequest.ProtoReflect.Descriptor instead.

func (*FSRequest) GetAction added in v0.4.7

func (x *FSRequest) GetAction() ActionType

func (*FSRequest) GetDID added in v0.4.7

func (x *FSRequest) GetDID() string

func (*FSRequest) GetPath added in v0.4.7

func (x *FSRequest) GetPath() string

func (*FSRequest) GetSignature added in v0.4.7

func (x *FSRequest) GetSignature() []byte

func (*FSRequest) ProtoMessage added in v0.4.7

func (*FSRequest) ProtoMessage()

func (*FSRequest) ProtoReflect added in v0.4.7

func (x *FSRequest) ProtoReflect() protoreflect.Message

func (*FSRequest) Reset added in v0.4.7

func (x *FSRequest) Reset()

func (*FSRequest) String added in v0.4.7

func (x *FSRequest) String() string

type File

type File struct {
	Name string  `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	D    []int32 `protobuf:"varint,2,rep,packed,name=d,proto3" json:"d,omitempty"`
	// contains filtered or unexported fields
}

func (*File) Descriptor deprecated

func (*File) Descriptor() ([]byte, []int)

Deprecated: Use File.ProtoReflect.Descriptor instead.

func (*File) GetD added in v0.4.7

func (x *File) GetD() []int32

func (*File) GetName added in v0.4.7

func (x *File) GetName() string

func (*File) ProtoMessage

func (*File) ProtoMessage()

func (*File) ProtoReflect

func (x *File) ProtoReflect() protoreflect.Message

func (*File) Reset

func (x *File) Reset()

func (*File) String

func (x *File) String() string

type Payload added in v0.4.7

type Payload struct {
	D []int32 `protobuf:"varint,1,rep,packed,name=d,proto3" json:"d,omitempty"`
	// contains filtered or unexported fields
}

func (*Payload) Descriptor deprecated added in v0.4.7

func (*Payload) Descriptor() ([]byte, []int)

Deprecated: Use Payload.ProtoReflect.Descriptor instead.

func (*Payload) GetD added in v0.4.7

func (x *Payload) GetD() []int32

func (*Payload) ProtoMessage added in v0.4.7

func (*Payload) ProtoMessage()

func (*Payload) ProtoReflect added in v0.4.7

func (x *Payload) ProtoReflect() protoreflect.Message

func (*Payload) Reset added in v0.4.7

func (x *Payload) Reset()

func (*Payload) String added in v0.4.7

func (x *Payload) String() string

type Response added in v0.4.7

type Response struct {
	Action ActionType `protobuf:"varint,1,opt,name=action,proto3,enum=file.ActionType" json:"action,omitempty"`
	// Types that are assignable to Body:
	//	*Response_File
	//	*Response_Cid
	//	*Response_Entries
	Body isResponse_Body `protobuf_oneof:"body"`
	// contains filtered or unexported fields
}

func (*Response) Descriptor deprecated added in v0.4.7

func (*Response) Descriptor() ([]byte, []int)

Deprecated: Use Response.ProtoReflect.Descriptor instead.

func (*Response) GetAction added in v0.4.7

func (x *Response) GetAction() ActionType

func (*Response) GetBody added in v0.4.7

func (m *Response) GetBody() isResponse_Body

func (*Response) GetCid added in v0.4.7

func (x *Response) GetCid() string

func (*Response) GetEntries added in v0.4.7

func (x *Response) GetEntries() *DirEntries

func (*Response) GetFile added in v0.4.7

func (x *Response) GetFile() *File

func (*Response) ProtoMessage added in v0.4.7

func (*Response) ProtoMessage()

func (*Response) ProtoReflect added in v0.4.7

func (x *Response) ProtoReflect() protoreflect.Message

func (*Response) Reset added in v0.4.7

func (x *Response) Reset()

func (*Response) String added in v0.4.7

func (x *Response) String() string

type Response_Cid added in v0.4.7

type Response_Cid struct {
	Cid string `protobuf:"bytes,3,opt,name=cid,proto3,oneof"`
}

type Response_Entries added in v0.4.7

type Response_Entries struct {
	Entries *DirEntries `protobuf:"bytes,4,opt,name=entries,proto3,oneof"`
}

type Response_File added in v0.4.7

type Response_File struct {
	File *File `protobuf:"bytes,2,opt,name=file,proto3,oneof"`
}

Jump to

Keyboard shortcuts

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