types

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRemoteFileNotFound = errors.New("remote file not found")

ErrRemoteFileNotFound is returned by RemoteFileStream.ReadAt when the peer reports the file no longer exists (gRPC NotFound), as opposed to a transient fetch failure (timeout, connection loss, server I/O error). The on-demand read path uses this to distinguish a genuinely gone file (surface EOF, e.g. git's transient .keep files) from a stall (surface EIO, so a media player does not see a false end-of-file mid-stream). Defined here, in the shared types package, so the filesystem package can check it without importing gRPC.

Functions

func AttrToStat

func AttrToStat(attr *keibidrop.Attr) *fuse.Stat_t

AttrToStat converts a protobuf Attr back to a FUSE Stat_t.

func NanoToTimespec

func NanoToTimespec(ns uint64) fuse.Timespec

NanoToTimespec converts nanoseconds since Unix epoch to a fuse.Timespec.

func StatToAttr

func StatToAttr(stat *fuse.Stat_t) *keibidrop.Attr

StatToAttr converts a FUSE Stat_t to a protobuf Attr.

Types

type ChunkHashReceiver added in v0.3.6

type ChunkHashReceiver interface {
	Recv() (chunkIndex uint64, hash uint64, err error)
}

ChunkHashReceiver streams (chunkIndex, hash) pairs from a peer's GetChunkHashes RPC.

type ChunkHasher added in v0.3.6

type ChunkHasher interface {
	GetChunkHashes(ctx context.Context, path string, chunkSize, fromChunk, count uint64) (ChunkHashReceiver, error)
}

ChunkHasher is implemented by providers that support the GetChunkHashes RPC. A provider that does not implement it (older peer, test fake) signals via the failed type assertion at the call site that the caller must fall back.

type FileAction

type FileAction int

FileAction maps local FS events

const (
	Unknown FileAction = iota
	AddDir
	AddFile
	RemoveDir
	RemoveFile
	EditDir
	EditFile
	RenameFile
	RenameDir
)

type FileEvent

type FileEvent struct {
	Path    string          // relative path in the FS (new path for renames)
	OldPath string          // for renames: the source path
	Action  FileAction      // type of event
	Attr    *keibidrop.Attr // file attributes (from Stat_t)
}

FileEvent represents a filesystem change

type FileStreamProvider

type FileStreamProvider interface {
	OpenRemoteFile(ctx context.Context, inode uint64, path string) (RemoteFileStream, error)
	// StreamFile starts a push-based download: server sends all chunks
	// from startOffset to EOF without per-chunk round-trips.
	StreamFile(ctx context.Context, path string, startOffset uint64) (StreamFileReceiver, error)
}

FileStreamProvider is a factory for RemoteFileStream and StreamFile.

type RemoteFileStream

type RemoteFileStream interface {
	// ReadAt sends offset & size, receives exactly those bytes.
	ReadAt(ctx context.Context, offset int64, size int64) ([]byte, error)
	Close() error
}

type StreamFileReceiver

type StreamFileReceiver interface {
	// Recv returns the next chunk. Returns io.EOF when the stream ends.
	Recv() (data []byte, offset uint64, totalSize uint64, err error)
}

StreamFileReceiver receives pushed chunks from the server.

Jump to

Keyboard shortcuts

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