1// Copyright (C) 2019 Storj Labs, Inc. 2// See LICENSE for copying information. 3 4package storj 5 6import ( 7 "time" 8 9 "github.com/zeebo/errs" 10) 11 12var ( 13 // ErrNoPath is an error class for using empty path. 14 ErrNoPath = errs.Class("no path specified") 15 16 // ErrObjectNotFound is an error class for non-existing object. 17 ErrObjectNotFound = errs.Class("object not found") 18) 19 20// Object contains information about a specific object. 21type Object struct { 22 Version uint32 23 Bucket Bucket 24 Path Path 25 IsPrefix bool 26 27 Metadata map[string]string 28 29 ContentType string 30 Created time.Time 31 Modified time.Time 32 Expires time.Time 33 34 Stream 35} 36 37// ObjectInfo contains information about a specific object. 38type ObjectInfo struct { 39 Version uint32 40 Bucket string 41 Path Path 42 IsPrefix bool 43 44 StreamID StreamID 45 46 Metadata []byte 47 48 ContentType string 49 Created time.Time 50 Modified time.Time 51 Expires time.Time 52 53 Stream 54} 55 56// Stream is information about an object stream. 57type Stream struct { 58 ID StreamID 59 60 // Size is the total size of the stream in bytes 61 Size int64 62 // Checksum is the checksum of the segment checksums 63 Checksum []byte 64 65 // SegmentCount is the number of segments 66 SegmentCount int64 67 // FixedSegmentSize is the size of each segment, 68 // when all segments have the same size. It is -1 otherwise. 69 FixedSegmentSize int64 70 71 // RedundancyScheme specifies redundancy strategy used for this stream 72 RedundancyScheme 73 // EncryptionParameters specifies encryption strategy used for this stream 74 EncryptionParameters 75 76 LastSegment LastSegment // TODO: remove 77} 78 79// LastSegment contains info about last segment. 80// 81// TODO: remove. 82type LastSegment struct { 83 Size int64 84 EncryptedKeyNonce Nonce 85 EncryptedKey EncryptedPrivateKey 86} 87 88// Segment is full segment information. 89type Segment struct { 90 Index int64 91 // Size is the size of the content in bytes 92 Size int64 93 // Checksum is the checksum of the content 94 Checksum []byte 95 // Local data 96 Inline []byte 97 // Remote data 98 PieceID PieceID 99 Pieces []Piece 100 // Encryption 101 EncryptedKeyNonce Nonce 102 EncryptedKey EncryptedPrivateKey 103} 104 105// Piece is information where a piece is located. 106type Piece struct { 107 Number byte 108 Location NodeID 109} 110