Line data Source code
1 : // Copyright 2023 The LevelDB-Go and Pebble Authors. All rights reserved. Use 2 : // of this source code is governed by a BSD-style license that can be found in 3 : // the LICENSE file. 4 : 5 : package objstorage 6 : 7 : import "context" 8 : 9 : // NoopReadHandle can be used by Readable implementations that don't 10 : // support read-ahead. 11 : type NoopReadHandle struct { 12 : readable Readable 13 : } 14 : 15 : // MakeNoopReadHandle initializes a NoopReadHandle. 16 1 : func MakeNoopReadHandle(r Readable) NoopReadHandle { 17 1 : return NoopReadHandle{readable: r} 18 1 : } 19 : 20 : var _ ReadHandle = (*NoopReadHandle)(nil) 21 : 22 : // ReadAt is part of the ReadHandle interface. 23 1 : func (h *NoopReadHandle) ReadAt(ctx context.Context, p []byte, off int64) error { 24 1 : return h.readable.ReadAt(ctx, p, off) 25 1 : } 26 : 27 : // Close is part of the ReadHandle interface. 28 1 : func (*NoopReadHandle) Close() error { return nil } 29 : 30 : // SetupForCompaction is part of the ReadHandle interface. 31 0 : func (*NoopReadHandle) SetupForCompaction() {} 32 : 33 : // RecordCacheHit is part of the ReadHandle interface. 34 1 : func (*NoopReadHandle) RecordCacheHit(_ context.Context, offset, size int64) {}