use crate::ber;
pub const OID: &str = "2.16.840.1.113730.3.4.9";
pub const OID_RESPONSE: &str = "2.16.840.1.113730.3.4.10";
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct VirtualListView {
pub before: u32,
pub after: u32,
pub offset: u32,
pub content_count: u32,
pub context_id: Option<Vec<u8>>,
}
impl VirtualListView {
pub fn by_offset(before: u32, after: u32, offset: u32, content_count: u32) -> Self {
Self {
before,
after,
offset,
content_count,
context_id: None,
}
}
pub fn encode(&self) -> Vec<u8> {
let mut target_body = Vec::with_capacity(12);
ber::write_u32(&mut target_body, self.offset);
ber::write_u32(&mut target_body, self.content_count);
let mut body = Vec::with_capacity(24);
ber::write_u32(&mut body, self.before);
ber::write_u32(&mut body, self.after);
body.push(0xA0);
ber::write_len(&mut body, target_body.len());
body.extend_from_slice(&target_body);
if let Some(ctx) = &self.context_id {
ber::write_octet_string(&mut body, ctx);
}
ber::wrap_sequence(&body)
}
}