/// A network [`Request`], used as an interface for network blocking in the [`crate::Engine`]. #[derive(Clone, Debug)] pubstruct Request { pub request_type: RequestType,
pubfn get_tokens_for_match(&self) -> impl Iterator<Item = &utils::Hash> { // We start matching with source_hostname_hashes for optimization, // as it contains far fewer elements. self.source_hostname_hashes
.as_ref()
.into_iter()
.flatten()
.chain(self.get_tokens())
}
let source_hostname_hashes = if !source_hostname.is_empty() { letmut hashes = Vec::with_capacity(4);
hashes.push(utils::fast_hash(source_hostname)); for (i, c) in source_hostname.char_indices() { if c == '.' && i + 1 < source_hostname.len() {
hashes.push(utils::fast_hash(&source_hostname[i + 1..]));
}
}
Some(hashes)
} else {
None
};
/// If you're building a [`Request`] in a context that already has access to parsed /// representations of the input URLs, you can use this constructor to avoid extra lookups from /// the public suffix list. Take care to pass data correctly. pubfn preparsed(
url: &str,
hostname: &str,
source_hostname: &str,
request_type: &str,
third_party: bool,
) -> Request { let splitter = memchr::memchr(b':', url.as_bytes()).unwrap_or(0); let schema: &str = &url[..splitter];
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.