Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f8e631e authored by George Burgess IV's avatar George Burgess IV
Browse files

upgrade to rustyline-10

rustyline-8 depends on nix-0.20, which is impacted by RUSTSEC-2021-0119.
rustyline-10 does not have this issue.

Tag: #floss
Bug: 239449434
Test: emerge floss in cros

Change-Id: Ib6b8ed2adb8247f834a25331b0e179c2c460b8b2
parent 7bd29ea8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2018"

[dependencies]
rustyline = "8.0"
rustyline = "10"
rustyline-derive = "0.4.0"
bt_topshim = { path = "../../topshim" }
btstack = { path = "../stack" }
+3 −3
Original line number Diff line number Diff line
@@ -178,16 +178,16 @@ impl AsyncEditor {
    pub(crate) fn new(
        command_rules: Vec<String>,
        client_context: Arc<Mutex<ClientContext>>,
    ) -> AsyncEditor {
    ) -> rustyline::Result<AsyncEditor> {
        let builder = Config::builder()
            .auto_add_history(true)
            .history_ignore_dups(true)
            .completion_type(CompletionType::List);
        let config = builder.build();
        let mut rl = rustyline::Editor::with_config(config);
        let mut rl = rustyline::Editor::with_config(config)?;
        let helper = BtHelper { command_rules, client_context };
        rl.set_helper(Some(helper));
        AsyncEditor { rl: Arc::new(Mutex::new(rl)) }
        Ok(AsyncEditor { rl: Arc::new(Mutex::new(rl)) })
    }

    /// Does async readline().
+5 −4
Original line number Diff line number Diff line
@@ -367,7 +367,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
                );
            }
            _ => {
                start_interactive_shell(handler, tx, rx, context).await;
                start_interactive_shell(handler, tx, rx, context).await?;
            }
        };
        return Result::Ok(());
@@ -379,7 +379,7 @@ async fn start_interactive_shell(
    tx: mpsc::Sender<ForegroundActions>,
    mut rx: mpsc::Receiver<ForegroundActions>,
    context: Arc<Mutex<ClientContext>>,
) {
) -> Result<(), Box<dyn std::error::Error>> {
    let command_rule_list = handler.get_command_rule_list().clone();
    let context_for_closure = context.clone();

@@ -387,9 +387,9 @@ async fn start_interactive_shell(

    // Async task to keep reading new lines from user
    let semaphore = semaphore_fg.clone();
    let editor = AsyncEditor::new(command_rule_list, context_for_closure)
        .map_err(|x| format!("creating async editor failed: {x}"))?;
    tokio::spawn(async move {
        let editor = AsyncEditor::new(command_rule_list, context_for_closure);

        loop {
            // Wait until ForegroundAction::Readline finishes its task.
            let permit = semaphore.acquire().await;
@@ -613,4 +613,5 @@ async fn start_interactive_shell(
    semaphore_fg.close();

    print_info!("Client exiting");
    Ok(())
}