byte

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 5 Imported by: 0

README

Sphire Mantis::Byte

The Byte package of Mantis provides helper functions for parsing and working with bytes and related units

Documentation

Index

Constants

View Source
const (
	// B byte (Unit)
	B BytesUnit = 1
	// KB Kilobyte (SI) - 1000 bytes
	KB BytesUnit = 1000
	// MB Megabyte (SI) - 1e6 bytes
	MB BytesUnit = 1e6
	// GB Gigabyte (SI) - 1e9 bytes
	GB BytesUnit = 1e9
	// TB Terabyte (SI) - 1e12 bytes
	TB BytesUnit = 1e12
	// PB Petabyte (SI) - 1e15 bytes
	PB BytesUnit = 1e15

	// KiB Kibibyte (NIST) - 1024 bytes
	KiB BytesUnit = 1024
	// MiB Mebibyte (NIST) - 2^20 bytes
	MiB = 1024 * KiB
	// GiB Gibibyte (NIST) - 2^30 bytes
	GiB = 1024 * MiB
	// TiB Tebibyte (NIST) - 2^40 bytes
	TiB = 1024 * GiB
	// PiB Pebibyte (NIST) - 2^50 bytes
	PiB = 1024 * TiB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bytes

type Bytes int64

Bytes is a formattable byte count

func ParseBytes

func ParseBytes(s string) (Bytes, error)

ParseBytes parses the given string with byte units into a Byte count

func (Bytes) Format

func (b Bytes) Format(s fmt.State, verb rune)

Format bytes

func (Bytes) String

func (b Bytes) String() string

type BytesUnit

type BytesUnit int64

BytesUnit represents a unit of magnitude for Bytes in either SI (base-10) or NIST (base-2)

func (BytesUnit) Convert

func (u BytesUnit) Convert(b Bytes) float64

Convert a byte count into the (possibly fractional) count in this unit

func (BytesUnit) String

func (u BytesUnit) String() string

type ParseErr

type ParseErr struct {
	Func string
	Str  string
	Err  error
}

ParseErr returned invalid strings are parsed

func (*ParseErr) Error

func (e *ParseErr) Error() string

func (*ParseErr) String

func (e *ParseErr) String() string

Jump to

Keyboard shortcuts

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