scuffle_ffmpeg/enums/av_io_flag.rs
1use nutype_enum::{bitwise_enum, nutype_enum};
2use rusty_ffmpeg::ffi::*;
3
4const _: () = {
5 assert!(std::mem::size_of::<AVIOFlag>() == std::mem::size_of_val(&AVIO_FLAG_READ));
6};
7
8nutype_enum! {
9 /// I/O flags used in FFmpeg's `AVIOContext`.
10 ///
11 /// These flags define how a file or stream should be opened and accessed.
12 ///
13 /// See the official FFmpeg documentation:
14 /// <https://ffmpeg.org/doxygen/trunk/avio_8h.html>
15 pub enum AVIOFlag(i32) {
16 /// Open the resource for reading.
17 /// - **Used for**: Opening files or streams in read mode.
18 /// - **Binary representation**: `0b0000000000000001`
19 /// - **Equivalent to**: `AVIO_FLAG_READ`
20 Read = AVIO_FLAG_READ as _,
21
22 /// Open the resource for writing.
23 /// - **Used for**: Creating or overwriting files.
24 /// - **Binary representation**: `0b0000000000000010`
25 /// - **Equivalent to**: `AVIO_FLAG_WRITE`
26 Write = AVIO_FLAG_WRITE as _,
27
28 /// Open the resource for both reading and writing.
29 /// - **Used for**: Modifying an existing file or stream.
30 /// - **Binary representation**: `0b0000000000000011`
31 /// - **Equivalent to**: `AVIO_FLAG_READ_WRITE`
32 ReadWrite = AVIO_FLAG_READ_WRITE as _,
33
34 /// Open the resource in non-blocking mode.
35 /// - **Used for**: Asynchronous I/O operations.
36 /// - **Binary representation**: `0b0000000000001000`
37 /// - **Equivalent to**: `AVIO_FLAG_NONBLOCK`
38 NonBlock = AVIO_FLAG_NONBLOCK as _,
39
40 /// Use direct I/O for lower-level access to storage.
41 /// - **Used for**: Avoiding caching effects by the OS.
42 /// - **Binary representation**: `0b1000000000000000`
43 /// - **Equivalent to**: `AVIO_FLAG_DIRECT`
44 Direct = AVIO_FLAG_DIRECT as _,
45 }
46}
47
48bitwise_enum!(AVIOFlag);
49
50impl PartialEq<i32> for AVIOFlag {
51 fn eq(&self, other: &i32) -> bool {
52 self.0 == *other
53 }
54}
55
56impl From<u32> for AVIOFlag {
57 fn from(value: u32) -> Self {
58 AVIOFlag(value as _)
59 }
60}
61
62impl From<AVIOFlag> for u32 {
63 fn from(value: AVIOFlag) -> Self {
64 value.0 as u32
65 }
66}