|
1 | 1 | package core |
2 | 2 |
|
3 | | -import "errors" |
| 3 | +import ( |
| 4 | + "errors" |
| 5 | + "io" |
| 6 | +) |
4 | 7 |
|
5 | | -//ErrStop is used to stop a ForEach function in an Iter |
6 | | -var ErrStop = errors.New("stop iter") |
| 8 | +var ( |
| 9 | + //ErrStop is used to stop a ForEach function in an Iter |
| 10 | + ErrStop = errors.New("stop iter") |
| 11 | + ErrNotImplemented = errors.New("method not-implemented") |
| 12 | +) |
7 | 13 |
|
8 | 14 | // ObjectStorage generic storage of objects |
9 | 15 | type ObjectStorage interface { |
10 | 16 | // NewObject returns a new Object, the real type of the object can be a |
11 | 17 | // custom implementation or the defaul one, MemoryObject |
12 | 18 | NewObject() Object |
| 19 | + // Writer retuns a writer for writing a packfile to the Storage, this method |
| 20 | + // is optional, if not implemented the ObjectStorage should return a |
| 21 | + // ErrNotImplemented error. |
| 22 | + // |
| 23 | + // If the implementation not implements Writer the objects should be written |
| 24 | + // using the Set method. |
| 25 | + Writer() (io.WriteCloser, error) |
13 | 26 | // Set save an object into the storage, the object shuld be create with |
14 | 27 | // the NewObject, method, and file if the type is not supported. |
15 | 28 | Set(Object) (Hash, error) |
16 | 29 | // Get an object by hash with the given ObjectType. Implementors should |
17 | 30 | // return (nil, ErrObjectNotFound) if an object doesn't exist with both the |
18 | 31 | // given hash and object type. |
19 | 32 | // |
20 | | - // Valid ObjectType values are CommitObject, BlobObject, TagObject, TreeObject |
21 | | - // and AnyObject. |
| 33 | + // Valid ObjectType values are CommitObject, BlobObject, TagObject, |
| 34 | + // TreeObject and AnyObject. |
22 | 35 | // |
23 | 36 | // If AnyObject is given, the object must be looked up regardless of its type. |
24 | 37 | Get(ObjectType, Hash) (Object, error) |
25 | 38 | // Iter returns a custom ObjectIter over all the object on the storage. |
26 | 39 | // |
27 | | - // Valid ObjectType values are CommitObject, BlobObject, TagObject, TreeObject |
28 | | - // and AnyObject. |
| 40 | + // Valid ObjectType values are CommitObject, BlobObject, TagObject, |
29 | 41 | Iter(ObjectType) (ObjectIter, error) |
30 | 42 | // Begin starts a transaction. |
31 | 43 | Begin() TxObjectStorage |
|
0 commit comments