40 lines
1008 B
Rust
40 lines
1008 B
Rust
use crate::codex::Codex;
|
|
use crate::error::Result as CodexResult;
|
|
use crate::protocol::Event;
|
|
use crate::protocol::Op;
|
|
use crate::protocol::Submission;
|
|
use std::path::PathBuf;
|
|
|
|
pub struct CodexConversation {
|
|
codex: Codex,
|
|
rollout_path: PathBuf,
|
|
}
|
|
|
|
/// Conduit for the bidirectional stream of messages that compose a conversation
|
|
/// in Codex.
|
|
impl CodexConversation {
|
|
pub(crate) fn new(codex: Codex, rollout_path: PathBuf) -> Self {
|
|
Self {
|
|
codex,
|
|
rollout_path,
|
|
}
|
|
}
|
|
|
|
pub async fn submit(&self, op: Op) -> CodexResult<String> {
|
|
self.codex.submit(op).await
|
|
}
|
|
|
|
/// Use sparingly: this is intended to be removed soon.
|
|
pub async fn submit_with_id(&self, sub: Submission) -> CodexResult<()> {
|
|
self.codex.submit_with_id(sub).await
|
|
}
|
|
|
|
pub async fn next_event(&self) -> CodexResult<Event> {
|
|
self.codex.next_event().await
|
|
}
|
|
|
|
pub fn rollout_path(&self) -> PathBuf {
|
|
self.rollout_path.clone()
|
|
}
|
|
}
|