2024-11-06 15:17:35 +01:00
|
|
|
package meta
|
|
|
|
|
|
|
|
|
|
import (
|
2024-11-20 18:27:01 +01:00
|
|
|
"iter"
|
|
|
|
|
|
2024-11-06 15:17:35 +01:00
|
|
|
"github.com/ipld/go-ipld-prime"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ReadOnly wraps a Meta into a read-only facade.
|
|
|
|
|
type ReadOnly struct {
|
2024-11-20 18:27:01 +01:00
|
|
|
meta *Meta
|
2024-11-06 15:17:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r ReadOnly) GetBool(key string) (bool, error) {
|
2024-11-20 18:27:01 +01:00
|
|
|
return r.meta.GetBool(key)
|
2024-11-06 15:17:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r ReadOnly) GetString(key string) (string, error) {
|
2024-11-20 18:27:01 +01:00
|
|
|
return r.meta.GetString(key)
|
2024-11-06 15:17:35 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-12 15:29:48 +01:00
|
|
|
func (r ReadOnly) GetEncryptedString(key string, encryptionKey []byte) (string, error) {
|
2024-11-20 18:27:01 +01:00
|
|
|
return r.meta.GetEncryptedString(key, encryptionKey)
|
2024-11-12 15:29:48 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 15:17:35 +01:00
|
|
|
func (r ReadOnly) GetInt64(key string) (int64, error) {
|
2024-11-20 18:27:01 +01:00
|
|
|
return r.meta.GetInt64(key)
|
2024-11-06 15:17:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r ReadOnly) GetFloat64(key string) (float64, error) {
|
2024-11-20 18:27:01 +01:00
|
|
|
return r.meta.GetFloat64(key)
|
2024-11-06 15:17:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r ReadOnly) GetBytes(key string) ([]byte, error) {
|
2024-11-20 18:27:01 +01:00
|
|
|
return r.meta.GetBytes(key)
|
2024-11-06 15:17:35 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-12 15:29:48 +01:00
|
|
|
func (r ReadOnly) GetEncryptedBytes(key string, encryptionKey []byte) ([]byte, error) {
|
2024-11-20 18:27:01 +01:00
|
|
|
return r.meta.GetEncryptedBytes(key, encryptionKey)
|
2024-11-12 15:29:48 +01:00
|
|
|
}
|
|
|
|
|
|
2024-11-06 15:17:35 +01:00
|
|
|
func (r ReadOnly) GetNode(key string) (ipld.Node, error) {
|
2024-11-20 18:27:01 +01:00
|
|
|
return r.meta.GetNode(key)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r ReadOnly) Iter() iter.Seq2[string, ipld.Node] {
|
|
|
|
|
return r.meta.Iter()
|
2024-11-06 15:17:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r ReadOnly) Equals(other ReadOnly) bool {
|
2024-11-20 18:27:01 +01:00
|
|
|
return r.meta.Equals(other.meta)
|
2024-11-06 15:17:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r ReadOnly) String() string {
|
2024-11-20 18:27:01 +01:00
|
|
|
return r.meta.String()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r ReadOnly) WriteableClone() *Meta {
|
|
|
|
|
return r.meta.Clone()
|
2024-11-06 15:17:35 +01:00
|
|
|
}
|