use crate::{
ContentLocationRef, EntryOwner, EntryOwnerLocationRef, Inline, LinkTarget, MAX_CONTENT_DEPTH,
SourceSpan,
};
pub const DEFAULT_REFERENCE_SCAN_STEPS: usize = 250_000;
pub const MAX_REFERENCE_SCAN_STEPS: usize = 1_000_000;
pub const DEFAULT_REFERENCE_SCAN_BYTES: usize = 8 * 1024 * 1024;
pub const MAX_REFERENCE_SCAN_BYTES: usize = 32 * 1024 * 1024;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ReferenceScanLimits {
pub steps: usize,
pub depth: usize,
pub bytes: usize,
}
impl Default for ReferenceScanLimits {
fn default() -> Self {
Self {
steps: DEFAULT_REFERENCE_SCAN_STEPS,
depth: MAX_CONTENT_DEPTH,
bytes: DEFAULT_REFERENCE_SCAN_BYTES,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ReferenceScanStop {
Visitor,
Steps,
Depth,
Bytes,
Position,
InvalidRoot,
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct ReferenceScanReport {
pub steps: usize,
pub bytes: usize,
pub occurrences: usize,
pub stopped: Option<ReferenceScanStop>,
}
impl ReferenceScanReport {
#[must_use]
pub const fn complete(self) -> bool {
self.stopped.is_none()
}
}
#[derive(Debug, Clone, Copy)]
pub struct ReferenceOwnerRef<'ir, 'path> {
pub owner: EntryOwner<'ir>,
pub location: EntryOwnerLocationRef<'path>,
}
#[derive(Debug, Clone, Copy)]
pub struct LinkOccurrenceRef<'ir, 'path> {
pub link: &'ir Inline,
pub target: &'ir LinkTarget,
pub label: &'ir [Inline],
pub location: ContentLocationRef<'path>,
pub content_owner: Option<ReferenceOwnerRef<'ir, 'path>>,
pub semantic_owner: Option<ReferenceOwnerRef<'ir, 'path>>,
pub source: Option<SourceSpan>,
}