diff options
Diffstat (limited to 'odb/source.h')
| -rw-r--r-- | odb/source.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/odb/source.h b/odb/source.h index c959e962f6..6c8bec1912 100644 --- a/odb/source.h +++ b/odb/source.h @@ -53,6 +53,7 @@ enum object_info_flags { struct object_id; struct object_info; struct odb_read_stream; +struct odb_write_stream; /* * A callback function that can be used to iterate through objects. If given, @@ -218,6 +219,18 @@ struct odb_source { struct object_id *oid, struct object_id *compat_oid, unsigned flags); + + /* + * This callback is expected to persist the given object stream into + * the object source. + * + * The resulting object ID shall be written into the out pointer. The + * callback is expected to return 0 on success, a negative error code + * otherwise. + */ + int (*write_object_stream)(struct odb_source *source, + struct odb_write_stream *stream, size_t len, + struct object_id *oid); }; /* @@ -356,4 +369,19 @@ static inline int odb_source_write_object(struct odb_source *source, compat_oid, flags); } +/* + * Write an object into the object database source via a stream. The overall + * length of the object must be known in advance. + * + * Return 0 on success, a negative error code otherwise. Populates the given + * out pointer for the object ID. + */ +static inline int odb_source_write_object_stream(struct odb_source *source, + struct odb_write_stream *stream, + size_t len, + struct object_id *oid) +{ + return source->write_object_stream(source, stream, len, oid); +} + #endif |
