diff options
Diffstat (limited to 'src/de_jmhoffmann_jwebmail_mail-storage.rs')
-rw-r--r-- | src/de_jmhoffmann_jwebmail_mail-storage.rs | 1035 |
1 files changed, 1035 insertions, 0 deletions
diff --git a/src/de_jmhoffmann_jwebmail_mail-storage.rs b/src/de_jmhoffmann_jwebmail_mail-storage.rs new file mode 100644 index 0000000..bf3b148 --- /dev/null +++ b/src/de_jmhoffmann_jwebmail_mail-storage.rs @@ -0,0 +1,1035 @@ +#![doc = "This file was automatically generated by the varlink rust generator"] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] +use serde_derive::{Deserialize, Serialize}; +use std::io::BufRead; +use std::sync::{Arc, RwLock}; +use varlink::{self, CallTrait}; +#[allow(dead_code)] +#[derive(Clone, PartialEq, Debug)] +#[allow(clippy::enum_variant_names)] +pub enum ErrorKind { + Varlink_Error, + VarlinkReply_Error, + InvalidFolder(Option<InvalidFolder_Args>), + InvalidMID(Option<InvalidMID_Args>), + InvalidMailbox(Option<InvalidMailbox_Args>), + InvalidPathInMail(Option<InvalidPathInMail_Args>), + InvalidSearchPattern(Option<InvalidSearchPattern_Args>), + InvalidUser(Option<InvalidUser_Args>), + NotInitialized(Option<NotInitialized_Args>), +} +impl ::std::fmt::Display for ErrorKind { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + match self { + ErrorKind::Varlink_Error => write!(f, "Varlink Error"), + ErrorKind::VarlinkReply_Error => write!(f, "Varlink error reply"), + ErrorKind::InvalidFolder(v) => write!( + f, + "de.jmhoffmann.jwebmail.mail-storage.InvalidFolder: {:#?}", + v + ), + ErrorKind::InvalidMID(v) => write!( + f, + "de.jmhoffmann.jwebmail.mail-storage.InvalidMID: {:#?}", + v + ), + ErrorKind::InvalidMailbox(v) => write!( + f, + "de.jmhoffmann.jwebmail.mail-storage.InvalidMailbox: {:#?}", + v + ), + ErrorKind::InvalidPathInMail(v) => write!( + f, + "de.jmhoffmann.jwebmail.mail-storage.InvalidPathInMail: {:#?}", + v + ), + ErrorKind::InvalidSearchPattern(v) => write!( + f, + "de.jmhoffmann.jwebmail.mail-storage.InvalidSearchPattern: {:#?}", + v + ), + ErrorKind::InvalidUser(v) => write!( + f, + "de.jmhoffmann.jwebmail.mail-storage.InvalidUser: {:#?}", + v + ), + ErrorKind::NotInitialized(v) => write!( + f, + "de.jmhoffmann.jwebmail.mail-storage.NotInitialized: {:#?}", + v + ), + } + } +} +pub struct Error( + pub ErrorKind, + pub Option<Box<dyn std::error::Error + 'static + Send + Sync>>, + pub Option<&'static str>, +); +impl Error { + #[allow(dead_code)] + pub fn kind(&self) -> &ErrorKind { + &self.0 + } +} +impl From<ErrorKind> for Error { + fn from(e: ErrorKind) -> Self { + Error(e, None, None) + } +} +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + self.1 + .as_ref() + .map(|e| e.as_ref() as &(dyn std::error::Error + 'static)) + } +} +impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + std::fmt::Display::fmt(&self.0, f) + } +} +impl std::fmt::Debug for Error { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + use std::error::Error as StdError; + if let Some(ref o) = self.2 { + std::fmt::Display::fmt(o, f)?; + } + std::fmt::Debug::fmt(&self.0, f)?; + if let Some(e) = self.source() { + std::fmt::Display::fmt("\nCaused by:\n", f)?; + std::fmt::Debug::fmt(&e, f)?; + } + Ok(()) + } +} +#[allow(dead_code)] +pub type Result<T> = std::result::Result<T, Error>; +impl From<varlink::Error> for Error { + fn from(e: varlink::Error) -> Self { + match e.kind() { + varlink::ErrorKind::VarlinkErrorReply(r) => Error( + ErrorKind::from(r), + Some(Box::from(e)), + Some(concat!(file!(), ":", line!(), ": ")), + ), + _ => Error( + ErrorKind::Varlink_Error, + Some(Box::from(e)), + Some(concat!(file!(), ":", line!(), ": ")), + ), + } + } +} +#[allow(dead_code)] +impl Error { + pub fn source_varlink_kind(&self) -> Option<&varlink::ErrorKind> { + use std::error::Error as StdError; + let mut s: &dyn StdError = self; + while let Some(c) = s.source() { + let k = self + .source() + .and_then(|e| e.downcast_ref::<varlink::Error>()) + .map(|e| e.kind()); + if k.is_some() { + return k; + } + s = c; + } + None + } +} +impl From<&varlink::Reply> for ErrorKind { + #[allow(unused_variables)] + fn from(e: &varlink::Reply) -> Self { + match e { + varlink::Reply { + error: Some(ref t), .. + } if t == "de.jmhoffmann.jwebmail.mail-storage.InvalidFolder" => match e { + varlink::Reply { + parameters: Some(p), + .. + } => match serde_json::from_value(p.clone()) { + Ok(v) => ErrorKind::InvalidFolder(v), + Err(_) => ErrorKind::InvalidFolder(None), + }, + _ => ErrorKind::InvalidFolder(None), + }, + varlink::Reply { + error: Some(ref t), .. + } if t == "de.jmhoffmann.jwebmail.mail-storage.InvalidMID" => match e { + varlink::Reply { + parameters: Some(p), + .. + } => match serde_json::from_value(p.clone()) { + Ok(v) => ErrorKind::InvalidMID(v), + Err(_) => ErrorKind::InvalidMID(None), + }, + _ => ErrorKind::InvalidMID(None), + }, + varlink::Reply { + error: Some(ref t), .. + } if t == "de.jmhoffmann.jwebmail.mail-storage.InvalidMailbox" => match e { + varlink::Reply { + parameters: Some(p), + .. + } => match serde_json::from_value(p.clone()) { + Ok(v) => ErrorKind::InvalidMailbox(v), + Err(_) => ErrorKind::InvalidMailbox(None), + }, + _ => ErrorKind::InvalidMailbox(None), + }, + varlink::Reply { + error: Some(ref t), .. + } if t == "de.jmhoffmann.jwebmail.mail-storage.InvalidPathInMail" => match e { + varlink::Reply { + parameters: Some(p), + .. + } => match serde_json::from_value(p.clone()) { + Ok(v) => ErrorKind::InvalidPathInMail(v), + Err(_) => ErrorKind::InvalidPathInMail(None), + }, + _ => ErrorKind::InvalidPathInMail(None), + }, + varlink::Reply { + error: Some(ref t), .. + } if t == "de.jmhoffmann.jwebmail.mail-storage.InvalidSearchPattern" => match e { + varlink::Reply { + parameters: Some(p), + .. + } => match serde_json::from_value(p.clone()) { + Ok(v) => ErrorKind::InvalidSearchPattern(v), + Err(_) => ErrorKind::InvalidSearchPattern(None), + }, + _ => ErrorKind::InvalidSearchPattern(None), + }, + varlink::Reply { + error: Some(ref t), .. + } if t == "de.jmhoffmann.jwebmail.mail-storage.InvalidUser" => match e { + varlink::Reply { + parameters: Some(p), + .. + } => match serde_json::from_value(p.clone()) { + Ok(v) => ErrorKind::InvalidUser(v), + Err(_) => ErrorKind::InvalidUser(None), + }, + _ => ErrorKind::InvalidUser(None), + }, + varlink::Reply { + error: Some(ref t), .. + } if t == "de.jmhoffmann.jwebmail.mail-storage.NotInitialized" => match e { + varlink::Reply { + parameters: Some(p), + .. + } => match serde_json::from_value(p.clone()) { + Ok(v) => ErrorKind::NotInitialized(v), + Err(_) => ErrorKind::NotInitialized(None), + }, + _ => ErrorKind::NotInitialized(None), + }, + _ => ErrorKind::VarlinkReply_Error, + } + } +} +pub trait VarlinkCallError: varlink::CallTrait { + fn reply_invalid_folder(&mut self, r#folder: String) -> varlink::Result<()> { + self.reply_struct(varlink::Reply::error( + "de.jmhoffmann.jwebmail.mail-storage.InvalidFolder", + Some( + serde_json::to_value(InvalidFolder_Args { r#folder }) + .map_err(varlink::map_context!())?, + ), + )) + } + fn reply_invalid_mid(&mut self, r#folder: String, r#mid: String) -> varlink::Result<()> { + self.reply_struct(varlink::Reply::error( + "de.jmhoffmann.jwebmail.mail-storage.InvalidMID", + Some( + serde_json::to_value(InvalidMID_Args { r#folder, r#mid }) + .map_err(varlink::map_context!())?, + ), + )) + } + fn reply_invalid_mailbox( + &mut self, + r#path: String, + r#not_a_mailbox: bool, + r#user_mismatch: bool, + ) -> varlink::Result<()> { + self.reply_struct(varlink::Reply::error( + "de.jmhoffmann.jwebmail.mail-storage.InvalidMailbox", + Some( + serde_json::to_value(InvalidMailbox_Args { + r#path, + r#not_a_mailbox, + r#user_mismatch, + }) + .map_err(varlink::map_context!())?, + ), + )) + } + fn reply_invalid_path_in_mail( + &mut self, + r#folder: String, + r#mid: String, + r#path: String, + ) -> varlink::Result<()> { + self.reply_struct(varlink::Reply::error( + "de.jmhoffmann.jwebmail.mail-storage.InvalidPathInMail", + Some( + serde_json::to_value(InvalidPathInMail_Args { + r#folder, + r#mid, + r#path, + }) + .map_err(varlink::map_context!())?, + ), + )) + } + fn reply_invalid_search_pattern(&mut self, r#pattern: String) -> varlink::Result<()> { + self.reply_struct(varlink::Reply::error( + "de.jmhoffmann.jwebmail.mail-storage.InvalidSearchPattern", + Some( + serde_json::to_value(InvalidSearchPattern_Args { r#pattern }) + .map_err(varlink::map_context!())?, + ), + )) + } + fn reply_invalid_user(&mut self, r#unix_user: String) -> varlink::Result<()> { + self.reply_struct(varlink::Reply::error( + "de.jmhoffmann.jwebmail.mail-storage.InvalidUser", + Some( + serde_json::to_value(InvalidUser_Args { r#unix_user }) + .map_err(varlink::map_context!())?, + ), + )) + } + fn reply_not_initialized(&mut self) -> varlink::Result<()> { + self.reply_struct(varlink::Reply::error( + "de.jmhoffmann.jwebmail.mail-storage.NotInitialized", + None, + )) + } +} +impl<'a> VarlinkCallError for varlink::Call<'a> {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct r#ListMailHeader { + pub r#byte_size: i64, + pub r#unread: bool, + pub r#rec_date: String, + pub r#mid: String, + pub r#header: MailHeader, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct r#MIMEHeader_mime_type { + pub r#main_type: String, + pub r#sub_type: String, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub enum r#MIMEHeader_content_dispo { + r#none, + r#inline, + r#attachment, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct r#MIMEHeader { + pub r#mime_type: MIMEHeader_mime_type, + pub r#content_dispo: MIMEHeader_content_dispo, + pub r#file_name: Option<String>, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct r#MIMEPart { + pub r#mime_header: MIMEHeader, + pub r#body: MailBody, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct r#Mail { + pub r#head: MailHeader, + pub r#body: MailBody, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct r#MailAddr { + pub r#name: Option<String>, + pub r#address: String, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct r#MailBody { + pub r#discrete: Option<String>, + pub r#multipart: Option<Multipart>, + pub r#mail: Option<Box<Mail>>, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct r#MailHeader { + pub r#send_date: String, + pub r#written_from: Vec<MailAddr>, + pub r#sender: Option<MailAddr>, + pub r#reply_to: Vec<MailAddr>, + pub r#send_to: Vec<MailAddr>, + pub r#cc: Vec<MailAddr>, + pub r#bcc: Vec<MailAddr>, + pub r#subject: String, + pub r#comments: Vec<String>, + pub r#keywords: Vec<String>, + pub r#mime: MIMEHeader, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct r#Multipart { + pub r#preamble: Option<String>, + pub r#parts: Vec<MIMEPart>, + pub r#epilogue: Option<String>, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub enum r#Sort_direction { + r#asc, + r#desc, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub enum r#Sort_parameter { + r#date, + r#size, + r#sender, + r#subject, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct r#Sort { + pub r#direction: Sort_direction, + pub r#parameter: Sort_parameter, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct InvalidFolder_Args { + pub r#folder: String, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct InvalidMID_Args { + pub r#folder: String, + pub r#mid: String, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct InvalidMailbox_Args { + pub r#path: String, + pub r#not_a_mailbox: bool, + pub r#user_mismatch: bool, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct InvalidPathInMail_Args { + pub r#folder: String, + pub r#mid: String, + pub r#path: String, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct InvalidSearchPattern_Args { + pub r#pattern: String, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct InvalidUser_Args { + pub r#unix_user: String, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct NotInitialized_Args {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub enum r#AddFolder_Reply_status { + r#created, + r#skiped, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct AddFolder_Reply { + pub r#status: AddFolder_Reply_status, +} +impl varlink::VarlinkReply for AddFolder_Reply {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct AddFolder_Args { + pub r#name: String, +} +pub trait Call_AddFolder: VarlinkCallError { + fn reply(&mut self, r#status: AddFolder_Reply_status) -> varlink::Result<()> { + self.reply_struct(AddFolder_Reply { r#status }.into()) + } +} +impl<'a> Call_AddFolder for varlink::Call<'a> {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Folders_Reply { + pub r#folders: Vec<String>, +} +impl varlink::VarlinkReply for Folders_Reply {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Folders_Args {} +pub trait Call_Folders: VarlinkCallError { + fn reply(&mut self, r#folders: Vec<String>) -> varlink::Result<()> { + self.reply_struct(Folders_Reply { r#folders }.into()) + } +} +impl<'a> Call_Folders for varlink::Call<'a> {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Init_Reply {} +impl varlink::VarlinkReply for Init_Reply {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Init_Args { + pub r#unix_user: String, + pub r#mailbox_path: String, +} +pub trait Call_Init: VarlinkCallError { + fn reply(&mut self) -> varlink::Result<()> { + self.reply_struct(varlink::Reply::parameters(None)) + } +} +impl<'a> Call_Init for varlink::Call<'a> {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct List_Reply { + pub r#mail_heads: Vec<ListMailHeader>, +} +impl varlink::VarlinkReply for List_Reply {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct List_Args { + pub r#folder: String, + pub r#start: i64, + pub r#end: i64, + pub r#sort: Sort, +} +pub trait Call_List: VarlinkCallError { + fn reply(&mut self, r#mail_heads: Vec<ListMailHeader>) -> varlink::Result<()> { + self.reply_struct(List_Reply { r#mail_heads }.into()) + } +} +impl<'a> Call_List for varlink::Call<'a> {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Move_Reply {} +impl varlink::VarlinkReply for Move_Reply {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Move_Args { + pub r#mid: String, + pub r#from_folder: String, + pub r#to_folder: String, +} +pub trait Call_Move: VarlinkCallError { + fn reply(&mut self) -> varlink::Result<()> { + self.reply_struct(varlink::Reply::parameters(None)) + } +} +impl<'a> Call_Move for varlink::Call<'a> {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Raw_Reply { + pub r#header: MIMEHeader, + pub r#body: String, +} +impl varlink::VarlinkReply for Raw_Reply {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Raw_Args { + pub r#folder: String, + pub r#mid: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub r#path: Option<String>, +} +pub trait Call_Raw: VarlinkCallError { + fn reply(&mut self, r#header: MIMEHeader, r#body: String) -> varlink::Result<()> { + self.reply_struct(Raw_Reply { r#header, r#body }.into()) + } +} +impl<'a> Call_Raw for varlink::Call<'a> {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Remove_Reply {} +impl varlink::VarlinkReply for Remove_Reply {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Remove_Args { + pub r#folder: String, + pub r#mid: String, +} +pub trait Call_Remove: VarlinkCallError { + fn reply(&mut self) -> varlink::Result<()> { + self.reply_struct(varlink::Reply::parameters(None)) + } +} +impl<'a> Call_Remove for varlink::Call<'a> {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Search_Reply { + pub r#found: Vec<ListMailHeader>, +} +impl varlink::VarlinkReply for Search_Reply {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Search_Args { + pub r#folder: String, + pub r#pattern: String, +} +pub trait Call_Search: VarlinkCallError { + fn reply(&mut self, r#found: Vec<ListMailHeader>) -> varlink::Result<()> { + self.reply_struct(Search_Reply { r#found }.into()) + } +} +impl<'a> Call_Search for varlink::Call<'a> {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Show_Reply { + pub r#mail: Mail, +} +impl varlink::VarlinkReply for Show_Reply {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Show_Args { + pub r#folder: String, + pub r#mid: String, +} +pub trait Call_Show: VarlinkCallError { + fn reply(&mut self, r#mail: Mail) -> varlink::Result<()> { + self.reply_struct(Show_Reply { r#mail }.into()) + } +} +impl<'a> Call_Show for varlink::Call<'a> {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Stats_Reply { + pub r#mail_count: i64, + pub r#unread_count: i64, + pub r#byte_size: i64, +} +impl varlink::VarlinkReply for Stats_Reply {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct Stats_Args { + pub r#folder: String, +} +pub trait Call_Stats: VarlinkCallError { + fn reply( + &mut self, + r#mail_count: i64, + r#unread_count: i64, + r#byte_size: i64, + ) -> varlink::Result<()> { + self.reply_struct( + Stats_Reply { + r#mail_count, + r#unread_count, + r#byte_size, + } + .into(), + ) + } +} +impl<'a> Call_Stats for varlink::Call<'a> {} +pub trait VarlinkInterface { + fn add_folder(&self, call: &mut dyn Call_AddFolder, r#name: String) -> varlink::Result<()>; + fn folders(&self, call: &mut dyn Call_Folders) -> varlink::Result<()>; + fn init( + &self, + call: &mut dyn Call_Init, + r#unix_user: String, + r#mailbox_path: String, + ) -> varlink::Result<()>; + fn list( + &self, + call: &mut dyn Call_List, + r#folder: String, + r#start: i64, + r#end: i64, + r#sort: Sort, + ) -> varlink::Result<()>; + fn r#move( + &self, + call: &mut dyn Call_Move, + r#mid: String, + r#from_folder: String, + r#to_folder: String, + ) -> varlink::Result<()>; + fn raw( + &self, + call: &mut dyn Call_Raw, + r#folder: String, + r#mid: String, + r#path: Option<String>, + ) -> varlink::Result<()>; + fn remove( + &self, + call: &mut dyn Call_Remove, + r#folder: String, + r#mid: String, + ) -> varlink::Result<()>; + fn search( + &self, + call: &mut dyn Call_Search, + r#folder: String, + r#pattern: String, + ) -> varlink::Result<()>; + fn show( + &self, + call: &mut dyn Call_Show, + r#folder: String, + r#mid: String, + ) -> varlink::Result<()>; + fn stats(&self, call: &mut dyn Call_Stats, r#folder: String) -> varlink::Result<()>; + fn call_upgraded( + &self, + _call: &mut varlink::Call, + _bufreader: &mut dyn BufRead, + ) -> varlink::Result<Vec<u8>> { + Ok(Vec::new()) + } +} +pub trait VarlinkClientInterface { + fn add_folder( + &mut self, + r#name: String, + ) -> varlink::MethodCall<AddFolder_Args, AddFolder_Reply, Error>; + fn folders(&mut self) -> varlink::MethodCall<Folders_Args, Folders_Reply, Error>; + fn init( + &mut self, + r#unix_user: String, + r#mailbox_path: String, + ) -> varlink::MethodCall<Init_Args, Init_Reply, Error>; + fn list( + &mut self, + r#folder: String, + r#start: i64, + r#end: i64, + r#sort: Sort, + ) -> varlink::MethodCall<List_Args, List_Reply, Error>; + fn r#move( + &mut self, + r#mid: String, + r#from_folder: String, + r#to_folder: String, + ) -> varlink::MethodCall<Move_Args, Move_Reply, Error>; + fn raw( + &mut self, + r#folder: String, + r#mid: String, + r#path: Option<String>, + ) -> varlink::MethodCall<Raw_Args, Raw_Reply, Error>; + fn remove( + &mut self, + r#folder: String, + r#mid: String, + ) -> varlink::MethodCall<Remove_Args, Remove_Reply, Error>; + fn search( + &mut self, + r#folder: String, + r#pattern: String, + ) -> varlink::MethodCall<Search_Args, Search_Reply, Error>; + fn show( + &mut self, + r#folder: String, + r#mid: String, + ) -> varlink::MethodCall<Show_Args, Show_Reply, Error>; + fn stats(&mut self, r#folder: String) -> varlink::MethodCall<Stats_Args, Stats_Reply, Error>; +} +#[allow(dead_code)] +pub struct VarlinkClient { + connection: Arc<RwLock<varlink::Connection>>, +} +impl VarlinkClient { + #[allow(dead_code)] + pub fn new(connection: Arc<RwLock<varlink::Connection>>) -> Self { + VarlinkClient { connection } + } +} +impl VarlinkClientInterface for VarlinkClient { + fn add_folder( + &mut self, + r#name: String, + ) -> varlink::MethodCall<AddFolder_Args, AddFolder_Reply, Error> { + varlink::MethodCall::<AddFolder_Args, AddFolder_Reply, Error>::new( + self.connection.clone(), + "de.jmhoffmann.jwebmail.mail-storage.AddFolder", + AddFolder_Args { r#name }, + ) + } + fn folders(&mut self) -> varlink::MethodCall<Folders_Args, Folders_Reply, Error> { + varlink::MethodCall::<Folders_Args, Folders_Reply, Error>::new( + self.connection.clone(), + "de.jmhoffmann.jwebmail.mail-storage.Folders", + Folders_Args {}, + ) + } + fn init( + &mut self, + r#unix_user: String, + r#mailbox_path: String, + ) -> varlink::MethodCall<Init_Args, Init_Reply, Error> { + varlink::MethodCall::<Init_Args, Init_Reply, Error>::new( + self.connection.clone(), + "de.jmhoffmann.jwebmail.mail-storage.Init", + Init_Args { + r#unix_user, + r#mailbox_path, + }, + ) + } + fn list( + &mut self, + r#folder: String, + r#start: i64, + r#end: i64, + r#sort: Sort, + ) -> varlink::MethodCall<List_Args, List_Reply, Error> { + varlink::MethodCall::<List_Args, List_Reply, Error>::new( + self.connection.clone(), + "de.jmhoffmann.jwebmail.mail-storage.List", + List_Args { + r#folder, + r#start, + r#end, + r#sort, + }, + ) + } + fn r#move( + &mut self, + r#mid: String, + r#from_folder: String, + r#to_folder: String, + ) -> varlink::MethodCall<Move_Args, Move_Reply, Error> { + varlink::MethodCall::<Move_Args, Move_Reply, Error>::new( + self.connection.clone(), + "de.jmhoffmann.jwebmail.mail-storage.Move", + Move_Args { + r#mid, + r#from_folder, + r#to_folder, + }, + ) + } + fn raw( + &mut self, + r#folder: String, + r#mid: String, + r#path: Option<String>, + ) -> varlink::MethodCall<Raw_Args, Raw_Reply, Error> { + varlink::MethodCall::<Raw_Args, Raw_Reply, Error>::new( + self.connection.clone(), + "de.jmhoffmann.jwebmail.mail-storage.Raw", + Raw_Args { + r#folder, + r#mid, + r#path, + }, + ) + } + fn remove( + &mut self, + r#folder: String, + r#mid: String, + ) -> varlink::MethodCall<Remove_Args, Remove_Reply, Error> { + varlink::MethodCall::<Remove_Args, Remove_Reply, Error>::new( + self.connection.clone(), + "de.jmhoffmann.jwebmail.mail-storage.Remove", + Remove_Args { r#folder, r#mid }, + ) + } + fn search( + &mut self, + r#folder: String, + r#pattern: String, + ) -> varlink::MethodCall<Search_Args, Search_Reply, Error> { + varlink::MethodCall::<Search_Args, Search_Reply, Error>::new( + self.connection.clone(), + "de.jmhoffmann.jwebmail.mail-storage.Search", + Search_Args { + r#folder, + r#pattern, + }, + ) + } + fn show( + &mut self, + r#folder: String, + r#mid: String, + ) -> varlink::MethodCall<Show_Args, Show_Reply, Error> { + varlink::MethodCall::<Show_Args, Show_Reply, Error>::new( + self.connection.clone(), + "de.jmhoffmann.jwebmail.mail-storage.Show", + Show_Args { r#folder, r#mid }, + ) + } + fn stats(&mut self, r#folder: String) -> varlink::MethodCall<Stats_Args, Stats_Reply, Error> { + varlink::MethodCall::<Stats_Args, Stats_Reply, Error>::new( + self.connection.clone(), + "de.jmhoffmann.jwebmail.mail-storage.Stats", + Stats_Args { r#folder }, + ) + } +} +#[allow(dead_code)] +pub struct VarlinkInterfaceProxy { + inner: Box<dyn VarlinkInterface + Send + Sync>, +} +#[allow(dead_code)] +pub fn new(inner: Box<dyn VarlinkInterface + Send + Sync>) -> VarlinkInterfaceProxy { + VarlinkInterfaceProxy { inner } +} +impl varlink::Interface for VarlinkInterfaceProxy { + fn get_description(&self) -> &'static str { + "interface de.jmhoffmann.jwebmail.mail-storage\n\n\ntype MIMEHeader (\n mime_type: (main_type: string, sub_type: string),\n content_dispo: (none, inline, attachment),\n file_name: ?string\n)\n\ntype MailAddr (\n name: ?string,\n address: string\n)\n\n# send_date is of ISO 8601 date-time format\ntype MailHeader (\n send_date: string,\n written_from: []MailAddr,\n sender: ?MailAddr,\n reply_to: []MailAddr,\n send_to: []MailAddr,\n cc: []MailAddr,\n bcc: []MailAddr,\n subject: string,\n comments: []string,\n keywords: []string,\n mime: MIMEHeader\n)\n\ntype ListMailHeader (\n byte_size: int,\n unread: bool,\n rec_date: string,\n mid: string,\n header: MailHeader\n)\n\ntype Multipart (\n preamble: ?string,\n parts: []MIMEPart,\n epilogue: ?string\n)\n\n# exactly one of these fileds must be present\ntype MailBody (\n discrete: ?string,\n multipart: ?Multipart,\n mail: ?Mail\n)\n\ntype Mail (\n head: MailHeader,\n body: MailBody\n)\n\ntype MIMEPart (\n mime_header: MIMEHeader,\n body: MailBody\n)\n\ntype Sort (\n direction: (asc, desc),\n parameter: (date, size, sender)\n)\n\n\nmethod Init(unix_user: string, mailbox_path: string) -> ()\nmethod List(folder: string, start: int, end: int, sort: Sort) -> (mail_heads: []ListMailHeader)\nmethod Stats(folder: string) -> (mail_count: int, unread_count: int, byte_size: int)\nmethod Show(folder: string, mid: string) -> (mail: Mail)\n# body is base64 encoded\nmethod Raw(folder: string, mid: string, path: ?string) -> (header: MIMEHeader, body: string)\nmethod Search(folder: string, pattern: string) -> (found: []ListMailHeader)\nmethod Folders() -> (folders: []string)\nmethod Move(mid: string, from_folder: string, to_folder: string) -> ()\nmethod Remove(folder: string, mid: string) -> ()\nmethod AddFolder(name: string) -> (status: (created, skiped))\n\n\nerror NotInitialized()\nerror InvalidFolder(folder: string)\nerror InvalidMID(folder: string, mid: string)\nerror InvalidPathInMail(folder: string, mid: string, path: string)\nerror InvalidSearchPattern(pattern: string)\nerror InvalidUser(unix_user: string)\nerror InvalidMailbox(path: string, not_a_mailbox: bool, user_mismatch: bool)\n" + } + fn get_name(&self) -> &'static str { + "de.jmhoffmann.jwebmail.mail-storage" + } + fn call_upgraded( + &self, + call: &mut varlink::Call, + bufreader: &mut dyn BufRead, + ) -> varlink::Result<Vec<u8>> { + self.inner.call_upgraded(call, bufreader) + } + fn call(&self, call: &mut varlink::Call) -> varlink::Result<()> { + let req = call.request.unwrap(); + match req.method.as_ref() { + "de.jmhoffmann.jwebmail.mail-storage.AddFolder" => { + if let Some(args) = req.parameters.clone() { + let args: AddFolder_Args = match serde_json::from_value(args) { + Ok(v) => v, + Err(e) => { + let es = format!("{}", e); + let _ = call.reply_invalid_parameter(es.clone()); + return Err(varlink::context!(varlink::ErrorKind::SerdeJsonDe(es))); + } + }; + self.inner + .add_folder(call as &mut dyn Call_AddFolder, args.r#name) + } else { + call.reply_invalid_parameter("parameters".into()) + } + } + "de.jmhoffmann.jwebmail.mail-storage.Folders" => { + self.inner.folders(call as &mut dyn Call_Folders) + } + "de.jmhoffmann.jwebmail.mail-storage.Init" => { + if let Some(args) = req.parameters.clone() { + let args: Init_Args = match serde_json::from_value(args) { + Ok(v) => v, + Err(e) => { + let es = format!("{}", e); + let _ = call.reply_invalid_parameter(es.clone()); + return Err(varlink::context!(varlink::ErrorKind::SerdeJsonDe(es))); + } + }; + self.inner.init( + call as &mut dyn Call_Init, + args.r#unix_user, + args.r#mailbox_path, + ) + } else { + call.reply_invalid_parameter("parameters".into()) + } + } + "de.jmhoffmann.jwebmail.mail-storage.List" => { + if let Some(args) = req.parameters.clone() { + let args: List_Args = match serde_json::from_value(args) { + Ok(v) => v, + Err(e) => { + let es = format!("{}", e); + let _ = call.reply_invalid_parameter(es.clone()); + return Err(varlink::context!(varlink::ErrorKind::SerdeJsonDe(es))); + } + }; + self.inner.list( + call as &mut dyn Call_List, + args.r#folder, + args.r#start, + args.r#end, + args.r#sort, + ) + } else { + call.reply_invalid_parameter("parameters".into()) + } + } + "de.jmhoffmann.jwebmail.mail-storage.Move" => { + if let Some(args) = req.parameters.clone() { + let args: Move_Args = match serde_json::from_value(args) { + Ok(v) => v, + Err(e) => { + let es = format!("{}", e); + let _ = call.reply_invalid_parameter(es.clone()); + return Err(varlink::context!(varlink::ErrorKind::SerdeJsonDe(es))); + } + }; + self.inner.r#move( + call as &mut dyn Call_Move, + args.r#mid, + args.r#from_folder, + args.r#to_folder, + ) + } else { + call.reply_invalid_parameter("parameters".into()) + } + } + "de.jmhoffmann.jwebmail.mail-storage.Raw" => { + if let Some(args) = req.parameters.clone() { + let args: Raw_Args = match serde_json::from_value(args) { + Ok(v) => v, + Err(e) => { + let es = format!("{}", e); + let _ = call.reply_invalid_parameter(es.clone()); + return Err(varlink::context!(varlink::ErrorKind::SerdeJsonDe(es))); + } + }; + self.inner.raw( + call as &mut dyn Call_Raw, + args.r#folder, + args.r#mid, + args.r#path, + ) + } else { + call.reply_invalid_parameter("parameters".into()) + } + } + "de.jmhoffmann.jwebmail.mail-storage.Remove" => { + if let Some(args) = req.parameters.clone() { + let args: Remove_Args = match serde_json::from_value(args) { + Ok(v) => v, + Err(e) => { + let es = format!("{}", e); + let _ = call.reply_invalid_parameter(es.clone()); + return Err(varlink::context!(varlink::ErrorKind::SerdeJsonDe(es))); + } + }; + self.inner + .remove(call as &mut dyn Call_Remove, args.r#folder, args.r#mid) + } else { + call.reply_invalid_parameter("parameters".into()) + } + } + "de.jmhoffmann.jwebmail.mail-storage.Search" => { + if let Some(args) = req.parameters.clone() { + let args: Search_Args = match serde_json::from_value(args) { + Ok(v) => v, + Err(e) => { + let es = format!("{}", e); + let _ = call.reply_invalid_parameter(es.clone()); + return Err(varlink::context!(varlink::ErrorKind::SerdeJsonDe(es))); + } + }; + self.inner + .search(call as &mut dyn Call_Search, args.r#folder, args.r#pattern) + } else { + call.reply_invalid_parameter("parameters".into()) + } + } + "de.jmhoffmann.jwebmail.mail-storage.Show" => { + if let Some(args) = req.parameters.clone() { + let args: Show_Args = match serde_json::from_value(args) { + Ok(v) => v, + Err(e) => { + let es = format!("{}", e); + let _ = call.reply_invalid_parameter(es.clone()); + return Err(varlink::context!(varlink::ErrorKind::SerdeJsonDe(es))); + } + }; + self.inner + .show(call as &mut dyn Call_Show, args.r#folder, args.r#mid) + } else { + call.reply_invalid_parameter("parameters".into()) + } + } + "de.jmhoffmann.jwebmail.mail-storage.Stats" => { + if let Some(args) = req.parameters.clone() { + let args: Stats_Args = match serde_json::from_value(args) { + Ok(v) => v, + Err(e) => { + let es = format!("{}", e); + let _ = call.reply_invalid_parameter(es.clone()); + return Err(varlink::context!(varlink::ErrorKind::SerdeJsonDe(es))); + } + }; + self.inner.stats(call as &mut dyn Call_Stats, args.r#folder) + } else { + call.reply_invalid_parameter("parameters".into()) + } + } + m => call.reply_method_not_found(String::from(m)), + } + } +} |