Enum hyper_scripter::script_repo::Visibility
source · pub enum Visibility {
Normal,
All,
Inverse,
}Variants§
Implementations§
source§impl Visibility
impl Visibility
pub fn is_normal(&self) -> bool
pub fn is_all(&self) -> bool
pub fn is_inverse(&self) -> bool
sourcepub fn invert(self) -> Self
pub fn invert(self) -> Self
Examples found in repository?
src/query/util.rs (line 88)
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
pub async fn do_script_query<'b>(
script_query: &ScriptQuery,
script_repo: &'b mut ScriptRepo,
finding_filtered: bool,
forbid_prompt: bool,
) -> Result<Option<RepoEntry<'b>>> {
log::debug!("開始尋找 `{:?}`", script_query);
let mut visibility = compute_vis(script_query.bang);
if finding_filtered {
visibility = visibility.invert();
}
match &script_query.inner {
ScriptQueryInner::Prev(prev) => {
assert!(!finding_filtered); // XXX 很難看的作法,應設法靜態檢查
let latest = script_repo.latest_mut(prev.get(), visibility);
log::trace!("找最新腳本");
return if latest.is_some() {
Ok(latest)
} else {
Err(Error::Empty)
};
}
ScriptQueryInner::Exact(name) => Ok(script_repo.get_mut(name, visibility)),
ScriptQueryInner::Fuzz(name) => {
let level = if forbid_prompt {
PromptLevel::Never
} else {
Config::get_prompt_level()
};
let iter = script_repo.iter_mut(visibility);
let fuzz_res = fuzzy::fuzz(name, iter, SEP).await?;
let mut is_low = false;
let mut is_multi_fuzz = false;
let entry = match fuzz_res {
Some(fuzzy::High(entry)) => entry,
Some(fuzzy::Low(entry)) => {
is_low = true;
entry
}
#[cfg(feature = "benching")]
Some(fuzzy::Multi { ans, .. }) => {
is_multi_fuzz = true;
ans
}
#[cfg(not(feature = "benching"))]
Some(fuzzy::Multi { ans, others, .. }) => {
is_multi_fuzz = true;
the_multifuzz_algo(ans, others)
}
None => return Ok(None),
};
let need_prompt = {
match level {
PromptLevel::Always => true,
PromptLevel::Never => false,
PromptLevel::Smart => is_low || is_multi_fuzz,
PromptLevel::OnMultiFuzz => is_multi_fuzz,
}
};
if need_prompt {
prompt_fuzz_acceptable(&*entry)?;
}
Ok(Some(entry))
}
}
}Trait Implementations§
source§impl Clone for Visibility
impl Clone for Visibility
source§fn clone(&self) -> Visibility
fn clone(&self) -> Visibility
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for Visibility
impl Debug for Visibility
source§impl PartialEq<Visibility> for Visibility
impl PartialEq<Visibility> for Visibility
source§fn eq(&self, other: &Visibility) -> bool
fn eq(&self, other: &Visibility) -> bool
This method tests for
self and other values to be equal, and is used
by ==.impl Copy for Visibility
impl Eq for Visibility
impl StructuralEq for Visibility
impl StructuralPartialEq for Visibility
Auto Trait Implementations§
impl RefUnwindSafe for Visibility
impl Send for Visibility
impl Sync for Visibility
impl Unpin for Visibility
impl UnwindSafe for Visibility
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.