fsdrpc

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: MIT Imports: 15 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",
	}
	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,
	}
)

Enum value maps for HashRequest_HashType.

View Source
var Fsd_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "fsd.Fsd",
	HandlerType: (*FsdServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "DownloadMetadata",
			Handler:    _Fsd_DownloadMetadata_Handler,
		},
		{
			MethodName: "Mkdir",
			Handler:    _Fsd_Mkdir_Handler,
		},
		{
			MethodName: "Remove",
			Handler:    _Fsd_Remove_Handler,
		},
		{
			MethodName: "Hash",
			Handler:    _Fsd_Hash_Handler,
		},
		{
			MethodName: "Exists",
			Handler:    _Fsd_Exists_Handler,
		},
		{
			MethodName: "IsFile",
			Handler:    _Fsd_IsFile_Handler,
		},
		{
			MethodName: "IsDir",
			Handler:    _Fsd_IsDir_Handler,
		},
		{
			MethodName: "IsDirEmpty",
			Handler:    _Fsd_IsDirEmpty_Handler,
		},
		{
			MethodName: "RemoveFile",
			Handler:    _Fsd_RemoveFile_Handler,
		},
		{
			MethodName: "MkdirRecursive",
			Handler:    _Fsd_MkdirRecursive_Handler,
		},
		{
			MethodName: "Rmdir",
			Handler:    _Fsd_Rmdir_Handler,
		},
		{
			MethodName: "RemoveAll",
			Handler:    _Fsd_RemoveAll_Handler,
		},
		{
			MethodName: "Copy",
			Handler:    _Fsd_Copy_Handler,
		},
		{
			MethodName: "CopyAll",
			Handler:    _Fsd_CopyAll_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Upload",
			Handler:       _Fsd_Upload_Handler,
			ClientStreams: true,
		},
		{
			StreamName:    "Download",
			Handler:       _Fsd_Download_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "Dir",
			Handler:       _Fsd_Dir_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "fsd.proto",
}

Fsd_ServiceDesc is the grpc.ServiceDesc for Fsd service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterFsdServer

func RegisterFsdServer(s grpc.ServiceRegistrar, 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"` // The number of bytes copied
	// contains filtered or unexported fields
}

CopiedBytes is the response to a Copy

func (*CopiedBytes) Descriptor deprecated

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

Deprecated: Use CopiedBytes.ProtoReflect.Descriptor instead.

func (*CopiedBytes) GetSize

func (x *CopiedBytes) GetSize() int64

func (*CopiedBytes) ProtoMessage

func (*CopiedBytes) ProtoMessage()

func (*CopiedBytes) ProtoReflect added in v0.1.12

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

func (*CopiedBytes) Reset

func (x *CopiedBytes) Reset()

func (*CopiedBytes) String

func (x *CopiedBytes) String() string

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"`
	// contains filtered or unexported fields
}

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 deprecated

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

Deprecated: Use DstAndSrc.ProtoReflect.Descriptor instead.

func (*DstAndSrc) GetDst

func (x *DstAndSrc) GetDst() *Path

func (*DstAndSrc) GetSrc

func (x *DstAndSrc) GetSrc() *Path

func (*DstAndSrc) ProtoMessage

func (*DstAndSrc) ProtoMessage()

func (*DstAndSrc) ProtoReflect added in v0.1.12

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

func (*DstAndSrc) Reset

func (x *DstAndSrc) Reset()

func (*DstAndSrc) String

func (x *DstAndSrc) String() string

type FileChunk

type FileChunk struct {

	// Types that are assignable to Chunk:
	//	*FileChunk_Path
	//	*FileChunk_Data
	Chunk isFileChunk_Chunk `protobuf_oneof:"chunk"`
	// contains filtered or unexported fields
}

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 deprecated

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

Deprecated: Use FileChunk.ProtoReflect.Descriptor instead.

func (*FileChunk) GetChunk

func (m *FileChunk) GetChunk() isFileChunk_Chunk

func (*FileChunk) GetData

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

func (*FileChunk) GetPath

func (x *FileChunk) GetPath() *Path

func (*FileChunk) ProtoMessage

func (*FileChunk) ProtoMessage()

func (*FileChunk) ProtoReflect added in v0.1.12

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

func (*FileChunk) Reset

func (x *FileChunk) Reset()

func (*FileChunk) String

func (x *FileChunk) String() string

type FileChunk_Data

type FileChunk_Data struct {
	Data []byte `protobuf:"bytes,2,opt,name=data,proto3,oneof"` // A chunk of the file
}

type FileChunk_Path

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

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) (*emptypb.Empty, error)
	// Remove attempts to remove the file or directory with the given path.
	Remove(ctx context.Context, in *Path, opts ...grpc.CallOption) (*emptypb.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) (*wrapperspb.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) (*wrapperspb.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) (*wrapperspb.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) (*wrapperspb.BoolValue, error)
	// RemoveFile attempts to remove the file with the given path.
	RemoveFile(ctx context.Context, in *Path, opts ...grpc.CallOption) (*emptypb.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) (*emptypb.Empty, error)
	// Rmdir removes the given path, provided it is an empty directory.
	Rmdir(ctx context.Context, in *Path, opts ...grpc.CallOption) (*emptypb.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) (*emptypb.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) (*emptypb.Empty, error)
}

FsdClient is the client API for Fsd service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewFsdClient

func NewFsdClient(cc grpc.ClientConnInterface) 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) (*emptypb.Empty, error)
	// Remove attempts to remove the file or directory with the given path.
	Remove(context.Context, *Path) (*emptypb.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) (*wrapperspb.BoolValue, error)
	// IsFile returns true if and only if a file with the given path exists.
	IsFile(context.Context, *Path) (*wrapperspb.BoolValue, error)
	// IsDir returns true if and only if a directory with the given path exists.
	IsDir(context.Context, *Path) (*wrapperspb.BoolValue, error)
	// IsDirEmpty returns true if and only if an empty directory with the given
	// path exists.
	IsDirEmpty(context.Context, *Path) (*wrapperspb.BoolValue, error)
	// RemoveFile attempts to remove the file with the given path.
	RemoveFile(context.Context, *Path) (*emptypb.Empty, error)
	// MkdirRecursive creates the directory with the given path p, along with
	// any intermediate directories as necessary.
	MkdirRecursive(context.Context, *Path) (*emptypb.Empty, error)
	// Rmdir removes the given path, provided it is an empty directory.
	Rmdir(context.Context, *Path) (*emptypb.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) (*emptypb.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) (*emptypb.Empty, error)
	// contains filtered or unexported methods
}

FsdServer is the server API for Fsd service. All implementations must embed UnimplementedFsdServer for forward compatibility

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() (*emptypb.Empty, error)
	grpc.ClientStream
}

type Fsd_UploadServer

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

type HashRequest

type HashRequest struct {
	Path *Path                `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`                                // The path to the file
	Hash HashRequest_HashType `protobuf:"varint,2,opt,name=hash,proto3,enum=fsd.HashRequest_HashType" json:"hash,omitempty"` // The hash type
	// contains filtered or unexported fields
}

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 deprecated

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

Deprecated: Use HashRequest.ProtoReflect.Descriptor instead.

func (*HashRequest) GetHash

func (x *HashRequest) GetHash() HashRequest_HashType

func (*HashRequest) GetPath

func (x *HashRequest) GetPath() *Path

func (*HashRequest) ProtoMessage

func (*HashRequest) ProtoMessage()

func (*HashRequest) ProtoReflect added in v0.1.12

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

func (*HashRequest) Reset

func (x *HashRequest) Reset()

func (*HashRequest) String

func (x *HashRequest) String() string

type HashRequest_HashType

type HashRequest_HashType int32

HashType describes a possible hash type

const (
	HashRequest_UNDEFINED   HashRequest_HashType = 0  // Illegal value
	HashRequest_MD5         HashRequest_HashType = 1  // MD5
	HashRequest_SHA1        HashRequest_HashType = 2  // SHA1
	HashRequest_SHA224      HashRequest_HashType = 3  // SHA224
	HashRequest_SHA256      HashRequest_HashType = 4  // SHA256
	HashRequest_SHA384      HashRequest_HashType = 5  // SHA384
	HashRequest_SHA512      HashRequest_HashType = 6  // SHA512
	HashRequest_SHA512_224  HashRequest_HashType = 7  // SHA512/224
	HashRequest_SHA512_256  HashRequest_HashType = 8  // SHA512/256
	HashRequest_SHA3_224    HashRequest_HashType = 9  // SHA3-224
	HashRequest_SHA3_256    HashRequest_HashType = 10 // SHA3-256
	HashRequest_SHA3_384    HashRequest_HashType = 11 // SHA3-384
	HashRequest_SHA3_512    HashRequest_HashType = 12 // SHA3-512
	HashRequest_BLAKE2S_256 HashRequest_HashType = 13 // BLAKE2s-256
	HashRequest_BLAKE2B_256 HashRequest_HashType = 14 // BLAKE2b-256
	HashRequest_BLAKE2B_384 HashRequest_HashType = 15 // BLAKE2b-384
	HashRequest_BLAKE2B_512 HashRequest_HashType = 16 // BLAKE2b-512
)

func (HashRequest_HashType) Descriptor added in v0.1.12

func (HashRequest_HashType) Enum added in v0.1.12

func (HashRequest_HashType) EnumDescriptor deprecated

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

Deprecated: Use HashRequest_HashType.Descriptor instead.

func (HashRequest_HashType) Number added in v0.1.12

func (HashRequest_HashType) String

func (x HashRequest_HashType) String() string

func (HashRequest_HashType) Type added in v0.1.12

type HashResponse

type HashResponse struct {
	Result []byte `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` // The hash
	// contains filtered or unexported fields
}

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 deprecated

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

Deprecated: Use HashResponse.ProtoReflect.Descriptor instead.

func (*HashResponse) GetResult

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

func (*HashResponse) ProtoMessage

func (*HashResponse) ProtoMessage()

func (*HashResponse) ProtoReflect added in v0.1.12

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

func (*HashResponse) Reset

func (x *HashResponse) Reset()

func (*HashResponse) String

func (x *HashResponse) String() string

type Metadata

type Metadata struct {
	Path    *Path                  `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`                      // The path to the file
	Size    int64                  `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"`                     // The size of the file
	ModTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=mod_time,json=modTime,proto3" json:"mod_time,omitempty"` // The creation time
	IsDir   bool                   `protobuf:"varint,4,opt,name=is_dir,json=isDir,proto3" json:"is_dir,omitempty"`      // True if and only if the path is a directory
	// contains filtered or unexported fields
}

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 deprecated

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

Deprecated: Use Metadata.ProtoReflect.Descriptor instead.

func (*Metadata) GetIsDir

func (x *Metadata) GetIsDir() bool

func (*Metadata) GetModTime

func (x *Metadata) GetModTime() *timestamppb.Timestamp

func (*Metadata) GetPath

func (x *Metadata) GetPath() *Path

func (*Metadata) GetSize

func (x *Metadata) GetSize() int64

func (*Metadata) ProtoMessage

func (*Metadata) ProtoMessage()

func (*Metadata) ProtoReflect added in v0.1.12

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

func (*Metadata) Reset

func (x *Metadata) Reset()

func (*Metadata) String

func (x *Metadata) String() string

type Path

type Path struct {
	Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
	// contains filtered or unexported fields
}

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 deprecated

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

Deprecated: Use Path.ProtoReflect.Descriptor instead.

func (*Path) GetPath

func (x *Path) GetPath() string

func (*Path) ProtoMessage

func (*Path) ProtoMessage()

func (*Path) ProtoReflect added in v0.1.12

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

func (*Path) Reset

func (x *Path) Reset()

func (*Path) String

func (x *Path) String() string

type UnimplementedFsdServer

type UnimplementedFsdServer struct {
}

UnimplementedFsdServer must be embedded to have forward compatible implementations.

func (UnimplementedFsdServer) Copy

func (UnimplementedFsdServer) CopyAll

func (UnimplementedFsdServer) Dir

func (UnimplementedFsdServer) Download

func (UnimplementedFsdServer) DownloadMetadata

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

func (UnimplementedFsdServer) Exists

func (UnimplementedFsdServer) Hash

func (UnimplementedFsdServer) IsDir

func (UnimplementedFsdServer) IsDirEmpty

func (UnimplementedFsdServer) IsFile

func (UnimplementedFsdServer) Mkdir

func (UnimplementedFsdServer) MkdirRecursive

func (UnimplementedFsdServer) Remove

func (UnimplementedFsdServer) RemoveAll

func (UnimplementedFsdServer) RemoveFile

func (UnimplementedFsdServer) Rmdir

func (UnimplementedFsdServer) Upload

type UnsafeFsdServer added in v0.1.12

type UnsafeFsdServer interface {
	// contains filtered or unexported methods
}

UnsafeFsdServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to FsdServer will result in compilation errors.

Jump to

Keyboard shortcuts

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