hayro_syntax/object/
null.rs1use crate::object::Object;
4use crate::object::macros::object;
5use crate::reader::Reader;
6use crate::reader::{Readable, ReaderContext, Skippable};
7
8#[derive(Debug, Eq, PartialEq, Clone, Copy, Hash)]
10pub struct Null;
11
12object!(Null, Null);
13
14impl Skippable for Null {
15 fn skip(r: &mut Reader<'_>, _: bool) -> Option<()> {
16 r.forward_tag(b"null")
17 }
18}
19
20impl Readable<'_> for Null {
21 fn read(r: &mut Reader<'_>, ctx: &ReaderContext<'_>) -> Option<Self> {
22 Self::skip(r, ctx.in_content_stream)?;
23
24 Some(Self)
25 }
26}
27
28#[cfg(test)]
29mod tests {
30 use crate::object::Null;
31 use crate::reader::Reader;
32 use crate::reader::ReaderExt;
33
34 #[test]
35 fn null() {
36 assert_eq!(
37 Reader::new("null".as_bytes())
38 .read_without_context::<Null>()
39 .unwrap(),
40 Null
41 );
42 }
43
44 #[test]
45 fn null_trailing() {
46 assert_eq!(
47 Reader::new("nullabs".as_bytes())
48 .read_without_context::<Null>()
49 .unwrap(),
50 Null
51 );
52 }
53}