github.com/safing/portbase@v0.19.5/database/storage/injectbase.go (about)

     1  package storage
     2  
     3  import (
     4  	"context"
     5  	"errors"
     6  	"time"
     7  
     8  	"github.com/safing/portbase/database/iterator"
     9  	"github.com/safing/portbase/database/query"
    10  	"github.com/safing/portbase/database/record"
    11  )
    12  
    13  // ErrNotImplemented is returned when a function is not implemented by a storage.
    14  var ErrNotImplemented = errors.New("not implemented")
    15  
    16  // InjectBase is a dummy base structure to reduce boilerplate code for injected storage interfaces.
    17  type InjectBase struct{}
    18  
    19  // Compile time interface check.
    20  var _ Interface = &InjectBase{}
    21  
    22  // Get returns a database record.
    23  func (i *InjectBase) Get(key string) (record.Record, error) {
    24  	return nil, ErrNotImplemented
    25  }
    26  
    27  // Put stores a record in the database.
    28  func (i *InjectBase) Put(m record.Record) (record.Record, error) {
    29  	return nil, ErrNotImplemented
    30  }
    31  
    32  // Delete deletes a record from the database.
    33  func (i *InjectBase) Delete(key string) error {
    34  	return ErrNotImplemented
    35  }
    36  
    37  // Query returns a an iterator for the supplied query.
    38  func (i *InjectBase) Query(q *query.Query, local, internal bool) (*iterator.Iterator, error) {
    39  	return nil, ErrNotImplemented
    40  }
    41  
    42  // ReadOnly returns whether the database is read only.
    43  func (i *InjectBase) ReadOnly() bool {
    44  	return true
    45  }
    46  
    47  // Injected returns whether the database is injected.
    48  func (i *InjectBase) Injected() bool {
    49  	return true
    50  }
    51  
    52  // MaintainRecordStates maintains records states in the database.
    53  func (i *InjectBase) MaintainRecordStates(ctx context.Context, purgeDeletedBefore time.Time, shadowDelete bool) error {
    54  	return nil
    55  }
    56  
    57  // Shutdown shuts down the database.
    58  func (i *InjectBase) Shutdown() error {
    59  	return nil
    60  }