Documentation ¶
Overview ¶
Package memio implements common types and functions used for in-memory I/O
Index ¶
- type File
- func (f *File) Bytes() []byte
- func (f *File) Close() error
- func (f *File) Expand(n int) []byte
- func (f *File) Grow(n int) *File
- func (f *File) IsDir() bool
- func (f *File) Len() int
- func (f *File) ModTime() time.Time
- func (f *File) Mode() fs.FileMode
- func (f *File) Name() string
- func (f *File) Offset() int64
- func (f *File) Read(p []byte) (int, error)
- func (f *File) ReadByte() (byte, error)
- func (f *File) ReadBytes(delim byte) ([]byte, error)
- func (f *File) ReadFloat32(o binary.ByteOrder) (float32, error)
- func (f *File) ReadFloat64(o binary.ByteOrder) (float64, error)
- func (f *File) ReadFrom(r io.Reader) (n int64, err error)
- func (f *File) ReadFull(p []byte) (int, error)
- func (f *File) ReadInt16(o binary.ByteOrder) (int16, error)
- func (f *File) ReadInt32(o binary.ByteOrder) (int32, error)
- func (f *File) ReadInt64(o binary.ByteOrder) (int64, error)
- func (f *File) ReadString(delim byte) (string, error)
- func (f *File) ReadUint16(o binary.ByteOrder) (uint16, error)
- func (f *File) ReadUint32(o binary.ByteOrder) (uint32, error)
- func (f *File) ReadUint64(o binary.ByteOrder) (uint64, error)
- func (f *File) Reset(p []byte)
- func (f *File) Rewind() *File
- func (f *File) Seek(offset int64, whence int) (int64, error)
- func (f *File) Size() int64
- func (f *File) Stat() (fs.FileInfo, error)
- func (f *File) String() string
- func (f *File) StringRef() string
- func (f *File) Sys() any
- func (f *File) Write(p []byte) (int, error)
- func (f *File) WriteByte(p byte) error
- func (f *File) WriteFloat32(o binary.ByteOrder, n float32)
- func (f *File) WriteFloat64(o binary.ByteOrder, n float64)
- func (f *File) WriteInt16(o binary.ByteOrder, n int16)
- func (f *File) WriteInt32(o binary.ByteOrder, n int32)
- func (f *File) WriteInt64(o binary.ByteOrder, n int64)
- func (f *File) WriteString(p string) (int, error)
- func (f *File) WriteTo(w io.Writer) (int64, error)
- func (f *File) WriteUint16(o binary.ByteOrder, n uint16)
- func (f *File) WriteUint32(o binary.ByteOrder, n uint32)
- func (f *File) WriteUint64(o binary.ByteOrder, n uint64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File implements file-like methods on an in-memory buffer
func (*File) Expand ¶
Expand grows the internal buffer to fill n bytes and sets pos to the end
It returns a slice that should be filled with n bytes of content
func (*File) Grow ¶
Grow increases the capacity of the internal buffer to guarantee space for another n byte without reallocation
func (*File) ModTime ¶
ModTime implements the fs.FileInfo.ModTime interface
It always returns time.Time{}
func (*File) Mode ¶
Mode implements the fs.FileInfo.Mode interface
It always returns fs.ModeIrregular
func (*File) ReadBytes ¶
ReadBytes reads bytes up to and excluding delim An error (wrapping io.ErrUnexpectedEOF) is returned iff delim is not found
func (*File) ReadFloat32 ¶
ReadFloat32 reads a 32-bit floating point number in the byte order specified by o
func (*File) ReadFloat64 ¶
ReadFloat64 reads a 64-bit floating point number in the byte order specified by o
func (*File) ReadFull ¶
ReadFull fills buffer p, or returns the number of bytes read and error io.ErrUnexpectedEOF
func (*File) ReadString ¶
ReadString reads bytes up to and excluding delim An error (wrapping io.ErrUnexpectedEOF) is returned iff delim is not found
func (*File) ReadUint16 ¶
ReadUint16 reads a 16-bit number in the byte order specified by o
func (*File) ReadUint32 ¶
ReadUint32 reads a 32-bit number in the byte order specified by o
func (*File) ReadUint64 ¶
ReadUint64 reads a 64-bit number in the byte order specified by o
func (*File) Rewind ¶
Rewind sets the Read position of the internal buffer back to the start
It's equivalent to Seek(0, io.SeekStart) or Seek(0, 0)
func (*File) Seek ¶
Seek implements io.Seeker
If the final offset is greater than Len(), the internal buffer is expanded accordingly
func (*File) Size ¶
Size implements the fs.FileInfo.Size interface
It returns the length of the internal buffer
func (*File) WriteFloat32 ¶
WriteFloat32 is a wrapper around f.WriteUint32(o, math.Float32bits(n))
func (*File) WriteFloat64 ¶
WriteFloat64 is a wrapper around f.WriteUint64(o, math.Float64bits(n))
func (*File) WriteInt16 ¶
WriteInt16 is a wrapper around f.WriteUint16(o, uint16(n))
func (*File) WriteInt32 ¶
WriteInt32 is a wrapper around f.WriteUint32(o, uint32(n))
func (*File) WriteInt64 ¶
WriteInt64 is a wrapper around f.WriteUint64(o, uint64(n))
func (*File) WriteString ¶
WriteString implements io.StringWriter
func (*File) WriteUint16 ¶
WriteUint16 writes n in the byte order specified by o
func (*File) WriteUint32 ¶
WriteUint32 writes n in the byte order specified by o