Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 14, 2025

This PR implements the WriteTo trait for gix::Blob<'repo>, enabling blob objects to be used with APIs that require this trait, such as Repository::write_object().

Changes Made

The implementation adds the WriteTo trait to gix::Blob<'repo> in gix/src/object/impls.rs with the following methods:

  • write_to() - writes the blob's data verbatim using write_all
  • kind() - returns gix_object::Kind::Blob
  • size() - returns the length of the blob's data as u64

This follows the same pattern as the existing WriteTo implementations for gix_object::Blob and gix_object::BlobRef.

Example Usage

use gix_object::WriteTo;

// Create a blob
let blob_id = repo.write_blob(b"hello world")?;
let blob = repo.find_object(blob_id)?.into_blob();

// Now you can use the blob with write_object (which requires WriteTo)
let written_id = repo.write_object(blob)?;

// Or use WriteTo methods directly
let mut buffer = Vec::new();
blob.write_to(&mut buffer)?;
assert_eq!(blob.kind(), gix_object::Kind::Blob);
assert_eq!(blob.size(), 11);

Testing

Added comprehensive tests covering:

  • Basic functionality with write_object()
  • All WriteTo trait methods (write_to, kind, size)
  • Edge cases like empty blobs
  • Integration with existing blob functionality

All existing tests continue to pass, ensuring no regressions.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI assigned Copilot and Byron Sep 14, 2025
@Copilot Copilot AI changed the title [WIP] Implement the WriteTo trait for gix::Blob. Implement WriteTo trait for gix::Blob Sep 14, 2025
@Copilot Copilot AI requested a review from Byron September 14, 2025 06:39
Copilot finished work on behalf of Byron September 14, 2025 06:39
Copilot AI and others added 2 commits September 15, 2025 05:20
Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
@Byron Byron force-pushed the copilot/fix-7a3e1d32-c145-43e2-8e87-319b255dbc2f branch from 221625a to 3499050 Compare September 15, 2025 03:20
@Byron Byron marked this pull request as ready for review September 15, 2025 03:20
@Byron Byron enabled auto-merge September 15, 2025 03:20
@Byron Byron merged commit d302fa2 into main Sep 15, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants