api

package
v0.0.0-...-711078c Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDevice

func RegisterDevice(fsType string, imp DeviceBuilder)
func RegisterHeaderDevice(fsType string, imp HeaderDeviceBuilder) {
	reg.HeaderDevices[fsType] = imp
}

func RegisterSimpleDevice

func RegisterSimpleDevice(fsType string, imp SimpleDeviceBuilder)

Types

type Device

type Device interface {
	StdDevice
	OpenLarge(path string) (File, error)
}

Device ... Normal file interface

func MountDevice

func MountDevice(fsType, mountPoint string, config []byte) (Device, error)

type DeviceBuilder

type DeviceBuilder func(mountPoint string, config []byte) Device

type HeaderDeviceBuilder func(mountPoint string, config []byte) HeaderDevice

type File

type File interface {
	Read(offest, size int) (body []byte, err error)
	Write(offset int, body []byte) (int, error)
	Close() error
}

File ... This interface support reading / writing large files

type HeaderDevice

type HeaderDevice interface {
	Mount(config []byte) error
	Unmount() error
	List(path string) ([]string, error)
	Open(path string) (HeaderFile, error)
}

HeaderDevice ... Devices that have a header as part of reading / writing

type HeaderFile

type HeaderFile interface {
	Read() (header, body []byte, err error)
	Write(offset int, header, body []byte) (int, error)
}
Devices with headers concept

HeaderFile ... Support for a file with header

type Registered

type Registered struct {
	MountPoint  string
	FSType      string
	Description string
	Config      []byte
}

type Registrar

type Registrar struct {
	//HeaderDevices map[string]HeaderDeviceBuilder
	Devices       map[string]DeviceBuilder
	SimpleDevices map[string]SimpleDeviceBuilder
}

type SimpleDevice

type SimpleDevice interface {
	StdDevice
	Open(path string) (SimpleFile, error)
}

SimpleDevice ... Simplified interface for interacting with a device

func MountSimpleDevice

func MountSimpleDevice(fsType, mountPoint string, config []byte) (SimpleDevice, error)
func MountHeaderDevice(fsType, mountPoint string, config []byte) (HeaderDevice, error) {
	imp, exists := reg.HeaderDevices[fsType]
	if !exists {
		return nil, errors.New(fmt.Sprintf("No file system type %s", fsType))
	}
	return imp(mountPoint, config), nil
}

type SimpleDeviceBuilder

type SimpleDeviceBuilder func(mountPoint string, config []byte) SimpleDevice

type SimpleFile

type SimpleFile interface {
	Read() (body []byte, err error)
	Write(body []byte) error
	Close() error
}

File ... Simplified file interface

type StdDevice

type StdDevice interface {
	Mount(config []byte) error
	Unmount() error
	List(path string) ([]string, error)
	Remove(path string) error
}

StdDevice ... Shared device functions

Jump to

Keyboard shortcuts

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