storj

package
v0.0.0-...-5f226fc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 20 Imported by: 150

Documentation

Overview

Package storj contains the types which represent the main entities of the Storj domain.

Index

Constants

View Source
const (
	// EncUnspecified indicates no encryption suite has been selected.
	EncUnspecified = CipherSuite(iota)
	// EncNull indicates use of the NULL cipher; that is, no encryption is
	// done. The ciphertext is equal to the plaintext.
	EncNull
	// EncAESGCM indicates use of AES128-GCM encryption.
	EncAESGCM
	// EncSecretBox indicates use of XSalsa20-Poly1305 encryption, as provided
	// by the NaCl cryptography library under the name "Secretbox".
	EncSecretBox
	// EncNullBase64URL is like EncNull but Base64 encodes/decodes the
	// binary path data (URL-safe).
	EncNullBase64URL
)
View Source
const (
	KeySize   = 32
	NonceSize = 24
)

Constant definitions for key and nonce sizes.

View Source
const (
	// NoiseProto_Unset is an unset protocol.
	NoiseProto_Unset = 0
	// NoiseProto_IK_25519_ChaChaPoly_BLAKE2b is a Noise protocol.
	NoiseProto_IK_25519_ChaChaPoly_BLAKE2b = 1
	// NoiseProto_IK_25519_AESGCM_BLAKE2b is a Noise protocol.
	NoiseProto_IK_25519_AESGCM_BLAKE2b = 2
)
View Source
const (
	InvalidRedundancyAlgorithm = RedundancyAlgorithm(iota)
	ReedSolomon
)

List of supported redundancy algorithms.

View Source
const NodeIDSize = 32

NodeIDSize is the byte length of a NodeID.

View Source
const (
	// V0 represents identity version 0
	// NB: identities created before identity versioning (i.e. which don't have a
	// version extension; "legacy") will be recognized as V0.
	V0 = IDVersionNumber(iota)
)

Variables

View Source
var (
	// IDVersions is a map of all identity versions.
	IDVersions = map[IDVersionNumber]IDVersion{
		V0: {
			Number:        V0,
			NewPrivateKey: pkcrypto.GeneratePrivateKey,
		},
	}

	// IDVersionHandler compares the identity version of the remote peers
	// certificate chain to the extension options passed to the factory.
	IDVersionHandler = extensions.NewHandlerFactory(
		&extensions.IdentityVersionExtID, idVersionHandler,
	)
)
View Source
var (
	// ErrNodeID is used when something goes wrong with a node id.
	ErrNodeID = errs.Class("node ID")
	// ErrVersion is used for identity version related errors.
	ErrVersion = errs.Class("node ID version")
)
View Source
var (
	// ErrNodeURL is used when something goes wrong with a node url.
	ErrNodeURL = errs.Class("node URL")
)
View Source
var ErrNonce = errs.Class("nonce")

ErrNonce is used when something goes wrong with a stream ID.

View Source
var ErrPieceID = errs.Class("piece ID")

ErrPieceID is used when something goes wrong with a piece ID.

View Source
var ErrPieceKey = errs.Class("piece key")

ErrPieceKey is used when something goes wrong with a piece key.

View Source
var ErrSegmentID = errs.Class("segment ID")

ErrSegmentID is used when something goes wrong with a segment ID.

View Source
var ErrSerialNumber = errs.Class("serial number")

ErrSerialNumber is used when something goes wrong with a serial number.

View Source
var ErrStreamID = errs.Class("stream ID")

ErrStreamID is used when something goes wrong with a stream ID.

Functions

func IDVersionInVersions

func IDVersionInVersions(versionNumber IDVersionNumber, versionsStr string) error

IDVersionInVersions returns an error if the given version is in the given string of version(s)/range(s).

func NewPieceKey

func NewPieceKey() (PiecePublicKey, PiecePrivateKey, error)

NewPieceKey creates a piece key pair.

func NewVersionExt

func NewVersionExt(version IDVersion) pkix.Extension

NewVersionExt creates a new identity version certificate extension for the given identity version.

func SplitPath

func SplitPath(path Path) []string

SplitPath splits path into a slice of path components.

Types

type CipherSuite

type CipherSuite byte

CipherSuite specifies one of the encryption suites supported by Storj libraries for encryption of in-network data.

func (CipherSuite) String

func (suite CipherSuite) String() string

String representation of the cipher suite.

type EncryptedPrivateKey

type EncryptedPrivateKey []byte

EncryptedPrivateKey is a private key that has been encrypted.

func (*EncryptedPrivateKey) Scan

func (pkey *EncryptedPrivateKey) Scan(src interface{}) (err error)

Scan extracts a EncryptedPrivateKey from a database field.

func (EncryptedPrivateKey) Value

func (pkey EncryptedPrivateKey) Value() (driver.Value, error)

Value converts a EncryptedPrivateKey to a database field.

type EncryptionParameters

type EncryptionParameters struct {
	// CipherSuite specifies the cipher suite to be used for encryption.
	CipherSuite CipherSuite
	// BlockSize determines the unit size at which encryption is performed.
	// It is important to distinguish this from the block size used by the
	// cipher suite (probably 128 bits). There is some small overhead for
	// each encryption unit, so BlockSize should not be too small, but
	// smaller sizes yield shorter first-byte latency and better seek times.
	// Note that BlockSize itself is the size of data blocks _after_ they
	// have been encrypted and the authentication overhead has been added.
	// It is _not_ the size of the data blocks to _be_ encrypted.
	BlockSize int32
}

EncryptionParameters is the cipher suite and parameters used for encryption.

func (EncryptionParameters) IsZero

func (params EncryptionParameters) IsZero() bool

IsZero returns true if no field in the struct is set to non-zero value.

type IDVersion

type IDVersion struct {
	Number        IDVersionNumber
	NewPrivateKey func() (crypto.PrivateKey, error)
}

IDVersion holds fields that are used to distinguish different identity versions from one another; used in identity generation.

func GetIDVersion

func GetIDVersion(number IDVersionNumber) (IDVersion, error)

GetIDVersion looks up the given version number in the map of registered versions, returning an error if none is found.

func IDVersionFromCert

func IDVersionFromCert(cert *x509.Certificate) (IDVersion, error)

IDVersionFromCert parsed the IDVersion from the passed certificate's IDVersion extension.

func LatestIDVersion

func LatestIDVersion() IDVersion

LatestIDVersion returns the last IDVersion registered.

type IDVersionNumber

type IDVersionNumber uint8

IDVersionNumber is the number of an identity version.

type Key

type Key [KeySize]byte

Key represents the largest key used by any encryption protocol.

func NewKey

func NewKey(humanReadableKey []byte) (*Key, error)

NewKey creates a new Storj key from humanReadableKey.

func (*Key) IsZero

func (key *Key) IsZero() bool

IsZero returns true if key is nil or it points to its zero value.

func (*Key) Raw

func (key *Key) Raw() *[KeySize]byte

Raw returns the key as a raw byte array pointer.

type NodeID

type NodeID [NodeIDSize]byte

NodeID is a unique node identifier.

func NewVersionedID

func NewVersionedID(id NodeID, version IDVersion) NodeID

NewVersionedID adds an identity version to a node ID.

func NodeIDFromBytes

func NodeIDFromBytes(b []byte) (NodeID, error)

NodeIDFromBytes converts a byte slice into a node id.

func NodeIDFromString

func NodeIDFromString(s string) (NodeID, error)

NodeIDFromString decodes a base58check encoded node id string.

func (NodeID) Bytes

func (id NodeID) Bytes() []byte

Bytes returns raw bytes of the id.

func (NodeID) Compare

func (id NodeID) Compare(other NodeID) int

Compare returns an integer comparing id and other lexicographically. The result will be 0 if id==other, -1 if id < other, and +1 if id > other.

func (*NodeID) DecodeSpanner

func (id *NodeID) DecodeSpanner(val any) (err error)

DecodeSpanner implements spanner.Decoder.

func (NodeID) Difficulty

func (id NodeID) Difficulty() (uint16, error)

Difficulty returns the number of trailing zero bits in a node ID.

func (NodeID) EncodeSpanner

func (id NodeID) EncodeSpanner() (any, error)

EncodeSpanner implements spanner.Encoder.

func (*NodeID) IsZero

func (id *NodeID) IsZero() bool

IsZero returns whether NodeID is unassigned.

func (NodeID) Less

func (id NodeID) Less(other NodeID) bool

Less returns whether id is smaller than other in lexicographic order.

func (NodeID) Marshal

func (id NodeID) Marshal() ([]byte, error)

Marshal serializes a node id.

func (NodeID) MarshalText

func (id NodeID) MarshalText() ([]byte, error)

MarshalText serializes a node ID to a base58 string.

func (*NodeID) MarshalTo

func (id *NodeID) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a node ID into the passed byte slice.

func (*NodeID) Scan

func (id *NodeID) Scan(src interface{}) (err error)

Scan extracts a NodeID from a database field.

func (*NodeID) Size

func (id *NodeID) Size() int

Size returns the length of a node ID (implements gogo's custom type interface).

func (NodeID) String

func (id NodeID) String() string

String returns NodeID as base58 encoded string with checksum and version bytes.

func (*NodeID) Unmarshal

func (id *NodeID) Unmarshal(data []byte) error

Unmarshal deserializes a node ID.

func (*NodeID) UnmarshalText

func (id *NodeID) UnmarshalText(data []byte) error

UnmarshalText deserializes a base58 string to a node ID.

func (NodeID) Value

func (id NodeID) Value() (driver.Value, error)

Value converts a NodeID to a database field.

func (NodeID) Version

func (id NodeID) Version() IDVersion

Version returns the version of the identity format.

type NodeIDList

type NodeIDList []NodeID

NodeIDList is a slice of NodeIDs (implements sort).

func NodeIDsFromBytes

func NodeIDsFromBytes(b [][]byte) (ids NodeIDList, err error)

NodeIDsFromBytes converts a 2d byte slice into a list of nodes.

func (NodeIDList) Bytes

func (n NodeIDList) Bytes() (idsBytes [][]byte)

Bytes returns a 2d byte slice of the node IDs.

func (NodeIDList) Contains

func (n NodeIDList) Contains(id NodeID) bool

Contains tests if the node IDs contain id.

func (NodeIDList) Len

func (n NodeIDList) Len() int

Len implements sort.Interface.Len().

func (NodeIDList) Less

func (n NodeIDList) Less(i, j int) bool

Less implements sort.Interface.Less().

func (NodeIDList) Strings

func (n NodeIDList) Strings() []string

Strings returns a string slice of the node IDs.

func (NodeIDList) Swap

func (n NodeIDList) Swap(i, j int)

Swap implements sort.Interface.Swap().

func (NodeIDList) Unique

func (n NodeIDList) Unique() NodeIDList

Unique returns slice of the unique node IDs.

type NodeURL

type NodeURL struct {
	ID            NodeID
	Address       string
	NoiseInfo     NoiseInfo
	DebounceLimit int
	Features      uint64 // this is a bitmask of pb.NodeAddress_Feature values.
}

NodeURL defines a structure for connecting to a node.

func ParseNodeURL

func ParseNodeURL(s string) (NodeURL, error)

ParseNodeURL parses node URL string.

Examples:

raw IP:
  33.20.0.1:7777
  [2001:db8:1f70::999:de8:7648:6e8]:7777

with NodeID:
  12vha9oTFnerxYRgeQ2BZqoFrLrnmmf5UWTCY2jA77dF3YvWew7@33.20.0.1:7777
  12vha9oTFnerxYRgeQ2BZqoFrLrnmmf5UWTCY2jA77dF3YvWew7@[2001:db8:1f70::999:de8:7648:6e8]:7777

without host:
  12vha9oTFnerxYRgeQ2BZqoFrLrnmmf5UWTCY2jA77dF3YvWew7@

with noise information:
  12vha9oTFnerxYRgeQ2BZqoFrLrnmmf5UWTCY2jA77dF3YvWew7@33.20.0.1:7777?noise_pub=12vha9oTFnerxY&noise_proto=1

func (NodeURL) IsZero

func (u NodeURL) IsZero() bool

IsZero returns whether the url is empty.

func (*NodeURL) Set

func (u *NodeURL) Set(s string) error

Set implements flag.Value interface.

func (NodeURL) String

func (u NodeURL) String() string

String converts NodeURL to a string.

func (NodeURL) Type

func (NodeURL) Type() string

Type implements pflag.Value.

type NodeURLs

type NodeURLs []NodeURL

NodeURLs defines a comma delimited flag for defining a list node url-s.

func ParseNodeURLs

func ParseNodeURLs(s string) (NodeURLs, error)

ParseNodeURLs parses comma delimited list of node urls.

func (*NodeURLs) Set

func (urls *NodeURLs) Set(s string) error

Set implements flag.Value interface.

func (NodeURLs) String

func (urls NodeURLs) String() string

String converts NodeURLs to a string.

func (NodeURLs) Type

func (NodeURLs) Type() string

Type implements pflag.Value.

type NoiseInfo

type NoiseInfo struct {
	Proto     NoiseProto
	PublicKey string // byte representation
}

NoiseInfo represents the information needed to dial a remote Noise peer.

func (*NoiseInfo) IsZero

func (info *NoiseInfo) IsZero() bool

IsZero returns whether it contains any information.

func (*NoiseInfo) WriteTo

func (info *NoiseInfo) WriteTo(values url.Values)

WriteTo assists in serializing a NoiseInfo to a NodeURL.

type NoiseProto

type NoiseProto int

NoiseProto represents different possible Noise handshake and cipher suite selections.

type Nonce

type Nonce [NonceSize]byte

Nonce represents the largest nonce used by any encryption protocol.

func NonceFromBytes

func NonceFromBytes(b []byte) (Nonce, error)

NonceFromBytes converts a byte slice into a nonce.

func NonceFromString

func NonceFromString(s string) (Nonce, error)

NonceFromString decodes an base32 encoded.

func (Nonce) Bytes

func (nonce Nonce) Bytes() []byte

Bytes returns bytes of the nonce.

func (*Nonce) IsZero

func (nonce *Nonce) IsZero() bool

IsZero returns whether nonce is unassigned.

func (Nonce) Marshal

func (nonce Nonce) Marshal() ([]byte, error)

Marshal serializes a nonce.

func (Nonce) MarshalText

func (nonce Nonce) MarshalText() ([]byte, error)

MarshalText serializes a nonce to a base32 string.

func (*Nonce) MarshalTo

func (nonce *Nonce) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a nonce into the passed byte slice.

func (*Nonce) Raw

func (nonce *Nonce) Raw() *[NonceSize]byte

Raw returns the nonce as a raw byte array pointer.

func (*Nonce) Scan

func (nonce *Nonce) Scan(src interface{}) (err error)

Scan extracts a Nonce from a database field.

func (Nonce) Size

func (nonce Nonce) Size() int

Size returns the length of a nonce (implements gogo's custom type interface).

func (Nonce) String

func (nonce Nonce) String() string

String representation of the nonce.

func (*Nonce) Unmarshal

func (nonce *Nonce) Unmarshal(data []byte) error

Unmarshal deserializes a nonce.

func (*Nonce) UnmarshalText

func (nonce *Nonce) UnmarshalText(data []byte) error

UnmarshalText deserializes a base32 string to a nonce.

func (Nonce) Value

func (nonce Nonce) Value() (driver.Value, error)

Value converts a Nonce to a database field.

type Path

type Path = string

Path represents a object path.

func JoinPaths

func JoinPaths(paths ...Path) Path

JoinPaths concatenates paths to a new single path.

type PieceID

type PieceID [32]byte

PieceID is the unique identifier for pieces.

func NewPieceID

func NewPieceID() PieceID

NewPieceID creates a piece ID.

func PieceIDFromBytes

func PieceIDFromBytes(b []byte) (PieceID, error)

PieceIDFromBytes converts a byte slice into a piece ID.

func PieceIDFromString

func PieceIDFromString(s string) (PieceID, error)

PieceIDFromString decodes a hex encoded piece ID string.

func (PieceID) Bytes

func (id PieceID) Bytes() []byte

Bytes returns bytes of the piece ID.

func (*PieceID) DecodeSpanner

func (id *PieceID) DecodeSpanner(val any) (err error)

DecodeSpanner implements spanner.Decoder.

func (PieceID) Derive

func (id PieceID) Derive(storagenodeID NodeID, pieceNum int32) PieceID

Derive a new PieceID from the current piece ID, the given storage node ID and piece number.

func (PieceID) Deriver

func (id PieceID) Deriver() PieceIDDeriver

Deriver creates piece ID dervier for multiple derive operations.

func (PieceID) EncodeSpanner

func (id PieceID) EncodeSpanner() (any, error)

EncodeSpanner implements spanner.Encoder.

func (*PieceID) IsZero

func (id *PieceID) IsZero() bool

IsZero returns whether piece ID is unassigned.

func (PieceID) Marshal

func (id PieceID) Marshal() ([]byte, error)

Marshal serializes a piece ID.

func (PieceID) MarshalText

func (id PieceID) MarshalText() ([]byte, error)

MarshalText serializes a piece ID to a base32 string.

func (*PieceID) MarshalTo

func (id *PieceID) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a piece ID into the passed byte slice.

func (*PieceID) Scan

func (id *PieceID) Scan(src interface{}) (err error)

Scan extracts a PieceID from a database field.

func (*PieceID) Size

func (id *PieceID) Size() int

Size returns the length of a piece ID (implements gogo's custom type interface).

func (PieceID) String

func (id PieceID) String() string

String representation of the piece ID.

func (*PieceID) Unmarshal

func (id *PieceID) Unmarshal(data []byte) error

Unmarshal deserializes a piece ID.

func (*PieceID) UnmarshalText

func (id *PieceID) UnmarshalText(data []byte) error

UnmarshalText deserializes a base32 string to a piece ID.

func (PieceID) Value

func (id PieceID) Value() (driver.Value, error)

Value set a PieceID to a database field.

type PieceIDDeriver

type PieceIDDeriver struct {
	// contains filtered or unexported fields
}

PieceIDDeriver can be used to for multiple derivation from the same PieceID without need to initialize mac for each Derive call.

func (PieceIDDeriver) Derive

func (pd PieceIDDeriver) Derive(storagenodeID NodeID, pieceNum int32) PieceID

Derive a new PieceID from the piece ID, the given storage node ID and piece number. Initial mac is created from piece ID once while creating PieceDeriver and just reset to initial state at the beginning of each call.

type PiecePrivateKey

type PiecePrivateKey struct {
	// contains filtered or unexported fields
}

PiecePrivateKey is the unique identifier for pieces.

func PiecePrivateKeyFromBytes

func PiecePrivateKeyFromBytes(data []byte) (PiecePrivateKey, error)

PiecePrivateKeyFromBytes converts bytes to a piece private key.

func (PiecePrivateKey) Bytes

func (key PiecePrivateKey) Bytes() []byte

Bytes returns bytes of the piece private key.

func (PiecePrivateKey) IsZero

func (key PiecePrivateKey) IsZero() bool

IsZero returns whether the key is empty.

func (PiecePrivateKey) Marshal

func (key PiecePrivateKey) Marshal() ([]byte, error)

Marshal serializes a piece private key.

func (*PiecePrivateKey) MarshalTo

func (key *PiecePrivateKey) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a piece private key into the passed byte slice.

func (*PiecePrivateKey) Scan

func (key *PiecePrivateKey) Scan(src interface{}) (err error)

Scan extracts a PiecePrivateKey from a database field.

func (PiecePrivateKey) Sign

func (key PiecePrivateKey) Sign(data []byte) ([]byte, error)

Sign signs the message with privateKey and returns a signature.

func (*PiecePrivateKey) Size

func (key *PiecePrivateKey) Size() int

Size returns the length of a piece private key (implements gogo's custom type interface).

func (*PiecePrivateKey) Unmarshal

func (key *PiecePrivateKey) Unmarshal(data []byte) error

Unmarshal deserializes a piece private key.

func (PiecePrivateKey) Value

func (key PiecePrivateKey) Value() (driver.Value, error)

Value set a PiecePrivateKey to a database field.

type PiecePublicKey

type PiecePublicKey struct {
	// contains filtered or unexported fields
}

PiecePublicKey is the unique identifier for pieces.

func PiecePublicKeyFromBytes

func PiecePublicKeyFromBytes(data []byte) (PiecePublicKey, error)

PiecePublicKeyFromBytes converts bytes to a piece public key.

func (PiecePublicKey) Bytes

func (key PiecePublicKey) Bytes() []byte

Bytes returns bytes of the piece public key.

func (PiecePublicKey) IsZero

func (key PiecePublicKey) IsZero() bool

IsZero returns whether the key is empty.

func (PiecePublicKey) Marshal

func (key PiecePublicKey) Marshal() ([]byte, error)

Marshal serializes a piece public key.

func (*PiecePublicKey) MarshalText

func (key *PiecePublicKey) MarshalText() ([]byte, error)

MarshalText serializes a piece public key to a base32 string.

func (*PiecePublicKey) MarshalTo

func (key *PiecePublicKey) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a piece public key into the passed byte slice.

func (*PiecePublicKey) Scan

func (key *PiecePublicKey) Scan(src interface{}) (err error)

Scan extracts a PiecePublicKey from a database field.

func (*PiecePublicKey) Size

func (key *PiecePublicKey) Size() int

Size returns the length of a piece public key (implements gogo's custom type interface).

func (*PiecePublicKey) Unmarshal

func (key *PiecePublicKey) Unmarshal(data []byte) error

Unmarshal deserializes a piece public key.

func (*PiecePublicKey) UnmarshalText

func (key *PiecePublicKey) UnmarshalText(data []byte) error

UnmarshalText deserializes a base32 string to a piece public key.

func (PiecePublicKey) Value

func (key PiecePublicKey) Value() (driver.Value, error)

Value set a PiecePublicKey to a database field.

func (PiecePublicKey) Verify

func (key PiecePublicKey) Verify(data, signature []byte) error

Verify reports whether signature is a valid signature of message by publicKey.

type PlacementConstraint

type PlacementConstraint uint16

PlacementConstraint is the ID of the placement/geofencing rule.

const (
	// DefaultPlacement placement is used, when no specific placement rule is defined.
	DefaultPlacement PlacementConstraint = 0

	// EveryCountry includes all countries.
	// Deprecated: use DefaultPlacement, which may exclude some nodes based on placement configuration.
	EveryCountry PlacementConstraint = 0

	// EU includes only the 27 members of European Union.
	// Deprecated: placement definitions depend on the configuration.
	EU PlacementConstraint = 1

	// EEA defines the European Economic Area (EU + 3 countries), the area where GDPR is valid.
	// Deprecated: placement definitions depend on the configuration.
	EEA PlacementConstraint = 2

	// US filters nodes only from the United States.
	// Deprecated: placement definitions depend on the configuration.
	US PlacementConstraint = 3

	// DE placement uses nodes only from Germany.
	// Deprecated: placement definitions depend on the configuration.
	DE PlacementConstraint = 4

	// InvalidPlacement is used when there is no information about the stored placement.
	// Deprecated: placement definitions depend on the configuration.
	InvalidPlacement PlacementConstraint = 5

	// NR placement uses nodes that are not in RU or other countries sanctioned because of the RU/UA War.
	// Deprecated: placement definitions depend on the configuration.
	NR PlacementConstraint = 6
)

func (*PlacementConstraint) Scan

func (p *PlacementConstraint) Scan(value interface{}) error

Scan implements the sql.Scanner interface.

func (PlacementConstraint) Value

func (p PlacementConstraint) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type RedundancyAlgorithm

type RedundancyAlgorithm byte

RedundancyAlgorithm is the algorithm used for redundancy.

type RedundancyScheme

type RedundancyScheme struct {
	// Algorithm determines the algorithm to be used for redundancy.
	Algorithm RedundancyAlgorithm

	// ShareSize is the size in bytes for each erasure shares.
	ShareSize int32

	// RequiredShares is the minimum number of shares required to recover a
	// stripe, reed-solomon k.
	RequiredShares int16
	// RepairShares is the minimum number of safe shares that can remain
	// before a repair is triggered.
	RepairShares int16
	// OptimalShares is the desired total number of shares for a segment.
	OptimalShares int16
	// TotalShares is the number of shares to encode. If it is larger than
	// OptimalShares, slower uploads of the excess shares will be aborted in
	// order to improve performance.
	TotalShares int16
}

RedundancyScheme specifies the parameters and the algorithm for redundancy.

func (RedundancyScheme) IsZero

func (scheme RedundancyScheme) IsZero() bool

IsZero returns true if no field in the struct is set to non-zero value.

func (RedundancyScheme) PieceSize

func (scheme RedundancyScheme) PieceSize(size int64) int64

PieceSize calculates piece size for give size.

func (RedundancyScheme) StripeCount

func (scheme RedundancyScheme) StripeCount(encryptedSegmentSize int32) int32

StripeCount returns segment's total number of stripes based on segment's encrypted size.

func (RedundancyScheme) StripeSize

func (scheme RedundancyScheme) StripeSize() int32

StripeSize is the number of bytes for a stripe. Stripes are erasure encoded and split into n shares, where we need k to reconstruct the stripe. Therefore a stripe size is the erasure share size times the required shares, k.

type RetentionMode

type RetentionMode uint8

RetentionMode represents the retention mode of an object version.

const (
	// NoRetention signifies that a retention period has not been set on an object version.
	NoRetention RetentionMode = 0

	// ComplianceMode signifies that an object version is locked in compliance mode
	// and cannot be deleted or modified until the retention period expires.
	ComplianceMode RetentionMode = 1
)

type SegmentID

type SegmentID []byte

SegmentID is the unique identifier for segment related to object.

func SegmentIDFromBytes

func SegmentIDFromBytes(b []byte) (SegmentID, error)

SegmentIDFromBytes converts a byte slice into a segment ID.

func SegmentIDFromString

func SegmentIDFromString(s string) (SegmentID, error)

SegmentIDFromString decodes an base32 encoded.

func (SegmentID) Bytes

func (id SegmentID) Bytes() []byte

Bytes returns bytes of the segment ID.

func (SegmentID) IsZero

func (id SegmentID) IsZero() bool

IsZero returns whether segment ID is unassigned.

func (SegmentID) Marshal

func (id SegmentID) Marshal() ([]byte, error)

Marshal serializes a segment ID (implements gogo's custom type interface).

func (SegmentID) MarshalText

func (id SegmentID) MarshalText() ([]byte, error)

MarshalText serializes a segment ID to a base32 string.

func (*SegmentID) MarshalTo

func (id *SegmentID) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a segment ID into the passed byte slice (implements gogo's custom type interface).

func (SegmentID) Size

func (id SegmentID) Size() int

Size returns the length of a segment ID (implements gogo's custom type interface).

func (SegmentID) String

func (id SegmentID) String() string

String representation of the segment ID.

func (*SegmentID) Unmarshal

func (id *SegmentID) Unmarshal(data []byte) error

Unmarshal deserializes a segment ID (implements gogo's custom type interface).

func (*SegmentID) UnmarshalText

func (id *SegmentID) UnmarshalText(data []byte) error

UnmarshalText deserializes a base32 string to a segment ID.

type SerialNumber

type SerialNumber [16]byte

SerialNumber is the unique identifier for pieces.

func SerialNumberFromBytes

func SerialNumberFromBytes(b []byte) (SerialNumber, error)

SerialNumberFromBytes converts a byte slice into a serial number.

func SerialNumberFromString

func SerialNumberFromString(s string) (SerialNumber, error)

SerialNumberFromString decodes an base32 encoded.

func (SerialNumber) Bytes

func (id SerialNumber) Bytes() []byte

Bytes returns bytes of the serial number.

func (SerialNumber) IsZero

func (id SerialNumber) IsZero() bool

IsZero returns whether serial number is unassigned.

func (SerialNumber) Less

func (id SerialNumber) Less(other SerialNumber) bool

Less returns whether id is smaller than other in lexicographic order.

func (SerialNumber) Marshal

func (id SerialNumber) Marshal() ([]byte, error)

Marshal serializes a serial number.

func (SerialNumber) MarshalText

func (id SerialNumber) MarshalText() ([]byte, error)

MarshalText serializes a serial number to a base32 string.

func (*SerialNumber) MarshalTo

func (id *SerialNumber) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a serial number into the passed byte slice.

func (*SerialNumber) Scan

func (id *SerialNumber) Scan(src interface{}) (err error)

Scan extracts a SerialNumber from a database field.

func (*SerialNumber) Size

func (id *SerialNumber) Size() int

Size returns the length of a serial number (implements gogo's custom type interface).

func (SerialNumber) String

func (id SerialNumber) String() string

String representation of the serial number.

func (*SerialNumber) Unmarshal

func (id *SerialNumber) Unmarshal(data []byte) error

Unmarshal deserializes a serial number.

func (*SerialNumber) UnmarshalText

func (id *SerialNumber) UnmarshalText(data []byte) error

UnmarshalText deserializes a base32 string to a serial number.

func (SerialNumber) Value

func (id SerialNumber) Value() (driver.Value, error)

Value set a SerialNumber to a database field.

type StreamID

type StreamID []byte

StreamID is the unique identifier for stream related to object.

func StreamIDFromBytes

func StreamIDFromBytes(b []byte) (StreamID, error)

StreamIDFromBytes converts a byte slice into a stream ID.

func StreamIDFromString

func StreamIDFromString(s string) (StreamID, error)

StreamIDFromString decodes an base32 encoded.

func (StreamID) Bytes

func (id StreamID) Bytes() []byte

Bytes returns bytes of the stream ID.

func (*StreamID) DecodeSpanner

func (id *StreamID) DecodeSpanner(val any) (err error)

DecodeSpanner implements spanner.Decoder.

func (StreamID) EncodeSpanner

func (id StreamID) EncodeSpanner() (any, error)

EncodeSpanner implements spanner.Encoder.

func (StreamID) IsZero

func (id StreamID) IsZero() bool

IsZero returns whether stream ID is unassigned.

func (StreamID) Marshal

func (id StreamID) Marshal() ([]byte, error)

Marshal serializes a stream ID.

func (StreamID) MarshalText

func (id StreamID) MarshalText() ([]byte, error)

MarshalText serializes a stream ID to a base32 string.

func (*StreamID) MarshalTo

func (id *StreamID) MarshalTo(data []byte) (n int, err error)

MarshalTo serializes a stream ID into the passed byte slice.

func (*StreamID) Scan

func (id *StreamID) Scan(src interface{}) (err error)

Scan extracts a stream ID from a database field.

func (StreamID) Size

func (id StreamID) Size() int

Size returns the length of a stream ID (implements gogo's custom type interface).

func (StreamID) String

func (id StreamID) String() string

String representation of the stream ID.

func (*StreamID) Unmarshal

func (id *StreamID) Unmarshal(data []byte) error

Unmarshal deserializes a stream ID.

func (*StreamID) UnmarshalText

func (id *StreamID) UnmarshalText(data []byte) error

UnmarshalText deserializes a base32 string to a stream ID.

func (StreamID) Value

func (id StreamID) Value() (driver.Value, error)

Value set a stream ID to a database field.

Directories

Path Synopsis
Package location contains geolocation related constants and variables.
Package location contains geolocation related constants and variables.
gen

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL