Fix unreachable-pub and disjoint-capture lint errors

pull/260/head
Manos Pitsidianakis 11 months ago
parent 1d0405ed5b
commit 8e698cabcf
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

@ -29,7 +29,7 @@ use quote::{format_ident, quote};
use regex::Regex;
// Write ConfigStructOverride to overrides.rs
pub fn override_derive(filenames: &[(&str, &str)]) {
pub(crate) fn override_derive(filenames: &[(&str, &str)]) {
let mut output_file =
File::create("src/conf/overrides.rs").expect("Unable to open output file");
let mut output_string = r##"// @generated

@ -40,7 +40,7 @@ use super::*;
use crate::{conf::accounts::JobRequest, jobs::JoinHandle, terminal::embed::EmbedTerminal};
#[cfg(feature = "gpgme")]
mod gpg;
pub mod gpg;
pub mod edit_attachments;
use edit_attachments::*;

@ -444,24 +444,20 @@ pub trait MailListingTrait: ListingTrait {
envs_to_set: SmallVec<[EnvelopeHash; 8]>,
a: &ListingAction,
) {
let account_hash = self.coordinates().0;
let account = &mut context.accounts[&account_hash];
let mailbox_hash = self.coordinates().1;
/*{
let threads_lck = account.collection.get_threads(mailbox_hash);
for thread_hash in thread_hashes {
for (_, h) in threads_lck.thread_iter(thread_hash) {
envs_to_set.push(threads_lck.thread_nodes()[&h].message().unwrap());
}
self.row_updates().push(thread_hash);
}
}
*/
let env_hashes = if let Ok(batch) = EnvelopeHashBatch::try_from(envs_to_set.as_slice()) {
fn inner(
context: &mut Context,
envs_to_set: SmallVec<[EnvelopeHash; 8]>,
account_hash: AccountHash,
mailbox_hash: MailboxHash,
a: &ListingAction,
) {
let env_hashes = if let Ok(batch) = EnvelopeHashBatch::try_from(envs_to_set.as_slice())
{
batch
} else {
return;
};
let account = &mut context.accounts[&account_hash];
match a {
ListingAction::SetSeen => {
let job = account.backend.write().unwrap().set_flags(
@ -480,8 +476,10 @@ pub trait MailListingTrait: ListingTrait {
.main_loop_handler
.job_executor
.spawn_specialized("set_seen".into(), fut);
account
.insert_job(handle.job_id, JobRequest::SetFlags { env_hashes, handle });
account.insert_job(
handle.job_id,
JobRequest::SetFlags { env_hashes, handle },
);
}
}
}
@ -502,8 +500,10 @@ pub trait MailListingTrait: ListingTrait {
.main_loop_handler
.job_executor
.spawn_specialized("set_unseen".into(), fut);
account
.insert_job(handle.job_id, JobRequest::SetFlags { env_hashes, handle });
account.insert_job(
handle.job_id,
JobRequest::SetFlags { env_hashes, handle },
);
}
}
}
@ -524,8 +524,10 @@ pub trait MailListingTrait: ListingTrait {
.main_loop_handler
.job_executor
.spawn_specialized("remove_tag".into(), fut);
account
.insert_job(handle.job_id, JobRequest::SetFlags { env_hashes, handle });
account.insert_job(
handle.job_id,
JobRequest::SetFlags { env_hashes, handle },
);
}
}
}
@ -546,8 +548,10 @@ pub trait MailListingTrait: ListingTrait {
.main_loop_handler
.job_executor
.spawn_specialized("add_tag".into(), fut);
account
.insert_job(handle.job_id, JobRequest::SetFlags { env_hashes, handle });
account.insert_job(
handle.job_id,
JobRequest::SetFlags { env_hashes, handle },
);
}
}
}
@ -576,16 +580,16 @@ pub trait MailListingTrait: ListingTrait {
}
}
ListingAction::CopyTo(ref mailbox_path) => {
match account
.mailbox_by_path(mailbox_path)
.and_then(|destination_mailbox_hash| {
match account.mailbox_by_path(mailbox_path).and_then(
|destination_mailbox_hash| {
account.backend.write().unwrap().copy_messages(
env_hashes,
mailbox_hash,
destination_mailbox_hash,
/* move? */ false,
)
}) {
},
) {
Err(err) => {
context.replies.push_back(UIEvent::StatusEvent(
StatusEvent::DisplayMessage(err.to_string()),
@ -616,16 +620,16 @@ pub trait MailListingTrait: ListingTrait {
)));
}
ListingAction::MoveTo(ref mailbox_path) => {
match account
.mailbox_by_path(mailbox_path)
.and_then(|destination_mailbox_hash| {
match account.mailbox_by_path(mailbox_path).and_then(
|destination_mailbox_hash| {
account.backend.write().unwrap().copy_messages(
env_hashes,
mailbox_hash,
destination_mailbox_hash,
/* move? */ true,
)
}) {
},
) {
Err(err) => {
context.replies.push_back(UIEvent::StatusEvent(
StatusEvent::DisplayMessage(err.to_string()),
@ -655,7 +659,9 @@ pub trait MailListingTrait: ListingTrait {
let futures: Result<Vec<_>> = envs_to_set
.iter()
.map(|&env_hash| account.operation(env_hash).and_then(|mut op| op.as_bytes()))
.map(|&env_hash| {
account.operation(env_hash).and_then(|mut op| op.as_bytes())
})
.collect::<Result<Vec<_>>>();
let path_ = path.to_path_buf();
let format = (*format).unwrap_or_default();
@ -670,7 +676,8 @@ pub trait MailListingTrait: ListingTrait {
.iter()
.map(|&env_hash| collection.get_env(env_hash))
.collect();
let mut file = std::io::BufWriter::new(std::fs::File::create(&path_)?);
let mut file =
std::io::BufWriter::new(std::fs::File::create(&path_)?);
let mut iter = envs.iter().zip(bytes.into_iter());
let tags_lck = collection.tag_index.read().unwrap();
if let Some((env, ref bytes)) = iter.next() {
@ -756,6 +763,20 @@ pub trait MailListingTrait: ListingTrait {
}
_ => unreachable!(),
}
}
let account_hash = self.coordinates().0;
let mailbox_hash = self.coordinates().1;
/*{
let threads_lck = account.collection.get_threads(mailbox_hash);
for thread_hash in thread_hashes {
for (_, h) in threads_lck.thread_iter(thread_hash) {
envs_to_set.push(threads_lck.thread_nodes()[&h].message().unwrap());
}
self.row_updates().push(thread_hash);
}
}
*/
inner(context, envs_to_set, account_hash, mailbox_hash, a);
self.set_dirty(true);
}

@ -45,7 +45,7 @@ mod thread;
pub use thread::*;
mod types;
pub use types::*;
mod state;
pub mod state;
use state::*;
pub mod envelope;

@ -1010,7 +1010,7 @@ mod pp {
/// Expands `include` macros in configuration file and other configuration
/// files (eg. themes) in the filesystem.
pub fn pp<P: AsRef<Path>>(path: P) -> Result<String> {
pub(super) fn pp<P: AsRef<Path>>(path: P) -> Result<String> {
let p_buf: PathBuf = if path.as_ref().is_relative() {
path.as_ref().expand().canonicalize()?
} else {

@ -466,6 +466,8 @@ impl Account {
let backend = map.get(&settings.account().format)(
settings.account(),
Box::new(move |path: &str| {
// disjoint-capture-in-closures
let _ = &s;
s.account.subscribed_mailboxes.is_empty()
|| (s.mailbox_confs.contains_key(path)
&& s.mailbox_confs[path].mailbox_conf().subscribe.is_true())

@ -171,7 +171,7 @@ macro_rules! named_unit_variant {
};
}
mod strings {
pub mod strings {
named_unit_variant!(server_submission);
}

@ -44,7 +44,11 @@ use crate::types::{ThreadEvent, UIEvent};
type AsyncTask = async_task::Runnable;
fn find_task<T>(local: &Worker<T>, global: &Injector<T>, stealers: &[Stealer<T>]) -> Option<T> {
fn find_task(
local: &Worker<MeliTask>,
global: &Injector<MeliTask>,
stealers: &[Stealer<MeliTask>],
) -> Option<MeliTask> {
// Pop a task from the local queue, if not empty.
local.pop().or_else(|| {
// Otherwise, we need to look for a task elsewhere.

@ -26,13 +26,13 @@ use serde::{de, de::Visitor, Deserialize, Deserializer};
mod color;
pub use color::*;
#[macro_use]
mod position;
pub mod position;
#[macro_use]
mod cells;
pub mod cells;
#[macro_use]
mod keys;
pub mod keys;
pub mod embed;
mod text_editing;
pub mod text_editing;
use std::fmt;
pub use self::{cells::*, keys::*, position::*, text_editing::*};

@ -746,7 +746,6 @@ impl Serialize for Color {
}
}
pub use aliases::*;
pub mod aliases {
use super::Color;

@ -34,10 +34,10 @@ mod watch;
pub use watch::*;
mod search;
pub use search::*;
mod cache;
pub mod cache;
pub mod error;
pub mod managesieve;
mod untagged;
pub mod untagged;
use std::{
collections::{hash_map::DefaultHasher, BTreeSet, HashMap, HashSet},

@ -20,7 +20,7 @@
*/
use super::*;
mod sync;
pub mod sync;
use std::convert::TryFrom;
use crate::{
@ -104,7 +104,7 @@ pub trait ImapCacheReset: Send + core::fmt::Debug {
pub use sqlite3_m::*;
#[cfg(feature = "sqlite3")]
mod sqlite3_m {
pub mod sqlite3_m {
use super::*;
use crate::utils::sqlite3::{
self,
@ -739,7 +739,7 @@ pub(super) async fn fetch_cached_envs(state: &mut FetchState) -> Result<Option<V
pub use default_m::*;
#[cfg(not(feature = "sqlite3"))]
mod default_m {
pub mod default_m {
use super::*;
#[derive(Debug)]
pub struct DefaultCache;

@ -25,11 +25,6 @@ use std::{
time::SystemTime,
};
use nom::{
branch::alt, bytes::complete::tag, combinator::map, multi::separated_list1,
sequence::separated_pair,
};
use super::{ImapConnection, ImapProtocol, ImapServerConf, UIDStore};
use crate::{
conf::AccountSettings,
@ -43,17 +38,6 @@ pub struct ManageSieveConnection {
pub inner: ImapConnection,
}
pub fn managesieve_capabilities(input: &[u8]) -> Result<Vec<(&[u8], &[u8])>> {
let (_, ret) = separated_list1(
tag(b"\r\n"),
alt((
separated_pair(quoted_raw, tag(b" "), quoted_raw),
map(quoted_raw, |q| (q, &b""[..])),
)),
)(input)?;
Ok(ret)
}
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum ManageSieveResponse<'a> {
Ok {
@ -66,11 +50,203 @@ pub enum ManageSieveResponse<'a> {
},
}
mod parser {
impl ManageSieveConnection {
pub fn new(
account_hash: crate::backends::AccountHash,
account_name: String,
s: &AccountSettings,
event_consumer: crate::backends::BackendEventConsumer,
) -> Result<Self> {
let server_hostname = get_conf_val!(s["server_hostname"])?;
let server_username = get_conf_val!(s["server_username"])?;
let server_password = get_conf_val!(s["server_password"])?;
let server_port = get_conf_val!(s["server_port"], 4190)?;
let danger_accept_invalid_certs: bool =
get_conf_val!(s["danger_accept_invalid_certs"], false)?;
let timeout = get_conf_val!(s["timeout"], 16_u64)?;
let timeout = if timeout == 0 {
None
} else {
Some(std::time::Duration::from_secs(timeout))
};
let server_conf = ImapServerConf {
server_hostname: server_hostname.to_string(),
server_username: server_username.to_string(),
server_password: server_password.to_string(),
server_port,
use_starttls: true,
use_tls: true,
danger_accept_invalid_certs,
protocol: ImapProtocol::ManageSieve,
timeout,
};
let uid_store = Arc::new(UIDStore {
is_online: Arc::new(Mutex::new((
SystemTime::now(),
Err(Error::new("Account is uninitialised.")),
))),
..UIDStore::new(
account_hash,
account_name.into(),
event_consumer,
server_conf.timeout,
)
});
Ok(Self {
inner: ImapConnection::new_connection(
&server_conf,
#[cfg(debug_assertions)]
"ManageSieveConnection::new()".into(),
uid_store,
),
})
}
pub async fn havespace(&mut self) -> Result<()> {
Ok(())
}
pub async fn putscript(&mut self, script_name: &[u8], script: &[u8]) -> Result<()> {
let mut ret = Vec::new();
self.inner
.send_literal(format!("Putscript {{{len}+}}\r\n", len = script_name.len()).as_bytes())
.await?;
self.inner.send_literal(script_name).await?;
self.inner
.send_literal(format!(" {{{len}+}}\r\n", len = script.len()).as_bytes())
.await?;
self.inner.send_literal(script).await?;
self.inner
.read_response(&mut ret, RequiredResponses::empty())
.await?;
let (_rest, response) = parser::response_oknobye(&ret)?;
match response {
ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!(
"Could not upload script: {} {}",
code.map(String::from_utf8_lossy).unwrap_or_default(),
message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into()),
}
}
pub async fn listscripts(&mut self) -> Result<Vec<(Vec<u8>, bool)>> {
let mut ret = Vec::new();
self.inner.send_command_raw(b"Listscripts").await?;
self.inner
.read_response(&mut ret, RequiredResponses::empty())
.await?;
let (_rest, scripts) =
parser::terminated(parser::listscripts, parser::tag_no_case(b"OK"))(&ret)?;
Ok(scripts
.into_iter()
.map(|(n, a)| (n.to_vec(), a))
.collect::<Vec<(Vec<u8>, bool)>>())
}
pub async fn checkscript(&mut self, script: &[u8]) -> Result<()> {
let mut ret = Vec::new();
self.inner
.send_literal(format!("Checkscript {{{len}+}}\r\n", len = script.len()).as_bytes())
.await?;
self.inner.send_literal(script).await?;
self.inner
.read_response(&mut ret, RequiredResponses::empty())
.await?;
let (_rest, response) = parser::response_oknobye(&ret)?;
match response {
ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!(
"Checkscript reply: {} {}",
code.map(String::from_utf8_lossy).unwrap_or_default(),
message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into()),
}
}
pub async fn setactive(&mut self, script_name: &[u8]) -> Result<()> {
let mut ret = Vec::new();
self.inner
.send_literal(format!("Setactive {{{len}+}}\r\n", len = script_name.len()).as_bytes())
.await?;
self.inner.send_literal(script_name).await?;
self.inner
.read_response(&mut ret, RequiredResponses::empty())
.await?;
let (_rest, response) = parser::response_oknobye(&ret)?;
match response {
ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!(
"Could not set active script: {} {}",
code.map(String::from_utf8_lossy).unwrap_or_default(),
message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into()),
}
}
pub async fn getscript(&mut self, script_name: &[u8]) -> Result<Vec<u8>> {
let mut ret = Vec::new();
self.inner
.send_literal(format!("Getscript {{{len}+}}\r\n", len = script_name.len()).as_bytes())
.await?;
self.inner.send_literal(script_name).await?;
self.inner
.read_response(&mut ret, RequiredResponses::empty())
.await?;
if let Ok((_, ManageSieveResponse::NoBye { code, message })) =
parser::response_oknobye(&ret)
{
return Err(format!(
"Could not set active script: {} {}",
code.map(String::from_utf8_lossy).unwrap_or_default(),
message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into());
}
let (_rest, script) =
parser::terminated(parser::getscript, parser::tag_no_case(b"OK"))(&ret)?;
Ok(script.to_vec())
}
pub async fn deletescript(&mut self, script_name: &[u8]) -> Result<()> {
let mut ret = Vec::new();
self.inner
.send_literal(
format!("Deletescript {{{len}+}}\r\n", len = script_name.len()).as_bytes(),
)
.await?;
self.inner.send_literal(script_name).await?;
self.inner
.read_response(&mut ret, RequiredResponses::empty())
.await?;
let (_rest, response) = parser::response_oknobye(&ret)?;
match response {
ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!(
"Could not delete script: {} {}",
code.map(String::from_utf8_lossy).unwrap_or_default(),
message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into()),
}
}
pub async fn renamescript(&mut self) -> Result<()> {
Ok(())
}
}
pub mod parser {
use nom::{
branch::alt,
bytes::complete::tag,
character::complete::crlf,
combinator::{iterator, map, opt},
multi::separated_list1,
sequence::separated_pair,
};
pub use nom::{
bytes::complete::{is_not, tag_no_case},
@ -79,6 +255,34 @@ mod parser {
use super::*;
/// Return a byte sequence surrounded by "s and decoded if necessary
pub fn quoted_raw(input: &[u8]) -> IResult<&[u8], &[u8]> {
if input.is_empty() || input[0] != b'"' {
return Err(nom::Err::Error((input, "empty").into()));
}
let mut i = 1;
while i < input.len() {
if input[i] == b'\"' && input[i - 1] != b'\\' {
return Ok((&input[i + 1..], &input[1..i]));
}
i += 1;
}
Err(nom::Err::Error((input, "no quotes").into()))
}
pub fn managesieve_capabilities(input: &[u8]) -> Result<Vec<(&[u8], &[u8])>> {
let (_, ret) = separated_list1(
tag(b"\r\n"),
alt((
separated_pair(quoted_raw, tag(b" "), quoted_raw),
map(quoted_raw, |q| (q, &b""[..])),
)),
)(input)?;
Ok(ret)
}
pub fn sieve_name(input: &[u8]) -> IResult<&[u8], &[u8]> {
crate::backends::imap::protocol_parser::string_token(input)
}
@ -148,6 +352,10 @@ mod parser {
))(input)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_managesieve_listscripts() {
let input_1 = b"\"summer_script\"\r\n\"vacation_script\"\r\n{13}\r\nclever\"script\r\n\"main_script\" ACTIVE\r\nOK";
@ -273,209 +481,4 @@ mod parser {
);
}
}
// Return a byte sequence surrounded by "s and decoded if necessary
pub fn quoted_raw(input: &[u8]) -> IResult<&[u8], &[u8]> {
if input.is_empty() || input[0] != b'"' {
return Err(nom::Err::Error((input, "empty").into()));
}
let mut i = 1;
while i < input.len() {
if input[i] == b'\"' && input[i - 1] != b'\\' {
return Ok((&input[i + 1..], &input[1..i]));
}
i += 1;
}
Err(nom::Err::Error((input, "no quotes").into()))
}
impl ManageSieveConnection {
pub fn new(
account_hash: crate::backends::AccountHash,
account_name: String,
s: &AccountSettings,
event_consumer: crate::backends::BackendEventConsumer,
) -> Result<Self> {
let server_hostname = get_conf_val!(s["server_hostname"])?;
let server_username = get_conf_val!(s["server_username"])?;
let server_password = get_conf_val!(s["server_password"])?;
let server_port = get_conf_val!(s["server_port"], 4190)?;
let danger_accept_invalid_certs: bool =
get_conf_val!(s["danger_accept_invalid_certs"], false)?;
let timeout = get_conf_val!(s["timeout"], 16_u64)?;
let timeout = if timeout == 0 {
None
} else {
Some(std::time::Duration::from_secs(timeout))
};
let server_conf = ImapServerConf {
server_hostname: server_hostname.to_string(),
server_username: server_username.to_string(),
server_password: server_password.to_string(),
server_port,
use_starttls: true,
use_tls: true,
danger_accept_invalid_certs,
protocol: ImapProtocol::ManageSieve,
timeout,
};
let uid_store = Arc::new(UIDStore {
is_online: Arc::new(Mutex::new((
SystemTime::now(),
Err(Error::new("Account is uninitialised.")),
))),
..UIDStore::new(
account_hash,
account_name.into(),
event_consumer,
server_conf.timeout,
)
});
Ok(Self {
inner: ImapConnection::new_connection(
&server_conf,
#[cfg(debug_assertions)]
"ManageSieveConnection::new()".into(),
uid_store,
),
})
}
pub async fn havespace(&mut self) -> Result<()> {
Ok(())
}
pub async fn putscript(&mut self, script_name: &[u8], script: &[u8]) -> Result<()> {
let mut ret = Vec::new();
self.inner
.send_literal(format!("Putscript {{{len}+}}\r\n", len = script_name.len()).as_bytes())
.await?;
self.inner.send_literal(script_name).await?;
self.inner
.send_literal(format!(" {{{len}+}}\r\n", len = script.len()).as_bytes())
.await?;
self.inner.send_literal(script).await?;
self.inner
.read_response(&mut ret, RequiredResponses::empty())
.await?;
let (_rest, response) = parser::response_oknobye(&ret)?;
match response {
ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!(
"Could not upload script: {} {}",
code.map(String::from_utf8_lossy).unwrap_or_default(),
message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into()),
}
}
pub async fn listscripts(&mut self) -> Result<Vec<(Vec<u8>, bool)>> {
let mut ret = Vec::new();
self.inner.send_command_raw(b"Listscripts").await?;
self.inner
.read_response(&mut ret, RequiredResponses::empty())
.await?;
let (_rest, scripts) =
parser::terminated(parser::listscripts, parser::tag_no_case(b"OK"))(&ret)?;
Ok(scripts
.into_iter()
.map(|(n, a)| (n.to_vec(), a))
.collect::<Vec<(Vec<u8>, bool)>>())
}
pub async fn checkscript(&mut self, script: &[u8]) -> Result<()> {
let mut ret = Vec::new();
self.inner
.send_literal(format!("Checkscript {{{len}+}}\r\n", len = script.len()).as_bytes())
.await?;
self.inner.send_literal(script).await?;
self.inner
.read_response(&mut ret, RequiredResponses::empty())
.await?;
let (_rest, response) = parser::response_oknobye(&ret)?;
match response {
ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!(
"Checkscript reply: {} {}",
code.map(String::from_utf8_lossy).unwrap_or_default(),
message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into()),
}
}
pub async fn setactive(&mut self, script_name: &[u8]) -> Result<()> {
let mut ret = Vec::new();
self.inner
.send_literal(format!("Setactive {{{len}+}}\r\n", len = script_name.len()).as_bytes())
.await?;
self.inner.send_literal(script_name).await?;
self.inner
.read_response(&mut ret, RequiredResponses::empty())
.await?;
let (_rest, response) = parser::response_oknobye(&ret)?;
match response {
ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!(
"Could not set active script: {} {}",
code.map(String::from_utf8_lossy).unwrap_or_default(),
message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into()),
}
}
pub async fn getscript(&mut self, script_name: &[u8]) -> Result<Vec<u8>> {
let mut ret = Vec::new();
self.inner
.send_literal(format!("Getscript {{{len}+}}\r\n", len = script_name.len()).as_bytes())
.await?;
self.inner.send_literal(script_name).await?;
self.inner
.read_response(&mut ret, RequiredResponses::empty())
.await?;
if let Ok((_, ManageSieveResponse::NoBye { code, message })) =
parser::response_oknobye(&ret)
{
return Err(format!(
"Could not set active script: {} {}",
code.map(String::from_utf8_lossy).unwrap_or_default(),
message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into());
}
let (_rest, script) =
parser::terminated(parser::getscript, parser::tag_no_case(b"OK"))(&ret)?;
Ok(script.to_vec())
}
pub async fn deletescript(&mut self, script_name: &[u8]) -> Result<()> {
let mut ret = Vec::new();
self.inner
.send_literal(
format!("Deletescript {{{len}+}}\r\n", len = script_name.len()).as_bytes(),
)
.await?;
self.inner.send_literal(script_name).await?;
self.inner
.read_response(&mut ret, RequiredResponses::empty())
.await?;
let (_rest, response) = parser::response_oknobye(&ret)?;
match response {
ManageSieveResponse::Ok { .. } => Ok(()),
ManageSieveResponse::NoBye { code, message } => Err(format!(
"Could not delete script: {} {}",
code.map(String::from_utf8_lossy).unwrap_or_default(),
message.map(String::from_utf8_lossy).unwrap_or_default()
)
.into()),
}
}
pub async fn renamescript(&mut self) -> Result<()> {
Ok(())
}
}

@ -202,20 +202,20 @@ fn get_rw_lock_blocking(f: &File, path: &Path) -> Result<()> {
}
#[derive(Debug)]
struct MboxMailbox {
hash: MailboxHash,
name: String,
path: PathBuf,
fs_path: PathBuf,
content: Vec<u8>,
children: Vec<MailboxHash>,
parent: Option<MailboxHash>,
usage: Arc<RwLock<SpecialUsageMailbox>>,
is_subscribed: bool,
permissions: MailboxPermissions,
pub struct MboxMailbox {
pub hash: MailboxHash,
pub name: String,
pub path: PathBuf,
pub fs_path: PathBuf,
pub content: Vec<u8>,
pub children: Vec<MailboxHash>,
pub parent: Option<MailboxHash>,
pub usage: Arc<RwLock<SpecialUsageMailbox>>,
pub is_subscribed: bool,
pub permissions: MailboxPermissions,
pub total: Arc<Mutex<usize>>,
pub unseen: Arc<Mutex<usize>>,
index: Arc<Mutex<HashMap<EnvelopeHash, (Offset, Length)>>>,
pub index: Arc<Mutex<HashMap<EnvelopeHash, (Offset, Length)>>>,
}
impl BackendMailbox for MboxMailbox {
@ -285,11 +285,11 @@ impl BackendMailbox for MboxMailbox {
/// `BackendOp` implementor for Mbox
#[derive(Debug, Default)]
pub struct MboxOp {
_hash: EnvelopeHash,
path: PathBuf,
offset: Offset,
length: Length,
slice: std::cell::RefCell<Option<Vec<u8>>>,
pub _hash: EnvelopeHash,
pub path: PathBuf,
pub offset: Offset,
pub length: Length,
pub slice: std::cell::RefCell<Option<Vec<u8>>>,
}
impl MboxOp {

@ -30,6 +30,7 @@ use smallvec::SmallVec;
use crate::{get_conf_val, get_path_hash};
mod store;
pub use store::*;
#[macro_use]
mod protocol_parser;
pub use protocol_parser::*;

@ -55,7 +55,7 @@ CREATE TABLE IF NOT EXISTS article (
#[derive(Debug)]
pub struct Store {
connection: Connection,
pub connection: Connection,
}
impl Store {

@ -718,7 +718,7 @@ impl MailBackend for NotmuchDb {
use notify::{watcher, RecursiveMode, Watcher};
let account_hash = self.account_hash;
let collection = self.collection.clone();
let tag_index = self.collection.tag_index.clone();
let lib = self.lib.clone();
let path = self.path.clone();
let revision_uuid = self.revision_uuid.clone();
@ -748,7 +748,7 @@ impl MailBackend for NotmuchDb {
mailboxes.clone(),
index.clone(),
mailbox_index.clone(),
collection.tag_index.clone(),
tag_index.clone(),
account_hash,
event_consumer.clone(),
new_revision_uuid,
@ -826,7 +826,7 @@ impl MailBackend for NotmuchDb {
self.lib.clone(),
true,
)?;
let collection = self.collection.clone();
let tag_index = self.collection.clone().tag_index;
let index = self.index.clone();
Ok(Box::pin(async move {
@ -914,11 +914,7 @@ impl MailBackend for NotmuchDb {
for (f, v) in flags.iter() {
if let (Err(tag), true) = (f, v) {
let hash = TagHash::from_bytes(tag.as_bytes());
collection
.tag_index
.write()
.unwrap()
.insert(hash, tag.to_string());
tag_index.write().unwrap().insert(hash, tag.to_string());
}
}

@ -186,7 +186,7 @@ macro_rules! named_unit_variant {
};
}
mod strings {
pub mod strings {
named_unit_variant!(ask);
}
@ -253,7 +253,7 @@ impl<'de> Deserialize<'de> for ToggleFlag {
{
#[derive(Deserialize)]
#[serde(untagged)]
pub enum InnerToggleFlag {
enum InnerToggleFlag {
Bool(bool),
#[serde(with = "strings::ask")]
Ask,

@ -2595,8 +2595,6 @@ pub mod address {
))
}
///`msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS]`
pub fn msg_id(input: &[u8]) -> IResult<&[u8], MessageID> {
///`no-fold-literal = "[" *dtext "]"`
pub fn no_fold_literal(input: &[u8]) -> IResult<&[u8], Cow<'_, [u8]>> {
let orig_input = input;
@ -2614,6 +2612,9 @@ pub mod address {
pub fn id_right(input: &[u8]) -> IResult<&[u8], Cow<'_, [u8]>> {
alt((dot_atom_text, no_fold_literal))(input)
}
///`msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS]`
pub fn msg_id(input: &[u8]) -> IResult<&[u8], MessageID> {
let (input, _) = opt(cfws)(input)?;
let orig_input = input;
let (input, _) = tag("<")(input)?;

@ -30,6 +30,9 @@ struct TagData {
io_state: Arc<Mutex<IoState>>,
}
///
/// # Safety
/// .
pub unsafe extern "C" fn gpgme_register_io_cb(
data: *mut ::std::os::raw::c_void,
fd: ::std::os::raw::c_int,
@ -66,6 +69,9 @@ pub unsafe extern "C" fn gpgme_register_io_cb(
0
}
///
/// # Safety
/// .
pub unsafe extern "C" fn gpgme_remove_io_cb(tag: *mut ::std::os::raw::c_void) {
let tag_data: Arc<TagData> = Arc::from_raw(tag as *const _);
let mut io_state_lck = tag_data.io_state.lock().unwrap();
@ -75,6 +81,9 @@ pub unsafe extern "C" fn gpgme_remove_io_cb(tag: *mut ::std::os::raw::c_void) {
let _ = Arc::into_raw(tag_data);
}
///
/// # Safety
/// .
pub unsafe extern "C" fn gpgme_event_io_cb(
data: *mut ::std::os::raw::c_void,
type_: gpgme_event_io_t,

@ -72,9 +72,9 @@ macro_rules! c_string_literal {
}
}};
}
mod bindings;
pub mod bindings;
use bindings::*;
mod io;
pub mod io;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GpgmeFlag {
@ -804,7 +804,8 @@ impl Context {
.chain_err_summary(|| {
"libgpgme error: could not perform seek on signature data object"
})?;
_ = text;
// disjoint-capture-in-closures
let _ = &text;
sig.into_bytes()
})
}
@ -1127,7 +1128,8 @@ impl Context {
cipher
.seek(std::io::SeekFrom::Start(0))
.chain_err_summary(|| "libgpgme error: could not perform seek on plain text")?;
_ = plain;
// disjoint-capture-in-closures
let _ = &plain;
cipher.into_bytes()
})
}

@ -22,8 +22,8 @@
pub mod grapheme_clusters;
pub mod line_break;
pub mod search;
mod tables;
mod types;
pub mod tables;
pub mod types;
pub use types::Reflow;
pub mod wcwidth;
pub use grapheme_clusters::*;

@ -741,7 +741,7 @@ const TIMEZONE_ABBR: &[(&[u8], (i8, i8))] = &[
(b"YEKT", (05, 0)),
];
mod lib {
pub mod lib {
use std::convert::TryFrom;
use libc::tm;

Loading…
Cancel
Save