-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
breaking: Remove
Async{Driver,Solver}
in favor of `Tokio{Driver,Sol…
…ver}` The previous implementations simply created a future and ran blocking code in that future. This was pretty much all we could do without having an actual variant of `Command` that was async. So instead of trying to find some executor-agnostic approach, we will be explicit about using tokio. This explicitness will allow is in the future to add other executors, and not give a false impression about being agnostic. We might lift this or change the naming in the future. One thing to note, is that the currenting naming is a bit strange; sort of a mix of suffixing/prefix `Tokio` where it fits. I could not immediately come up with a holistic way of doing this, so we stick with this for now.
- Loading branch information
Showing
17 changed files
with
367 additions
and
147 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use std::ffi::OsStr; | ||
|
||
use super::{Backend, BinaryBackend}; | ||
|
||
pub struct Cvc5Binary { | ||
bin: BinaryBackend, | ||
} | ||
|
||
impl Cvc5Binary { | ||
pub fn new(cvc5: impl AsRef<OsStr>) -> Result<Self, std::io::Error> { | ||
Ok(Cvc5Binary { | ||
bin: BinaryBackend::new(cvc5, |cmd| { | ||
cmd.args(["--lang", "smt2"]) | ||
.args(["--produce-models"]) | ||
.args(["--incremental"]); | ||
})?, | ||
}) | ||
} | ||
} | ||
|
||
impl Backend for Cvc5Binary { | ||
fn exec(&mut self, cmd: &crate::Command) -> Result<String, crate::Error> { | ||
self.bin.exec(cmd).map(Into::into) | ||
} | ||
} | ||
|
||
#[cfg(feature = "tokio")] | ||
pub mod tokio { | ||
use std::{ffi::OsStr, future::Future}; | ||
|
||
use crate::backend::tokio::TokioBinaryBackend; | ||
|
||
pub struct Cvc5BinaryTokio { | ||
bin: TokioBinaryBackend, | ||
} | ||
|
||
impl Cvc5BinaryTokio { | ||
pub async fn new(cvc5: impl AsRef<OsStr>) -> Result<Self, std::io::Error> { | ||
Ok(Cvc5BinaryTokio { | ||
bin: TokioBinaryBackend::new(cvc5, |cmd| { | ||
cmd.args(["--lang", "smt2"]) | ||
.args(["--produce-models"]) | ||
.args(["--incremental"]); | ||
}) | ||
.await?, | ||
}) | ||
} | ||
} | ||
|
||
impl crate::backend::tokio::TokioBackend for Cvc5BinaryTokio { | ||
fn exec( | ||
&mut self, | ||
cmd: &crate::Command, | ||
) -> impl Future<Output = Result<String, crate::Error>> { | ||
async { self.bin.exec(cmd).await.map(Into::into) } | ||
} | ||
} | ||
} |
Oops, something went wrong.