Skip to content

Commit 1ae9475

Browse files
committed
Rework features for next version
1 parent 644a6d8 commit 1ae9475

File tree

9 files changed

+126
-123
lines changed

9 files changed

+126
-123
lines changed

.github/workflows/test.yml

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,32 @@ jobs:
1111
rust: [stable]
1212
webp: [0.4.4, 0.5.2, 1.0.3, 1.1.0, 1.2.0, 1.4.0, 1.5.0]
1313
webp_from: ["build"]
14-
common_features: [""]
14+
common_features: ["std,"]
1515
include:
1616
- rust: stable
1717
webp: 1.3.2
1818
webp_from: distr
19-
common_features: ""
19+
common_features: std,
2020
- rust: stable
2121
webp: 1.5.0
2222
webp_from: bundled
23-
common_features: ""
23+
common_features: std,
2424
- rust: 1.85.0
2525
webp: 1.5.0
2626
webp_from: build
27-
common_features: ""
27+
common_features: std,
2828
- rust: beta
2929
webp: 1.5.0
3030
webp_from: build
31-
common_features: ""
31+
common_features: std,
3232
- rust: nightly
3333
webp: 1.5.0
3434
webp_from: build
35-
common_features: ""
35+
common_features: std,
3636
- rust: nightly
3737
webp: 1.5.0
3838
webp_from: build
39-
common_features: extern-types,
39+
common_features: std,extern-types,
4040

4141
steps:
4242
- uses: actions/checkout@v4
@@ -70,62 +70,62 @@ jobs:
7070
if: matrix.rust == '1.85.0'
7171
- name: Test 0.4
7272
run: |
73-
cargo test --all --features "${{ matrix.common_features }}"
74-
cargo test --all --features "${{ matrix.common_features }}demux"
75-
cargo test --all --features "${{ matrix.common_features }}mux"
76-
cargo test --all --features "${{ matrix.common_features }}demux,mux"
73+
cargo test --all --no-default-features --features "${{ matrix.common_features }}"
74+
cargo test --all --no-default-features --features "${{ matrix.common_features }}demux"
75+
cargo test --all --no-default-features --features "${{ matrix.common_features }}mux"
76+
cargo test --all --no-default-features --features "${{ matrix.common_features }}demux,mux"
7777
- name: Test 0.5
7878
run: |
79-
cargo test --all --features "${{ matrix.common_features }}0_5"
80-
cargo test --all --features "${{ matrix.common_features }}0_5,demux"
81-
cargo test --all --features "${{ matrix.common_features }}0_5,mux"
82-
cargo test --all --features "${{ matrix.common_features }}0_5,demux,mux"
79+
cargo test --all --no-default-features --features "${{ matrix.common_features }}0_5"
80+
cargo test --all --no-default-features --features "${{ matrix.common_features }}0_5,demux"
81+
cargo test --all --no-default-features --features "${{ matrix.common_features }}0_5,mux"
82+
cargo test --all --no-default-features --features "${{ matrix.common_features }}0_5,demux,mux"
8383
if: matrix.webp >= '0.5'
8484
- name: Test 0.6
8585
run: |
86-
cargo test --all --features "${{ matrix.common_features }}0_6"
87-
cargo test --all --features "${{ matrix.common_features }}0_6,demux"
88-
cargo test --all --features "${{ matrix.common_features }}0_6,mux"
89-
cargo test --all --features "${{ matrix.common_features }}0_6,demux,mux"
86+
cargo test --all --no-default-features --features "${{ matrix.common_features }}0_6"
87+
cargo test --all --no-default-features --features "${{ matrix.common_features }}0_6,demux"
88+
cargo test --all --no-default-features --features "${{ matrix.common_features }}0_6,mux"
89+
cargo test --all --no-default-features --features "${{ matrix.common_features }}0_6,demux,mux"
9090
if: matrix.webp >= '0.6'
9191
- name: Test 1.1
9292
run: |
93-
cargo test --all --features "${{ matrix.common_features }}1_1"
94-
cargo test --all --features "${{ matrix.common_features }}1_1,demux"
95-
cargo test --all --features "${{ matrix.common_features }}1_1,mux"
96-
cargo test --all --features "${{ matrix.common_features }}1_1,demux,mux"
93+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_1"
94+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_1,demux"
95+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_1,mux"
96+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_1,demux,mux"
9797
if: matrix.webp >= '1.1'
9898
- name: Test 1.2
9999
run: |
100-
cargo test --all --features "${{ matrix.common_features }}1_2"
101-
cargo test --all --features "${{ matrix.common_features }}1_2,demux"
102-
cargo test --all --features "${{ matrix.common_features }}1_2,mux"
103-
cargo test --all --features "${{ matrix.common_features }}1_2,demux,mux"
100+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_2"
101+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_2,demux"
102+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_2,mux"
103+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_2,demux,mux"
104104
if: matrix.webp >= '1.2'
105105
- name: Test 1.4
106106
run: |
107-
cargo test --all --features "${{ matrix.common_features }}1_4"
108-
cargo test --all --features "${{ matrix.common_features }}1_4,demux"
109-
cargo test --all --features "${{ matrix.common_features }}1_4,mux"
110-
cargo test --all --features "${{ matrix.common_features }}1_4,demux,mux"
107+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_4"
108+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_4,demux"
109+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_4,mux"
110+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_4,demux,mux"
111111
if: matrix.webp >= '1.4'
112112
- name: Test 1.5
113113
run: |
114-
cargo test --all --features "${{ matrix.common_features }}1_5"
115-
cargo test --all --features "${{ matrix.common_features }}1_5,demux"
116-
cargo test --all --features "${{ matrix.common_features }}1_5,mux"
117-
cargo test --all --features "${{ matrix.common_features }}1_5,demux,mux"
114+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_5"
115+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_5,demux"
116+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_5,mux"
117+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_5,demux,mux"
118118
if: matrix.webp >= '1.5'
119119
- name: Test static builds
120120
run: |
121-
cargo test --all --features "${{ matrix.common_features }}1_5,static"
122-
cargo test --all --features "${{ matrix.common_features }}1_5,static,demux"
123-
cargo test --all --features "${{ matrix.common_features }}1_5,static,mux"
124-
cargo test --all --features "${{ matrix.common_features }}1_5,static,demux,mux"
121+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_5,static"
122+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_5,static,demux"
123+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_5,static,mux"
124+
cargo test --all --no-default-features --features "${{ matrix.common_features }}1_5,static,demux,mux"
125125
if: matrix.webp_from == 'bundled'
126126
- name: Test __doc_cfg
127127
run: |
128-
cargo doc --all --features "${{ matrix.common_features }}__doc_cfg"
128+
cargo doc --all --no-default-features --features "${{ matrix.common_features }}__doc_cfg"
129129
if: matrix.rust == 'nightly'
130130
- name: Check format
131131
run: |

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ cfg-if = "1.0.0"
2929
libc = "0.2.169"
3030

3131
[features]
32-
default = []
32+
default = ["std", "1_2"]
33+
std = []
3334
demux = []
3435
mux = []
3536
"0_5" = []
@@ -40,11 +41,10 @@ mux = []
4041
"1_5" = ["1_4"]
4142
static = []
4243
extern-types = []
43-
must-use = []
4444
__doc_cfg = ["1_5", "demux", "mux"]
4545

4646
[package.metadata.docs.rs]
47-
features = ["1_5", "demux", "mux", "__doc_cfg", "extern-types", "must-use"]
47+
features = ["1_5", "demux", "mux", "__doc_cfg", "extern-types"]
4848

4949
[build-dependencies]
5050
pkg-config = "0.3.31"

src/decode.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl std::fmt::Debug for __WebPDecBufferUnion {
171171

172172
/// Enumeration of the status codes
173173
#[allow(non_camel_case_types)]
174-
// #[cfg_attr(feature = "must-use", must_use)] // meaningless for type aliases
174+
// #[must_use] // meaningless for type aliases
175175
pub type VP8StatusCode = u32;
176176

177177
pub const VP8_STATUS_OK: VP8StatusCode = 0;
@@ -325,7 +325,7 @@ unsafe extern "C" {
325325
/// RIFF + VP8X + (optional chunks) + VP8(L)
326326
/// ALPH + VP8 <-- Not a valid WebP format: only allowed for internal purpose.
327327
/// VP8(L) <-- Not a valid WebP format: only allowed for internal purpose.
328-
#[cfg_attr(feature = "must-use", must_use)]
328+
#[must_use]
329329
pub fn WebPGetInfo(
330330
data: *const u8,
331331
data_size: usize,
@@ -337,23 +337,23 @@ unsafe extern "C" {
337337
/// memory is R, G, B, A, R, G, B, A... in scan order (endian-independent).
338338
/// The returned pointer should be deleted calling WebPFree().
339339
/// Returns NULL in case of error.
340-
#[cfg_attr(feature = "must-use", must_use)]
340+
#[must_use]
341341
pub fn WebPDecodeRGBA(
342342
data: *const u8,
343343
data_size: usize,
344344
width: *mut c_int,
345345
height: *mut c_int,
346346
) -> *mut u8;
347347
/// Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data.
348-
#[cfg_attr(feature = "must-use", must_use)]
348+
#[must_use]
349349
pub fn WebPDecodeARGB(
350350
data: *const u8,
351351
data_size: usize,
352352
width: *mut c_int,
353353
height: *mut c_int,
354354
) -> *mut u8;
355355
/// Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data.
356-
#[cfg_attr(feature = "must-use", must_use)]
356+
#[must_use]
357357
pub fn WebPDecodeBGRA(
358358
data: *const u8,
359359
data_size: usize,
@@ -362,15 +362,15 @@ unsafe extern "C" {
362362
) -> *mut u8;
363363
/// Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data.
364364
/// If the bitstream contains transparency, it is ignored.
365-
#[cfg_attr(feature = "must-use", must_use)]
365+
#[must_use]
366366
pub fn WebPDecodeRGB(
367367
data: *const u8,
368368
data_size: usize,
369369
width: *mut c_int,
370370
height: *mut c_int,
371371
) -> *mut u8;
372372
/// Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data.
373-
#[cfg_attr(feature = "must-use", must_use)]
373+
#[must_use]
374374
pub fn WebPDecodeBGR(
375375
data: *const u8,
376376
data_size: usize,
@@ -387,7 +387,7 @@ unsafe extern "C" {
387387
/// 'width' and 'height' may be NULL, the other pointers must not be.
388388
/// Returns NULL in case of error.
389389
/// (*) Also named Y'CbCr. See: <https://en.wikipedia.org/wiki/YCbCr>
390-
#[cfg_attr(feature = "must-use", must_use)]
390+
#[must_use]
391391
pub fn WebPDecodeYUV(
392392
data: *const u8,
393393
data_size: usize,
@@ -406,23 +406,23 @@ unsafe extern "C" {
406406
// The parameter 'output_stride' specifies the distance (in bytes)
407407
// between scanlines. Hence, output_buffer_size is expected to be at least
408408
// output_stride x picture-height.
409-
#[cfg_attr(feature = "must-use", must_use)]
409+
#[must_use]
410410
pub fn WebPDecodeRGBAInto(
411411
data: *const u8,
412412
data_size: usize,
413413
output_buffer: *mut u8,
414414
output_buffer_size: usize,
415415
output_stride: c_int,
416416
) -> *mut u8;
417-
#[cfg_attr(feature = "must-use", must_use)]
417+
#[must_use]
418418
pub fn WebPDecodeARGBInto(
419419
data: *const u8,
420420
data_size: usize,
421421
output_buffer: *mut u8,
422422
output_buffer_size: usize,
423423
output_stride: c_int,
424424
) -> *mut u8;
425-
#[cfg_attr(feature = "must-use", must_use)]
425+
#[must_use]
426426
pub fn WebPDecodeBGRAInto(
427427
data: *const u8,
428428
data_size: usize,
@@ -432,15 +432,15 @@ unsafe extern "C" {
432432
) -> *mut u8;
433433
// RGB and BGR variants. Here too the transparency information, if present,
434434
// will be dropped and ignored.
435-
#[cfg_attr(feature = "must-use", must_use)]
435+
#[must_use]
436436
pub fn WebPDecodeRGBInto(
437437
data: *const u8,
438438
data_size: usize,
439439
output_buffer: *mut u8,
440440
output_buffer_size: usize,
441441
output_stride: c_int,
442442
) -> *mut u8;
443-
#[cfg_attr(feature = "must-use", must_use)]
443+
#[must_use]
444444
pub fn WebPDecodeBGRInto(
445445
data: *const u8,
446446
data_size: usize,
@@ -455,7 +455,7 @@ unsafe extern "C" {
455455
/// 'u_size' and 'v_size' respectively.
456456
/// Pointer to the luma plane ('*luma') is returned or NULL if an error occurred
457457
/// during decoding (or because some buffers were found to be too small).
458-
#[cfg_attr(feature = "must-use", must_use)]
458+
#[must_use]
459459
pub fn WebPDecodeYUVInto(
460460
data: *const u8,
461461
data_size: usize,
@@ -471,7 +471,7 @@ unsafe extern "C" {
471471
) -> *mut u8;
472472
/// Internal, version-checked, entry point
473473
#[doc(hidden)]
474-
#[cfg_attr(feature = "must-use", must_use)]
474+
#[must_use]
475475
pub fn WebPInitDecBufferInternal(_: *mut WebPDecBuffer, _: c_int) -> c_int;
476476
/// Free any memory associated with the buffer. Must always be called last.
477477
/// Note: doesn't free the 'buffer' structure itself.
@@ -488,7 +488,7 @@ unsafe extern "C" {
488488
/// within valid bounds.
489489
/// All other fields of WebPDecBuffer MUST remain constant between calls.
490490
/// Returns NULL if the allocation failed.
491-
#[cfg_attr(feature = "must-use", must_use)]
491+
#[must_use]
492492
pub fn WebPINewDecoder(output_buffer: *mut WebPDecBuffer) -> *mut WebPIDecoder;
493493
/// This function allocates and initializes an incremental-decoder object, which
494494
/// will output the RGB/A samples specified by 'csp' into a preallocated
@@ -500,7 +500,7 @@ unsafe extern "C" {
500500
/// colorspace 'csp' is taken into account for allocating this buffer. All other
501501
/// parameters are ignored.
502502
/// Returns NULL if the allocation failed, or if some parameters are invalid.
503-
#[cfg_attr(feature = "must-use", must_use)]
503+
#[must_use]
504504
pub fn WebPINewRGB(
505505
csp: WEBP_CSP_MODE,
506506
output_buffer: *mut u8,
@@ -518,7 +518,7 @@ unsafe extern "C" {
518518
/// In this case, the output buffer will be automatically allocated (using
519519
/// MODE_YUVA) when decoding starts. All parameters are then ignored.
520520
/// Returns NULL if the allocation failed or if a parameter is invalid.
521-
#[cfg_attr(feature = "must-use", must_use)]
521+
#[must_use]
522522
pub fn WebPINewYUVA(
523523
luma: *mut u8,
524524
luma_size: usize,
@@ -535,7 +535,7 @@ unsafe extern "C" {
535535
) -> *mut WebPIDecoder;
536536
/// Deprecated version of the above, without the alpha plane.
537537
/// Kept for backward compatibility.
538-
#[cfg_attr(feature = "must-use", must_use)]
538+
#[must_use]
539539
pub fn WebPINewYUV(
540540
luma: *mut u8,
541541
luma_size: usize,
@@ -569,7 +569,7 @@ unsafe extern "C" {
569569
/// (*last_y, *width etc.) can be NULL if corresponding information is not
570570
/// needed. The values in these pointers are only valid on successful (non-NULL)
571571
/// return.
572-
#[cfg_attr(feature = "must-use", must_use)]
572+
#[must_use]
573573
pub fn WebPIDecGetRGB(
574574
idec: *const WebPIDecoder,
575575
last_y: *mut c_int,
@@ -580,7 +580,7 @@ unsafe extern "C" {
580580
/// Same as above function to get a YUVA image. Returns pointer to the luma
581581
/// plane or NULL in case of error. If there is no alpha information
582582
/// the alpha pointer '*a' will be returned NULL.
583-
#[cfg_attr(feature = "must-use", must_use)]
583+
#[must_use]
584584
pub fn WebPIDecGetYUVA(
585585
idec: *const WebPIDecoder,
586586
last_y: *mut c_int,
@@ -599,7 +599,7 @@ unsafe extern "C" {
599599
/// Returns NULL in case the incremental decoder object is in an invalid state.
600600
/// Otherwise returns the pointer to the internal representation. This structure
601601
/// is read-only, tied to WebPIDecoder's lifespan and should not be modified.
602-
#[cfg_attr(feature = "must-use", must_use)]
602+
#[must_use]
603603
pub fn WebPIDecodedArea(
604604
idec: *const WebPIDecoder,
605605
left: *mut c_int,
@@ -617,7 +617,7 @@ unsafe extern "C" {
617617
) -> VP8StatusCode;
618618
/// Internal, version-checked, entry point
619619
#[doc(hidden)]
620-
#[cfg_attr(feature = "must-use", must_use)]
620+
#[must_use]
621621
pub fn WebPInitDecoderConfigInternal(_: *mut WebPDecoderConfig, _: c_int) -> c_int;
622622
/// Instantiate a new incremental decoder object with the requested
623623
/// configuration. The bitstream can be passed using 'data' and 'data_size'
@@ -630,7 +630,7 @@ unsafe extern "C" {
630630
/// The return WebPIDecoder object must always be deleted calling WebPIDelete().
631631
/// Returns NULL in case of error (and config->status will then reflect
632632
/// the error condition, if available).
633-
#[cfg_attr(feature = "must-use", must_use)]
633+
#[must_use]
634634
pub fn WebPIDecode(
635635
data: *const u8,
636636
data_size: usize,
@@ -649,7 +649,7 @@ unsafe extern "C" {
649649
/// Initialize the structure as empty. Must be called before any other use.
650650
/// Returns false in case of version mismatch
651651
#[allow(non_snake_case)]
652-
#[cfg_attr(feature = "must-use", must_use)]
652+
#[must_use]
653653
#[inline]
654654
pub unsafe extern "C" fn WebPInitDecBuffer(buffer: *mut WebPDecBuffer) -> c_int {
655655
unsafe { WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION) }
@@ -680,7 +680,7 @@ pub unsafe extern "C" fn WebPGetFeatures(
680680
/// called first, unless WebPGetFeatures() is to be called.
681681
/// Returns false in case of mismatched version.
682682
#[allow(non_snake_case)]
683-
#[cfg_attr(feature = "must-use", must_use)]
683+
#[must_use]
684684
#[inline]
685685
pub unsafe extern "C" fn WebPInitDecoderConfig(config: *mut WebPDecoderConfig) -> c_int {
686686
unsafe { WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION) }

0 commit comments

Comments
 (0)