scuffle_ffmpeg/enums/
av_io_flag.rs

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