imap_types/extensions/
move.rs1use crate::{
4 command::CommandBody, extensions::r#move::error::MoveError, mailbox::Mailbox,
5 sequence::SequenceSet,
6};
7
8impl<'a> CommandBody<'a> {
9 pub fn r#move<S, M>(
10 sequence_set: S,
11 mailbox: M,
12 uid: bool,
13 ) -> Result<Self, MoveError<S::Error, M::Error>>
14 where
15 S: TryInto<SequenceSet>,
16 M: TryInto<Mailbox<'a>>,
17 {
18 Ok(CommandBody::Move {
19 sequence_set: sequence_set.try_into().map_err(MoveError::Sequence)?,
20 mailbox: mailbox.try_into().map_err(MoveError::Mailbox)?,
21 uid,
22 })
23 }
24}
25
26pub mod error {
28 use thiserror::Error;
29
30 #[derive(Clone, Debug, Eq, Error, Hash, Ord, PartialEq, PartialOrd)]
31 pub enum MoveError<S, M> {
32 #[error("Invalid sequence: {0}")]
33 Sequence(S),
34 #[error("Invalid mailbox: {0}")]
35 Mailbox(M),
36 }
37}