syntax = "proto3";

package git.v1;

import "common.proto";

// Mirrors: cmd/blob/blob_load.rs — BlobLoadParams
message BlobLoadParams {
  ObjectId id = 1;
  string path = 2;
}

// Mirrors: cmd/blob/blob_load.rs — BlobLoadResult
message BlobLoadResult {
  BlobLoadParams params = 1;
  bytes blob = 2;
}

// Mirrors: cmd/blob/blob_size.rs — BlobSizeParams
message BlobSizeParams {
  ObjectId id = 1;
  string path = 2;
}

// Mirrors: cmd/blob/blob_upload.rs — BlobUploadParams
message BlobUploadParams {
  bytes blob = 1;
  string path = 2;
}

// Mirrors: cmd/blob/blob_upload.rs — BlobUploadResult
message BlobUploadResult {
  ObjectId id = 1;
}

// Mirrors: cmd/blob/blob_chunk.rs — BlobChunkParam
message BlobChunkParam {
  string path = 1;
  ObjectId oid = 2;
  uint64 size = 3;
  uint64 offset = 4;
}

// Mirrors: cmd/blob/blob_chunk.rs — BlobChunk
message BlobChunk {
  BlobChunkParam param = 1;
  bytes chunk = 2;
}

message BlobLoadRequest {
  string repo_id = 1;
  ObjectId id = 2;
  string path = 3;
}

message BlobLoadResponse {
  bytes blob = 1;
}

message BlobSizeRequest {
  string repo_id = 1;
  ObjectId id = 2;
  string path = 3;
}

message BlobSizeResponse {
  uint64 size = 1;
}

message BlobExistsRequest {
  string repo_id = 1;
  ObjectId id = 2;
}

message BlobExistsResponse {
  bool exists = 1;
}

message BlobIsBinaryRequest {
  string repo_id = 1;
  ObjectId id = 2;
}

message BlobIsBinaryResponse {
  bool is_binary = 1;
}

message BlobUploadRequest {
  string repo_id = 1;
  bytes blob = 2;
  string path = 3;
}

message BlobUploadResponse {
  ObjectId id = 1;
}

message BlobChunkRequest {
  string repo_id = 1;
  string path = 2;
  ObjectId oid = 3;
  uint64 size = 4;
  uint64 offset = 5;
}

service BlobService {
  rpc BlobLoad(BlobLoadRequest) returns (BlobLoadResponse);
  rpc BlobSize(BlobSizeRequest) returns (BlobSizeResponse);
  rpc BlobExists(BlobExistsRequest) returns (BlobExistsResponse);
  rpc BlobIsBinary(BlobIsBinaryRequest) returns (BlobIsBinaryResponse);
  rpc BlobUpload(BlobUploadRequest) returns (BlobUploadResponse);
  rpc BlobChunkStream(BlobChunkRequest) returns (stream BlobChunk);
}