#![no_std]
#![allow(async_fn_in_trait)]
#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;
mod error;
mod time;
#[cfg(feature = "alloc")]
pub mod dir;
#[cfg(feature = "alloc")]
pub mod file;
pub use error::{UdfError, UdfResult};
pub use time::UdfTimestamp;
#[cfg(feature = "alloc")]
pub use dir::UdfDir;
#[cfg(feature = "alloc")]
pub use file::{FileType, UdfFile};
#[cfg(feature = "sync")]
#[path = ""]
pub mod sync {
pub use hadris_io::Result as IoResult;
pub use hadris_io::sync::{Parsable, Read, ReadExt, Seek, Writable, Write};
pub use hadris_io::{Error, ErrorKind, SeekFrom};
macro_rules! io_transform {
($($item:tt)*) => { hadris_macros::strip_async!{ $($item)* } };
}
#[allow(unused_macros)]
macro_rules! sync_only {
($($item:tt)*) => { $($item)* };
}
#[allow(unused_macros)]
macro_rules! async_only {
($($item:tt)*) => {};
}
#[path = "."]
mod __inner {
pub mod descriptor;
#[cfg(feature = "alloc")]
pub mod fs;
#[cfg(feature = "write")]
pub mod modify;
#[cfg(feature = "write")]
pub mod write;
}
pub use __inner::*;
#[cfg(feature = "alloc")]
pub use __inner::fs::{UdfFs, UdfInfo};
}
#[cfg(feature = "async")]
#[path = ""]
pub mod r#async {
pub use hadris_io::Result as IoResult;
pub use hadris_io::r#async::{Parsable, Read, ReadExt, Seek, Writable, Write};
pub use hadris_io::{Error, ErrorKind, SeekFrom};
macro_rules! io_transform {
($($item:tt)*) => { $($item)* };
}
#[allow(unused_macros)]
macro_rules! sync_only {
($($item:tt)*) => {};
}
#[allow(unused_macros)]
macro_rules! async_only {
($($item:tt)*) => { $($item)* };
}
#[path = "."]
mod __inner {
pub mod descriptor;
#[cfg(feature = "alloc")]
pub mod fs;
#[cfg(feature = "write")]
pub mod modify;
#[cfg(feature = "write")]
pub mod write;
}
pub use __inner::*;
}
#[cfg(feature = "sync")]
pub use sync::*;
#[cfg(all(feature = "async", not(feature = "sync")))]
pub use r#async::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct UdfRevision(u16);
impl UdfRevision {
pub const V1_02: Self = Self(0x0102);
pub const V1_50: Self = Self(0x0150);
pub const V2_00: Self = Self(0x0200);
pub const V2_01: Self = Self(0x0201);
pub const V2_50: Self = Self(0x0250);
pub const V2_60: Self = Self(0x0260);
pub const fn from_raw(value: u16) -> Self {
Self(value)
}
pub const fn to_raw(self) -> u16 {
self.0
}
pub const fn major(self) -> u8 {
((self.0 >> 8) & 0xFF) as u8
}
pub const fn minor(self) -> u8 {
(self.0 & 0xFF) as u8
}
}
impl core::fmt::Display for UdfRevision {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}.{:02x}", self.major(), self.minor())
}
}
pub const SECTOR_SIZE: usize = 2048;
pub const AVDP_LOCATION: u32 = 256;
#[cfg(test)]
mod tests {
extern crate std;
use super::*;
use std::format;
#[test]
fn test_udf_revision() {
let rev = UdfRevision::V2_01;
assert_eq!(rev.major(), 2);
assert_eq!(rev.minor(), 1);
assert_eq!(rev.to_raw(), 0x0201);
}
#[test]
fn test_udf_revision_display() {
assert_eq!(format!("{}", UdfRevision::V1_02), "1.02");
assert_eq!(format!("{}", UdfRevision::V2_50), "2.50");
}
}