github.com/ethersphere/bee/v2@v2.2.0/pkg/manifest/simple/entry.go (about)

     1  // Copyright 2020 The Swarm 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 simple
     6  
     7  // Entry is a representation of a single manifest entry.
     8  type Entry interface {
     9  	// Reference returns the address of the file in the entry.
    10  	Reference() string
    11  	// Metadata returns the metadata for this entry.
    12  	Metadata() map[string]string
    13  }
    14  
    15  // entry is a JSON representation of a single manifest entry.
    16  type entry struct {
    17  	Ref  string            `json:"reference"`
    18  	Meta map[string]string `json:"metadata,omitempty"`
    19  }
    20  
    21  // newEntry creates a new Entry struct and returns it.
    22  func newEntry(reference string, metadata map[string]string) *entry {
    23  	return &entry{
    24  		Ref:  reference,
    25  		Meta: metadata,
    26  	}
    27  }
    28  
    29  func (me *entry) Reference() string {
    30  	return me.Ref
    31  }
    32  
    33  func (me *entry) Metadata() map[string]string {
    34  	return me.Meta
    35  }