go-hep.org/x/hep@v0.38.1/groot/riofs/memfile.go (about) 1 // Copyright ©2018 The go-hep Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package riofs 6 7 import "bytes" 8 9 // RMemFile creates a simple in-memory read-only ROOT file 10 // from the provided slice of bytes. 11 func RMemFile(p []byte) Reader { 12 return &memFile{bytes.NewReader(p)} 13 } 14 15 // memFile is a simple in-memory read-only ROOT file 16 type memFile struct { 17 r *bytes.Reader 18 } 19 20 func (r *memFile) Close() error { return nil } 21 func (r *memFile) Read(p []byte) (int, error) { return r.r.Read(p) } 22 func (r *memFile) ReadAt(p []byte, off int64) (int, error) { return r.r.ReadAt(p, off) } 23 func (r *memFile) Seek(offset int64, whence int) (int64, error) { return r.r.Seek(offset, whence) } 24 25 var ( 26 _ Reader = (*memFile)(nil) 27 )