Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
Expose backend_proto publicly for AnkiDroid, and rename to pb
Browse files Browse the repository at this point in the history
We were aliasing it on import half the time anyway
  • Loading branch information
dae committed Jun 27, 2022
1 parent 6ff1593 commit 67e4edc
Show file tree
Hide file tree
Showing 74 changed files with 109 additions and 115 deletions.
2 changes: 1 addition & 1 deletion rslib/src/backend/adding.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::{adding::DeckAndNotetype, backend_proto::DeckAndNotetype as DeckAndNotetypeProto};
use crate::{adding::DeckAndNotetype, pb::DeckAndNotetype as DeckAndNotetypeProto};

impl From<DeckAndNotetype> for DeckAndNotetypeProto {
fn from(s: DeckAndNotetype) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use super::Backend;
pub(super) use crate::backend_proto::cards_service::Service as CardsService;
pub(super) use crate::pb::cards_service::Service as CardsService;
use crate::{
backend_proto as pb,
card::{CardQueue, CardType},
pb,
prelude::*,
};

Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/cardrendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use super::Backend;
pub(super) use crate::backend_proto::cardrendering_service::Service as CardRenderingService;
pub(super) use crate::pb::cardrendering_service::Service as CardRenderingService;
use crate::{
backend_proto as pb,
card_rendering::{extract_av_tags, strip_av_tags},
latex::{extract_latex, extract_latex_expanding_clozes, ExtractedLatex},
markdown::render_markdown,
notetype::{CardTemplateSchema11, RenderCardOutput},
pb,
prelude::*,
template::RenderedNode,
text::{
Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use std::sync::MutexGuard;
use slog::error;

use super::{progress::Progress, Backend};
pub(super) use crate::backend_proto::collection_service::Service as CollectionService;
pub(super) use crate::pb::collection_service::Service as CollectionService;
use crate::{
backend::progress::progress_to_proto,
backend_proto::{self as pb},
collection::CollectionBuilder,
pb::{self as pb},
prelude::*,
storage::SchemaVersion,
};
Expand Down
6 changes: 3 additions & 3 deletions rslib/src/backend/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
use serde_json::Value;

use super::Backend;
pub(super) use crate::backend_proto::config_service::Service as ConfigService;
pub(super) use crate::pb::config_service::Service as ConfigService;
use crate::{
backend_proto as pb,
backend_proto::config_key::{Bool as BoolKeyProto, String as StringKeyProto},
config::{BoolKey, StringKey},
pb,
pb::config_key::{Bool as BoolKeyProto, String as StringKeyProto},
prelude::*,
};

Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/deckconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use super::Backend;
pub(super) use crate::backend_proto::deckconfig_service::Service as DeckConfigService;
pub(super) use crate::pb::deckconfig_service::Service as DeckConfigService;
use crate::{
backend_proto as pb,
deckconfig::{DeckConfSchema11, DeckConfig, UpdateDeckConfigsRequest},
pb,
prelude::*,
};

Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/decks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
use std::convert::TryFrom;

use super::Backend;
pub(super) use crate::backend_proto::decks_service::Service as DecksService;
pub(super) use crate::pb::decks_service::Service as DecksService;
use crate::{
backend_proto::{self as pb},
decks::{DeckSchema11, FilteredSearchOrder},
pb::{self as pb},
prelude::*,
scheduler::filtered::FilteredDeckForUpdate,
};
Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::{
backend_proto as pb,
backend_proto::backend_error::Kind,
error::{AnkiError, SyncErrorKind},
pb,
pb::backend_error::Kind,
prelude::*,
};

Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/generic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::{backend_proto as pb, prelude::*};
use crate::{pb, prelude::*};

impl From<Vec<u8>> for pb::Json {
fn from(json: Vec<u8>) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/i18n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use std::collections::HashMap;
use fluent::{FluentArgs, FluentValue};

use super::Backend;
pub(super) use crate::backend_proto::i18n_service::Service as I18nService;
pub(super) use crate::pb::i18n_service::Service as I18nService;
use crate::{
backend_proto as pb,
pb,
prelude::*,
scheduler::timespan::{answer_button_time, time_span},
};
Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/import_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
use std::path::Path;

use super::{progress::Progress, Backend};
pub(super) use crate::backend_proto::importexport_service::Service as ImportExportService;
pub(super) use crate::pb::importexport_service::Service as ImportExportService;
use crate::{
backend_proto::{self as pb, export_limit, ExportLimit},
import_export::{package::import_colpkg, ExportProgress, ImportProgress, NoteLog},
pb::{self as pb, export_limit, ExportLimit},
prelude::*,
search::SearchNode,
};
Expand Down
6 changes: 2 additions & 4 deletions rslib/src/backend/links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use super::Backend;
pub(super) use crate::backend_proto::links_service::Service as LinksService;
use crate::{
backend_proto as pb, backend_proto::links::help_page_link_request::HelpPage, prelude::*,
};
pub(super) use crate::pb::links_service::Service as LinksService;
use crate::{pb, pb::links::help_page_link_request::HelpPage, prelude::*};

impl LinksService for Backend {
fn help_page_link(&self, input: pb::HelpPageLinkRequest) -> Result<pb::String> {
Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use super::{progress::Progress, Backend};
pub(super) use crate::backend_proto::media_service::Service as MediaService;
pub(super) use crate::pb::media_service::Service as MediaService;
use crate::{
backend_proto as pb,
media::{check::MediaChecker, MediaManager},
pb,
prelude::*,
};

Expand Down
3 changes: 1 addition & 2 deletions rslib/src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ use self::{
};
use crate::{
backend::dbproxy::db_command_bytes,
backend_proto as pb,
collection::Collection,
error::{AnkiError, Result},
i18n::I18n,
log,
log, pb,
};

pub struct Backend {
Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
use std::collections::HashSet;

use super::Backend;
pub(super) use crate::backend_proto::notes_service::Service as NotesService;
pub(super) use crate::pb::notes_service::Service as NotesService;
use crate::{
backend_proto::{self as pb},
cloze::add_cloze_numbers_in_string,
pb::{self as pb},
prelude::*,
};

Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/notetypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use super::Backend;
pub(super) use crate::backend_proto::notetypes_service::Service as NotetypesService;
pub(super) use crate::pb::notetypes_service::Service as NotetypesService;
use crate::{
backend_proto as pb,
config::get_aux_notetype_config_key,
notetype::{
all_stock_notetypes, ChangeNotetypeInput, Notetype, NotetypeChangeInfo, NotetypeSchema11,
},
pb,
prelude::*,
};

Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::{
backend_proto as pb,
ops::OpChanges,
pb,
prelude::*,
undo::{UndoOutput, UndoStatus},
};
Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use futures::future::AbortHandle;

use super::Backend;
use crate::{
backend_proto as pb,
dbcheck::DatabaseCheckProgress,
i18n::I18n,
import_export::{ExportProgress, ImportProgress},
media::sync::MediaSyncProgress,
pb,
sync::{FullSyncProgress, NormalSyncProgress, SyncStage},
};

Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/scheduler/answering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::{
backend_proto as pb,
pb,
prelude::*,
scheduler::{
answering::{CardAnswer, Rating},
Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/scheduler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ mod answering;
mod states;

use super::Backend;
pub(super) use crate::backend_proto::scheduler_service::Service as SchedulerService;
pub(super) use crate::pb::scheduler_service::Service as SchedulerService;
use crate::{
backend_proto as pb,
pb,
prelude::*,
scheduler::{
new::NewCardDueOrder,
Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/scheduler/states/filtered.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::{backend_proto as pb, scheduler::states::FilteredState};
use crate::{pb, scheduler::states::FilteredState};

impl From<FilteredState> for pb::scheduling_state::Filtered {
fn from(state: FilteredState) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/scheduler/states/learning.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::{backend_proto as pb, scheduler::states::LearnState};
use crate::{pb, scheduler::states::LearnState};

impl From<pb::scheduling_state::Learning> for LearnState {
fn from(state: pb::scheduling_state::Learning) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/scheduler/states/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod rescheduling;
mod review;

use crate::{
backend_proto as pb,
pb,
scheduler::states::{CardState, NewState, NextCardStates, NormalState},
};

Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/scheduler/states/new.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::{backend_proto as pb, scheduler::states::NewState};
use crate::{pb, scheduler::states::NewState};

impl From<pb::scheduling_state::New> for NewState {
fn from(state: pb::scheduling_state::New) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/scheduler/states/normal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::{backend_proto as pb, scheduler::states::NormalState};
use crate::{pb, scheduler::states::NormalState};

impl From<NormalState> for pb::scheduling_state::Normal {
fn from(state: NormalState) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/scheduler/states/preview.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::{backend_proto as pb, scheduler::states::PreviewState};
use crate::{pb, scheduler::states::PreviewState};

impl From<pb::scheduling_state::Preview> for PreviewState {
fn from(state: pb::scheduling_state::Preview) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/scheduler/states/relearning.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::{backend_proto as pb, scheduler::states::RelearnState};
use crate::{pb, scheduler::states::RelearnState};

impl From<pb::scheduling_state::Relearning> for RelearnState {
fn from(state: pb::scheduling_state::Relearning) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/scheduler/states/rescheduling.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::{backend_proto as pb, scheduler::states::ReschedulingFilterState};
use crate::{pb, scheduler::states::ReschedulingFilterState};

impl From<pb::scheduling_state::ReschedulingFilter> for ReschedulingFilterState {
fn from(state: pb::scheduling_state::ReschedulingFilter) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/scheduler/states/review.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use crate::{backend_proto as pb, scheduler::states::ReviewState};
use crate::{pb, scheduler::states::ReviewState};

impl From<pb::scheduling_state::Review> for ReviewState {
fn from(state: pb::scheduling_state::Review) -> Self {
Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/search/browser_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::str::FromStr;

use crate::{backend_proto as pb, browser_table, i18n::I18n};
use crate::{browser_table, i18n::I18n, pb};

impl browser_table::Column {
pub fn to_pb_column(self, i18n: &I18n) -> pb::browser_columns::Column {
Expand Down
6 changes: 3 additions & 3 deletions rslib/src/backend/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ mod search_node;
use std::{str::FromStr, sync::Arc};

use super::{notes::to_note_ids, Backend};
pub(super) use crate::backend_proto::search_service::Service as SearchService;
pub(super) use crate::pb::search_service::Service as SearchService;
use crate::{
backend_proto as pb,
backend_proto::sort_order::Value as SortOrderProto,
browser_table::Column,
pb,
pb::sort_order::Value as SortOrderProto,
prelude::*,
search::{replace_search_node, JoinSearches, Node, SortMode},
};
Expand Down
2 changes: 1 addition & 1 deletion rslib/src/backend/search/search_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use itertools::Itertools;

use crate::{
backend_proto as pb,
pb,
prelude::*,
search::{
parse_search, Negated, Node, PropertyKind, RatingKind, SearchNode, StateKind, TemplateKind,
Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use super::Backend;
pub(super) use crate::backend_proto::stats_service::Service as StatsService;
use crate::{backend_proto as pb, prelude::*, revlog::RevlogReviewKind};
pub(super) use crate::pb::stats_service::Service as StatsService;
use crate::{pb, prelude::*, revlog::RevlogReviewKind};

impl StatsService for Backend {
fn card_stats(&self, input: pb::CardId) -> Result<pb::CardStatsResponse> {
Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use futures::future::{AbortHandle, AbortRegistration, Abortable};
use slog::warn;

use super::{progress::AbortHandleSlot, Backend};
pub(super) use crate::backend_proto::sync_service::Service as SyncService;
pub(super) use crate::pb::sync_service::Service as SyncService;
use crate::{
backend_proto as pb,
media::MediaManager,
pb,
prelude::*,
sync::{
get_remote_sync_meta, http::SyncRequest, sync_abort, sync_login, FullSyncProgress,
Expand Down
4 changes: 2 additions & 2 deletions rslib/src/backend/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html

use super::{notes::to_note_ids, Backend};
pub(super) use crate::backend_proto::tags_service::Service as TagsService;
use crate::{backend_proto as pb, prelude::*};
pub(super) use crate::pb::tags_service::Service as TagsService;
use crate::{pb, prelude::*};

impl TagsService for Backend {
fn clear_unused_tags(&self, _input: pb::Empty) -> Result<pb::OpChangesWithCount> {
Expand Down
Loading

0 comments on commit 67e4edc

Please sign in to comment.