newFile

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ProtocolId = "/fx/new-file/0.1.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.

View Source
var File_newFile_proto protoreflect.FileDescriptor

Functions

func Handle

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

func HandleDelete

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

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

func HandleLs

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

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

func HandleMkDir

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

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

func HandleRead

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

Read a file at a given path from the user's drive

func HandleWrite

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

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

func RequestDelete

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

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

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

func RequestRead

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

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

func RequestWrite

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

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

Types

type ActionType

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

func (ActionType) Descriptor() protoreflect.EnumDescriptor

func (ActionType) Enum

func (x ActionType) Enum() *ActionType

func (ActionType) EnumDescriptor deprecated

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

Deprecated: Use ActionType.Descriptor instead.

func (ActionType) Number

func (x ActionType) Number() protoreflect.EnumNumber

func (ActionType) String

func (x ActionType) String() string

func (ActionType) Type

type DirEntries

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

func RequestLs

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

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

Deprecated: Use DirEntries.ProtoReflect.Descriptor instead.

func (*DirEntries) GetItems

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

func (*DirEntries) ProtoMessage

func (*DirEntries) ProtoMessage()

func (*DirEntries) ProtoReflect

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

func (*DirEntries) Reset

func (x *DirEntries) Reset()

func (*DirEntries) String

func (x *DirEntries) String() string

type DirEntry

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=newFile.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

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

Deprecated: Use DirEntry.ProtoReflect.Descriptor instead.

func (*DirEntry) GetCid

func (x *DirEntry) GetCid() string

func (*DirEntry) GetName

func (x *DirEntry) GetName() string

func (*DirEntry) GetSize

func (x *DirEntry) GetSize() int32

func (*DirEntry) GetType

func (x *DirEntry) GetType() EntryType

func (*DirEntry) ProtoMessage

func (*DirEntry) ProtoMessage()

func (*DirEntry) ProtoReflect

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

func (*DirEntry) Reset

func (x *DirEntry) Reset()

func (*DirEntry) String

func (x *DirEntry) String() string

type EntryType

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

func (EntryType) Descriptor

func (EntryType) Descriptor() protoreflect.EnumDescriptor

func (EntryType) Enum

func (x EntryType) Enum() *EntryType

func (EntryType) EnumDescriptor deprecated

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

Deprecated: Use EntryType.Descriptor instead.

func (EntryType) Number

func (x EntryType) Number() protoreflect.EnumNumber

func (EntryType) String

func (x EntryType) String() string

func (EntryType) Type

type FSRequest

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=newFile.ActionType" json:"action,omitempty"`
	// contains filtered or unexported fields
}

func (*FSRequest) Descriptor deprecated

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

Deprecated: Use FSRequest.ProtoReflect.Descriptor instead.

func (*FSRequest) GetAction

func (x *FSRequest) GetAction() ActionType

func (*FSRequest) GetDID

func (x *FSRequest) GetDID() string

func (*FSRequest) GetPath

func (x *FSRequest) GetPath() string

func (*FSRequest) GetSignature

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

func (*FSRequest) ProtoMessage

func (*FSRequest) ProtoMessage()

func (*FSRequest) ProtoReflect

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

func (*FSRequest) Reset

func (x *FSRequest) Reset()

func (*FSRequest) String

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

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

func (*File) GetName

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

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

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

Deprecated: Use Payload.ProtoReflect.Descriptor instead.

func (*Payload) GetD

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

func (*Payload) ProtoMessage

func (*Payload) ProtoMessage()

func (*Payload) ProtoReflect

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

func (*Payload) Reset

func (x *Payload) Reset()

func (*Payload) String

func (x *Payload) String() string

type Response

type Response struct {
	Action ActionType `protobuf:"varint,1,opt,name=action,proto3,enum=newFile.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

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

Deprecated: Use Response.ProtoReflect.Descriptor instead.

func (*Response) GetAction

func (x *Response) GetAction() ActionType

func (*Response) GetBody

func (m *Response) GetBody() isResponse_Body

func (*Response) GetCid

func (x *Response) GetCid() string

func (*Response) GetEntries

func (x *Response) GetEntries() *DirEntries

func (*Response) GetFile

func (x *Response) GetFile() *File

func (*Response) ProtoMessage

func (*Response) ProtoMessage()

func (*Response) ProtoReflect

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

func (*Response) Reset

func (x *Response) Reset()

func (*Response) String

func (x *Response) String() string

type Response_Cid

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

type Response_Entries

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

type Response_File

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