Skip to content

Commit

Permalink
cram/io/writer/builder: Rename Builder::build_with_writer to Builder:…
Browse files Browse the repository at this point in the history
…:build_from_writer

Closes #295.
  • Loading branch information
zaeleus committed Aug 27, 2024
1 parent 8b2cd79 commit e601e3d
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 16 deletions.
11 changes: 7 additions & 4 deletions noodles-cram/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@

### Changed

* cram/io/writer/builder: Rename `Builder::build_with_path` to
`Builder::build_from_path` ([#295]).
* cram/io/writer/builder: Rename `Builder::build_with_path` and
`Builder::build_with_writer` to `Builder::build_from_path` and
`Builder::build_from_writer`, respectively ([#295]).

[#295]: https://github.com/zaeleus/noodles/issues/295

### Deprecated

* cram/io/writer/builder: Deprecate `Builder::build_with_path`.
* cram/io/writer/builder: Deprecate `Builder::build_with_path` and
`Builder::build_with_writer`.

Use `Builder::build_from_path` instead.
Use `Builder::build_from_path` and `Builder::build_from_writer`,
respectively, instead.

## 0.67.0 - 2024-08-04

Expand Down
2 changes: 1 addition & 1 deletion noodles-cram/examples/cram_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let repository = fasta::Repository::new(reference_sequences);
let mut writer = cram::io::writer::Builder::default()
.set_reference_sequence_repository(repository)
.build_with_writer(stdout);
.build_from_writer(stdout);

writer.write_header(&header)?;

Expand Down
2 changes: 1 addition & 1 deletion noodles-cram/examples/cram_write_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let repository = fasta::Repository::new(reference_sequences);
let mut writer = cram::r#async::io::writer::Builder::default()
.set_reference_sequence_repository(repository)
.build_with_writer(io::stdout());
.build_from_writer(io::stdout());

writer.write_file_definition().await?;
writer.write_file_header(&header).await?;
Expand Down
2 changes: 1 addition & 1 deletion noodles-cram/src/async/io/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ where
/// let writer = cram::r#async::io::Writer::new(io::sink());
/// ```
pub fn new(inner: W) -> Self {
Builder::default().build_with_writer(inner)
Builder::default().build_from_writer(inner)
}

/// Returns a reference to the underlying writer.
Expand Down
15 changes: 12 additions & 3 deletions noodles-cram/src/async/io/writer/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Builder {
{
File::create(dst)
.await
.map(|file| self.build_with_writer(file))
.map(|file| self.build_from_writer(file))
}

/// Builds an async CRAM writer from a path.
Expand All @@ -92,9 +92,9 @@ impl Builder {
/// ```
/// use noodles_cram as cram;
/// use tokio::io;
/// let writer = cram::r#async::io::writer::Builder::default().build_with_writer(io::sink());
/// let writer = cram::r#async::io::writer::Builder::default().build_from_writer(io::sink());
/// ```
pub fn build_with_writer<W>(mut self, writer: W) -> Writer<W>
pub fn build_from_writer<W>(mut self, writer: W) -> Writer<W>
where
W: AsyncWrite + Unpin,
{
Expand All @@ -112,4 +112,13 @@ impl Builder {
record_counter: 0,
}
}

/// Builds an async CRAM writer from a writer.
#[deprecated(since = "0.68.0", note = "Use `Builder::build_from_writer` instead.")]
pub fn build_with_writer<W>(self, writer: W) -> Writer<W>
where
W: AsyncWrite + Unpin,
{
self.build_from_writer(writer)
}
}
2 changes: 1 addition & 1 deletion noodles-cram/src/io/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ where
/// let writer = cram::io::Writer::new(Vec::new());
/// ```
pub fn new(inner: W) -> Self {
Builder::default().build_with_writer(inner)
Builder::default().build_from_writer(inner)
}

/// Returns a reference to the underlying writer.
Expand Down
15 changes: 12 additions & 3 deletions noodles-cram/src/io/writer/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl Builder {
where
P: AsRef<Path>,
{
File::create(dst).map(|file| self.build_with_writer(file))
File::create(dst).map(|file| self.build_from_writer(file))
}

/// Builds a CRAM writer from a path.
Expand All @@ -122,9 +122,9 @@ impl Builder {
///
/// ```
/// use noodles_cram::io::writer::Builder;
/// let writer = Builder::default().build_with_writer(Vec::new());
/// let writer = Builder::default().build_from_writer(Vec::new());
/// ```
pub fn build_with_writer<W>(mut self, writer: W) -> Writer<W>
pub fn build_from_writer<W>(mut self, writer: W) -> Writer<W>
where
W: Write,
{
Expand All @@ -140,6 +140,15 @@ impl Builder {
record_counter: 0,
}
}

/// Builds a CRAM writer from a writer.
#[deprecated(since = "0.68.0", note = "Use `Builder::build_from_writer` instead.")]
pub fn build_with_writer<W>(self, writer: W) -> Writer<W>
where
W: Write,
{
self.build_from_writer(writer)
}
}

pub fn uses_cram_3_1_codecs(block_content_encoder_map: &BlockContentEncoderMap) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion noodles-util/src/alignment/async/io/writer/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl Builder {
let inner: Box<dyn AsyncWrite + Unpin> = Box::new(writer);
let inner = cram::r#async::io::writer::Builder::default()
.set_reference_sequence_repository(self.reference_sequence_repository)
.build_with_writer(inner);
.build_from_writer(inner);
Writer::Cram(inner)
}
(Format::Cram, Some(CompressionMethod::Bgzf)) => {
Expand Down
2 changes: 1 addition & 1 deletion noodles-util/src/alignment/io/writer/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl Builder {
cram::io::writer::Builder::default()
.set_reference_sequence_repository(self.reference_sequence_repository)
.set_block_content_encoder_map(self.block_content_encoder_map)
.build_with_writer(writer),
.build_from_writer(writer),
),
(Format::Cram, Some(CompressionMethod::Bgzf)) => {
return Err(io::Error::new(
Expand Down

0 comments on commit e601e3d

Please sign in to comment.