use crate::{Endian, serialized::Format};
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub struct Context {
format: Format,
position: usize,
endian: Endian,
}
impl Context {
pub fn new(format: Format, endian: Endian, position: usize) -> Self {
Self {
format,
position,
endian,
}
}
pub fn new_dbus(endian: Endian, position: usize) -> Self {
Self::new(Format::DBus, endian, position)
}
#[cfg(feature = "gvariant")]
pub fn new_gvariant(endian: Endian, position: usize) -> Self {
Self::new(Format::GVariant, endian, position)
}
pub fn format(self) -> Format {
self.format
}
pub fn endian(self) -> Endian {
self.endian
}
pub fn position(self) -> usize {
self.position
}
}