findshlibs/
unsupported.rs

1//! The fallback implementation of the [SharedLibrary
2//! trait](../trait.SharedLibrary.html) that does nothing.
3
4use crate::Segment as SegmentTrait;
5use crate::SharedLibrary as SharedLibraryTrait;
6use crate::{Bias, IterationControl, SharedLibraryId, Svma};
7
8use std::ffi::OsStr;
9use std::marker::PhantomData;
10use std::usize;
11
12/// An unsupported segment
13#[derive(Debug)]
14pub struct Segment<'a> {
15    phantom: PhantomData<&'a SharedLibrary<'a>>,
16}
17
18impl<'a> SegmentTrait for Segment<'a> {
19    type SharedLibrary = SharedLibrary<'a>;
20
21    #[inline]
22    fn name(&self) -> &str {
23        unreachable!()
24    }
25
26    #[inline]
27    fn stated_virtual_memory_address(&self) -> Svma {
28        unreachable!()
29    }
30
31    #[inline]
32    fn len(&self) -> usize {
33        unreachable!()
34    }
35}
36
37/// An iterator over Mach-O segments.
38#[derive(Debug)]
39pub struct SegmentIter<'a> {
40    phantom: PhantomData<&'a SharedLibrary<'a>>,
41}
42
43impl<'a> Iterator for SegmentIter<'a> {
44    type Item = Segment<'a>;
45
46    fn next(&mut self) -> Option<Self::Item> {
47        None
48    }
49}
50
51/// The fallback implementation of the [SharedLibrary
52/// trait](../trait.SharedLibrary.html).
53#[derive(Debug)]
54pub struct SharedLibrary<'a> {
55    phantom: PhantomData<&'a SharedLibrary<'a>>,
56}
57
58impl<'a> SharedLibraryTrait for SharedLibrary<'a> {
59    type Segment = Segment<'a>;
60    type SegmentIter = SegmentIter<'a>;
61
62    #[inline]
63    fn name(&self) -> &OsStr {
64        unreachable!()
65    }
66
67    fn id(&self) -> Option<SharedLibraryId> {
68        unreachable!()
69    }
70
71    fn segments(&self) -> Self::SegmentIter {
72        SegmentIter {
73            phantom: PhantomData,
74        }
75    }
76
77    #[inline]
78    fn virtual_memory_bias(&self) -> Bias {
79        unreachable!()
80    }
81
82    fn each<F, C>(_f: F)
83    where
84        F: FnMut(&Self) -> C,
85        C: Into<IterationControl>,
86    {
87    }
88}