itd/fuse/mock.go
2023-02-19 13:51:06 +00:00

107 lines
2.1 KiB
Go

package main
import (
"io/fs"
"errors"
)
var (
ErrFileNotExists = errors.New("file does not exist")
ErrFileReadOnly = errors.New("file is read only")
ErrFileWriteOnly = errors.New("file is write only")
ErrInvalidOffset = errors.New("invalid file offset")
ErrOffsetChanged = errors.New("offset has already been changed")
ErrReadOpen = errors.New("only one file can be opened for reading at a time")
ErrWriteOpen = errors.New("only one file can be opened for writing at a time")
ErrNoRemoveRoot = errors.New("refusing to remove root directory")
)
type Device struct {
}
type FS struct {
}
type File struct {
fs *FS
path string
offset uint32
offsetCh chan uint32
length uint32
amtLeft uint32
amtTferd uint32
isReadOnly bool
isWriteOnly bool
offsetChanged bool
}
func (i *Device) HeartRate() (uint8, error) {
return 10, nil
}
func (i *Device) BatteryLevel() (uint8, error) {
return 95, nil
}
func (i *Device) StepCount() (uint32, error) {
return 27000, nil
}
type MotionValues struct {
X int16
Y int16
Z int16
}
func (i *Device) Motion() (MotionValues, error) {
return MotionValues{-12, +64, -19}, nil
}
func (i *Device) Address() string {
return "FA:E4:00:00:00:00"
}
func (i *Device) Version() (string, error) {
return "1.11.0", nil
}
func (blefs *FS) ReadDir(path string) ([]fs.DirEntry, error) {
var out []fs.DirEntry
return out, nil
}
func (blefs *FS) Mkdir(path string) error {
return nil
}
func (blefs *FS) Stat(path string) (fs.FileInfo, error) {
return nil, ErrFileNotExists
}
func (blefs *FS) Rename(old, new string) error {
return nil
}
func (blefs *FS) Remove(path string) error {
return nil
}
func (blefs *FS) Open(path string) (*File, error) {
return &File{}, nil
}
func (blefs *FS) Create(path string, size uint32) (*File, error) {
return &File{}, nil
}
func (fl *File) Read(b []byte) (n int, err error) {
return 0, ErrFileWriteOnly
}
func (fl *File) Write(b []byte) (n int, err error) {
return 0, ErrFileWriteOnly
}
func (fl *File) Close() error {
return nil
}
// func (fl *File) Stat() (fs.FileInfo, error) {
// }