objects

package
v0.4.25-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: ISC Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const CHUNK_VERSION = "1.0.0"
View Source
const OBJECT_VERSION = "1.0.0"

Variables

This section is empty.

Functions

func ParseFileInfoSortKeys

func ParseFileInfoSortKeys(sortKeysStr string) ([]string, error)

func SortFileInfos

func SortFileInfos(infos []FileInfo, sortKeys []string) error

Types

type Chunk

type Chunk struct {
	Version versioning.Version `msgpack:"version" json:"version"`
	MAC     MAC                `msgpack:"MAC" json:"MAC"`
	Length  uint32             `msgpack:"length" json:"length"`
	Entropy float64            `msgpack:"entropy" json:"entropy"`
	Flags   uint32             `msgpack:"flags" json:"flags"`
}

func NewChunk

func NewChunk() *Chunk

func NewChunkFromBytes

func NewChunkFromBytes(serialized []byte) (*Chunk, error)

func (*Chunk) MarshalJSON

func (c *Chunk) MarshalJSON() ([]byte, error)

func (*Chunk) Serialize

func (c *Chunk) Serialize() ([]byte, error)

type FileInfo

type FileInfo struct {
	Lname      string      `json:"name" msgpack:"name"`
	Lsize      int64       `json:"size" msgpack:"size"`
	Lmode      fs.FileMode `json:"mode" msgpack:"mode"`
	LmodTime   time.Time   `json:"mod_time" msgpack:"mod_time"`
	Ldev       uint64      `json:"dev" msgpack:"dev"`
	Lino       uint64      `json:"ino" msgpack:"ino"`
	Luid       uint64      `json:"uid" msgpack:"uid"`
	Lgid       uint64      `json:"gid" msgpack:"gid"`
	Lnlink     uint16      `json:"nlink" msgpack:"nlink"`
	Lusername  string      `json:"username" msgpack:"username"`   // local addition
	Lgroupname string      `json:"groupname" msgpack:"groupname"` // local addition

	// Just in case we need something special to handle special
	// OSes.
	Flags uint32 `json:"flags" msgpack:"flags"`
}

func FileInfoFromStat

func FileInfoFromStat(stat fs.FileInfo) FileInfo

func NewFileInfo

func NewFileInfo(name string, size int64, mode os.FileMode, modTime time.Time, dev uint64, ino uint64, uid uint64, gid uint64, nlink uint16) FileInfo

func (FileInfo) Dev

func (f FileInfo) Dev() uint64

func (*FileInfo) Equal

func (fileinfo *FileInfo) Equal(fi *FileInfo) bool

func (FileInfo) Gid

func (f FileInfo) Gid() uint64

func (FileInfo) Groupname

func (f FileInfo) Groupname() string

func (*FileInfo) HumanSize

func (fileinfo *FileInfo) HumanSize() string

func (FileInfo) Ino

func (f FileInfo) Ino() uint64

func (FileInfo) IsDir

func (f FileInfo) IsDir() bool

func (FileInfo) ModTime

func (f FileInfo) ModTime() time.Time

func (FileInfo) Mode

func (f FileInfo) Mode() os.FileMode

func (FileInfo) Name

func (f FileInfo) Name() string
func (f FileInfo) Nlink() uint16

func (FileInfo) Size

func (f FileInfo) Size() int64

func (FileInfo) Sys

func (f FileInfo) Sys() any

func (*FileInfo) Type

func (fileinfo *FileInfo) Type() string

func (FileInfo) Uid

func (f FileInfo) Uid() uint64

func (FileInfo) Username

func (f FileInfo) Username() string

type MAC

type MAC [32]byte

func (MAC) MarshalJSON

func (m MAC) MarshalJSON() ([]byte, error)

func (*MAC) UnmarshalJSON

func (m *MAC) UnmarshalJSON(data []byte) error

type Object

type Object struct {
	Version     versioning.Version `msgpack:"version" json:"version"`
	MAC         MAC                `msgpack:"MAC" json:"MAC"`
	Chunks      []Chunk            `msgpack:"chunks" json:"chunks"`
	ContentType string             `msgpack:"content_type,omitempty" json:"content_type"`
	Entropy     float64            `msgpack:"entropy,omitempty" json:"entropy"`
	Flags       uint32             `msgpack:"flags" json:"flags"`
}

func NewObject

func NewObject() *Object

func NewObjectFromBytes

func NewObjectFromBytes(serialized []byte) (*Object, error)

func (*Object) MarshalJSON

func (o *Object) MarshalJSON() ([]byte, error)

Return empty lists for nil slices.

func (*Object) Serialize

func (o *Object) Serialize() ([]byte, error)

Jump to

Keyboard shortcuts

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