mupdf 0.7.0

Safe Rust wrapper to MuPDF
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
use std::{
    convert::TryInto,
    ffi::{c_int, c_void, CString},
    io::Read,
    marker::PhantomData,
    ptr::{self, NonNull},
    slice,
};

use bitflags::bitflags;
use mupdf_sys::*;

use crate::{
    context, from_enum, rust_slice_to_ffi_ptr, unsafe_impl_ffi_wrapper, Buffer, Error, FFIWrapper,
    Font, Image, Matrix, Point, Quad, Rect, WriteMode,
};
use crate::{output::Output, FFIAnalogue};

bitflags! {
    /// Per-char flags reported by the structured-text extractor.
    pub struct TextCharFlags: u16 {
        const STRIKEOUT = FZ_STEXT_STRIKEOUT as _;
        const UNDERLINE = FZ_STEXT_UNDERLINE as _;
        const SYNTHETIC = FZ_STEXT_SYNTHETIC as _;
        /// Real or synthesised ("fake") bold.
        const BOLD = FZ_STEXT_BOLD as _;
        const FILLED = FZ_STEXT_FILLED as _;
        const STROKED = FZ_STEXT_STROKED as _;
        const CLIPPED = FZ_STEXT_CLIPPED as _;
        const UNICODE_IS_CID = FZ_STEXT_UNICODE_IS_CID as _;
        const UNICODE_IS_GID = FZ_STEXT_UNICODE_IS_GID as _;
        const SYNTHETIC_LARGE = FZ_STEXT_SYNTHETIC_LARGE as _;
    }
}

bitflags! {
    /// Options for creating a pixmap and draw device.
    pub struct TextPageFlags: u32 {
        const PRESERVE_LIGATURES = FZ_STEXT_PRESERVE_LIGATURES as _;
        const PRESERVE_WHITESPACE = FZ_STEXT_PRESERVE_WHITESPACE as _;
        const PRESERVE_IMAGES = FZ_STEXT_PRESERVE_IMAGES as _;
        const INHIBIT_SPACES = FZ_STEXT_INHIBIT_SPACES as _;
        const DEHYPHENATE = FZ_STEXT_DEHYPHENATE as _;
        const PRESERVE_SPANS = FZ_STEXT_PRESERVE_SPANS as _;
        const CLIP = FZ_STEXT_CLIP as _;
        const USE_CID_FOR_UNKNOWN_UNICODE = FZ_STEXT_USE_CID_FOR_UNKNOWN_UNICODE as _;
        const COLLECT_STRUCTURE = FZ_STEXT_COLLECT_STRUCTURE as _;
        const ACCURATE_BBOXES = FZ_STEXT_ACCURATE_BBOXES as _;
        const COLLECT_VECTORS = FZ_STEXT_COLLECT_VECTORS as _;
        const IGNORE_ACTUALTEXT = FZ_STEXT_IGNORE_ACTUALTEXT as _;
        const SEGMENT = FZ_STEXT_SEGMENT as _;
        const PARAGRAPH_BREAK = FZ_STEXT_PARAGRAPH_BREAK as _;
        const TABLE_HUNT = FZ_STEXT_TABLE_HUNT as _;
        const COLLECT_STYLES = FZ_STEXT_COLLECT_STYLES as _;
        const USE_GID_FOR_UNKNOWN_UNICODE = FZ_STEXT_USE_GID_FOR_UNKNOWN_UNICODE as _;
        const ACCURATE_ASCENDERS = FZ_STEXT_ACCURATE_ASCENDERS as _;
        const ACCURATE_SIDE_BEARINGS = FZ_STEXT_ACCURATE_SIDE_BEARINGS as _;
    }
}

/// A text page is a list of blocks, together with an overall bounding box
#[derive(Debug)]
pub struct TextPage {
    pub(crate) inner: NonNull<fz_stext_page>,
}

unsafe_impl_ffi_wrapper!(TextPage, fz_stext_page, fz_drop_stext_page);

impl TextPage {
    pub fn to_html(&self, id: i32, full: bool) -> Result<String, Error> {
        let mut buf = Buffer::with_capacity(8192);

        let out = Output::from_buffer(&buf);
        if full {
            unsafe {
                ffi_try!(mupdf_print_stext_header_as_html(
                    context(),
                    out.inner.as_ptr()
                ))?
            };
        }
        unsafe {
            ffi_try!(mupdf_print_stext_page_as_html(
                context(),
                out.inner.as_ptr(),
                self.inner.as_ptr(),
                id
            ))?
        };
        if full {
            unsafe {
                ffi_try!(mupdf_print_stext_trailer_as_html(
                    context(),
                    out.inner.as_ptr()
                ))?
            };
        }
        drop(out);

        let mut res = String::new();
        buf.read_to_string(&mut res)?;
        Ok(res)
    }

    pub fn to_xhtml(&self, id: i32) -> Result<String, Error> {
        let mut buf = Buffer::with_capacity(8192);

        let out = Output::from_buffer(&buf);
        unsafe {
            ffi_try!(mupdf_print_stext_header_as_xhtml(
                context(),
                out.inner.as_ptr()
            ))?;
            ffi_try!(mupdf_print_stext_page_as_xhtml(
                context(),
                out.inner.as_ptr(),
                self.inner.as_ptr(),
                id
            ))?;
            ffi_try!(mupdf_print_stext_trailer_as_html(
                context(),
                out.inner.as_ptr()
            ))?;
        }
        drop(out);

        let mut res = String::new();
        buf.read_to_string(&mut res)?;
        Ok(res)
    }

    pub fn to_xml(&self, id: i32) -> Result<String, Error> {
        let mut buf = Buffer::with_capacity(8192);

        let out = Output::from_buffer(&buf);
        unsafe {
            ffi_try!(mupdf_print_stext_page_as_xml(
                context(),
                out.inner.as_ptr(),
                self.inner.as_ptr(),
                id
            ))?
        };
        drop(out);

        let mut res = String::new();
        buf.read_to_string(&mut res)?;
        Ok(res)
    }

    pub fn to_text(&self) -> Result<String, Error> {
        let mut buf = Buffer::with_capacity(8192);

        let out = Output::from_buffer(&buf);
        unsafe {
            ffi_try!(mupdf_print_stext_page_as_text(
                context(),
                out.inner.as_ptr(),
                self.inner.as_ptr()
            ))?
        };
        drop(out);

        let mut res = String::new();
        buf.read_to_string(&mut res)?;
        Ok(res)
    }

    pub fn to_json(&self, scale: f32) -> Result<String, Error> {
        let mut buf = Buffer::with_capacity(8192);

        let out = Output::from_buffer(&buf);
        unsafe {
            ffi_try!(mupdf_print_stext_page_as_json(
                context(),
                out.inner.as_ptr(),
                self.inner.as_ptr(),
                scale
            ))?
        };
        drop(out);

        let mut res = String::new();
        buf.read_to_string(&mut res)?;
        Ok(res)
    }

    pub fn blocks(&self) -> TextBlockIter<'_> {
        TextBlockIter {
            next: unsafe { (*self.as_ptr().cast_mut()).first_block },
            _marker: PhantomData,
        }
    }

    pub fn search(&self, needle: &str) -> Result<Vec<Quad>, Error> {
        let mut vec = Vec::new();
        self.search_cb(needle, &mut vec, |v, quads| {
            v.extend(quads.iter().cloned());
            SearchHitResponse::ContinueSearch
        })?;
        Ok(vec)
    }

    /// Search through the page, finding all instances of `needle` and processing them through
    /// `cb`.
    /// Note that the `&[Quad]` given to `cb` in its invocation lives only during the time that
    /// `cb` is being evaluated. That means the following won't work or compile:
    ///
    /// ```compile_fail
    /// # use mupdf::{TextPage, Quad, text_page::SearchHitResponse};
    /// # let text_page: TextPage = todo!();
    /// let mut quads: Vec<&Quad> = Vec::new();
    /// text_page.search_cb("search term", &mut quads, |v, quads: &[Quad]| {
    ///     v.extend(quads);
    ///     SearchHitResponse::ContinueSearch
    /// }).unwrap();
    /// ```
    ///
    /// But the following will:
    /// ```no_run
    /// # use mupdf::{TextPage, Quad, text_page::SearchHitResponse};
    /// # let text_page: TextPage = todo!();
    /// let mut quads: Vec<Quad> = Vec::new();
    /// text_page.search_cb("search term", &mut quads, |v, quads: &[Quad]| {
    ///     v.extend(quads.iter().cloned());
    ///     SearchHitResponse::ContinueSearch
    /// }).unwrap();
    /// ```
    pub fn search_cb<T, F>(&self, needle: &str, data: &mut T, cb: F) -> Result<u32, Error>
    where
        T: ?Sized,
        F: Fn(&mut T, &[Quad]) -> SearchHitResponse,
    {
        // This struct allows us to wrap both the callback that the user gave us and the data so
        // that we can pass it into the ffi callback nicely
        struct FnWithData<'parent, T: ?Sized, F>
        where
            F: Fn(&mut T, &[Quad]) -> SearchHitResponse,
        {
            data: &'parent mut T,
            f: F,
        }

        let mut opaque = FnWithData { data, f: cb };

        // And then here's the `fn` that we'll pass in - it has to be an fn, not capturing context,
        // because it needs to be unsafe extern "C". to be used with FFI.
        unsafe extern "C" fn ffi_cb<T, F>(
            _ctx: *mut fz_context,
            data: *mut c_void,
            num_quads: c_int,
            hit_bbox: *mut fz_quad,
        ) -> c_int
        where
            T: ?Sized,
            F: Fn(&mut T, &[Quad]) -> SearchHitResponse,
            Quad: FFIAnalogue<FFIType = fz_quad>,
        {
            // This is upheld by our `FFIAnalogue` bound above
            let quad_ptr = hit_bbox.cast::<Quad>();
            let Some(nn) = NonNull::new(quad_ptr) else {
                return SearchHitResponse::ContinueSearch as c_int;
            };

            // This guarantee is upheld by mupdf - they're giving us a pointer to the same type we
            // gave them.
            let data = data.cast::<FnWithData<'_, T, F>>();

            // But if they like gave us a -1 for number of results or whatever, give up on
            // decoding.
            let Ok(len) = usize::try_from(num_quads) else {
                return SearchHitResponse::ContinueSearch as c_int;
            };

            // SAFETY: We've ensure nn is not null, and we're trusting the FFI layer for the other
            // invariants (about actually holding the data, etc)
            let slice = unsafe { slice::from_raw_parts_mut(nn.as_ptr(), len) };

            // Get the function and the data
            // SAFETY: Trusting that the FFI layer actually gave us this ptr
            let f = unsafe { &(*data).f };
            // SAFETY: Trusting that the FFI layer actually gave us this ptr
            let data = unsafe { &mut (*data).data };

            // And call the function with the data
            f(data, slice) as c_int
        }

        let c_needle = CString::new(needle)?;
        unsafe {
            ffi_try!(mupdf_search_stext_page_cb(
                context(),
                self.as_ptr().cast_mut(),
                c_needle.as_ptr(),
                Some(ffi_cb::<T, F>),
                &raw mut opaque as *mut c_void
            ))
        }
        .map(|count| count as u32)
    }

    pub fn highlight_selection(
        &mut self,
        a: Point,
        b: Point,
        quads: &[Quad],
    ) -> Result<i32, Error> {
        let (ptr, len): (*const fz_quad, _) = rust_slice_to_ffi_ptr(quads)?;

        unsafe {
            ffi_try!(mupdf_highlight_selection(
                context(),
                self.as_mut_ptr(),
                a.into(),
                b.into(),
                ptr as *mut fz_quad,
                len
            ))
        }
    }
}

#[repr(i32)]
pub enum SearchHitResponse {
    ContinueSearch = 0,
    AbortSearch = 1,
}

from_enum! { c_int => c_int,
    #[derive(Debug, Clone, Copy, PartialEq)]
    pub enum TextBlockType {
        Text = FZ_STEXT_BLOCK_TEXT,
        Image = FZ_STEXT_BLOCK_IMAGE,
        Struct = FZ_STEXT_BLOCK_STRUCT,
        Vector = FZ_STEXT_BLOCK_VECTOR,
        Grid = FZ_STEXT_BLOCK_GRID,
    }
}

/// A text block is a list of lines of text (typically a paragraph), or an image.
pub struct TextBlock<'a> {
    inner: &'a fz_stext_block,
}

impl TextBlock<'_> {
    pub fn r#type(&self) -> TextBlockType {
        self.inner.type_.try_into().unwrap()
    }

    pub fn bounds(&self) -> Rect {
        self.inner.bbox.into()
    }

    pub fn lines(&self) -> TextLineIter<'_> {
        unsafe {
            if self.inner.type_ == FZ_STEXT_BLOCK_TEXT as c_int {
                return TextLineIter {
                    next: self.inner.u.t.first_line,
                    _marker: PhantomData,
                };
            }
        }
        TextLineIter {
            next: ptr::null_mut(),
            _marker: PhantomData,
        }
    }

    pub fn ctm(&self) -> Option<Matrix> {
        unsafe {
            if self.inner.type_ == FZ_STEXT_BLOCK_IMAGE as i32 {
                return Some(self.inner.u.i.transform.into());
            }
        }
        None
    }

    pub fn image(&self) -> Option<Image> {
        unsafe {
            if self.inner.type_ == FZ_STEXT_BLOCK_IMAGE as i32 {
                let inner = self.inner.u.i.image;
                fz_keep_image(context(), inner);
                return Some(Image::from_raw(inner));
            }
        }
        None
    }
}

#[derive(Debug)]
pub struct TextBlockIter<'a> {
    next: *mut fz_stext_block,
    _marker: PhantomData<TextBlock<'a>>,
}

impl<'a> Iterator for TextBlockIter<'a> {
    type Item = TextBlock<'a>;

    fn next(&mut self) -> Option<Self::Item> {
        if self.next.is_null() {
            return None;
        }
        let node = unsafe { &*self.next };
        self.next = node.next;
        Some(TextBlock { inner: node })
    }
}

/// A text line is a list of characters that share a common baseline.
#[derive(Debug)]
pub struct TextLine<'a> {
    inner: &'a fz_stext_line,
}

impl TextLine<'_> {
    pub fn bounds(&self) -> Rect {
        self.inner.bbox.into()
    }

    pub fn wmode(&self) -> WriteMode {
        (self.inner.wmode as u32).try_into().unwrap()
    }

    pub fn chars(&self) -> TextCharIter<'_> {
        TextCharIter {
            next: self.inner.first_char,
            _marker: PhantomData,
        }
    }
}

#[derive(Debug)]
pub struct TextLineIter<'a> {
    next: *mut fz_stext_line,
    _marker: PhantomData<TextLine<'a>>,
}

impl<'a> Iterator for TextLineIter<'a> {
    type Item = TextLine<'a>;

    fn next(&mut self) -> Option<Self::Item> {
        if self.next.is_null() {
            return None;
        }
        let node = unsafe { &*self.next };
        self.next = node.next;
        Some(TextLine { inner: node })
    }
}

/// A text char is a unicode character, the style in which is appears,
/// and the point at which it is positioned.
#[derive(Debug)]
pub struct TextChar<'a> {
    inner: &'a fz_stext_char,
}

impl TextChar<'_> {
    pub fn char(&self) -> Option<char> {
        std::char::from_u32(self.inner.c as u32)
    }

    pub fn origin(&self) -> Point {
        self.inner.origin.into()
    }

    pub fn size(&self) -> f32 {
        self.inner.size
    }

    pub fn quad(&self) -> Quad {
        self.inner.quad.into()
    }

    /// Fill color, packed as `0xAARRGGBB` (sRGB).
    pub fn argb(&self) -> u32 {
        self.inner.argb
    }

    pub fn flags(&self) -> TextCharFlags {
        TextCharFlags::from_bits_truncate(self.inner.flags)
    }

    /// Returns `None` if mupdf did not associate a font to the TextChar.
    /// Bumps the font refcount so the returned [`Font`] can outlive this [`TextChar`].
    pub fn font(&self) -> Option<Font> {
        let ptr = self.inner.font;
        if ptr.is_null() {
            return None;
        }
        unsafe {
            fz_keep_font(context(), ptr);
            Some(Font::from_raw(ptr))
        }
    }
}

#[derive(Debug)]
pub struct TextCharIter<'a> {
    next: *mut fz_stext_char,
    _marker: PhantomData<TextChar<'a>>,
}

impl<'a> Iterator for TextCharIter<'a> {
    type Item = TextChar<'a>;

    fn next(&mut self) -> Option<Self::Item> {
        if self.next.is_null() {
            return None;
        }
        let node = unsafe { &*self.next };
        self.next = node.next;
        Some(TextChar { inner: node })
    }
}

#[cfg(test)]
mod test {
    use crate::{document::test_document, text_page::SearchHitResponse, Document, TextPageFlags};

    #[test]
    fn test_page_to_html() {
        let doc = test_document!("..", "files/dummy.pdf").unwrap();
        let page0 = doc.load_page(0).unwrap();
        let text_page = page0.to_text_page(TextPageFlags::empty()).unwrap();

        let html = text_page.to_html(0, false).unwrap();
        assert!(!html.starts_with("<!DOCTYPE html>"));
        assert!(html.contains("Dummy PDF file"));

        let html = text_page.to_html(0, true).unwrap();
        assert!(html.starts_with("<!DOCTYPE html>"));
        assert!(html.contains("Dummy PDF file"));
    }

    #[test]
    fn test_page_to_xhtml() {
        let doc = test_document!("..", "files/dummy.pdf").unwrap();
        let page0 = doc.load_page(0).unwrap();
        let text_page = page0.to_text_page(TextPageFlags::empty()).unwrap();

        let xhtml = text_page.to_xhtml(0).unwrap();
        assert!(xhtml.starts_with("<?xml "));
        assert!(xhtml.contains("Dummy PDF file"));
    }

    #[test]
    fn test_page_to_xml() {
        let doc = test_document!("..", "files/dummy.pdf").unwrap();
        let page0 = doc.load_page(0).unwrap();
        let text_page = page0.to_text_page(TextPageFlags::empty()).unwrap();
        let xml = text_page.to_xml(0).unwrap();
        assert!(xml.contains("Dummy PDF file"));
    }

    #[test]
    fn test_page_to_text() {
        let doc = test_document!("..", "files/dummy.pdf").unwrap();
        let page0 = doc.load_page(0).unwrap();
        let text_page = page0.to_text_page(TextPageFlags::empty()).unwrap();
        let text = text_page.to_text().unwrap();
        assert_eq!(text, "Dummy PDF file\n\n");
    }

    #[test]
    fn test_text_page_search() {
        use crate::{Point, Quad};

        let doc = test_document!("..", "files/dummy.pdf").unwrap();
        let page0 = doc.load_page(0).unwrap();
        let text_page = page0.to_text_page(TextPageFlags::empty()).unwrap();
        let hits = text_page.search("Dummy").unwrap();
        assert_eq!(hits.len(), 1);
        assert_eq!(
            &*hits,
            [Quad {
                ul: Point {
                    x: 56.8,
                    y: 69.32953
                },
                ur: Point {
                    x: 115.85159,
                    y: 69.32953
                },
                ll: Point {
                    x: 56.8,
                    y: 87.29713
                },
                lr: Point {
                    x: 115.85159,
                    y: 87.29713
                }
            }]
        );

        let hits = text_page.search("Not Found").unwrap();
        assert_eq!(hits.len(), 0);
    }

    #[test]
    fn test_text_char_font_and_flags() {
        use crate::TextCharFlags;

        let doc = test_document!("..", "files/dummy.pdf").unwrap();
        let page0 = doc.load_page(0).unwrap();
        let text_page = page0.to_text_page(TextPageFlags::empty()).unwrap();

        let block = text_page.blocks().next().expect("at least one block");
        let line = block.lines().next().expect("at least one line");
        let first_char = line.chars().next().expect("at least one char");

        assert_eq!(first_char.char(), Some('D'));
        assert_eq!(first_char.argb(), 0xff000000);
        assert!(first_char.flags().contains(TextCharFlags::FILLED));

        let font = first_char.font().expect("char should have a font");
        assert!(!font.name().is_empty());
    }

    #[test]
    fn test_text_char_font_outlives_text_page() {
        let doc = test_document!("..", "files/dummy.pdf").unwrap();
        let page0 = doc.load_page(0).unwrap();
        let text_page = page0.to_text_page(TextPageFlags::empty()).unwrap();

        let (font, expected_name) = {
            let block = text_page.blocks().next().expect("at least one block");
            let line = block.lines().next().expect("at least one line");
            let text_char = line.chars().next().expect("at least one char");
            let font = text_char.font().expect("char should have a font");
            let expected_name = font.name().to_owned();
            (font, expected_name)
        };

        drop(text_page);
        drop(page0);
        drop(doc);

        assert_eq!(font.name(), expected_name);
        assert!(!font.name().is_empty());
        let _ = font.is_bold();
        let _ = font.ascender();
    }

    #[test]
    fn test_text_page_cb_search() {
        let doc = test_document!("..", "files/dummy.pdf").unwrap();
        let page0 = doc.load_page(0).unwrap();
        let text_page = page0.to_text_page(TextPageFlags::empty()).unwrap();
        let mut sum_x = 0.0;
        let num_hits = text_page
            .search_cb("Dummy", &mut sum_x, |acc, hits| {
                for q in hits {
                    *acc += q.ul.x + q.ur.x + q.ll.x + q.lr.x;
                }
                SearchHitResponse::ContinueSearch
            })
            .unwrap();
        assert_eq!(num_hits, 1);
        assert_eq!(sum_x, 56.8 + 115.85159 + 56.8 + 115.85159);

        let hits = text_page.search("Not Found").unwrap();
        assert_eq!(hits.len(), 0);
    }
}