use crate::error::Result;
use prost::Message;
pub trait SyncService {}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_sync_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait CollectionService {
    fn check_database(
        &mut self,
    ) -> Result<anki_proto::collection::CheckDatabaseResponse>;
    fn get_undo_status(&mut self) -> Result<anki_proto::collection::UndoStatus>;
    fn undo(&mut self) -> Result<anki_proto::collection::OpChangesAfterUndo>;
    fn redo(&mut self) -> Result<anki_proto::collection::OpChangesAfterUndo>;
    fn add_custom_undo_entry(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::UInt32>;
    fn merge_undo_entries(
        &mut self,
        input: anki_proto::generic::UInt32,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn latest_progress(&mut self) -> Result<anki_proto::collection::Progress>;
    fn set_wants_abort(&mut self) -> Result<()>;
    fn set_load_balancer_enabled(
        &mut self,
        input: anki_proto::generic::Bool,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn get_custom_colours(
        &mut self,
    ) -> Result<anki_proto::collection::GetCustomColoursResponse>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_collection_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let output = CollectionService::check_database(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let output = CollectionService::get_undo_status(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let output = CollectionService::undo(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let output = CollectionService::redo(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = CollectionService::add_custom_undo_entry(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::generic::UInt32::decode(input)?;
                let output = CollectionService::merge_undo_entries(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let output = CollectionService::latest_progress(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                CollectionService::set_wants_abort(self)?;
                Ok(Vec::new())
            }
            8 => {
                let input = anki_proto::generic::Bool::decode(input)?;
                let output = CollectionService::set_load_balancer_enabled(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let output = CollectionService::get_custom_colours(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait CardsService {
    fn get_card(
        &mut self,
        input: anki_proto::cards::CardId,
    ) -> Result<anki_proto::cards::Card>;
    fn update_cards(
        &mut self,
        input: anki_proto::cards::UpdateCardsRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn remove_cards(
        &mut self,
        input: anki_proto::cards::RemoveCardsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn set_deck(
        &mut self,
        input: anki_proto::cards::SetDeckRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn set_flag(
        &mut self,
        input: anki_proto::cards::SetFlagRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_cards_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::cards::CardId::decode(input)?;
                let output = CardsService::get_card(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::cards::UpdateCardsRequest::decode(input)?;
                let output = CardsService::update_cards(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::cards::RemoveCardsRequest::decode(input)?;
                let output = CardsService::remove_cards(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::cards::SetDeckRequest::decode(input)?;
                let output = CardsService::set_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::cards::SetFlagRequest::decode(input)?;
                let output = CardsService::set_flag(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait DecksService {
    fn new_deck(&mut self) -> Result<anki_proto::decks::Deck>;
    fn add_deck(
        &mut self,
        input: anki_proto::decks::Deck,
    ) -> Result<anki_proto::collection::OpChangesWithId>;
    fn add_deck_legacy(
        &mut self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::collection::OpChangesWithId>;
    fn add_or_update_deck_legacy(
        &mut self,
        input: anki_proto::decks::AddOrUpdateDeckLegacyRequest,
    ) -> Result<anki_proto::decks::DeckId>;
    fn deck_tree(
        &mut self,
        input: anki_proto::decks::DeckTreeRequest,
    ) -> Result<anki_proto::decks::DeckTreeNode>;
    fn deck_tree_legacy(&mut self) -> Result<anki_proto::generic::Json>;
    fn get_all_decks_legacy(&mut self) -> Result<anki_proto::generic::Json>;
    fn get_deck_id_by_name(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::decks::DeckId>;
    fn get_deck(
        &mut self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::decks::Deck>;
    fn update_deck(
        &mut self,
        input: anki_proto::decks::Deck,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn update_deck_legacy(
        &mut self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn set_deck_collapsed(
        &mut self,
        input: anki_proto::decks::SetDeckCollapsedRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn get_deck_legacy(
        &mut self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::generic::Json>;
    fn get_deck_names(
        &mut self,
        input: anki_proto::decks::GetDeckNamesRequest,
    ) -> Result<anki_proto::decks::DeckNames>;
    fn get_deck_and_child_names(
        &mut self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::decks::DeckNames>;
    fn new_deck_legacy(
        &mut self,
        input: anki_proto::generic::Bool,
    ) -> Result<anki_proto::generic::Json>;
    fn remove_decks(
        &mut self,
        input: anki_proto::decks::DeckIds,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn reparent_decks(
        &mut self,
        input: anki_proto::decks::ReparentDecksRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn rename_deck(
        &mut self,
        input: anki_proto::decks::RenameDeckRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn get_or_create_filtered_deck(
        &mut self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::decks::FilteredDeckForUpdate>;
    fn add_or_update_filtered_deck(
        &mut self,
        input: anki_proto::decks::FilteredDeckForUpdate,
    ) -> Result<anki_proto::collection::OpChangesWithId>;
    fn filtered_deck_order_labels(&mut self) -> Result<anki_proto::generic::StringList>;
    fn set_current_deck(
        &mut self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn get_current_deck(&mut self) -> Result<anki_proto::decks::Deck>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_decks_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let output = DecksService::new_deck(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::decks::Deck::decode(input)?;
                let output = DecksService::add_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = DecksService::add_deck_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::decks::AddOrUpdateDeckLegacyRequest::decode(
                    input,
                )?;
                let output = DecksService::add_or_update_deck_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::decks::DeckTreeRequest::decode(input)?;
                let output = DecksService::deck_tree(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let output = DecksService::deck_tree_legacy(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let output = DecksService::get_all_decks_legacy(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = DecksService::get_deck_id_by_name(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = DecksService::get_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let input = anki_proto::decks::Deck::decode(input)?;
                let output = DecksService::update_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = DecksService::update_deck_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            11 => {
                let input = anki_proto::decks::SetDeckCollapsedRequest::decode(input)?;
                let output = DecksService::set_deck_collapsed(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            12 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = DecksService::get_deck_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            13 => {
                let input = anki_proto::decks::GetDeckNamesRequest::decode(input)?;
                let output = DecksService::get_deck_names(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            14 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = DecksService::get_deck_and_child_names(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            15 => {
                let input = anki_proto::generic::Bool::decode(input)?;
                let output = DecksService::new_deck_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            16 => {
                let input = anki_proto::decks::DeckIds::decode(input)?;
                let output = DecksService::remove_decks(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            17 => {
                let input = anki_proto::decks::ReparentDecksRequest::decode(input)?;
                let output = DecksService::reparent_decks(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            18 => {
                let input = anki_proto::decks::RenameDeckRequest::decode(input)?;
                let output = DecksService::rename_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            19 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = DecksService::get_or_create_filtered_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            20 => {
                let input = anki_proto::decks::FilteredDeckForUpdate::decode(input)?;
                let output = DecksService::add_or_update_filtered_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            21 => {
                let output = DecksService::filtered_deck_order_labels(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            22 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = DecksService::set_current_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            23 => {
                let output = DecksService::get_current_deck(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait ConfigService {
    fn get_config_json(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::Json>;
    fn set_config_json(
        &mut self,
        input: anki_proto::config::SetConfigJsonRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn set_config_json_no_undo(
        &mut self,
        input: anki_proto::config::SetConfigJsonRequest,
    ) -> Result<()>;
    fn remove_config(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn get_all_config(&mut self) -> Result<anki_proto::generic::Json>;
    fn get_config_bool(
        &mut self,
        input: anki_proto::config::GetConfigBoolRequest,
    ) -> Result<anki_proto::generic::Bool>;
    fn set_config_bool(
        &mut self,
        input: anki_proto::config::SetConfigBoolRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn get_config_string(
        &mut self,
        input: anki_proto::config::GetConfigStringRequest,
    ) -> Result<anki_proto::generic::String>;
    fn set_config_string(
        &mut self,
        input: anki_proto::config::SetConfigStringRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn get_preferences(&mut self) -> Result<anki_proto::config::Preferences>;
    fn set_preferences(
        &mut self,
        input: anki_proto::config::Preferences,
    ) -> Result<anki_proto::collection::OpChanges>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_config_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = ConfigService::get_config_json(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::config::SetConfigJsonRequest::decode(input)?;
                let output = ConfigService::set_config_json(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::config::SetConfigJsonRequest::decode(input)?;
                ConfigService::set_config_json_no_undo(self, input)?;
                Ok(Vec::new())
            }
            3 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = ConfigService::remove_config(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let output = ConfigService::get_all_config(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::config::GetConfigBoolRequest::decode(input)?;
                let output = ConfigService::get_config_bool(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::config::SetConfigBoolRequest::decode(input)?;
                let output = ConfigService::set_config_bool(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::config::GetConfigStringRequest::decode(input)?;
                let output = ConfigService::get_config_string(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::config::SetConfigStringRequest::decode(input)?;
                let output = ConfigService::set_config_string(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let output = ConfigService::get_preferences(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::config::Preferences::decode(input)?;
                let output = ConfigService::set_preferences(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait DeckConfigService {
    fn add_or_update_deck_config_legacy(
        &mut self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::deck_config::DeckConfigId>;
    fn get_deck_config(
        &mut self,
        input: anki_proto::deck_config::DeckConfigId,
    ) -> Result<anki_proto::deck_config::DeckConfig>;
    fn all_deck_config_legacy(&mut self) -> Result<anki_proto::generic::Json>;
    fn get_deck_config_legacy(
        &mut self,
        input: anki_proto::deck_config::DeckConfigId,
    ) -> Result<anki_proto::generic::Json>;
    fn new_deck_config_legacy(&mut self) -> Result<anki_proto::generic::Json>;
    fn remove_deck_config(
        &mut self,
        input: anki_proto::deck_config::DeckConfigId,
    ) -> Result<()>;
    fn get_deck_configs_for_update(
        &mut self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::deck_config::DeckConfigsForUpdate>;
    fn update_deck_configs(
        &mut self,
        input: anki_proto::deck_config::UpdateDeckConfigsRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn get_ignored_before_count(
        &mut self,
        input: anki_proto::deck_config::GetIgnoredBeforeCountRequest,
    ) -> Result<anki_proto::deck_config::GetIgnoredBeforeCountResponse>;
    fn get_retention_workload(
        &mut self,
        input: anki_proto::deck_config::GetRetentionWorkloadRequest,
    ) -> Result<anki_proto::deck_config::GetRetentionWorkloadResponse>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_deck_config_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = DeckConfigService::add_or_update_deck_config_legacy(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::deck_config::DeckConfigId::decode(input)?;
                let output = DeckConfigService::get_deck_config(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let output = DeckConfigService::all_deck_config_legacy(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::deck_config::DeckConfigId::decode(input)?;
                let output = DeckConfigService::get_deck_config_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let output = DeckConfigService::new_deck_config_legacy(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::deck_config::DeckConfigId::decode(input)?;
                DeckConfigService::remove_deck_config(self, input)?;
                Ok(Vec::new())
            }
            6 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = DeckConfigService::get_deck_configs_for_update(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::deck_config::UpdateDeckConfigsRequest::decode(
                    input,
                )?;
                let output = DeckConfigService::update_deck_configs(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::deck_config::GetIgnoredBeforeCountRequest::decode(
                    input,
                )?;
                let output = DeckConfigService::get_ignored_before_count(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let input = anki_proto::deck_config::GetRetentionWorkloadRequest::decode(
                    input,
                )?;
                let output = DeckConfigService::get_retention_workload(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait SchedulerService {
    fn get_queued_cards(
        &mut self,
        input: anki_proto::scheduler::GetQueuedCardsRequest,
    ) -> Result<anki_proto::scheduler::QueuedCards>;
    fn answer_card(
        &mut self,
        input: anki_proto::scheduler::CardAnswer,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn sched_timing_today(
        &mut self,
    ) -> Result<anki_proto::scheduler::SchedTimingTodayResponse>;
    fn studied_today(&mut self) -> Result<anki_proto::generic::String>;
    fn studied_today_message(
        &mut self,
        input: anki_proto::scheduler::StudiedTodayMessageRequest,
    ) -> Result<anki_proto::generic::String>;
    fn update_stats(
        &mut self,
        input: anki_proto::scheduler::UpdateStatsRequest,
    ) -> Result<()>;
    fn extend_limits(
        &mut self,
        input: anki_proto::scheduler::ExtendLimitsRequest,
    ) -> Result<()>;
    fn counts_for_deck_today(
        &mut self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::scheduler::CountsForDeckTodayResponse>;
    fn congrats_info(&mut self) -> Result<anki_proto::scheduler::CongratsInfoResponse>;
    fn restore_buried_and_suspended_cards(
        &mut self,
        input: anki_proto::cards::CardIds,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn unbury_deck(
        &mut self,
        input: anki_proto::scheduler::UnburyDeckRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn bury_or_suspend_cards(
        &mut self,
        input: anki_proto::scheduler::BuryOrSuspendCardsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn empty_filtered_deck(
        &mut self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn rebuild_filtered_deck(
        &mut self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn schedule_cards_as_new(
        &mut self,
        input: anki_proto::scheduler::ScheduleCardsAsNewRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn schedule_cards_as_new_defaults(
        &mut self,
        input: anki_proto::scheduler::ScheduleCardsAsNewDefaultsRequest,
    ) -> Result<anki_proto::scheduler::ScheduleCardsAsNewDefaultsResponse>;
    fn set_due_date(
        &mut self,
        input: anki_proto::scheduler::SetDueDateRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn grade_now(
        &mut self,
        input: anki_proto::scheduler::GradeNowRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn sort_cards(
        &mut self,
        input: anki_proto::scheduler::SortCardsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn sort_deck(
        &mut self,
        input: anki_proto::scheduler::SortDeckRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn get_scheduling_states(
        &mut self,
        input: anki_proto::cards::CardId,
    ) -> Result<anki_proto::scheduler::SchedulingStates>;
    fn describe_next_states(
        &mut self,
        input: anki_proto::scheduler::SchedulingStates,
    ) -> Result<anki_proto::generic::StringList>;
    fn state_is_leech(
        &mut self,
        input: anki_proto::scheduler::SchedulingState,
    ) -> Result<anki_proto::generic::Bool>;
    fn upgrade_scheduler(&mut self) -> Result<()>;
    fn custom_study(
        &mut self,
        input: anki_proto::scheduler::CustomStudyRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn custom_study_defaults(
        &mut self,
        input: anki_proto::scheduler::CustomStudyDefaultsRequest,
    ) -> Result<anki_proto::scheduler::CustomStudyDefaultsResponse>;
    fn reposition_defaults(
        &mut self,
    ) -> Result<anki_proto::scheduler::RepositionDefaultsResponse>;
    fn compute_fsrs_params(
        &mut self,
        input: anki_proto::scheduler::ComputeFsrsParamsRequest,
    ) -> Result<anki_proto::scheduler::ComputeFsrsParamsResponse>;
    fn get_optimal_retention_parameters(
        &mut self,
        input: anki_proto::scheduler::GetOptimalRetentionParametersRequest,
    ) -> Result<anki_proto::scheduler::GetOptimalRetentionParametersResponse>;
    fn compute_optimal_retention(
        &mut self,
        input: anki_proto::scheduler::SimulateFsrsReviewRequest,
    ) -> Result<anki_proto::scheduler::ComputeOptimalRetentionResponse>;
    fn simulate_fsrs_review(
        &mut self,
        input: anki_proto::scheduler::SimulateFsrsReviewRequest,
    ) -> Result<anki_proto::scheduler::SimulateFsrsReviewResponse>;
    fn simulate_fsrs_workload(
        &mut self,
        input: anki_proto::scheduler::SimulateFsrsReviewRequest,
    ) -> Result<anki_proto::scheduler::SimulateFsrsWorkloadResponse>;
    fn evaluate_params(
        &mut self,
        input: anki_proto::scheduler::EvaluateParamsRequest,
    ) -> Result<anki_proto::scheduler::EvaluateParamsResponse>;
    fn evaluate_params_legacy(
        &mut self,
        input: anki_proto::scheduler::EvaluateParamsLegacyRequest,
    ) -> Result<anki_proto::scheduler::EvaluateParamsResponse>;
    fn compute_memory_state(
        &mut self,
        input: anki_proto::cards::CardId,
    ) -> Result<anki_proto::scheduler::ComputeMemoryStateResponse>;
    fn fuzz_delta(
        &mut self,
        input: anki_proto::scheduler::FuzzDeltaRequest,
    ) -> Result<anki_proto::scheduler::FuzzDeltaResponse>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_scheduler_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::scheduler::GetQueuedCardsRequest::decode(input)?;
                let output = SchedulerService::get_queued_cards(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::scheduler::CardAnswer::decode(input)?;
                let output = SchedulerService::answer_card(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let output = SchedulerService::sched_timing_today(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let output = SchedulerService::studied_today(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::scheduler::StudiedTodayMessageRequest::decode(
                    input,
                )?;
                let output = SchedulerService::studied_today_message(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::scheduler::UpdateStatsRequest::decode(input)?;
                SchedulerService::update_stats(self, input)?;
                Ok(Vec::new())
            }
            6 => {
                let input = anki_proto::scheduler::ExtendLimitsRequest::decode(input)?;
                SchedulerService::extend_limits(self, input)?;
                Ok(Vec::new())
            }
            7 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = SchedulerService::counts_for_deck_today(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let output = SchedulerService::congrats_info(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let input = anki_proto::cards::CardIds::decode(input)?;
                let output = SchedulerService::restore_buried_and_suspended_cards(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::scheduler::UnburyDeckRequest::decode(input)?;
                let output = SchedulerService::unbury_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            11 => {
                let input = anki_proto::scheduler::BuryOrSuspendCardsRequest::decode(
                    input,
                )?;
                let output = SchedulerService::bury_or_suspend_cards(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            12 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = SchedulerService::empty_filtered_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            13 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = SchedulerService::rebuild_filtered_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            14 => {
                let input = anki_proto::scheduler::ScheduleCardsAsNewRequest::decode(
                    input,
                )?;
                let output = SchedulerService::schedule_cards_as_new(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            15 => {
                let input = anki_proto::scheduler::ScheduleCardsAsNewDefaultsRequest::decode(
                    input,
                )?;
                let output = SchedulerService::schedule_cards_as_new_defaults(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            16 => {
                let input = anki_proto::scheduler::SetDueDateRequest::decode(input)?;
                let output = SchedulerService::set_due_date(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            17 => {
                let input = anki_proto::scheduler::GradeNowRequest::decode(input)?;
                let output = SchedulerService::grade_now(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            18 => {
                let input = anki_proto::scheduler::SortCardsRequest::decode(input)?;
                let output = SchedulerService::sort_cards(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            19 => {
                let input = anki_proto::scheduler::SortDeckRequest::decode(input)?;
                let output = SchedulerService::sort_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            20 => {
                let input = anki_proto::cards::CardId::decode(input)?;
                let output = SchedulerService::get_scheduling_states(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            21 => {
                let input = anki_proto::scheduler::SchedulingStates::decode(input)?;
                let output = SchedulerService::describe_next_states(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            22 => {
                let input = anki_proto::scheduler::SchedulingState::decode(input)?;
                let output = SchedulerService::state_is_leech(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            23 => {
                SchedulerService::upgrade_scheduler(self)?;
                Ok(Vec::new())
            }
            24 => {
                let input = anki_proto::scheduler::CustomStudyRequest::decode(input)?;
                let output = SchedulerService::custom_study(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            25 => {
                let input = anki_proto::scheduler::CustomStudyDefaultsRequest::decode(
                    input,
                )?;
                let output = SchedulerService::custom_study_defaults(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            26 => {
                let output = SchedulerService::reposition_defaults(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            27 => {
                let input = anki_proto::scheduler::ComputeFsrsParamsRequest::decode(
                    input,
                )?;
                let output = SchedulerService::compute_fsrs_params(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            28 => {
                let input = anki_proto::scheduler::GetOptimalRetentionParametersRequest::decode(
                    input,
                )?;
                let output = SchedulerService::get_optimal_retention_parameters(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            29 => {
                let input = anki_proto::scheduler::SimulateFsrsReviewRequest::decode(
                    input,
                )?;
                let output = SchedulerService::compute_optimal_retention(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            30 => {
                let input = anki_proto::scheduler::SimulateFsrsReviewRequest::decode(
                    input,
                )?;
                let output = SchedulerService::simulate_fsrs_review(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            31 => {
                let input = anki_proto::scheduler::SimulateFsrsReviewRequest::decode(
                    input,
                )?;
                let output = SchedulerService::simulate_fsrs_workload(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            32 => {
                let input = anki_proto::scheduler::EvaluateParamsRequest::decode(input)?;
                let output = SchedulerService::evaluate_params(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            33 => {
                let input = anki_proto::scheduler::EvaluateParamsLegacyRequest::decode(
                    input,
                )?;
                let output = SchedulerService::evaluate_params_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            34 => {
                let input = anki_proto::cards::CardId::decode(input)?;
                let output = SchedulerService::compute_memory_state(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            35 => {
                let input = anki_proto::scheduler::FuzzDeltaRequest::decode(input)?;
                let output = SchedulerService::fuzz_delta(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait AnkidroidService {
    fn run_db_command(
        &mut self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::generic::Json>;
    fn run_db_command_proto(
        &mut self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::ankidroid::DbResponse>;
    fn insert_for_id(
        &mut self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::generic::Int64>;
    fn run_db_command_for_row_count(
        &mut self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::generic::Int64>;
    fn flush_all_queries(&mut self) -> Result<()>;
    fn flush_query(&mut self, input: anki_proto::generic::Int32) -> Result<()>;
    fn get_next_result_page(
        &mut self,
        input: anki_proto::ankidroid::GetNextResultPageRequest,
    ) -> Result<anki_proto::ankidroid::DbResponse>;
    fn get_column_names_from_query(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::StringList>;
    fn get_active_sequence_numbers(
        &mut self,
    ) -> Result<anki_proto::ankidroid::GetActiveSequenceNumbersResponse>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_ankidroid_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = AnkidroidService::run_db_command(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = AnkidroidService::run_db_command_proto(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = AnkidroidService::insert_for_id(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = AnkidroidService::run_db_command_for_row_count(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                AnkidroidService::flush_all_queries(self)?;
                Ok(Vec::new())
            }
            5 => {
                let input = anki_proto::generic::Int32::decode(input)?;
                AnkidroidService::flush_query(self, input)?;
                Ok(Vec::new())
            }
            6 => {
                let input = anki_proto::ankidroid::GetNextResultPageRequest::decode(
                    input,
                )?;
                let output = AnkidroidService::get_next_result_page(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = AnkidroidService::get_column_names_from_query(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let output = AnkidroidService::get_active_sequence_numbers(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait AnkiHubService {}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_anki_hub_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait AnkiwebService {}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_ankiweb_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait LinksService {
    fn help_page_link(
        &mut self,
        input: anki_proto::links::HelpPageLinkRequest,
    ) -> Result<anki_proto::generic::String>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_links_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::links::HelpPageLinkRequest::decode(input)?;
                let output = LinksService::help_page_link(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait NotetypesService {
    fn add_notetype(
        &mut self,
        input: anki_proto::notetypes::Notetype,
    ) -> Result<anki_proto::collection::OpChangesWithId>;
    fn update_notetype(
        &mut self,
        input: anki_proto::notetypes::Notetype,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn add_notetype_legacy(
        &mut self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::collection::OpChangesWithId>;
    fn update_notetype_legacy(
        &mut self,
        input: anki_proto::notetypes::UpdateNotetypeLegacyRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn add_or_update_notetype(
        &mut self,
        input: anki_proto::notetypes::AddOrUpdateNotetypeRequest,
    ) -> Result<anki_proto::notetypes::NotetypeId>;
    fn get_stock_notetype_legacy(
        &mut self,
        input: anki_proto::notetypes::StockNotetype,
    ) -> Result<anki_proto::generic::Json>;
    fn get_notetype(
        &mut self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::notetypes::Notetype>;
    fn get_notetype_legacy(
        &mut self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::generic::Json>;
    fn get_notetype_names(&mut self) -> Result<anki_proto::notetypes::NotetypeNames>;
    fn get_notetype_names_and_counts(
        &mut self,
    ) -> Result<anki_proto::notetypes::NotetypeUseCounts>;
    fn get_notetype_id_by_name(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::notetypes::NotetypeId>;
    fn remove_notetype(
        &mut self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn get_aux_notetype_config_key(
        &mut self,
        input: anki_proto::notetypes::GetAuxConfigKeyRequest,
    ) -> Result<anki_proto::generic::String>;
    fn get_aux_template_config_key(
        &mut self,
        input: anki_proto::notetypes::GetAuxTemplateConfigKeyRequest,
    ) -> Result<anki_proto::generic::String>;
    fn get_change_notetype_info(
        &mut self,
        input: anki_proto::notetypes::GetChangeNotetypeInfoRequest,
    ) -> Result<anki_proto::notetypes::ChangeNotetypeInfo>;
    fn change_notetype(
        &mut self,
        input: anki_proto::notetypes::ChangeNotetypeRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn get_field_names(
        &mut self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::generic::StringList>;
    fn restore_notetype_to_stock(
        &mut self,
        input: anki_proto::notetypes::RestoreNotetypeToStockRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn get_cloze_field_ords(
        &mut self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::notetypes::GetClozeFieldOrdsResponse>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_notetypes_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::notetypes::Notetype::decode(input)?;
                let output = NotetypesService::add_notetype(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::notetypes::Notetype::decode(input)?;
                let output = NotetypesService::update_notetype(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = NotetypesService::add_notetype_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::notetypes::UpdateNotetypeLegacyRequest::decode(
                    input,
                )?;
                let output = NotetypesService::update_notetype_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::notetypes::AddOrUpdateNotetypeRequest::decode(
                    input,
                )?;
                let output = NotetypesService::add_or_update_notetype(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::notetypes::StockNotetype::decode(input)?;
                let output = NotetypesService::get_stock_notetype_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = NotetypesService::get_notetype(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = NotetypesService::get_notetype_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let output = NotetypesService::get_notetype_names(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let output = NotetypesService::get_notetype_names_and_counts(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = NotetypesService::get_notetype_id_by_name(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            11 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = NotetypesService::remove_notetype(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            12 => {
                let input = anki_proto::notetypes::GetAuxConfigKeyRequest::decode(
                    input,
                )?;
                let output = NotetypesService::get_aux_notetype_config_key(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            13 => {
                let input = anki_proto::notetypes::GetAuxTemplateConfigKeyRequest::decode(
                    input,
                )?;
                let output = NotetypesService::get_aux_template_config_key(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            14 => {
                let input = anki_proto::notetypes::GetChangeNotetypeInfoRequest::decode(
                    input,
                )?;
                let output = NotetypesService::get_change_notetype_info(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            15 => {
                let input = anki_proto::notetypes::ChangeNotetypeRequest::decode(input)?;
                let output = NotetypesService::change_notetype(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            16 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = NotetypesService::get_field_names(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            17 => {
                let input = anki_proto::notetypes::RestoreNotetypeToStockRequest::decode(
                    input,
                )?;
                let output = NotetypesService::restore_notetype_to_stock(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            18 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = NotetypesService::get_cloze_field_ords(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait NotesService {
    fn new_note(
        &mut self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::notes::Note>;
    fn add_note(
        &mut self,
        input: anki_proto::notes::AddNoteRequest,
    ) -> Result<anki_proto::notes::AddNoteResponse>;
    fn add_notes(
        &mut self,
        input: anki_proto::notes::AddNotesRequest,
    ) -> Result<anki_proto::notes::AddNotesResponse>;
    fn defaults_for_adding(
        &mut self,
        input: anki_proto::notes::DefaultsForAddingRequest,
    ) -> Result<anki_proto::notes::DeckAndNotetype>;
    fn default_deck_for_notetype(
        &mut self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::decks::DeckId>;
    fn update_notes(
        &mut self,
        input: anki_proto::notes::UpdateNotesRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn get_note(
        &mut self,
        input: anki_proto::notes::NoteId,
    ) -> Result<anki_proto::notes::Note>;
    fn remove_notes(
        &mut self,
        input: anki_proto::notes::RemoveNotesRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn cloze_numbers_in_note(
        &mut self,
        input: anki_proto::notes::Note,
    ) -> Result<anki_proto::notes::ClozeNumbersInNoteResponse>;
    fn after_note_updates(
        &mut self,
        input: anki_proto::notes::AfterNoteUpdatesRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn field_names_for_notes(
        &mut self,
        input: anki_proto::notes::FieldNamesForNotesRequest,
    ) -> Result<anki_proto::notes::FieldNamesForNotesResponse>;
    fn note_fields_check(
        &mut self,
        input: anki_proto::notes::Note,
    ) -> Result<anki_proto::notes::NoteFieldsCheckResponse>;
    fn cards_of_note(
        &mut self,
        input: anki_proto::notes::NoteId,
    ) -> Result<anki_proto::cards::CardIds>;
    fn get_single_notetype_of_notes(
        &mut self,
        input: anki_proto::notes::NoteIds,
    ) -> Result<anki_proto::notetypes::NotetypeId>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_notes_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = NotesService::new_note(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::notes::AddNoteRequest::decode(input)?;
                let output = NotesService::add_note(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::notes::AddNotesRequest::decode(input)?;
                let output = NotesService::add_notes(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::notes::DefaultsForAddingRequest::decode(input)?;
                let output = NotesService::defaults_for_adding(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = NotesService::default_deck_for_notetype(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::notes::UpdateNotesRequest::decode(input)?;
                let output = NotesService::update_notes(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::notes::NoteId::decode(input)?;
                let output = NotesService::get_note(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::notes::RemoveNotesRequest::decode(input)?;
                let output = NotesService::remove_notes(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::notes::Note::decode(input)?;
                let output = NotesService::cloze_numbers_in_note(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let input = anki_proto::notes::AfterNoteUpdatesRequest::decode(input)?;
                let output = NotesService::after_note_updates(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::notes::FieldNamesForNotesRequest::decode(input)?;
                let output = NotesService::field_names_for_notes(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            11 => {
                let input = anki_proto::notes::Note::decode(input)?;
                let output = NotesService::note_fields_check(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            12 => {
                let input = anki_proto::notes::NoteId::decode(input)?;
                let output = NotesService::cards_of_note(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            13 => {
                let input = anki_proto::notes::NoteIds::decode(input)?;
                let output = NotesService::get_single_notetype_of_notes(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait CardRenderingService {
    fn extract_av_tags(
        &mut self,
        input: anki_proto::card_rendering::ExtractAvTagsRequest,
    ) -> Result<anki_proto::card_rendering::ExtractAvTagsResponse>;
    fn extract_latex(
        &mut self,
        input: anki_proto::card_rendering::ExtractLatexRequest,
    ) -> Result<anki_proto::card_rendering::ExtractLatexResponse>;
    fn get_empty_cards(
        &mut self,
    ) -> Result<anki_proto::card_rendering::EmptyCardsReport>;
    fn render_existing_card(
        &mut self,
        input: anki_proto::card_rendering::RenderExistingCardRequest,
    ) -> Result<anki_proto::card_rendering::RenderCardResponse>;
    fn render_uncommitted_card(
        &mut self,
        input: anki_proto::card_rendering::RenderUncommittedCardRequest,
    ) -> Result<anki_proto::card_rendering::RenderCardResponse>;
    fn render_uncommitted_card_legacy(
        &mut self,
        input: anki_proto::card_rendering::RenderUncommittedCardLegacyRequest,
    ) -> Result<anki_proto::card_rendering::RenderCardResponse>;
    fn strip_av_tags(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::String>;
    fn render_markdown(
        &mut self,
        input: anki_proto::card_rendering::RenderMarkdownRequest,
    ) -> Result<anki_proto::generic::String>;
    fn encode_iri_paths(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::String>;
    fn decode_iri_paths(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::String>;
    fn strip_html(
        &mut self,
        input: anki_proto::card_rendering::StripHtmlRequest,
    ) -> Result<anki_proto::generic::String>;
    fn html_to_text_line(
        &mut self,
        input: anki_proto::card_rendering::HtmlToTextLineRequest,
    ) -> Result<anki_proto::generic::String>;
    fn compare_answer(
        &mut self,
        input: anki_proto::card_rendering::CompareAnswerRequest,
    ) -> Result<anki_proto::generic::String>;
    fn extract_cloze_for_typing(
        &mut self,
        input: anki_proto::card_rendering::ExtractClozeForTypingRequest,
    ) -> Result<anki_proto::generic::String>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_card_rendering_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::card_rendering::ExtractAvTagsRequest::decode(
                    input,
                )?;
                let output = CardRenderingService::extract_av_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::card_rendering::ExtractLatexRequest::decode(
                    input,
                )?;
                let output = CardRenderingService::extract_latex(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let output = CardRenderingService::get_empty_cards(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::card_rendering::RenderExistingCardRequest::decode(
                    input,
                )?;
                let output = CardRenderingService::render_existing_card(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::card_rendering::RenderUncommittedCardRequest::decode(
                    input,
                )?;
                let output = CardRenderingService::render_uncommitted_card(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::card_rendering::RenderUncommittedCardLegacyRequest::decode(
                    input,
                )?;
                let output = CardRenderingService::render_uncommitted_card_legacy(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = CardRenderingService::strip_av_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::card_rendering::RenderMarkdownRequest::decode(
                    input,
                )?;
                let output = CardRenderingService::render_markdown(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = CardRenderingService::encode_iri_paths(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = CardRenderingService::decode_iri_paths(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::card_rendering::StripHtmlRequest::decode(input)?;
                let output = CardRenderingService::strip_html(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            11 => {
                let input = anki_proto::card_rendering::HtmlToTextLineRequest::decode(
                    input,
                )?;
                let output = CardRenderingService::html_to_text_line(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            12 => {
                let input = anki_proto::card_rendering::CompareAnswerRequest::decode(
                    input,
                )?;
                let output = CardRenderingService::compare_answer(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            13 => {
                let input = anki_proto::card_rendering::ExtractClozeForTypingRequest::decode(
                    input,
                )?;
                let output = CardRenderingService::extract_cloze_for_typing(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait SearchService {
    fn build_search_string(
        &mut self,
        input: anki_proto::search::SearchNode,
    ) -> Result<anki_proto::generic::String>;
    fn search_cards(
        &mut self,
        input: anki_proto::search::SearchRequest,
    ) -> Result<anki_proto::search::SearchResponse>;
    fn search_notes(
        &mut self,
        input: anki_proto::search::SearchRequest,
    ) -> Result<anki_proto::search::SearchResponse>;
    fn join_search_nodes(
        &mut self,
        input: anki_proto::search::JoinSearchNodesRequest,
    ) -> Result<anki_proto::generic::String>;
    fn replace_search_node(
        &mut self,
        input: anki_proto::search::ReplaceSearchNodeRequest,
    ) -> Result<anki_proto::generic::String>;
    fn find_and_replace(
        &mut self,
        input: anki_proto::search::FindAndReplaceRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn all_browser_columns(&mut self) -> Result<anki_proto::search::BrowserColumns>;
    fn browser_row_for_id(
        &mut self,
        input: anki_proto::generic::Int64,
    ) -> Result<anki_proto::search::BrowserRow>;
    fn set_active_browser_columns(
        &mut self,
        input: anki_proto::generic::StringList,
    ) -> Result<()>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_search_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::search::SearchNode::decode(input)?;
                let output = SearchService::build_search_string(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::search::SearchRequest::decode(input)?;
                let output = SearchService::search_cards(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::search::SearchRequest::decode(input)?;
                let output = SearchService::search_notes(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::search::JoinSearchNodesRequest::decode(input)?;
                let output = SearchService::join_search_nodes(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::search::ReplaceSearchNodeRequest::decode(input)?;
                let output = SearchService::replace_search_node(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::search::FindAndReplaceRequest::decode(input)?;
                let output = SearchService::find_and_replace(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let output = SearchService::all_browser_columns(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::generic::Int64::decode(input)?;
                let output = SearchService::browser_row_for_id(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::generic::StringList::decode(input)?;
                SearchService::set_active_browser_columns(self, input)?;
                Ok(Vec::new())
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait GithubService {}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_github_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait I18nService {
    fn translate_string(
        &mut self,
        input: anki_proto::i18n::TranslateStringRequest,
    ) -> Result<anki_proto::generic::String>;
    fn format_timespan(
        &mut self,
        input: anki_proto::i18n::FormatTimespanRequest,
    ) -> Result<anki_proto::generic::String>;
    fn i18n_resources(
        &mut self,
        input: anki_proto::i18n::I18nResourcesRequest,
    ) -> Result<anki_proto::generic::Json>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_i18n_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::i18n::TranslateStringRequest::decode(input)?;
                let output = I18nService::translate_string(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::i18n::FormatTimespanRequest::decode(input)?;
                let output = I18nService::format_timespan(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::i18n::I18nResourcesRequest::decode(input)?;
                let output = I18nService::i18n_resources(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait ImageOcclusionService {
    fn get_image_for_occlusion(
        &mut self,
        input: anki_proto::image_occlusion::GetImageForOcclusionRequest,
    ) -> Result<anki_proto::image_occlusion::GetImageForOcclusionResponse>;
    fn get_image_occlusion_note(
        &mut self,
        input: anki_proto::image_occlusion::GetImageOcclusionNoteRequest,
    ) -> Result<anki_proto::image_occlusion::GetImageOcclusionNoteResponse>;
    fn get_image_occlusion_fields(
        &mut self,
        input: anki_proto::image_occlusion::GetImageOcclusionFieldsRequest,
    ) -> Result<anki_proto::image_occlusion::GetImageOcclusionFieldsResponse>;
    fn add_image_occlusion_notetype(
        &mut self,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn add_image_occlusion_note(
        &mut self,
        input: anki_proto::image_occlusion::AddImageOcclusionNoteRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn update_image_occlusion_note(
        &mut self,
        input: anki_proto::image_occlusion::UpdateImageOcclusionNoteRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_image_occlusion_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::image_occlusion::GetImageForOcclusionRequest::decode(
                    input,
                )?;
                let output = ImageOcclusionService::get_image_for_occlusion(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::image_occlusion::GetImageOcclusionNoteRequest::decode(
                    input,
                )?;
                let output = ImageOcclusionService::get_image_occlusion_note(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::image_occlusion::GetImageOcclusionFieldsRequest::decode(
                    input,
                )?;
                let output = ImageOcclusionService::get_image_occlusion_fields(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let output = ImageOcclusionService::add_image_occlusion_notetype(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::image_occlusion::AddImageOcclusionNoteRequest::decode(
                    input,
                )?;
                let output = ImageOcclusionService::add_image_occlusion_note(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::image_occlusion::UpdateImageOcclusionNoteRequest::decode(
                    input,
                )?;
                let output = ImageOcclusionService::update_image_occlusion_note(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait ImportExportService {
    fn import_anki_package(
        &mut self,
        input: anki_proto::import_export::ImportAnkiPackageRequest,
    ) -> Result<anki_proto::import_export::ImportResponse>;
    fn get_import_anki_package_presets(
        &mut self,
    ) -> Result<anki_proto::import_export::ImportAnkiPackageOptions>;
    fn export_anki_package(
        &mut self,
        input: anki_proto::import_export::ExportAnkiPackageRequest,
    ) -> Result<anki_proto::generic::UInt32>;
    fn get_csv_metadata(
        &mut self,
        input: anki_proto::import_export::CsvMetadataRequest,
    ) -> Result<anki_proto::import_export::CsvMetadata>;
    fn import_csv(
        &mut self,
        input: anki_proto::import_export::ImportCsvRequest,
    ) -> Result<anki_proto::import_export::ImportResponse>;
    fn export_note_csv(
        &mut self,
        input: anki_proto::import_export::ExportNoteCsvRequest,
    ) -> Result<anki_proto::generic::UInt32>;
    fn export_card_csv(
        &mut self,
        input: anki_proto::import_export::ExportCardCsvRequest,
    ) -> Result<anki_proto::generic::UInt32>;
    fn import_json_file(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::import_export::ImportResponse>;
    fn import_json_string(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::import_export::ImportResponse>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_import_export_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::import_export::ImportAnkiPackageRequest::decode(
                    input,
                )?;
                let output = ImportExportService::import_anki_package(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let output = ImportExportService::get_import_anki_package_presets(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::import_export::ExportAnkiPackageRequest::decode(
                    input,
                )?;
                let output = ImportExportService::export_anki_package(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::import_export::CsvMetadataRequest::decode(
                    input,
                )?;
                let output = ImportExportService::get_csv_metadata(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::import_export::ImportCsvRequest::decode(input)?;
                let output = ImportExportService::import_csv(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::import_export::ExportNoteCsvRequest::decode(
                    input,
                )?;
                let output = ImportExportService::export_note_csv(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::import_export::ExportCardCsvRequest::decode(
                    input,
                )?;
                let output = ImportExportService::export_card_csv(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = ImportExportService::import_json_file(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = ImportExportService::import_json_string(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait MediaService {
    fn check_media(&mut self) -> Result<anki_proto::media::CheckMediaResponse>;
    fn add_media_file(
        &mut self,
        input: anki_proto::media::AddMediaFileRequest,
    ) -> Result<anki_proto::generic::String>;
    fn add_media_from_path(
        &mut self,
        input: anki_proto::media::AddMediaFromPathRequest,
    ) -> Result<anki_proto::generic::String>;
    fn trash_media_files(
        &mut self,
        input: anki_proto::media::TrashMediaFilesRequest,
    ) -> Result<()>;
    fn empty_trash(&mut self) -> Result<()>;
    fn restore_trash(&mut self) -> Result<()>;
    fn extract_static_media_files(
        &mut self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::generic::StringList>;
    fn extract_media_files(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::StringList>;
    fn get_absolute_media_path(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::String>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_media_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let output = MediaService::check_media(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::media::AddMediaFileRequest::decode(input)?;
                let output = MediaService::add_media_file(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::media::AddMediaFromPathRequest::decode(input)?;
                let output = MediaService::add_media_from_path(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::media::TrashMediaFilesRequest::decode(input)?;
                MediaService::trash_media_files(self, input)?;
                Ok(Vec::new())
            }
            4 => {
                MediaService::empty_trash(self)?;
                Ok(Vec::new())
            }
            5 => {
                MediaService::restore_trash(self)?;
                Ok(Vec::new())
            }
            6 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = MediaService::extract_static_media_files(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = MediaService::extract_media_files(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = MediaService::get_absolute_media_path(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait StatsService {
    fn card_stats(
        &mut self,
        input: anki_proto::cards::CardId,
    ) -> Result<anki_proto::stats::CardStatsResponse>;
    fn get_review_logs(
        &mut self,
        input: anki_proto::cards::CardId,
    ) -> Result<anki_proto::stats::ReviewLogs>;
    fn graphs(
        &mut self,
        input: anki_proto::stats::GraphsRequest,
    ) -> Result<anki_proto::stats::GraphsResponse>;
    fn get_graph_preferences(&mut self) -> Result<anki_proto::stats::GraphPreferences>;
    fn set_graph_preferences(
        &mut self,
        input: anki_proto::stats::GraphPreferences,
    ) -> Result<()>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_stats_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::cards::CardId::decode(input)?;
                let output = StatsService::card_stats(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::cards::CardId::decode(input)?;
                let output = StatsService::get_review_logs(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::stats::GraphsRequest::decode(input)?;
                let output = StatsService::graphs(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let output = StatsService::get_graph_preferences(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::stats::GraphPreferences::decode(input)?;
                StatsService::set_graph_preferences(self, input)?;
                Ok(Vec::new())
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait TagsService {
    fn clear_unused_tags(
        &mut self,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn all_tags(&mut self) -> Result<anki_proto::generic::StringList>;
    fn remove_tags(
        &mut self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn set_tag_collapsed(
        &mut self,
        input: anki_proto::tags::SetTagCollapsedRequest,
    ) -> Result<anki_proto::collection::OpChanges>;
    fn tag_tree(&mut self) -> Result<anki_proto::tags::TagTreeNode>;
    fn reparent_tags(
        &mut self,
        input: anki_proto::tags::ReparentTagsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn rename_tags(
        &mut self,
        input: anki_proto::tags::RenameTagsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn add_note_tags(
        &mut self,
        input: anki_proto::tags::NoteIdsAndTagsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn remove_note_tags(
        &mut self,
        input: anki_proto::tags::NoteIdsAndTagsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn find_and_replace_tag(
        &mut self,
        input: anki_proto::tags::FindAndReplaceTagRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount>;
    fn complete_tag(
        &mut self,
        input: anki_proto::tags::CompleteTagRequest,
    ) -> Result<anki_proto::tags::CompleteTagResponse>;
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::collection::Collection {
    pub(crate) fn run_tags_service_method(
        &mut self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let output = TagsService::clear_unused_tags(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let output = TagsService::all_tags(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = TagsService::remove_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::tags::SetTagCollapsedRequest::decode(input)?;
                let output = TagsService::set_tag_collapsed(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let output = TagsService::tag_tree(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::tags::ReparentTagsRequest::decode(input)?;
                let output = TagsService::reparent_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::tags::RenameTagsRequest::decode(input)?;
                let output = TagsService::rename_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::tags::NoteIdsAndTagsRequest::decode(input)?;
                let output = TagsService::add_note_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::tags::NoteIdsAndTagsRequest::decode(input)?;
                let output = TagsService::remove_note_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let input = anki_proto::tags::FindAndReplaceTagRequest::decode(input)?;
                let output = TagsService::find_and_replace_tag(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::tags::CompleteTagRequest::decode(input)?;
                let output = TagsService::complete_tag(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
impl crate::collection::Collection {
    pub fn run_service_method(
        &mut self,
        service: u32,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>, Vec<u8>> {
        match service {
            0 => self.run_sync_service_method(method, input),
            2 => self.run_collection_service_method(method, input),
            4 => self.run_cards_service_method(method, input),
            6 => self.run_decks_service_method(method, input),
            8 => self.run_config_service_method(method, input),
            10 => self.run_deck_config_service_method(method, input),
            12 => self.run_scheduler_service_method(method, input),
            14 => self.run_ankidroid_service_method(method, input),
            16 => self.run_anki_hub_service_method(method, input),
            18 => self.run_ankiweb_service_method(method, input),
            20 => self.run_links_service_method(method, input),
            22 => self.run_notetypes_service_method(method, input),
            24 => self.run_notes_service_method(method, input),
            26 => self.run_card_rendering_service_method(method, input),
            28 => self.run_search_service_method(method, input),
            32 => self.run_github_service_method(method, input),
            34 => self.run_i18n_service_method(method, input),
            36 => self.run_image_occlusion_service_method(method, input),
            38 => self.run_import_export_service_method(method, input),
            40 => self.run_media_service_method(method, input),
            42 => self.run_stats_service_method(method, input),
            44 => self.run_tags_service_method(method, input),
            _ => Err(crate::error::AnkiError::InvalidServiceIndex),
        }
            .map_err(|err| {
                let backend_err = err.into_protobuf(&self.tr);
                let mut bytes = Vec::new();
                backend_err.encode(&mut bytes).unwrap();
                bytes
            })
    }
}
pub trait BackendSyncService {
    fn sync_media(&self, input: anki_proto::sync::SyncAuth) -> Result<()>;
    fn abort_media_sync(&self) -> Result<()>;
    fn media_sync_status(&self) -> Result<anki_proto::sync::MediaSyncStatusResponse>;
    fn sync_login(
        &self,
        input: anki_proto::sync::SyncLoginRequest,
    ) -> Result<anki_proto::sync::SyncAuth>;
    fn sync_status(
        &self,
        input: anki_proto::sync::SyncAuth,
    ) -> Result<anki_proto::sync::SyncStatusResponse>;
    fn sync_collection(
        &self,
        input: anki_proto::sync::SyncCollectionRequest,
    ) -> Result<anki_proto::sync::SyncCollectionResponse>;
    fn full_upload_or_download(
        &self,
        input: anki_proto::sync::FullUploadOrDownloadRequest,
    ) -> Result<()>;
    fn abort_sync(&self) -> Result<()>;
    fn set_custom_certificate(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::Bool>;
}
impl crate::backend::Backend {}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_sync_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::sync::SyncAuth::decode(input)?;
                BackendSyncService::sync_media(self, input)?;
                Ok(Vec::new())
            }
            1 => {
                BackendSyncService::abort_media_sync(self)?;
                Ok(Vec::new())
            }
            2 => {
                let output = BackendSyncService::media_sync_status(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::sync::SyncLoginRequest::decode(input)?;
                let output = BackendSyncService::sync_login(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::sync::SyncAuth::decode(input)?;
                let output = BackendSyncService::sync_status(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::sync::SyncCollectionRequest::decode(input)?;
                let output = BackendSyncService::sync_collection(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::sync::FullUploadOrDownloadRequest::decode(
                    input,
                )?;
                BackendSyncService::full_upload_or_download(self, input)?;
                Ok(Vec::new())
            }
            7 => {
                BackendSyncService::abort_sync(self)?;
                Ok(Vec::new())
            }
            8 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = BackendSyncService::set_custom_certificate(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendCollectionService {
    fn open_collection(
        &self,
        input: anki_proto::collection::OpenCollectionRequest,
    ) -> Result<()>;
    fn close_collection(
        &self,
        input: anki_proto::collection::CloseCollectionRequest,
    ) -> Result<()>;
    fn create_backup(
        &self,
        input: anki_proto::collection::CreateBackupRequest,
    ) -> Result<anki_proto::generic::Bool>;
    fn await_backup_completion(&self) -> Result<()>;
    fn latest_progress(&self) -> Result<anki_proto::collection::Progress>;
    fn set_wants_abort(&self) -> Result<()>;
}
impl crate::backend::Backend {
    fn check_database(&self) -> Result<anki_proto::collection::CheckDatabaseResponse> {
        self.with_col(|col| CollectionService::check_database(col))
    }
    fn get_undo_status(&self) -> Result<anki_proto::collection::UndoStatus> {
        self.with_col(|col| CollectionService::get_undo_status(col))
    }
    fn undo(&self) -> Result<anki_proto::collection::OpChangesAfterUndo> {
        self.with_col(|col| CollectionService::undo(col))
    }
    fn redo(&self) -> Result<anki_proto::collection::OpChangesAfterUndo> {
        self.with_col(|col| CollectionService::redo(col))
    }
    fn add_custom_undo_entry(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::UInt32> {
        self.with_col(|col| CollectionService::add_custom_undo_entry(col, input))
    }
    fn merge_undo_entries(
        &self,
        input: anki_proto::generic::UInt32,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| CollectionService::merge_undo_entries(col, input))
    }
    fn set_load_balancer_enabled(
        &self,
        input: anki_proto::generic::Bool,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| CollectionService::set_load_balancer_enabled(col, input))
    }
    fn get_custom_colours(
        &self,
    ) -> Result<anki_proto::collection::GetCustomColoursResponse> {
        self.with_col(|col| CollectionService::get_custom_colours(col))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_collection_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::collection::OpenCollectionRequest::decode(
                    input,
                )?;
                BackendCollectionService::open_collection(self, input)?;
                Ok(Vec::new())
            }
            1 => {
                let input = anki_proto::collection::CloseCollectionRequest::decode(
                    input,
                )?;
                BackendCollectionService::close_collection(self, input)?;
                Ok(Vec::new())
            }
            2 => {
                let input = anki_proto::collection::CreateBackupRequest::decode(input)?;
                let output = BackendCollectionService::create_backup(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                BackendCollectionService::await_backup_completion(self)?;
                Ok(Vec::new())
            }
            4 => {
                let output = BackendCollectionService::latest_progress(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                BackendCollectionService::set_wants_abort(self)?;
                Ok(Vec::new())
            }
            6 => {
                let output = crate::backend::Backend::check_database(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let output = crate::backend::Backend::get_undo_status(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let output = crate::backend::Backend::undo(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let output = crate::backend::Backend::redo(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::add_custom_undo_entry(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            11 => {
                let input = anki_proto::generic::UInt32::decode(input)?;
                let output = crate::backend::Backend::merge_undo_entries(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            14 => {
                let input = anki_proto::generic::Bool::decode(input)?;
                let output = crate::backend::Backend::set_load_balancer_enabled(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            15 => {
                let output = crate::backend::Backend::get_custom_colours(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendCardsService {}
impl crate::backend::Backend {
    fn get_card(
        &self,
        input: anki_proto::cards::CardId,
    ) -> Result<anki_proto::cards::Card> {
        self.with_col(|col| CardsService::get_card(col, input))
    }
    fn update_cards(
        &self,
        input: anki_proto::cards::UpdateCardsRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| CardsService::update_cards(col, input))
    }
    fn remove_cards(
        &self,
        input: anki_proto::cards::RemoveCardsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| CardsService::remove_cards(col, input))
    }
    fn set_deck(
        &self,
        input: anki_proto::cards::SetDeckRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| CardsService::set_deck(col, input))
    }
    fn set_flag(
        &self,
        input: anki_proto::cards::SetFlagRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| CardsService::set_flag(col, input))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_cards_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::cards::CardId::decode(input)?;
                let output = crate::backend::Backend::get_card(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::cards::UpdateCardsRequest::decode(input)?;
                let output = crate::backend::Backend::update_cards(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::cards::RemoveCardsRequest::decode(input)?;
                let output = crate::backend::Backend::remove_cards(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::cards::SetDeckRequest::decode(input)?;
                let output = crate::backend::Backend::set_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::cards::SetFlagRequest::decode(input)?;
                let output = crate::backend::Backend::set_flag(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendDecksService {}
impl crate::backend::Backend {
    fn new_deck(&self) -> Result<anki_proto::decks::Deck> {
        self.with_col(|col| DecksService::new_deck(col))
    }
    fn add_deck(
        &self,
        input: anki_proto::decks::Deck,
    ) -> Result<anki_proto::collection::OpChangesWithId> {
        self.with_col(|col| DecksService::add_deck(col, input))
    }
    fn add_deck_legacy(
        &self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::collection::OpChangesWithId> {
        self.with_col(|col| DecksService::add_deck_legacy(col, input))
    }
    fn add_or_update_deck_legacy(
        &self,
        input: anki_proto::decks::AddOrUpdateDeckLegacyRequest,
    ) -> Result<anki_proto::decks::DeckId> {
        self.with_col(|col| DecksService::add_or_update_deck_legacy(col, input))
    }
    fn deck_tree(
        &self,
        input: anki_proto::decks::DeckTreeRequest,
    ) -> Result<anki_proto::decks::DeckTreeNode> {
        self.with_col(|col| DecksService::deck_tree(col, input))
    }
    fn deck_tree_legacy(&self) -> Result<anki_proto::generic::Json> {
        self.with_col(|col| DecksService::deck_tree_legacy(col))
    }
    fn get_all_decks_legacy(&self) -> Result<anki_proto::generic::Json> {
        self.with_col(|col| DecksService::get_all_decks_legacy(col))
    }
    fn get_deck_id_by_name(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::decks::DeckId> {
        self.with_col(|col| DecksService::get_deck_id_by_name(col, input))
    }
    fn get_deck(
        &self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::decks::Deck> {
        self.with_col(|col| DecksService::get_deck(col, input))
    }
    fn update_deck(
        &self,
        input: anki_proto::decks::Deck,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| DecksService::update_deck(col, input))
    }
    fn update_deck_legacy(
        &self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| DecksService::update_deck_legacy(col, input))
    }
    fn set_deck_collapsed(
        &self,
        input: anki_proto::decks::SetDeckCollapsedRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| DecksService::set_deck_collapsed(col, input))
    }
    fn get_deck_legacy(
        &self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::generic::Json> {
        self.with_col(|col| DecksService::get_deck_legacy(col, input))
    }
    fn get_deck_names(
        &self,
        input: anki_proto::decks::GetDeckNamesRequest,
    ) -> Result<anki_proto::decks::DeckNames> {
        self.with_col(|col| DecksService::get_deck_names(col, input))
    }
    fn get_deck_and_child_names(
        &self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::decks::DeckNames> {
        self.with_col(|col| DecksService::get_deck_and_child_names(col, input))
    }
    fn new_deck_legacy(
        &self,
        input: anki_proto::generic::Bool,
    ) -> Result<anki_proto::generic::Json> {
        self.with_col(|col| DecksService::new_deck_legacy(col, input))
    }
    fn remove_decks(
        &self,
        input: anki_proto::decks::DeckIds,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| DecksService::remove_decks(col, input))
    }
    fn reparent_decks(
        &self,
        input: anki_proto::decks::ReparentDecksRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| DecksService::reparent_decks(col, input))
    }
    fn rename_deck(
        &self,
        input: anki_proto::decks::RenameDeckRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| DecksService::rename_deck(col, input))
    }
    fn get_or_create_filtered_deck(
        &self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::decks::FilteredDeckForUpdate> {
        self.with_col(|col| DecksService::get_or_create_filtered_deck(col, input))
    }
    fn add_or_update_filtered_deck(
        &self,
        input: anki_proto::decks::FilteredDeckForUpdate,
    ) -> Result<anki_proto::collection::OpChangesWithId> {
        self.with_col(|col| DecksService::add_or_update_filtered_deck(col, input))
    }
    fn filtered_deck_order_labels(&self) -> Result<anki_proto::generic::StringList> {
        self.with_col(|col| DecksService::filtered_deck_order_labels(col))
    }
    fn set_current_deck(
        &self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| DecksService::set_current_deck(col, input))
    }
    fn get_current_deck(&self) -> Result<anki_proto::decks::Deck> {
        self.with_col(|col| DecksService::get_current_deck(col))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_decks_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let output = crate::backend::Backend::new_deck(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::decks::Deck::decode(input)?;
                let output = crate::backend::Backend::add_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = crate::backend::Backend::add_deck_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::decks::AddOrUpdateDeckLegacyRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::add_or_update_deck_legacy(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::decks::DeckTreeRequest::decode(input)?;
                let output = crate::backend::Backend::deck_tree(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let output = crate::backend::Backend::deck_tree_legacy(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let output = crate::backend::Backend::get_all_decks_legacy(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::get_deck_id_by_name(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = crate::backend::Backend::get_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let input = anki_proto::decks::Deck::decode(input)?;
                let output = crate::backend::Backend::update_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = crate::backend::Backend::update_deck_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            11 => {
                let input = anki_proto::decks::SetDeckCollapsedRequest::decode(input)?;
                let output = crate::backend::Backend::set_deck_collapsed(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            12 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = crate::backend::Backend::get_deck_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            13 => {
                let input = anki_proto::decks::GetDeckNamesRequest::decode(input)?;
                let output = crate::backend::Backend::get_deck_names(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            14 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = crate::backend::Backend::get_deck_and_child_names(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            15 => {
                let input = anki_proto::generic::Bool::decode(input)?;
                let output = crate::backend::Backend::new_deck_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            16 => {
                let input = anki_proto::decks::DeckIds::decode(input)?;
                let output = crate::backend::Backend::remove_decks(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            17 => {
                let input = anki_proto::decks::ReparentDecksRequest::decode(input)?;
                let output = crate::backend::Backend::reparent_decks(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            18 => {
                let input = anki_proto::decks::RenameDeckRequest::decode(input)?;
                let output = crate::backend::Backend::rename_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            19 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = crate::backend::Backend::get_or_create_filtered_deck(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            20 => {
                let input = anki_proto::decks::FilteredDeckForUpdate::decode(input)?;
                let output = crate::backend::Backend::add_or_update_filtered_deck(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            21 => {
                let output = crate::backend::Backend::filtered_deck_order_labels(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            22 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = crate::backend::Backend::set_current_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            23 => {
                let output = crate::backend::Backend::get_current_deck(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendConfigService {}
impl crate::backend::Backend {
    fn get_config_json(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::Json> {
        self.with_col(|col| ConfigService::get_config_json(col, input))
    }
    fn set_config_json(
        &self,
        input: anki_proto::config::SetConfigJsonRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| ConfigService::set_config_json(col, input))
    }
    fn set_config_json_no_undo(
        &self,
        input: anki_proto::config::SetConfigJsonRequest,
    ) -> Result<()> {
        self.with_col(|col| ConfigService::set_config_json_no_undo(col, input))
    }
    fn remove_config(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| ConfigService::remove_config(col, input))
    }
    fn get_all_config(&self) -> Result<anki_proto::generic::Json> {
        self.with_col(|col| ConfigService::get_all_config(col))
    }
    fn get_config_bool(
        &self,
        input: anki_proto::config::GetConfigBoolRequest,
    ) -> Result<anki_proto::generic::Bool> {
        self.with_col(|col| ConfigService::get_config_bool(col, input))
    }
    fn set_config_bool(
        &self,
        input: anki_proto::config::SetConfigBoolRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| ConfigService::set_config_bool(col, input))
    }
    fn get_config_string(
        &self,
        input: anki_proto::config::GetConfigStringRequest,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| ConfigService::get_config_string(col, input))
    }
    fn set_config_string(
        &self,
        input: anki_proto::config::SetConfigStringRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| ConfigService::set_config_string(col, input))
    }
    fn get_preferences(&self) -> Result<anki_proto::config::Preferences> {
        self.with_col(|col| ConfigService::get_preferences(col))
    }
    fn set_preferences(
        &self,
        input: anki_proto::config::Preferences,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| ConfigService::set_preferences(col, input))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_config_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::get_config_json(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::config::SetConfigJsonRequest::decode(input)?;
                let output = crate::backend::Backend::set_config_json(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::config::SetConfigJsonRequest::decode(input)?;
                crate::backend::Backend::set_config_json_no_undo(self, input)?;
                Ok(Vec::new())
            }
            3 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::remove_config(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let output = crate::backend::Backend::get_all_config(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::config::GetConfigBoolRequest::decode(input)?;
                let output = crate::backend::Backend::get_config_bool(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::config::SetConfigBoolRequest::decode(input)?;
                let output = crate::backend::Backend::set_config_bool(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::config::GetConfigStringRequest::decode(input)?;
                let output = crate::backend::Backend::get_config_string(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::config::SetConfigStringRequest::decode(input)?;
                let output = crate::backend::Backend::set_config_string(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let output = crate::backend::Backend::get_preferences(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::config::Preferences::decode(input)?;
                let output = crate::backend::Backend::set_preferences(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendDeckConfigService {}
impl crate::backend::Backend {
    fn add_or_update_deck_config_legacy(
        &self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::deck_config::DeckConfigId> {
        self.with_col(|col| DeckConfigService::add_or_update_deck_config_legacy(
            col,
            input,
        ))
    }
    fn get_deck_config(
        &self,
        input: anki_proto::deck_config::DeckConfigId,
    ) -> Result<anki_proto::deck_config::DeckConfig> {
        self.with_col(|col| DeckConfigService::get_deck_config(col, input))
    }
    fn all_deck_config_legacy(&self) -> Result<anki_proto::generic::Json> {
        self.with_col(|col| DeckConfigService::all_deck_config_legacy(col))
    }
    fn get_deck_config_legacy(
        &self,
        input: anki_proto::deck_config::DeckConfigId,
    ) -> Result<anki_proto::generic::Json> {
        self.with_col(|col| DeckConfigService::get_deck_config_legacy(col, input))
    }
    fn new_deck_config_legacy(&self) -> Result<anki_proto::generic::Json> {
        self.with_col(|col| DeckConfigService::new_deck_config_legacy(col))
    }
    fn remove_deck_config(
        &self,
        input: anki_proto::deck_config::DeckConfigId,
    ) -> Result<()> {
        self.with_col(|col| DeckConfigService::remove_deck_config(col, input))
    }
    fn get_deck_configs_for_update(
        &self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::deck_config::DeckConfigsForUpdate> {
        self.with_col(|col| DeckConfigService::get_deck_configs_for_update(col, input))
    }
    fn update_deck_configs(
        &self,
        input: anki_proto::deck_config::UpdateDeckConfigsRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| DeckConfigService::update_deck_configs(col, input))
    }
    fn get_ignored_before_count(
        &self,
        input: anki_proto::deck_config::GetIgnoredBeforeCountRequest,
    ) -> Result<anki_proto::deck_config::GetIgnoredBeforeCountResponse> {
        self.with_col(|col| DeckConfigService::get_ignored_before_count(col, input))
    }
    fn get_retention_workload(
        &self,
        input: anki_proto::deck_config::GetRetentionWorkloadRequest,
    ) -> Result<anki_proto::deck_config::GetRetentionWorkloadResponse> {
        self.with_col(|col| DeckConfigService::get_retention_workload(col, input))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_deck_config_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = crate::backend::Backend::add_or_update_deck_config_legacy(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::deck_config::DeckConfigId::decode(input)?;
                let output = crate::backend::Backend::get_deck_config(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let output = crate::backend::Backend::all_deck_config_legacy(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::deck_config::DeckConfigId::decode(input)?;
                let output = crate::backend::Backend::get_deck_config_legacy(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let output = crate::backend::Backend::new_deck_config_legacy(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::deck_config::DeckConfigId::decode(input)?;
                crate::backend::Backend::remove_deck_config(self, input)?;
                Ok(Vec::new())
            }
            6 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = crate::backend::Backend::get_deck_configs_for_update(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::deck_config::UpdateDeckConfigsRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::update_deck_configs(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::deck_config::GetIgnoredBeforeCountRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::get_ignored_before_count(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let input = anki_proto::deck_config::GetRetentionWorkloadRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::get_retention_workload(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendSchedulerService {
    fn compute_fsrs_params_from_items(
        &self,
        input: anki_proto::scheduler::ComputeFsrsParamsFromItemsRequest,
    ) -> Result<anki_proto::scheduler::ComputeFsrsParamsResponse>;
    fn fsrs_benchmark(
        &self,
        input: anki_proto::scheduler::FsrsBenchmarkRequest,
    ) -> Result<anki_proto::scheduler::FsrsBenchmarkResponse>;
    fn export_dataset(
        &self,
        input: anki_proto::scheduler::ExportDatasetRequest,
    ) -> Result<()>;
}
impl crate::backend::Backend {
    fn get_queued_cards(
        &self,
        input: anki_proto::scheduler::GetQueuedCardsRequest,
    ) -> Result<anki_proto::scheduler::QueuedCards> {
        self.with_col(|col| SchedulerService::get_queued_cards(col, input))
    }
    fn answer_card(
        &self,
        input: anki_proto::scheduler::CardAnswer,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| SchedulerService::answer_card(col, input))
    }
    fn sched_timing_today(
        &self,
    ) -> Result<anki_proto::scheduler::SchedTimingTodayResponse> {
        self.with_col(|col| SchedulerService::sched_timing_today(col))
    }
    fn studied_today(&self) -> Result<anki_proto::generic::String> {
        self.with_col(|col| SchedulerService::studied_today(col))
    }
    fn studied_today_message(
        &self,
        input: anki_proto::scheduler::StudiedTodayMessageRequest,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| SchedulerService::studied_today_message(col, input))
    }
    fn update_stats(
        &self,
        input: anki_proto::scheduler::UpdateStatsRequest,
    ) -> Result<()> {
        self.with_col(|col| SchedulerService::update_stats(col, input))
    }
    fn extend_limits(
        &self,
        input: anki_proto::scheduler::ExtendLimitsRequest,
    ) -> Result<()> {
        self.with_col(|col| SchedulerService::extend_limits(col, input))
    }
    fn counts_for_deck_today(
        &self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::scheduler::CountsForDeckTodayResponse> {
        self.with_col(|col| SchedulerService::counts_for_deck_today(col, input))
    }
    fn congrats_info(&self) -> Result<anki_proto::scheduler::CongratsInfoResponse> {
        self.with_col(|col| SchedulerService::congrats_info(col))
    }
    fn restore_buried_and_suspended_cards(
        &self,
        input: anki_proto::cards::CardIds,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| SchedulerService::restore_buried_and_suspended_cards(
            col,
            input,
        ))
    }
    fn unbury_deck(
        &self,
        input: anki_proto::scheduler::UnburyDeckRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| SchedulerService::unbury_deck(col, input))
    }
    fn bury_or_suspend_cards(
        &self,
        input: anki_proto::scheduler::BuryOrSuspendCardsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| SchedulerService::bury_or_suspend_cards(col, input))
    }
    fn empty_filtered_deck(
        &self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| SchedulerService::empty_filtered_deck(col, input))
    }
    fn rebuild_filtered_deck(
        &self,
        input: anki_proto::decks::DeckId,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| SchedulerService::rebuild_filtered_deck(col, input))
    }
    fn schedule_cards_as_new(
        &self,
        input: anki_proto::scheduler::ScheduleCardsAsNewRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| SchedulerService::schedule_cards_as_new(col, input))
    }
    fn schedule_cards_as_new_defaults(
        &self,
        input: anki_proto::scheduler::ScheduleCardsAsNewDefaultsRequest,
    ) -> Result<anki_proto::scheduler::ScheduleCardsAsNewDefaultsResponse> {
        self.with_col(|col| SchedulerService::schedule_cards_as_new_defaults(col, input))
    }
    fn set_due_date(
        &self,
        input: anki_proto::scheduler::SetDueDateRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| SchedulerService::set_due_date(col, input))
    }
    fn grade_now(
        &self,
        input: anki_proto::scheduler::GradeNowRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| SchedulerService::grade_now(col, input))
    }
    fn sort_cards(
        &self,
        input: anki_proto::scheduler::SortCardsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| SchedulerService::sort_cards(col, input))
    }
    fn sort_deck(
        &self,
        input: anki_proto::scheduler::SortDeckRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| SchedulerService::sort_deck(col, input))
    }
    fn get_scheduling_states(
        &self,
        input: anki_proto::cards::CardId,
    ) -> Result<anki_proto::scheduler::SchedulingStates> {
        self.with_col(|col| SchedulerService::get_scheduling_states(col, input))
    }
    fn describe_next_states(
        &self,
        input: anki_proto::scheduler::SchedulingStates,
    ) -> Result<anki_proto::generic::StringList> {
        self.with_col(|col| SchedulerService::describe_next_states(col, input))
    }
    fn state_is_leech(
        &self,
        input: anki_proto::scheduler::SchedulingState,
    ) -> Result<anki_proto::generic::Bool> {
        self.with_col(|col| SchedulerService::state_is_leech(col, input))
    }
    fn upgrade_scheduler(&self) -> Result<()> {
        self.with_col(|col| SchedulerService::upgrade_scheduler(col))
    }
    fn custom_study(
        &self,
        input: anki_proto::scheduler::CustomStudyRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| SchedulerService::custom_study(col, input))
    }
    fn custom_study_defaults(
        &self,
        input: anki_proto::scheduler::CustomStudyDefaultsRequest,
    ) -> Result<anki_proto::scheduler::CustomStudyDefaultsResponse> {
        self.with_col(|col| SchedulerService::custom_study_defaults(col, input))
    }
    fn reposition_defaults(
        &self,
    ) -> Result<anki_proto::scheduler::RepositionDefaultsResponse> {
        self.with_col(|col| SchedulerService::reposition_defaults(col))
    }
    fn compute_fsrs_params(
        &self,
        input: anki_proto::scheduler::ComputeFsrsParamsRequest,
    ) -> Result<anki_proto::scheduler::ComputeFsrsParamsResponse> {
        self.with_col(|col| SchedulerService::compute_fsrs_params(col, input))
    }
    fn get_optimal_retention_parameters(
        &self,
        input: anki_proto::scheduler::GetOptimalRetentionParametersRequest,
    ) -> Result<anki_proto::scheduler::GetOptimalRetentionParametersResponse> {
        self.with_col(|col| SchedulerService::get_optimal_retention_parameters(
            col,
            input,
        ))
    }
    fn compute_optimal_retention(
        &self,
        input: anki_proto::scheduler::SimulateFsrsReviewRequest,
    ) -> Result<anki_proto::scheduler::ComputeOptimalRetentionResponse> {
        self.with_col(|col| SchedulerService::compute_optimal_retention(col, input))
    }
    fn simulate_fsrs_review(
        &self,
        input: anki_proto::scheduler::SimulateFsrsReviewRequest,
    ) -> Result<anki_proto::scheduler::SimulateFsrsReviewResponse> {
        self.with_col(|col| SchedulerService::simulate_fsrs_review(col, input))
    }
    fn simulate_fsrs_workload(
        &self,
        input: anki_proto::scheduler::SimulateFsrsReviewRequest,
    ) -> Result<anki_proto::scheduler::SimulateFsrsWorkloadResponse> {
        self.with_col(|col| SchedulerService::simulate_fsrs_workload(col, input))
    }
    fn evaluate_params(
        &self,
        input: anki_proto::scheduler::EvaluateParamsRequest,
    ) -> Result<anki_proto::scheduler::EvaluateParamsResponse> {
        self.with_col(|col| SchedulerService::evaluate_params(col, input))
    }
    fn evaluate_params_legacy(
        &self,
        input: anki_proto::scheduler::EvaluateParamsLegacyRequest,
    ) -> Result<anki_proto::scheduler::EvaluateParamsResponse> {
        self.with_col(|col| SchedulerService::evaluate_params_legacy(col, input))
    }
    fn compute_memory_state(
        &self,
        input: anki_proto::cards::CardId,
    ) -> Result<anki_proto::scheduler::ComputeMemoryStateResponse> {
        self.with_col(|col| SchedulerService::compute_memory_state(col, input))
    }
    fn fuzz_delta(
        &self,
        input: anki_proto::scheduler::FuzzDeltaRequest,
    ) -> Result<anki_proto::scheduler::FuzzDeltaResponse> {
        self.with_col(|col| SchedulerService::fuzz_delta(col, input))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_scheduler_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::scheduler::ComputeFsrsParamsFromItemsRequest::decode(
                    input,
                )?;
                let output = BackendSchedulerService::compute_fsrs_params_from_items(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::scheduler::FsrsBenchmarkRequest::decode(input)?;
                let output = BackendSchedulerService::fsrs_benchmark(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::scheduler::ExportDatasetRequest::decode(input)?;
                BackendSchedulerService::export_dataset(self, input)?;
                Ok(Vec::new())
            }
            3 => {
                let input = anki_proto::scheduler::GetQueuedCardsRequest::decode(input)?;
                let output = crate::backend::Backend::get_queued_cards(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::scheduler::CardAnswer::decode(input)?;
                let output = crate::backend::Backend::answer_card(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let output = crate::backend::Backend::sched_timing_today(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let output = crate::backend::Backend::studied_today(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::scheduler::StudiedTodayMessageRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::studied_today_message(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::scheduler::UpdateStatsRequest::decode(input)?;
                crate::backend::Backend::update_stats(self, input)?;
                Ok(Vec::new())
            }
            9 => {
                let input = anki_proto::scheduler::ExtendLimitsRequest::decode(input)?;
                crate::backend::Backend::extend_limits(self, input)?;
                Ok(Vec::new())
            }
            10 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = crate::backend::Backend::counts_for_deck_today(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            11 => {
                let output = crate::backend::Backend::congrats_info(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            12 => {
                let input = anki_proto::cards::CardIds::decode(input)?;
                let output = crate::backend::Backend::restore_buried_and_suspended_cards(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            13 => {
                let input = anki_proto::scheduler::UnburyDeckRequest::decode(input)?;
                let output = crate::backend::Backend::unbury_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            14 => {
                let input = anki_proto::scheduler::BuryOrSuspendCardsRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::bury_or_suspend_cards(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            15 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = crate::backend::Backend::empty_filtered_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            16 => {
                let input = anki_proto::decks::DeckId::decode(input)?;
                let output = crate::backend::Backend::rebuild_filtered_deck(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            17 => {
                let input = anki_proto::scheduler::ScheduleCardsAsNewRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::schedule_cards_as_new(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            18 => {
                let input = anki_proto::scheduler::ScheduleCardsAsNewDefaultsRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::schedule_cards_as_new_defaults(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            19 => {
                let input = anki_proto::scheduler::SetDueDateRequest::decode(input)?;
                let output = crate::backend::Backend::set_due_date(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            20 => {
                let input = anki_proto::scheduler::GradeNowRequest::decode(input)?;
                let output = crate::backend::Backend::grade_now(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            21 => {
                let input = anki_proto::scheduler::SortCardsRequest::decode(input)?;
                let output = crate::backend::Backend::sort_cards(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            22 => {
                let input = anki_proto::scheduler::SortDeckRequest::decode(input)?;
                let output = crate::backend::Backend::sort_deck(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            23 => {
                let input = anki_proto::cards::CardId::decode(input)?;
                let output = crate::backend::Backend::get_scheduling_states(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            24 => {
                let input = anki_proto::scheduler::SchedulingStates::decode(input)?;
                let output = crate::backend::Backend::describe_next_states(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            25 => {
                let input = anki_proto::scheduler::SchedulingState::decode(input)?;
                let output = crate::backend::Backend::state_is_leech(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            26 => {
                crate::backend::Backend::upgrade_scheduler(self)?;
                Ok(Vec::new())
            }
            27 => {
                let input = anki_proto::scheduler::CustomStudyRequest::decode(input)?;
                let output = crate::backend::Backend::custom_study(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            28 => {
                let input = anki_proto::scheduler::CustomStudyDefaultsRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::custom_study_defaults(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            29 => {
                let output = crate::backend::Backend::reposition_defaults(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            30 => {
                let input = anki_proto::scheduler::ComputeFsrsParamsRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::compute_fsrs_params(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            31 => {
                let input = anki_proto::scheduler::GetOptimalRetentionParametersRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::get_optimal_retention_parameters(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            32 => {
                let input = anki_proto::scheduler::SimulateFsrsReviewRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::compute_optimal_retention(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            33 => {
                let input = anki_proto::scheduler::SimulateFsrsReviewRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::simulate_fsrs_review(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            34 => {
                let input = anki_proto::scheduler::SimulateFsrsReviewRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::simulate_fsrs_workload(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            35 => {
                let input = anki_proto::scheduler::EvaluateParamsRequest::decode(input)?;
                let output = crate::backend::Backend::evaluate_params(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            36 => {
                let input = anki_proto::scheduler::EvaluateParamsLegacyRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::evaluate_params_legacy(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            37 => {
                let input = anki_proto::cards::CardId::decode(input)?;
                let output = crate::backend::Backend::compute_memory_state(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            38 => {
                let input = anki_proto::scheduler::FuzzDeltaRequest::decode(input)?;
                let output = crate::backend::Backend::fuzz_delta(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendAnkidroidService {
    fn sched_timing_today_legacy(
        &self,
        input: anki_proto::ankidroid::SchedTimingTodayLegacyRequest,
    ) -> Result<anki_proto::scheduler::SchedTimingTodayResponse>;
    fn local_minutes_west_legacy(
        &self,
        input: anki_proto::generic::Int64,
    ) -> Result<anki_proto::generic::Int32>;
    fn set_page_size(&self, input: anki_proto::generic::Int64) -> Result<()>;
    fn debug_produce_error(&self, input: anki_proto::generic::String) -> Result<()>;
}
impl crate::backend::Backend {
    fn run_db_command(
        &self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::generic::Json> {
        self.with_col(|col| AnkidroidService::run_db_command(col, input))
    }
    fn run_db_command_proto(
        &self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::ankidroid::DbResponse> {
        self.with_col(|col| AnkidroidService::run_db_command_proto(col, input))
    }
    fn insert_for_id(
        &self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::generic::Int64> {
        self.with_col(|col| AnkidroidService::insert_for_id(col, input))
    }
    fn run_db_command_for_row_count(
        &self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::generic::Int64> {
        self.with_col(|col| AnkidroidService::run_db_command_for_row_count(col, input))
    }
    fn flush_all_queries(&self) -> Result<()> {
        self.with_col(|col| AnkidroidService::flush_all_queries(col))
    }
    fn flush_query(&self, input: anki_proto::generic::Int32) -> Result<()> {
        self.with_col(|col| AnkidroidService::flush_query(col, input))
    }
    fn get_next_result_page(
        &self,
        input: anki_proto::ankidroid::GetNextResultPageRequest,
    ) -> Result<anki_proto::ankidroid::DbResponse> {
        self.with_col(|col| AnkidroidService::get_next_result_page(col, input))
    }
    fn get_column_names_from_query(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::StringList> {
        self.with_col(|col| AnkidroidService::get_column_names_from_query(col, input))
    }
    fn get_active_sequence_numbers(
        &self,
    ) -> Result<anki_proto::ankidroid::GetActiveSequenceNumbersResponse> {
        self.with_col(|col| AnkidroidService::get_active_sequence_numbers(col))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_ankidroid_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::ankidroid::SchedTimingTodayLegacyRequest::decode(
                    input,
                )?;
                let output = BackendAnkidroidService::sched_timing_today_legacy(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::generic::Int64::decode(input)?;
                let output = BackendAnkidroidService::local_minutes_west_legacy(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::generic::Int64::decode(input)?;
                BackendAnkidroidService::set_page_size(self, input)?;
                Ok(Vec::new())
            }
            3 => {
                let input = anki_proto::generic::String::decode(input)?;
                BackendAnkidroidService::debug_produce_error(self, input)?;
                Ok(Vec::new())
            }
            4 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = crate::backend::Backend::run_db_command(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = crate::backend::Backend::run_db_command_proto(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = crate::backend::Backend::insert_for_id(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = crate::backend::Backend::run_db_command_for_row_count(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                crate::backend::Backend::flush_all_queries(self)?;
                Ok(Vec::new())
            }
            9 => {
                let input = anki_proto::generic::Int32::decode(input)?;
                crate::backend::Backend::flush_query(self, input)?;
                Ok(Vec::new())
            }
            10 => {
                let input = anki_proto::ankidroid::GetNextResultPageRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::get_next_result_page(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            11 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::get_column_names_from_query(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            12 => {
                let output = crate::backend::Backend::get_active_sequence_numbers(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendAnkiHubService {
    fn ankihub_login(
        &self,
        input: anki_proto::ankihub::LoginRequest,
    ) -> Result<anki_proto::ankihub::LoginResponse>;
    fn ankihub_logout(&self, input: anki_proto::ankihub::LogoutRequest) -> Result<()>;
}
impl crate::backend::Backend {}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_anki_hub_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::ankihub::LoginRequest::decode(input)?;
                let output = BackendAnkiHubService::ankihub_login(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::ankihub::LogoutRequest::decode(input)?;
                BackendAnkiHubService::ankihub_logout(self, input)?;
                Ok(Vec::new())
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendAnkiwebService {
    fn get_addon_info(
        &self,
        input: anki_proto::ankiweb::GetAddonInfoRequest,
    ) -> Result<anki_proto::ankiweb::GetAddonInfoResponse>;
    fn check_for_update(
        &self,
        input: anki_proto::ankiweb::CheckForUpdateRequest,
    ) -> Result<anki_proto::ankiweb::CheckForUpdateResponse>;
}
impl crate::backend::Backend {}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_ankiweb_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::ankiweb::GetAddonInfoRequest::decode(input)?;
                let output = BackendAnkiwebService::get_addon_info(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::ankiweb::CheckForUpdateRequest::decode(input)?;
                let output = BackendAnkiwebService::check_for_update(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendLinksService {}
impl crate::backend::Backend {
    fn help_page_link(
        &self,
        input: anki_proto::links::HelpPageLinkRequest,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| LinksService::help_page_link(col, input))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_links_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::links::HelpPageLinkRequest::decode(input)?;
                let output = crate::backend::Backend::help_page_link(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendNotetypesService {}
impl crate::backend::Backend {
    fn add_notetype(
        &self,
        input: anki_proto::notetypes::Notetype,
    ) -> Result<anki_proto::collection::OpChangesWithId> {
        self.with_col(|col| NotetypesService::add_notetype(col, input))
    }
    fn update_notetype(
        &self,
        input: anki_proto::notetypes::Notetype,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| NotetypesService::update_notetype(col, input))
    }
    fn add_notetype_legacy(
        &self,
        input: anki_proto::generic::Json,
    ) -> Result<anki_proto::collection::OpChangesWithId> {
        self.with_col(|col| NotetypesService::add_notetype_legacy(col, input))
    }
    fn update_notetype_legacy(
        &self,
        input: anki_proto::notetypes::UpdateNotetypeLegacyRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| NotetypesService::update_notetype_legacy(col, input))
    }
    fn add_or_update_notetype(
        &self,
        input: anki_proto::notetypes::AddOrUpdateNotetypeRequest,
    ) -> Result<anki_proto::notetypes::NotetypeId> {
        self.with_col(|col| NotetypesService::add_or_update_notetype(col, input))
    }
    fn get_stock_notetype_legacy(
        &self,
        input: anki_proto::notetypes::StockNotetype,
    ) -> Result<anki_proto::generic::Json> {
        self.with_col(|col| NotetypesService::get_stock_notetype_legacy(col, input))
    }
    fn get_notetype(
        &self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::notetypes::Notetype> {
        self.with_col(|col| NotetypesService::get_notetype(col, input))
    }
    fn get_notetype_legacy(
        &self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::generic::Json> {
        self.with_col(|col| NotetypesService::get_notetype_legacy(col, input))
    }
    fn get_notetype_names(&self) -> Result<anki_proto::notetypes::NotetypeNames> {
        self.with_col(|col| NotetypesService::get_notetype_names(col))
    }
    fn get_notetype_names_and_counts(
        &self,
    ) -> Result<anki_proto::notetypes::NotetypeUseCounts> {
        self.with_col(|col| NotetypesService::get_notetype_names_and_counts(col))
    }
    fn get_notetype_id_by_name(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::notetypes::NotetypeId> {
        self.with_col(|col| NotetypesService::get_notetype_id_by_name(col, input))
    }
    fn remove_notetype(
        &self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| NotetypesService::remove_notetype(col, input))
    }
    fn get_aux_notetype_config_key(
        &self,
        input: anki_proto::notetypes::GetAuxConfigKeyRequest,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| NotetypesService::get_aux_notetype_config_key(col, input))
    }
    fn get_aux_template_config_key(
        &self,
        input: anki_proto::notetypes::GetAuxTemplateConfigKeyRequest,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| NotetypesService::get_aux_template_config_key(col, input))
    }
    fn get_change_notetype_info(
        &self,
        input: anki_proto::notetypes::GetChangeNotetypeInfoRequest,
    ) -> Result<anki_proto::notetypes::ChangeNotetypeInfo> {
        self.with_col(|col| NotetypesService::get_change_notetype_info(col, input))
    }
    fn change_notetype(
        &self,
        input: anki_proto::notetypes::ChangeNotetypeRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| NotetypesService::change_notetype(col, input))
    }
    fn get_field_names(
        &self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::generic::StringList> {
        self.with_col(|col| NotetypesService::get_field_names(col, input))
    }
    fn restore_notetype_to_stock(
        &self,
        input: anki_proto::notetypes::RestoreNotetypeToStockRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| NotetypesService::restore_notetype_to_stock(col, input))
    }
    fn get_cloze_field_ords(
        &self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::notetypes::GetClozeFieldOrdsResponse> {
        self.with_col(|col| NotetypesService::get_cloze_field_ords(col, input))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_notetypes_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::notetypes::Notetype::decode(input)?;
                let output = crate::backend::Backend::add_notetype(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::notetypes::Notetype::decode(input)?;
                let output = crate::backend::Backend::update_notetype(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::generic::Json::decode(input)?;
                let output = crate::backend::Backend::add_notetype_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::notetypes::UpdateNotetypeLegacyRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::update_notetype_legacy(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::notetypes::AddOrUpdateNotetypeRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::add_or_update_notetype(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::notetypes::StockNotetype::decode(input)?;
                let output = crate::backend::Backend::get_stock_notetype_legacy(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = crate::backend::Backend::get_notetype(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = crate::backend::Backend::get_notetype_legacy(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let output = crate::backend::Backend::get_notetype_names(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let output = crate::backend::Backend::get_notetype_names_and_counts(
                    self,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::get_notetype_id_by_name(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            11 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = crate::backend::Backend::remove_notetype(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            12 => {
                let input = anki_proto::notetypes::GetAuxConfigKeyRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::get_aux_notetype_config_key(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            13 => {
                let input = anki_proto::notetypes::GetAuxTemplateConfigKeyRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::get_aux_template_config_key(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            14 => {
                let input = anki_proto::notetypes::GetChangeNotetypeInfoRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::get_change_notetype_info(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            15 => {
                let input = anki_proto::notetypes::ChangeNotetypeRequest::decode(input)?;
                let output = crate::backend::Backend::change_notetype(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            16 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = crate::backend::Backend::get_field_names(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            17 => {
                let input = anki_proto::notetypes::RestoreNotetypeToStockRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::restore_notetype_to_stock(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            18 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = crate::backend::Backend::get_cloze_field_ords(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendNotesService {}
impl crate::backend::Backend {
    fn new_note(
        &self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::notes::Note> {
        self.with_col(|col| NotesService::new_note(col, input))
    }
    fn add_note(
        &self,
        input: anki_proto::notes::AddNoteRequest,
    ) -> Result<anki_proto::notes::AddNoteResponse> {
        self.with_col(|col| NotesService::add_note(col, input))
    }
    fn add_notes(
        &self,
        input: anki_proto::notes::AddNotesRequest,
    ) -> Result<anki_proto::notes::AddNotesResponse> {
        self.with_col(|col| NotesService::add_notes(col, input))
    }
    fn defaults_for_adding(
        &self,
        input: anki_proto::notes::DefaultsForAddingRequest,
    ) -> Result<anki_proto::notes::DeckAndNotetype> {
        self.with_col(|col| NotesService::defaults_for_adding(col, input))
    }
    fn default_deck_for_notetype(
        &self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::decks::DeckId> {
        self.with_col(|col| NotesService::default_deck_for_notetype(col, input))
    }
    fn update_notes(
        &self,
        input: anki_proto::notes::UpdateNotesRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| NotesService::update_notes(col, input))
    }
    fn get_note(
        &self,
        input: anki_proto::notes::NoteId,
    ) -> Result<anki_proto::notes::Note> {
        self.with_col(|col| NotesService::get_note(col, input))
    }
    fn remove_notes(
        &self,
        input: anki_proto::notes::RemoveNotesRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| NotesService::remove_notes(col, input))
    }
    fn cloze_numbers_in_note(
        &self,
        input: anki_proto::notes::Note,
    ) -> Result<anki_proto::notes::ClozeNumbersInNoteResponse> {
        self.with_col(|col| NotesService::cloze_numbers_in_note(col, input))
    }
    fn after_note_updates(
        &self,
        input: anki_proto::notes::AfterNoteUpdatesRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| NotesService::after_note_updates(col, input))
    }
    fn field_names_for_notes(
        &self,
        input: anki_proto::notes::FieldNamesForNotesRequest,
    ) -> Result<anki_proto::notes::FieldNamesForNotesResponse> {
        self.with_col(|col| NotesService::field_names_for_notes(col, input))
    }
    fn note_fields_check(
        &self,
        input: anki_proto::notes::Note,
    ) -> Result<anki_proto::notes::NoteFieldsCheckResponse> {
        self.with_col(|col| NotesService::note_fields_check(col, input))
    }
    fn cards_of_note(
        &self,
        input: anki_proto::notes::NoteId,
    ) -> Result<anki_proto::cards::CardIds> {
        self.with_col(|col| NotesService::cards_of_note(col, input))
    }
    fn get_single_notetype_of_notes(
        &self,
        input: anki_proto::notes::NoteIds,
    ) -> Result<anki_proto::notetypes::NotetypeId> {
        self.with_col(|col| NotesService::get_single_notetype_of_notes(col, input))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_notes_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = crate::backend::Backend::new_note(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::notes::AddNoteRequest::decode(input)?;
                let output = crate::backend::Backend::add_note(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::notes::AddNotesRequest::decode(input)?;
                let output = crate::backend::Backend::add_notes(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::notes::DefaultsForAddingRequest::decode(input)?;
                let output = crate::backend::Backend::defaults_for_adding(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = crate::backend::Backend::default_deck_for_notetype(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::notes::UpdateNotesRequest::decode(input)?;
                let output = crate::backend::Backend::update_notes(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::notes::NoteId::decode(input)?;
                let output = crate::backend::Backend::get_note(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::notes::RemoveNotesRequest::decode(input)?;
                let output = crate::backend::Backend::remove_notes(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::notes::Note::decode(input)?;
                let output = crate::backend::Backend::cloze_numbers_in_note(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let input = anki_proto::notes::AfterNoteUpdatesRequest::decode(input)?;
                let output = crate::backend::Backend::after_note_updates(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::notes::FieldNamesForNotesRequest::decode(input)?;
                let output = crate::backend::Backend::field_names_for_notes(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            11 => {
                let input = anki_proto::notes::Note::decode(input)?;
                let output = crate::backend::Backend::note_fields_check(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            12 => {
                let input = anki_proto::notes::NoteId::decode(input)?;
                let output = crate::backend::Backend::cards_of_note(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            13 => {
                let input = anki_proto::notes::NoteIds::decode(input)?;
                let output = crate::backend::Backend::get_single_notetype_of_notes(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendCardRenderingService {
    fn strip_html(
        &self,
        input: anki_proto::card_rendering::StripHtmlRequest,
    ) -> Result<anki_proto::generic::String>;
    fn all_tts_voices(
        &self,
        input: anki_proto::card_rendering::AllTtsVoicesRequest,
    ) -> Result<anki_proto::card_rendering::AllTtsVoicesResponse>;
    fn write_tts_stream(
        &self,
        input: anki_proto::card_rendering::WriteTtsStreamRequest,
    ) -> Result<()>;
}
impl crate::backend::Backend {
    fn extract_av_tags(
        &self,
        input: anki_proto::card_rendering::ExtractAvTagsRequest,
    ) -> Result<anki_proto::card_rendering::ExtractAvTagsResponse> {
        self.with_col(|col| CardRenderingService::extract_av_tags(col, input))
    }
    fn extract_latex(
        &self,
        input: anki_proto::card_rendering::ExtractLatexRequest,
    ) -> Result<anki_proto::card_rendering::ExtractLatexResponse> {
        self.with_col(|col| CardRenderingService::extract_latex(col, input))
    }
    fn get_empty_cards(&self) -> Result<anki_proto::card_rendering::EmptyCardsReport> {
        self.with_col(|col| CardRenderingService::get_empty_cards(col))
    }
    fn render_existing_card(
        &self,
        input: anki_proto::card_rendering::RenderExistingCardRequest,
    ) -> Result<anki_proto::card_rendering::RenderCardResponse> {
        self.with_col(|col| CardRenderingService::render_existing_card(col, input))
    }
    fn render_uncommitted_card(
        &self,
        input: anki_proto::card_rendering::RenderUncommittedCardRequest,
    ) -> Result<anki_proto::card_rendering::RenderCardResponse> {
        self.with_col(|col| CardRenderingService::render_uncommitted_card(col, input))
    }
    fn render_uncommitted_card_legacy(
        &self,
        input: anki_proto::card_rendering::RenderUncommittedCardLegacyRequest,
    ) -> Result<anki_proto::card_rendering::RenderCardResponse> {
        self.with_col(|col| CardRenderingService::render_uncommitted_card_legacy(
            col,
            input,
        ))
    }
    fn strip_av_tags(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| CardRenderingService::strip_av_tags(col, input))
    }
    fn render_markdown(
        &self,
        input: anki_proto::card_rendering::RenderMarkdownRequest,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| CardRenderingService::render_markdown(col, input))
    }
    fn encode_iri_paths(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| CardRenderingService::encode_iri_paths(col, input))
    }
    fn decode_iri_paths(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| CardRenderingService::decode_iri_paths(col, input))
    }
    fn html_to_text_line(
        &self,
        input: anki_proto::card_rendering::HtmlToTextLineRequest,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| CardRenderingService::html_to_text_line(col, input))
    }
    fn compare_answer(
        &self,
        input: anki_proto::card_rendering::CompareAnswerRequest,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| CardRenderingService::compare_answer(col, input))
    }
    fn extract_cloze_for_typing(
        &self,
        input: anki_proto::card_rendering::ExtractClozeForTypingRequest,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| CardRenderingService::extract_cloze_for_typing(col, input))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_card_rendering_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::card_rendering::StripHtmlRequest::decode(input)?;
                let output = BackendCardRenderingService::strip_html(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::card_rendering::AllTtsVoicesRequest::decode(
                    input,
                )?;
                let output = BackendCardRenderingService::all_tts_voices(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::card_rendering::WriteTtsStreamRequest::decode(
                    input,
                )?;
                BackendCardRenderingService::write_tts_stream(self, input)?;
                Ok(Vec::new())
            }
            3 => {
                let input = anki_proto::card_rendering::ExtractAvTagsRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::extract_av_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::card_rendering::ExtractLatexRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::extract_latex(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let output = crate::backend::Backend::get_empty_cards(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::card_rendering::RenderExistingCardRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::render_existing_card(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::card_rendering::RenderUncommittedCardRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::render_uncommitted_card(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::card_rendering::RenderUncommittedCardLegacyRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::render_uncommitted_card_legacy(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::strip_av_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::card_rendering::RenderMarkdownRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::render_markdown(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            11 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::encode_iri_paths(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            12 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::decode_iri_paths(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            14 => {
                let input = anki_proto::card_rendering::HtmlToTextLineRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::html_to_text_line(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            15 => {
                let input = anki_proto::card_rendering::CompareAnswerRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::compare_answer(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            16 => {
                let input = anki_proto::card_rendering::ExtractClozeForTypingRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::extract_cloze_for_typing(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendSearchService {}
impl crate::backend::Backend {
    fn build_search_string(
        &self,
        input: anki_proto::search::SearchNode,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| SearchService::build_search_string(col, input))
    }
    fn search_cards(
        &self,
        input: anki_proto::search::SearchRequest,
    ) -> Result<anki_proto::search::SearchResponse> {
        self.with_col(|col| SearchService::search_cards(col, input))
    }
    fn search_notes(
        &self,
        input: anki_proto::search::SearchRequest,
    ) -> Result<anki_proto::search::SearchResponse> {
        self.with_col(|col| SearchService::search_notes(col, input))
    }
    fn join_search_nodes(
        &self,
        input: anki_proto::search::JoinSearchNodesRequest,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| SearchService::join_search_nodes(col, input))
    }
    fn replace_search_node(
        &self,
        input: anki_proto::search::ReplaceSearchNodeRequest,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| SearchService::replace_search_node(col, input))
    }
    fn find_and_replace(
        &self,
        input: anki_proto::search::FindAndReplaceRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| SearchService::find_and_replace(col, input))
    }
    fn all_browser_columns(&self) -> Result<anki_proto::search::BrowserColumns> {
        self.with_col(|col| SearchService::all_browser_columns(col))
    }
    fn browser_row_for_id(
        &self,
        input: anki_proto::generic::Int64,
    ) -> Result<anki_proto::search::BrowserRow> {
        self.with_col(|col| SearchService::browser_row_for_id(col, input))
    }
    fn set_active_browser_columns(
        &self,
        input: anki_proto::generic::StringList,
    ) -> Result<()> {
        self.with_col(|col| SearchService::set_active_browser_columns(col, input))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_search_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::search::SearchNode::decode(input)?;
                let output = crate::backend::Backend::build_search_string(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::search::SearchRequest::decode(input)?;
                let output = crate::backend::Backend::search_cards(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::search::SearchRequest::decode(input)?;
                let output = crate::backend::Backend::search_notes(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::search::JoinSearchNodesRequest::decode(input)?;
                let output = crate::backend::Backend::join_search_nodes(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::search::ReplaceSearchNodeRequest::decode(input)?;
                let output = crate::backend::Backend::replace_search_node(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::search::FindAndReplaceRequest::decode(input)?;
                let output = crate::backend::Backend::find_and_replace(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let output = crate::backend::Backend::all_browser_columns(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::generic::Int64::decode(input)?;
                let output = crate::backend::Backend::browser_row_for_id(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::generic::StringList::decode(input)?;
                crate::backend::Backend::set_active_browser_columns(self, input)?;
                Ok(Vec::new())
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendGithubService {
    fn get_latest_release(
        &self,
        input: anki_proto::github::LatestReleaseRequest,
    ) -> Result<anki_proto::github::GithubRelease>;
    fn download_release(
        &self,
        input: anki_proto::github::GithubRelease,
    ) -> Result<anki_proto::generic::String>;
}
impl crate::backend::Backend {}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_github_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::github::LatestReleaseRequest::decode(input)?;
                let output = BackendGithubService::get_latest_release(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::github::GithubRelease::decode(input)?;
                let output = BackendGithubService::download_release(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendI18nService {
    fn translate_string(
        &self,
        input: anki_proto::i18n::TranslateStringRequest,
    ) -> Result<anki_proto::generic::String>;
    fn format_timespan(
        &self,
        input: anki_proto::i18n::FormatTimespanRequest,
    ) -> Result<anki_proto::generic::String>;
    fn i18n_resources(
        &self,
        input: anki_proto::i18n::I18nResourcesRequest,
    ) -> Result<anki_proto::generic::Json>;
}
impl crate::backend::Backend {}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_i18n_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::i18n::TranslateStringRequest::decode(input)?;
                let output = BackendI18nService::translate_string(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::i18n::FormatTimespanRequest::decode(input)?;
                let output = BackendI18nService::format_timespan(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::i18n::I18nResourcesRequest::decode(input)?;
                let output = BackendI18nService::i18n_resources(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendImageOcclusionService {}
impl crate::backend::Backend {
    fn get_image_for_occlusion(
        &self,
        input: anki_proto::image_occlusion::GetImageForOcclusionRequest,
    ) -> Result<anki_proto::image_occlusion::GetImageForOcclusionResponse> {
        self.with_col(|col| ImageOcclusionService::get_image_for_occlusion(col, input))
    }
    fn get_image_occlusion_note(
        &self,
        input: anki_proto::image_occlusion::GetImageOcclusionNoteRequest,
    ) -> Result<anki_proto::image_occlusion::GetImageOcclusionNoteResponse> {
        self.with_col(|col| ImageOcclusionService::get_image_occlusion_note(col, input))
    }
    fn get_image_occlusion_fields(
        &self,
        input: anki_proto::image_occlusion::GetImageOcclusionFieldsRequest,
    ) -> Result<anki_proto::image_occlusion::GetImageOcclusionFieldsResponse> {
        self.with_col(|col| ImageOcclusionService::get_image_occlusion_fields(
            col,
            input,
        ))
    }
    fn add_image_occlusion_notetype(&self) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| ImageOcclusionService::add_image_occlusion_notetype(col))
    }
    fn add_image_occlusion_note(
        &self,
        input: anki_proto::image_occlusion::AddImageOcclusionNoteRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| ImageOcclusionService::add_image_occlusion_note(col, input))
    }
    fn update_image_occlusion_note(
        &self,
        input: anki_proto::image_occlusion::UpdateImageOcclusionNoteRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| ImageOcclusionService::update_image_occlusion_note(
            col,
            input,
        ))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_image_occlusion_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::image_occlusion::GetImageForOcclusionRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::get_image_for_occlusion(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::image_occlusion::GetImageOcclusionNoteRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::get_image_occlusion_note(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::image_occlusion::GetImageOcclusionFieldsRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::get_image_occlusion_fields(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let output = crate::backend::Backend::add_image_occlusion_notetype(
                    self,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::image_occlusion::AddImageOcclusionNoteRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::add_image_occlusion_note(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::image_occlusion::UpdateImageOcclusionNoteRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::update_image_occlusion_note(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendImportExportService {
    fn import_collection_package(
        &self,
        input: anki_proto::import_export::ImportCollectionPackageRequest,
    ) -> Result<()>;
    fn export_collection_package(
        &self,
        input: anki_proto::import_export::ExportCollectionPackageRequest,
    ) -> Result<()>;
}
impl crate::backend::Backend {
    fn import_anki_package(
        &self,
        input: anki_proto::import_export::ImportAnkiPackageRequest,
    ) -> Result<anki_proto::import_export::ImportResponse> {
        self.with_col(|col| ImportExportService::import_anki_package(col, input))
    }
    fn get_import_anki_package_presets(
        &self,
    ) -> Result<anki_proto::import_export::ImportAnkiPackageOptions> {
        self.with_col(|col| ImportExportService::get_import_anki_package_presets(col))
    }
    fn export_anki_package(
        &self,
        input: anki_proto::import_export::ExportAnkiPackageRequest,
    ) -> Result<anki_proto::generic::UInt32> {
        self.with_col(|col| ImportExportService::export_anki_package(col, input))
    }
    fn get_csv_metadata(
        &self,
        input: anki_proto::import_export::CsvMetadataRequest,
    ) -> Result<anki_proto::import_export::CsvMetadata> {
        self.with_col(|col| ImportExportService::get_csv_metadata(col, input))
    }
    fn import_csv(
        &self,
        input: anki_proto::import_export::ImportCsvRequest,
    ) -> Result<anki_proto::import_export::ImportResponse> {
        self.with_col(|col| ImportExportService::import_csv(col, input))
    }
    fn export_note_csv(
        &self,
        input: anki_proto::import_export::ExportNoteCsvRequest,
    ) -> Result<anki_proto::generic::UInt32> {
        self.with_col(|col| ImportExportService::export_note_csv(col, input))
    }
    fn export_card_csv(
        &self,
        input: anki_proto::import_export::ExportCardCsvRequest,
    ) -> Result<anki_proto::generic::UInt32> {
        self.with_col(|col| ImportExportService::export_card_csv(col, input))
    }
    fn import_json_file(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::import_export::ImportResponse> {
        self.with_col(|col| ImportExportService::import_json_file(col, input))
    }
    fn import_json_string(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::import_export::ImportResponse> {
        self.with_col(|col| ImportExportService::import_json_string(col, input))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_import_export_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::import_export::ImportCollectionPackageRequest::decode(
                    input,
                )?;
                BackendImportExportService::import_collection_package(self, input)?;
                Ok(Vec::new())
            }
            1 => {
                let input = anki_proto::import_export::ExportCollectionPackageRequest::decode(
                    input,
                )?;
                BackendImportExportService::export_collection_package(self, input)?;
                Ok(Vec::new())
            }
            2 => {
                let input = anki_proto::import_export::ImportAnkiPackageRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::import_anki_package(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let output = crate::backend::Backend::get_import_anki_package_presets(
                    self,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::import_export::ExportAnkiPackageRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::export_anki_package(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::import_export::CsvMetadataRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::get_csv_metadata(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::import_export::ImportCsvRequest::decode(input)?;
                let output = crate::backend::Backend::import_csv(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::import_export::ExportNoteCsvRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::export_note_csv(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::import_export::ExportCardCsvRequest::decode(
                    input,
                )?;
                let output = crate::backend::Backend::export_card_csv(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::import_json_file(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::import_json_string(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendMediaService {
    fn add_media_from_url(
        &self,
        input: anki_proto::media::AddMediaFromUrlRequest,
    ) -> Result<anki_proto::media::AddMediaFromUrlResponse>;
}
impl crate::backend::Backend {
    fn check_media(&self) -> Result<anki_proto::media::CheckMediaResponse> {
        self.with_col(|col| MediaService::check_media(col))
    }
    fn add_media_file(
        &self,
        input: anki_proto::media::AddMediaFileRequest,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| MediaService::add_media_file(col, input))
    }
    fn add_media_from_path(
        &self,
        input: anki_proto::media::AddMediaFromPathRequest,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| MediaService::add_media_from_path(col, input))
    }
    fn trash_media_files(
        &self,
        input: anki_proto::media::TrashMediaFilesRequest,
    ) -> Result<()> {
        self.with_col(|col| MediaService::trash_media_files(col, input))
    }
    fn empty_trash(&self) -> Result<()> {
        self.with_col(|col| MediaService::empty_trash(col))
    }
    fn restore_trash(&self) -> Result<()> {
        self.with_col(|col| MediaService::restore_trash(col))
    }
    fn extract_static_media_files(
        &self,
        input: anki_proto::notetypes::NotetypeId,
    ) -> Result<anki_proto::generic::StringList> {
        self.with_col(|col| MediaService::extract_static_media_files(col, input))
    }
    fn extract_media_files(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::StringList> {
        self.with_col(|col| MediaService::extract_media_files(col, input))
    }
    fn get_absolute_media_path(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::generic::String> {
        self.with_col(|col| MediaService::get_absolute_media_path(col, input))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_media_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::media::AddMediaFromUrlRequest::decode(input)?;
                let output = BackendMediaService::add_media_from_url(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let output = crate::backend::Backend::check_media(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::media::AddMediaFileRequest::decode(input)?;
                let output = crate::backend::Backend::add_media_file(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::media::AddMediaFromPathRequest::decode(input)?;
                let output = crate::backend::Backend::add_media_from_path(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::media::TrashMediaFilesRequest::decode(input)?;
                crate::backend::Backend::trash_media_files(self, input)?;
                Ok(Vec::new())
            }
            5 => {
                crate::backend::Backend::empty_trash(self)?;
                Ok(Vec::new())
            }
            6 => {
                crate::backend::Backend::restore_trash(self)?;
                Ok(Vec::new())
            }
            7 => {
                let input = anki_proto::notetypes::NotetypeId::decode(input)?;
                let output = crate::backend::Backend::extract_static_media_files(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::extract_media_files(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::get_absolute_media_path(
                    self,
                    input,
                )?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendStatsService {}
impl crate::backend::Backend {
    fn card_stats(
        &self,
        input: anki_proto::cards::CardId,
    ) -> Result<anki_proto::stats::CardStatsResponse> {
        self.with_col(|col| StatsService::card_stats(col, input))
    }
    fn get_review_logs(
        &self,
        input: anki_proto::cards::CardId,
    ) -> Result<anki_proto::stats::ReviewLogs> {
        self.with_col(|col| StatsService::get_review_logs(col, input))
    }
    fn graphs(
        &self,
        input: anki_proto::stats::GraphsRequest,
    ) -> Result<anki_proto::stats::GraphsResponse> {
        self.with_col(|col| StatsService::graphs(col, input))
    }
    fn get_graph_preferences(&self) -> Result<anki_proto::stats::GraphPreferences> {
        self.with_col(|col| StatsService::get_graph_preferences(col))
    }
    fn set_graph_preferences(
        &self,
        input: anki_proto::stats::GraphPreferences,
    ) -> Result<()> {
        self.with_col(|col| StatsService::set_graph_preferences(col, input))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_stats_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let input = anki_proto::cards::CardId::decode(input)?;
                let output = crate::backend::Backend::card_stats(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let input = anki_proto::cards::CardId::decode(input)?;
                let output = crate::backend::Backend::get_review_logs(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::stats::GraphsRequest::decode(input)?;
                let output = crate::backend::Backend::graphs(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let output = crate::backend::Backend::get_graph_preferences(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let input = anki_proto::stats::GraphPreferences::decode(input)?;
                crate::backend::Backend::set_graph_preferences(self, input)?;
                Ok(Vec::new())
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
pub trait BackendTagsService {}
impl crate::backend::Backend {
    fn clear_unused_tags(&self) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| TagsService::clear_unused_tags(col))
    }
    fn all_tags(&self) -> Result<anki_proto::generic::StringList> {
        self.with_col(|col| TagsService::all_tags(col))
    }
    fn remove_tags(
        &self,
        input: anki_proto::generic::String,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| TagsService::remove_tags(col, input))
    }
    fn set_tag_collapsed(
        &self,
        input: anki_proto::tags::SetTagCollapsedRequest,
    ) -> Result<anki_proto::collection::OpChanges> {
        self.with_col(|col| TagsService::set_tag_collapsed(col, input))
    }
    fn tag_tree(&self) -> Result<anki_proto::tags::TagTreeNode> {
        self.with_col(|col| TagsService::tag_tree(col))
    }
    fn reparent_tags(
        &self,
        input: anki_proto::tags::ReparentTagsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| TagsService::reparent_tags(col, input))
    }
    fn rename_tags(
        &self,
        input: anki_proto::tags::RenameTagsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| TagsService::rename_tags(col, input))
    }
    fn add_note_tags(
        &self,
        input: anki_proto::tags::NoteIdsAndTagsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| TagsService::add_note_tags(col, input))
    }
    fn remove_note_tags(
        &self,
        input: anki_proto::tags::NoteIdsAndTagsRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| TagsService::remove_note_tags(col, input))
    }
    fn find_and_replace_tag(
        &self,
        input: anki_proto::tags::FindAndReplaceTagRequest,
    ) -> Result<anki_proto::collection::OpChangesWithCount> {
        self.with_col(|col| TagsService::find_and_replace_tag(col, input))
    }
    fn complete_tag(
        &self,
        input: anki_proto::tags::CompleteTagRequest,
    ) -> Result<anki_proto::tags::CompleteTagResponse> {
        self.with_col(|col| TagsService::complete_tag(col, input))
    }
}
#[allow(unused_variables, clippy::match_single_binding)]
impl crate::backend::Backend {
    pub(crate) fn run_backend_tags_service_method(
        &self,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>> {
        match method {
            0 => {
                let output = crate::backend::Backend::clear_unused_tags(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            1 => {
                let output = crate::backend::Backend::all_tags(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            2 => {
                let input = anki_proto::generic::String::decode(input)?;
                let output = crate::backend::Backend::remove_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            3 => {
                let input = anki_proto::tags::SetTagCollapsedRequest::decode(input)?;
                let output = crate::backend::Backend::set_tag_collapsed(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            4 => {
                let output = crate::backend::Backend::tag_tree(self)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            5 => {
                let input = anki_proto::tags::ReparentTagsRequest::decode(input)?;
                let output = crate::backend::Backend::reparent_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            6 => {
                let input = anki_proto::tags::RenameTagsRequest::decode(input)?;
                let output = crate::backend::Backend::rename_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            7 => {
                let input = anki_proto::tags::NoteIdsAndTagsRequest::decode(input)?;
                let output = crate::backend::Backend::add_note_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            8 => {
                let input = anki_proto::tags::NoteIdsAndTagsRequest::decode(input)?;
                let output = crate::backend::Backend::remove_note_tags(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            9 => {
                let input = anki_proto::tags::FindAndReplaceTagRequest::decode(input)?;
                let output = crate::backend::Backend::find_and_replace_tag(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            10 => {
                let input = anki_proto::tags::CompleteTagRequest::decode(input)?;
                let output = crate::backend::Backend::complete_tag(self, input)?;
                Ok({
                    let mut out_bytes = Vec::new();
                    output.encode(&mut out_bytes)?;
                    out_bytes
                })
            }
            _ => Err(crate::error::AnkiError::InvalidMethodIndex),
        }
    }
}
impl crate::backend::Backend {
    pub fn run_service_method(
        &self,
        service: u32,
        method: u32,
        input: &[u8],
    ) -> Result<Vec<u8>, Vec<u8>> {
        match service {
            1 => self.run_backend_sync_service_method(method, input),
            3 => self.run_backend_collection_service_method(method, input),
            5 => self.run_backend_cards_service_method(method, input),
            7 => self.run_backend_decks_service_method(method, input),
            9 => self.run_backend_config_service_method(method, input),
            11 => self.run_backend_deck_config_service_method(method, input),
            13 => self.run_backend_scheduler_service_method(method, input),
            15 => self.run_backend_ankidroid_service_method(method, input),
            17 => self.run_backend_anki_hub_service_method(method, input),
            19 => self.run_backend_ankiweb_service_method(method, input),
            21 => self.run_backend_links_service_method(method, input),
            23 => self.run_backend_notetypes_service_method(method, input),
            25 => self.run_backend_notes_service_method(method, input),
            27 => self.run_backend_card_rendering_service_method(method, input),
            29 => self.run_backend_search_service_method(method, input),
            33 => self.run_backend_github_service_method(method, input),
            35 => self.run_backend_i18n_service_method(method, input),
            37 => self.run_backend_image_occlusion_service_method(method, input),
            39 => self.run_backend_import_export_service_method(method, input),
            41 => self.run_backend_media_service_method(method, input),
            43 => self.run_backend_stats_service_method(method, input),
            45 => self.run_backend_tags_service_method(method, input),
            _ => Err(crate::error::AnkiError::InvalidServiceIndex),
        }
            .map_err(|err| {
                let backend_err = err.into_protobuf(&self.tr);
                let mut bytes = Vec::new();
                backend_err.encode(&mut bytes).unwrap();
                bytes
            })
    }
}
