Skip to content

Commit e42db6c

Browse files
Rename Encoder::encoding to Encoder::options (image-rs#100)
1 parent 661fd5f commit e42db6c

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

benches/encode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ where
102102

103103
let mut encoder =
104104
Encoder::new_image(black_box(&mut output), image.size, format, false).unwrap();
105-
encoder.encoding = black_box(options).clone();
105+
encoder.options = black_box(options).clone();
106106
let result = encoder.write_surface(black_box(image.view()));
107107
black_box(result).unwrap();
108108
black_box(encoder.finish()).unwrap();

src/encode/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ fn encode_parallel(
227227
/// ## See also
228228
///
229229
/// - [`encode`]
230-
/// - [`Encoder::encoding`](crate::Encoder::encoding)
230+
/// - [`Encoder::options`](crate::Encoder::options)
231231
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
232232
#[non_exhaustive]
233233
pub struct EncodeOptions {

src/encoder.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ pub struct Encoder<W> {
2121

2222
/// The encoding options used to encode surfaces.
2323
///
24-
/// Default: `EncodeOptions::default()`
25-
pub encoding: EncodeOptions,
24+
/// Default: [`EncodeOptions::default()`]
25+
pub options: EncodeOptions,
2626
/// Options regarding automatic mipmap generation.
2727
///
2828
/// Set `self.mipmaps.generate = false` to disable automatic mipmap
2929
/// generation.
3030
///
31-
/// Default: `MipmapOptions::default()`
31+
/// Default: [`MipmapOptions::default()`]
3232
pub mipmaps: MipmapOptions,
3333

3434
// internal cache for resizing
@@ -62,7 +62,7 @@ impl<W> Encoder<W> {
6262
format,
6363
layout,
6464
iter: SurfaceIterator::new(layout),
65-
encoding: EncodeOptions::default(),
65+
options: EncodeOptions::default(),
6666
mipmaps: MipmapOptions::default(),
6767
mipmap_cache: MipmapCache::new(),
6868
})
@@ -195,7 +195,7 @@ impl<W> Encoder<W> {
195195
image,
196196
self.format,
197197
Some(&mut progress.sub_range(get_level_progress_range(0))),
198-
&self.encoding,
198+
&self.options,
199199
)?;
200200
self.iter.advance();
201201

@@ -222,7 +222,7 @@ impl<W> Encoder<W> {
222222
mipmap,
223223
self.format,
224224
Some(&mut progress.sub_range(get_level_progress_range(level))),
225-
&self.encoding,
225+
&self.options,
226226
)
227227
})?;
228228
}

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
//! let size = Size::new(width, height);
8484
//! let mut encoder = Encoder::new_image(file, size, Format::BC7_UNORM, mipmaps)?;
8585
//! // lower quality for faster encoding
86-
//! encoder.encoding.quality = CompressionQuality::Fast;
86+
//! encoder.options.quality = CompressionQuality::Fast;
8787
//!
8888
//! let view = ImageView::new(image_data, size, ColorFormat::RGBA_U8)
8989
//! .expect("invalid image data");
@@ -97,7 +97,7 @@
9797
//! are generated can be configured using [`Encoder::mipmaps`].
9898
//!
9999
//! Most formats also support encoding options to change the encoded image data
100-
//! in some way. These can be set using the [`Encoder::encoding`] field. E.g.
100+
//! in some way. These can be set using the [`Encoder::options`] field. E.g.
101101
//! most formats support [dithering](EncodeOptions::dithering) and compressed
102102
//! formats support different [quality levels](EncodeOptions::quality) among
103103
//! others.

tests/encode.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn encode_decode(
6060
// encode
6161
let mut encoded = Vec::new();
6262
let mut encoder = Encoder::new_image(&mut encoded, image.size, format, false).unwrap();
63-
encoder.encoding = options.clone();
63+
encoder.options = options.clone();
6464
encoder.write_surface(image.view()).unwrap();
6565
encoder.finish().unwrap();
6666

@@ -117,8 +117,8 @@ fn encode_base() {
117117

118118
let mut output = Vec::new();
119119
let mut encoder = Encoder::new_image(&mut output, size, format, false)?;
120-
encoder.encoding.quality = CompressionQuality::High;
121-
encoder.encoding.parallel = false;
120+
encoder.options.quality = CompressionQuality::High;
121+
encoder.options.parallel = false;
122122

123123
// and now the image data
124124
if format.precision() == Precision::U16 {
@@ -161,8 +161,8 @@ fn encode_dither() {
161161
) -> Result<String, Box<dyn std::error::Error>> {
162162
let mut output = Vec::new();
163163
let mut encoder = Encoder::new_image(&mut output, image.size, format, false)?;
164-
encoder.encoding.quality = CompressionQuality::High;
165-
encoder.encoding.dithering = Dithering::ColorAndAlpha;
164+
encoder.options.quality = CompressionQuality::High;
165+
encoder.options.dithering = Dithering::ColorAndAlpha;
166166
encoder.write_surface(image.view())?;
167167
encoder.finish()?;
168168

tests/progress.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn track_progress() {
8181
format,
8282
mipmaps && format.encoding_support().unwrap().size_multiple().is_none(),
8383
)?;
84-
encoder.encoding = options.clone();
84+
encoder.options = options.clone();
8585

8686
encoder.write_surface_with_progress(image, &mut progress)?;
8787
encoder.finish()?;
@@ -199,7 +199,7 @@ fn forward_progress() {
199199
format,
200200
format.encoding_support().unwrap().size_multiple().is_none(),
201201
)?;
202-
encoder.encoding = options.clone();
202+
encoder.options = options.clone();
203203

204204
encoder.write_surface_with_progress(image, &mut progress)?;
205205
encoder.finish()?;

0 commit comments

Comments
 (0)