diff options
| author | Vicent Martà <vicent@github.com> | 2013-08-19 02:17:00 -0700 |
|---|---|---|
| committer | Vicent Martà <vicent@github.com> | 2013-08-19 02:17:00 -0700 |
| commit | 520287f63a86c5d284ff4d23a2d5d61decbb8685 (patch) | |
| tree | 4a0111fcf75db57c0ad15f4c4c152e4a2b6d5cff /include/git2/odb_backend.h | |
| parent | 1c1b4e8a15b059ae8feb61342de0408755d849ec (diff) | |
| parent | 090a07d29548ce69034b4be6ba043014226893c9 (diff) | |
| download | libgit2-520287f63a86c5d284ff4d23a2d5d61decbb8685.tar.gz | |
Merge pull request #1785 from libgit2/cmn/odb-hash-frontend
odb: move hashing to the frontend for streaming
Diffstat (limited to 'include/git2/odb_backend.h')
| -rw-r--r-- | include/git2/odb_backend.h | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h index af1e3e5b9..dca499583 100644 --- a/include/git2/odb_backend.h +++ b/include/git2/odb_backend.h @@ -65,14 +65,41 @@ typedef enum { GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY), } git_odb_stream_t; -/** A stream to read/write from a backend */ +typedef struct git_hash_ctx git_hash_ctx; + +/** + * A stream to read/write from a backend. + * + * This represents a stream of data being written to or read from a + * backend. When writing, the frontend functions take care of + * calculating the object's id and all `finalize_write` needs to do is + * store the object with the id it is passed. + */ struct git_odb_stream { git_odb_backend *backend; unsigned int mode; + git_hash_ctx *hash_ctx; + /** + * Write at most `len` bytes into `buffer` and advance the + * stream. + */ int (*read)(git_odb_stream *stream, char *buffer, size_t len); + + /** + * Write `len` bytes from `buffer` into the stream. + */ int (*write)(git_odb_stream *stream, const char *buffer, size_t len); - int (*finalize_write)(git_oid *oid_p, git_odb_stream *stream); + + /** + * Store the contents of the stream as an object with the id + * specified in `oid`. + */ + int (*finalize_write)(git_odb_stream *stream, const git_oid *oid); + + /** + * Free the stream's memory. + */ void (*free)(git_odb_stream *stream); }; |
