pub const TAG_LITE_OPTIONS: u32 = 0x49534F05;
pub const TAG_BIOP: u32 = 0x49534F06;
pub const TAG_CONN_BINDER: u32 = 0x49534F40;
pub const TAG_SERVICE_LOCATION: u32 = 0x49534F46;
pub const TAG_OBJECT_LOCATION: u32 = 0x49534F50;
pub const BIOP_DELIVERY_PARA_USE: u16 = 0x0016;
pub const BIOP_OBJECT_USE: u16 = 0x0017;
pub const BINDING_NOBJECT: u8 = 0x01;
pub const BINDING_NCONTEXT: u8 = 0x02;
pub const BIOP_MAGIC: u32 = 0x42494F50;
pub const BIOP_VERSION_MAJOR: u8 = 0x01;
pub const BIOP_VERSION_MINOR: u8 = 0x00;
pub const BYTE_ORDER_BIG_ENDIAN: u8 = 0x00;
pub(super) fn span(
pos: usize,
len: u32,
end: usize,
) -> crate::error::Result<core::ops::Range<usize>> {
let len = len as usize;
pos.checked_add(len)
.filter(|&stop| stop <= end)
.map(|stop| pos..stop)
.ok_or(crate::error::Error::SectionLengthOverflow {
declared: len,
available: end.saturating_sub(pos),
})
}
pub mod fs;
pub mod ior;
pub mod message;
pub use fs::{CarouselFs, CarouselObject};
pub use ior::{
BiopProfileBody, ConnBinder, Ior, LiteComponent, LiteOptionsProfileBody, NameComponent,
NsapAddress, ObjectKind, ObjectLocation, ServiceLocation, TaggedProfile, Tap,
};
pub use message::{
Binding, BiopMessage, CompressedModuleDescriptor, DirectoryMessage, DsmStreamInfo, FileMessage,
ModuleInfo, ServiceContext, ServiceGatewayInfo, StreamEventMessage, StreamMessage,
};
#[cfg(test)]
mod tests {
use super::span;
#[test]
fn span_ok_within_bounds() {
assert_eq!(span(10, 5, 20).unwrap(), 10..15);
assert_eq!(span(0, 0, 0).unwrap(), 0..0);
}
#[test]
fn span_rejects_len_past_end() {
assert!(matches!(
&(span(10, 11, 20)),
Err(crate::error::Error::SectionLengthOverflow { .. })
));
}
#[test]
fn span_rejects_pos_plus_len_overflowing_usize() {
assert!(matches!(
&(span(usize::MAX - 1, 4, usize::MAX)),
Err(crate::error::Error::SectionLengthOverflow { .. })
));
}
}