pub(crate) struct FragmentChecker {
cache: Arc<Mutex<HashMap<String, HashSet<String>>>>,
}Expand description
Holds a cache of fragments for a given URL.
Fragments, also known as anchors, are used to link to a specific
part of a page. For example, the URL https://example.com#foo
will link to the element with the id of foo.
This cache is used to avoid having to re-parse the same file multiple times when checking if a given URL contains a fragment.
The cache is stored in a HashMap with the URL as the key and
a HashSet of fragments as the value.
Fields§
§cache: Arc<Mutex<HashMap<String, HashSet<String>>>>Implementations§
Source§impl FragmentChecker
impl FragmentChecker
Sourcepub(crate) async fn check(
&self,
input: FragmentInput<'_>,
url: &Url,
) -> Result<bool>
pub(crate) async fn check( &self, input: FragmentInput<'_>, url: &Url, ) -> Result<bool>
Checks if the given FragmentInput contains the given fragment.
Returns false, if there is a fragment in the link which is not empty or “top” and the path is to a Markdown file, which doesn’t contain the given fragment. (Empty # and #top fragments are always valid, triggering the browser to scroll to top.)
In all other cases, returns true.
fn remove_fragment(url: Url) -> String
Trait Implementations§
Source§impl Clone for FragmentChecker
impl Clone for FragmentChecker
Source§fn clone(&self) -> FragmentChecker
fn clone(&self) -> FragmentChecker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FragmentChecker
impl Debug for FragmentChecker
Source§impl Default for FragmentChecker
impl Default for FragmentChecker
Source§fn default() -> FragmentChecker
fn default() -> FragmentChecker
Auto Trait Implementations§
impl Freeze for FragmentChecker
impl !RefUnwindSafe for FragmentChecker
impl Send for FragmentChecker
impl Sync for FragmentChecker
impl Unpin for FragmentChecker
impl UnsafeUnpin for FragmentChecker
impl !UnwindSafe for FragmentChecker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more