summaryrefslogtreecommitdiff
path: root/include/git2/odb_backend.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/git2/odb_backend.h')
-rw-r--r--include/git2/odb_backend.h40
1 files changed, 32 insertions, 8 deletions
diff --git a/include/git2/odb_backend.h b/include/git2/odb_backend.h
index 0e817eb37..3875ec7f6 100644
--- a/include/git2/odb_backend.h
+++ b/include/git2/odb_backend.h
@@ -39,24 +39,32 @@
*/
GIT_BEGIN_DECL
+struct git_odb_stream;
+
/** An instance for a custom backend */
struct git_odb_backend {
git_odb *odb;
int (* read)(
- git_rawobj *,
+ void **, size_t *, git_otype *,
struct git_odb_backend *,
const git_oid *);
int (* read_header)(
- git_rawobj *,
+ size_t *, git_otype *,
struct git_odb_backend *,
const git_oid *);
- int (* write)(
- git_oid *id,
+ int (* writestream)(
+ struct git_odb_stream **,
+ struct git_odb_backend *,
+ size_t,
+ git_otype);
+
+ int (* readstream)(
+ struct git_odb_stream **,
struct git_odb_backend *,
- git_rawobj *obj);
+ const git_oid *);
int (* exists)(
struct git_odb_backend *,
@@ -65,12 +73,28 @@ struct git_odb_backend {
void (* free)(struct git_odb_backend *);
};
+/** A stream to read/write from a backend */
+struct git_odb_stream {
+ struct git_odb_backend *backend;
+ int mode;
+
+ int (*read)(struct git_odb_stream *stream, char *buffer, size_t len);
+ int (*write)(struct git_odb_stream *stream, const char *buffer, size_t len);
+ int (*finalize_write)(git_oid *oid_p, struct git_odb_stream *stream);
+ void (*free)(struct git_odb_stream *stream);
+};
+
+/** Streaming mode */
+typedef enum {
+ GIT_STREAM_RDONLY = (1 << 1),
+ GIT_STREAM_WRONLY = (1 << 2),
+ GIT_STREAM_RW = (GIT_STREAM_RDONLY | GIT_STREAM_WRONLY),
+} git_odb_streammode;
+
+
GIT_EXTERN(int) git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir);
GIT_EXTERN(int) git_odb_backend_loose(git_odb_backend **backend_out, const char *objects_dir);
-
-#ifdef GIT2_SQLITE_BACKEND
GIT_EXTERN(int) git_odb_backend_sqlite(git_odb_backend **backend_out, const char *sqlite_db);
-#endif
GIT_END_DECL