fsdrpc

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: CC0-1.0, CC0-1.0, CC0-1.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HashRequest_HashType_name = map[int32]string{
	0:  "UNDEFINED",
	1:  "MD5",
	2:  "SHA1",
	3:  "SHA224",
	4:  "SHA256",
	5:  "SHA384",
	6:  "SHA512",
	7:  "SHA512_224",
	8:  "SHA512_256",
	9:  "SHA3_224",
	10: "SHA3_256",
	11: "SHA3_384",
	12: "SHA3_512",
	13: "BLAKE2S_256",
	14: "BLAKE2B_256",
	15: "BLAKE2B_384",
	16: "BLAKE2B_512",
}
View Source
var HashRequest_HashType_value = map[string]int32{
	"UNDEFINED":   0,
	"MD5":         1,
	"SHA1":        2,
	"SHA224":      3,
	"SHA256":      4,
	"SHA384":      5,
	"SHA512":      6,
	"SHA512_224":  7,
	"SHA512_256":  8,
	"SHA3_224":    9,
	"SHA3_256":    10,
	"SHA3_384":    11,
	"SHA3_512":    12,
	"BLAKE2S_256": 13,
	"BLAKE2B_256": 14,
	"BLAKE2B_384": 15,
	"BLAKE2B_512": 16,
}

Functions

func RegisterFsdServer

func RegisterFsdServer(s *grpc.Server, srv FsdServer)

func ToBytes

func ToBytes(hr *HashResponse) ([]byte, error)

ToBytes converts the given *HashResponse to a slice of bytes.

func ToDstAndSrc

func ToDstAndSrc(s *DstAndSrc) (string, string, error)

ToDstAndSrc converts the given *DstAndSrc to a pair of strings.

func ToMetadata

func ToMetadata(m *Metadata) (*fs.Metadata, error)

ToMetadata converts the given *Metadata to an *fs.Metadata.

func ToPath

func ToPath(p *Path) (string, error)

ToPath converts the given *Path to a string.

func ToPathAndHash

func ToPathAndHash(hr *HashRequest) (string, crypto.Hash, error)

ToPathAndHash converts the given *HashRequest to a string and crypto.Hash.

Types

type CopiedBytes

type CopiedBytes struct {
	Size                 int64    `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

CopiedBytes is the response to a Copy

func (*CopiedBytes) Descriptor

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

func (*CopiedBytes) GetSize

func (m *CopiedBytes) GetSize() int64

func (*CopiedBytes) ProtoMessage

func (*CopiedBytes) ProtoMessage()

func (*CopiedBytes) Reset

func (m *CopiedBytes) Reset()

func (*CopiedBytes) String

func (m *CopiedBytes) String() string

func (*CopiedBytes) XXX_DiscardUnknown

func (m *CopiedBytes) XXX_DiscardUnknown()

func (*CopiedBytes) XXX_Marshal

func (m *CopiedBytes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CopiedBytes) XXX_Merge

func (m *CopiedBytes) XXX_Merge(src proto.Message)

func (*CopiedBytes) XXX_Size

func (m *CopiedBytes) XXX_Size() int

func (*CopiedBytes) XXX_Unmarshal

func (m *CopiedBytes) XXX_Unmarshal(b []byte) error

type DstAndSrc

type DstAndSrc struct {
	Dst                  *Path    `protobuf:"bytes,1,opt,name=dst,proto3" json:"dst,omitempty"`
	Src                  *Path    `protobuf:"bytes,2,opt,name=src,proto3" json:"src,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

DstAndSrc represents two Paths, a destination and a source

func FromDstAndSrc

func FromDstAndSrc(dst string, src string) *DstAndSrc

FromDstAndSrc converts the given pair of strings to a *DstAndSrc.

func (*DstAndSrc) Descriptor

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

func (*DstAndSrc) GetDst

func (m *DstAndSrc) GetDst() *Path

func (*DstAndSrc) GetSrc

func (m *DstAndSrc) GetSrc() *Path

func (*DstAndSrc) ProtoMessage

func (*DstAndSrc) ProtoMessage()

func (*DstAndSrc) Reset

func (m *DstAndSrc) Reset()

func (*DstAndSrc) String

func (m *DstAndSrc) String() string

func (*DstAndSrc) XXX_DiscardUnknown

func (m *DstAndSrc) XXX_DiscardUnknown()

func (*DstAndSrc) XXX_Marshal

func (m *DstAndSrc) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DstAndSrc) XXX_Merge

func (m *DstAndSrc) XXX_Merge(src proto.Message)

func (*DstAndSrc) XXX_Size

func (m *DstAndSrc) XXX_Size() int

func (*DstAndSrc) XXX_Unmarshal

func (m *DstAndSrc) XXX_Unmarshal(b []byte) error

type FileChunk

type FileChunk struct {
	// Types that are valid to be assigned to Chunk:
	//	*FileChunk_Path
	//	*FileChunk_Data
	Chunk                isFileChunk_Chunk `protobuf_oneof:"chunk"`
	XXX_NoUnkeyedLiteral struct{}          `json:"-"`
	XXX_unrecognized     []byte            `json:"-"`
	XXX_sizecache        int32             `json:"-"`
}

FileChunk represents a chunk of a file

func FileChunkFromData

func FileChunkFromData(b []byte) *FileChunk

FileChunkFromData converts the slice b to a *FileChunk.

func FileChunkFromPath

func FileChunkFromPath(p string) *FileChunk

FileChunkFromPath converts the path p to a *FileChunk.

func (*FileChunk) Descriptor

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

func (*FileChunk) GetChunk

func (m *FileChunk) GetChunk() isFileChunk_Chunk

func (*FileChunk) GetData

func (m *FileChunk) GetData() []byte

func (*FileChunk) GetPath

func (m *FileChunk) GetPath() *Path

func (*FileChunk) ProtoMessage

func (*FileChunk) ProtoMessage()

func (*FileChunk) Reset

func (m *FileChunk) Reset()

func (*FileChunk) String

func (m *FileChunk) String() string

func (*FileChunk) XXX_DiscardUnknown

func (m *FileChunk) XXX_DiscardUnknown()

func (*FileChunk) XXX_Marshal

func (m *FileChunk) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*FileChunk) XXX_Merge

func (m *FileChunk) XXX_Merge(src proto.Message)

func (*FileChunk) XXX_OneofWrappers

func (*FileChunk) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*FileChunk) XXX_Size

func (m *FileChunk) XXX_Size() int

func (*FileChunk) XXX_Unmarshal

func (m *FileChunk) XXX_Unmarshal(b []byte) error

type FileChunk_Data

type FileChunk_Data struct {
	Data []byte `protobuf:"bytes,2,opt,name=data,proto3,oneof"`
}

type FileChunk_Path

type FileChunk_Path struct {
	Path *Path `protobuf:"bytes,1,opt,name=path,proto3,oneof"`
}

type FsdClient

type FsdClient interface {
	// Upload uploads a file. The first FileChunk MUST contain the path; all
	// subsequent FileChunks MUST contain the data.
	Upload(ctx context.Context, opts ...grpc.CallOption) (Fsd_UploadClient, error)
	// Download downloads the file with a given path. The first FileChunk will
	// contain the path; all subsequent FileChunks will contain the data.
	Download(ctx context.Context, in *Path, opts ...grpc.CallOption) (Fsd_DownloadClient, error)
	// DownloadMetadata downloads the metadata for the file or directory with
	// a given path.
	DownloadMetadata(ctx context.Context, in *Path, opts ...grpc.CallOption) (*Metadata, error)
	// Mkdir creates the directory with the given path.
	Mkdir(ctx context.Context, in *Path, opts ...grpc.CallOption) (*empty.Empty, error)
	// Remove attempts to remove the file or directory with the given path.
	Remove(ctx context.Context, in *Path, opts ...grpc.CallOption) (*empty.Empty, error)
	// Dir requests metadata for files and directories in the directory with
	// the given path.
	Dir(ctx context.Context, in *Path, opts ...grpc.CallOption) (Fsd_DirClient, error)
	// Hash requests a hash of the file with a given path.
	Hash(ctx context.Context, in *HashRequest, opts ...grpc.CallOption) (*HashResponse, error)
	// Exists determines if a file or directory with the given path exists.
	Exists(ctx context.Context, in *Path, opts ...grpc.CallOption) (*wrappers.BoolValue, error)
	// IsFile returns true if and only if a file with the given path exists.
	IsFile(ctx context.Context, in *Path, opts ...grpc.CallOption) (*wrappers.BoolValue, error)
	// IsDir returns true if and only if a directory with the given path exists.
	IsDir(ctx context.Context, in *Path, opts ...grpc.CallOption) (*wrappers.BoolValue, error)
	// IsDirEmpty returns true if and only if an empty directory with the given
	// path exists.
	IsDirEmpty(ctx context.Context, in *Path, opts ...grpc.CallOption) (*wrappers.BoolValue, error)
	// RemoveFile attempts to remove the file with the given path.
	RemoveFile(ctx context.Context, in *Path, opts ...grpc.CallOption) (*empty.Empty, error)
	// MkdirRecursive creates the directory with the given path p, along with
	// any intermediate directories as necessary.
	MkdirRecursive(ctx context.Context, in *Path, opts ...grpc.CallOption) (*empty.Empty, error)
	// Rmdir removes the given path, provided it is an empty directory.
	Rmdir(ctx context.Context, in *Path, opts ...grpc.CallOption) (*empty.Empty, error)
	// RemoveAll removes the given path, if it is a file, and the given path
	// and all its contents, if it is a directory.
	RemoveAll(ctx context.Context, in *Path, opts ...grpc.CallOption) (*empty.Empty, error)
	// Copy copies the contents of the file at path src to path dst.
	Copy(ctx context.Context, in *DstAndSrc, opts ...grpc.CallOption) (*CopiedBytes, error)
	// CopyAll recursively copies the file or directory structure rooted at
	// path src to path dst.
	CopyAll(ctx context.Context, in *DstAndSrc, opts ...grpc.CallOption) (*empty.Empty, error)
}

FsdClient is the client API for Fsd service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewFsdClient

func NewFsdClient(cc *grpc.ClientConn) FsdClient

type FsdServer

type FsdServer interface {
	// Upload uploads a file. The first FileChunk MUST contain the path; all
	// subsequent FileChunks MUST contain the data.
	Upload(Fsd_UploadServer) error
	// Download downloads the file with a given path. The first FileChunk will
	// contain the path; all subsequent FileChunks will contain the data.
	Download(*Path, Fsd_DownloadServer) error
	// DownloadMetadata downloads the metadata for the file or directory with
	// a given path.
	DownloadMetadata(context.Context, *Path) (*Metadata, error)
	// Mkdir creates the directory with the given path.
	Mkdir(context.Context, *Path) (*empty.Empty, error)
	// Remove attempts to remove the file or directory with the given path.
	Remove(context.Context, *Path) (*empty.Empty, error)
	// Dir requests metadata for files and directories in the directory with
	// the given path.
	Dir(*Path, Fsd_DirServer) error
	// Hash requests a hash of the file with a given path.
	Hash(context.Context, *HashRequest) (*HashResponse, error)
	// Exists determines if a file or directory with the given path exists.
	Exists(context.Context, *Path) (*wrappers.BoolValue, error)
	// IsFile returns true if and only if a file with the given path exists.
	IsFile(context.Context, *Path) (*wrappers.BoolValue, error)
	// IsDir returns true if and only if a directory with the given path exists.
	IsDir(context.Context, *Path) (*wrappers.BoolValue, error)
	// IsDirEmpty returns true if and only if an empty directory with the given
	// path exists.
	IsDirEmpty(context.Context, *Path) (*wrappers.BoolValue, error)
	// RemoveFile attempts to remove the file with the given path.
	RemoveFile(context.Context, *Path) (*empty.Empty, error)
	// MkdirRecursive creates the directory with the given path p, along with
	// any intermediate directories as necessary.
	MkdirRecursive(context.Context, *Path) (*empty.Empty, error)
	// Rmdir removes the given path, provided it is an empty directory.
	Rmdir(context.Context, *Path) (*empty.Empty, error)
	// RemoveAll removes the given path, if it is a file, and the given path
	// and all its contents, if it is a directory.
	RemoveAll(context.Context, *Path) (*empty.Empty, error)
	// Copy copies the contents of the file at path src to path dst.
	Copy(context.Context, *DstAndSrc) (*CopiedBytes, error)
	// CopyAll recursively copies the file or directory structure rooted at
	// path src to path dst.
	CopyAll(context.Context, *DstAndSrc) (*empty.Empty, error)
}

FsdServer is the server API for Fsd service.

type Fsd_DirClient

type Fsd_DirClient interface {
	Recv() (*Metadata, error)
	grpc.ClientStream
}

type Fsd_DirServer

type Fsd_DirServer interface {
	Send(*Metadata) error
	grpc.ServerStream
}

type Fsd_DownloadClient

type Fsd_DownloadClient interface {
	Recv() (*FileChunk, error)
	grpc.ClientStream
}

type Fsd_DownloadServer

type Fsd_DownloadServer interface {
	Send(*FileChunk) error
	grpc.ServerStream
}

type Fsd_UploadClient

type Fsd_UploadClient interface {
	Send(*FileChunk) error
	CloseAndRecv() (*empty.Empty, error)
	grpc.ClientStream
}

type Fsd_UploadServer

type Fsd_UploadServer interface {
	SendAndClose(*empty.Empty) error
	Recv() (*FileChunk, error)
	grpc.ServerStream
}

type HashRequest

type HashRequest struct {
	Path                 *Path                `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
	Hash                 HashRequest_HashType `protobuf:"varint,2,opt,name=hash,proto3,enum=fsd.HashRequest_HashType" json:"hash,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

HashRequest requests the hash for a file

func FromPathAndHash

func FromPathAndHash(p string, h crypto.Hash) *HashRequest

FromPathAndHash converts the given string and crypto.Hash to a *HashRequest. Returns nil if the hash is not supported.

func (*HashRequest) Descriptor

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

func (*HashRequest) GetHash

func (m *HashRequest) GetHash() HashRequest_HashType

func (*HashRequest) GetPath

func (m *HashRequest) GetPath() *Path

func (*HashRequest) ProtoMessage

func (*HashRequest) ProtoMessage()

func (*HashRequest) Reset

func (m *HashRequest) Reset()

func (*HashRequest) String

func (m *HashRequest) String() string

func (*HashRequest) XXX_DiscardUnknown

func (m *HashRequest) XXX_DiscardUnknown()

func (*HashRequest) XXX_Marshal

func (m *HashRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*HashRequest) XXX_Merge

func (m *HashRequest) XXX_Merge(src proto.Message)

func (*HashRequest) XXX_Size

func (m *HashRequest) XXX_Size() int

func (*HashRequest) XXX_Unmarshal

func (m *HashRequest) XXX_Unmarshal(b []byte) error

type HashRequest_HashType

type HashRequest_HashType int32

HashType describes a possible hash type

const (
	HashRequest_UNDEFINED   HashRequest_HashType = 0
	HashRequest_MD5         HashRequest_HashType = 1
	HashRequest_SHA1        HashRequest_HashType = 2
	HashRequest_SHA224      HashRequest_HashType = 3
	HashRequest_SHA256      HashRequest_HashType = 4
	HashRequest_SHA384      HashRequest_HashType = 5
	HashRequest_SHA512      HashRequest_HashType = 6
	HashRequest_SHA512_224  HashRequest_HashType = 7
	HashRequest_SHA512_256  HashRequest_HashType = 8
	HashRequest_SHA3_224    HashRequest_HashType = 9
	HashRequest_SHA3_256    HashRequest_HashType = 10
	HashRequest_SHA3_384    HashRequest_HashType = 11
	HashRequest_SHA3_512    HashRequest_HashType = 12
	HashRequest_BLAKE2S_256 HashRequest_HashType = 13
	HashRequest_BLAKE2B_256 HashRequest_HashType = 14
	HashRequest_BLAKE2B_384 HashRequest_HashType = 15
	HashRequest_BLAKE2B_512 HashRequest_HashType = 16
)

func (HashRequest_HashType) EnumDescriptor

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

func (HashRequest_HashType) String

func (x HashRequest_HashType) String() string

type HashResponse

type HashResponse struct {
	Result               []byte   `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

HashResponse is the response to a HashRequest

func FromBytes

func FromBytes(b []byte) (*HashResponse, error)

FromBytes converts the given slice of bytes to a *HashResponse.

func (*HashResponse) Descriptor

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

func (*HashResponse) GetResult

func (m *HashResponse) GetResult() []byte

func (*HashResponse) ProtoMessage

func (*HashResponse) ProtoMessage()

func (*HashResponse) Reset

func (m *HashResponse) Reset()

func (*HashResponse) String

func (m *HashResponse) String() string

func (*HashResponse) XXX_DiscardUnknown

func (m *HashResponse) XXX_DiscardUnknown()

func (*HashResponse) XXX_Marshal

func (m *HashResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*HashResponse) XXX_Merge

func (m *HashResponse) XXX_Merge(src proto.Message)

func (*HashResponse) XXX_Size

func (m *HashResponse) XXX_Size() int

func (*HashResponse) XXX_Unmarshal

func (m *HashResponse) XXX_Unmarshal(b []byte) error

type Metadata

type Metadata struct {
	Path                 *Path                `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
	Size                 int64                `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"`
	ModTime              *timestamp.Timestamp `protobuf:"bytes,3,opt,name=mod_time,json=modTime,proto3" json:"mod_time,omitempty"`
	IsDir                bool                 `protobuf:"varint,4,opt,name=is_dir,json=isDir,proto3" json:"is_dir,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

Metadata represents metadata for a file or directory

func FromMetadata

func FromMetadata(m *fs.Metadata) (*Metadata, error)

FromMetadata converts the given *fs.Metadata to a *Metadata.

func (*Metadata) Descriptor

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

func (*Metadata) GetIsDir

func (m *Metadata) GetIsDir() bool

func (*Metadata) GetModTime

func (m *Metadata) GetModTime() *timestamp.Timestamp

func (*Metadata) GetPath

func (m *Metadata) GetPath() *Path

func (*Metadata) GetSize

func (m *Metadata) GetSize() int64

func (*Metadata) ProtoMessage

func (*Metadata) ProtoMessage()

func (*Metadata) Reset

func (m *Metadata) Reset()

func (*Metadata) String

func (m *Metadata) String() string

func (*Metadata) XXX_DiscardUnknown

func (m *Metadata) XXX_DiscardUnknown()

func (*Metadata) XXX_Marshal

func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Metadata) XXX_Merge

func (m *Metadata) XXX_Merge(src proto.Message)

func (*Metadata) XXX_Size

func (m *Metadata) XXX_Size() int

func (*Metadata) XXX_Unmarshal

func (m *Metadata) XXX_Unmarshal(b []byte) error

type Path

type Path struct {
	Path                 string   `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Path represents a path to a file or directory

func FromPath

func FromPath(p string) *Path

FromPath converts the path p to a *Path.

func (*Path) Descriptor

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

func (*Path) GetPath

func (m *Path) GetPath() string

func (*Path) ProtoMessage

func (*Path) ProtoMessage()

func (*Path) Reset

func (m *Path) Reset()

func (*Path) String

func (m *Path) String() string

func (*Path) XXX_DiscardUnknown

func (m *Path) XXX_DiscardUnknown()

func (*Path) XXX_Marshal

func (m *Path) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Path) XXX_Merge

func (m *Path) XXX_Merge(src proto.Message)

func (*Path) XXX_Size

func (m *Path) XXX_Size() int

func (*Path) XXX_Unmarshal

func (m *Path) XXX_Unmarshal(b []byte) error

type UnimplementedFsdServer

type UnimplementedFsdServer struct {
}

UnimplementedFsdServer can be embedded to have forward compatible implementations.

func (*UnimplementedFsdServer) Copy

func (*UnimplementedFsdServer) CopyAll

func (*UnimplementedFsdServer) Dir

func (*UnimplementedFsdServer) Download

func (*UnimplementedFsdServer) Download(req *Path, srv Fsd_DownloadServer) error

func (*UnimplementedFsdServer) DownloadMetadata

func (*UnimplementedFsdServer) DownloadMetadata(ctx context.Context, req *Path) (*Metadata, error)

func (*UnimplementedFsdServer) Exists

func (*UnimplementedFsdServer) Hash

func (*UnimplementedFsdServer) IsDir

func (*UnimplementedFsdServer) IsDirEmpty

func (*UnimplementedFsdServer) IsDirEmpty(ctx context.Context, req *Path) (*wrappers.BoolValue, error)

func (*UnimplementedFsdServer) IsFile

func (*UnimplementedFsdServer) Mkdir

func (*UnimplementedFsdServer) Mkdir(ctx context.Context, req *Path) (*empty.Empty, error)

func (*UnimplementedFsdServer) MkdirRecursive

func (*UnimplementedFsdServer) MkdirRecursive(ctx context.Context, req *Path) (*empty.Empty, error)

func (*UnimplementedFsdServer) Remove

func (*UnimplementedFsdServer) Remove(ctx context.Context, req *Path) (*empty.Empty, error)

func (*UnimplementedFsdServer) RemoveAll

func (*UnimplementedFsdServer) RemoveAll(ctx context.Context, req *Path) (*empty.Empty, error)

func (*UnimplementedFsdServer) RemoveFile

func (*UnimplementedFsdServer) RemoveFile(ctx context.Context, req *Path) (*empty.Empty, error)

func (*UnimplementedFsdServer) Rmdir

func (*UnimplementedFsdServer) Rmdir(ctx context.Context, req *Path) (*empty.Empty, error)

func (*UnimplementedFsdServer) Upload

Jump to

Keyboard shortcuts

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