Added create document to client.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled

This commit is contained in:
2026-03-25 04:52:27 -04:00
parent 316ae06654
commit d960d8fd03
2 changed files with 54 additions and 1 deletions

View File

@@ -125,6 +125,36 @@ impl MTTClient {
pub fn session_id(&self) -> String {
self.session_id.to_string()
}
pub fn create_document(&self, docdef: DocDef) -> Result<(), MTTError> {
let msg_id = MessageID::new();
let paths = [
Path::new(
Include::Just(msg_id.clone()),
Include::All,
Include::Just(Action::DocumentCreated),
),
Path::new(
Include::Just(msg_id.clone()),
Include::All,
Include::Just(Action::Error),
),
];
for path in paths.iter() {
let reg_msg = Register::new(self.sender_id.clone(), RegMsg::AddRoute(path.clone()));
self.queue.send(Message::with_id(msg_id.clone(), reg_msg));
self.rx.recv().unwrap(); // Wait for completion.
}
self.queue.send(Message::with_id(msg_id.clone(), docdef));
match self.rx.recv_timeout(TIMEOUT) {
Ok(data) => match data.get_action() {
MsgAction::DocumentCreated => Ok(()),
MsgAction::Error(err) => Err(err.clone()),
_ => unreachable!("should only receive confirmation or errors"),
},
Err(_) => Err(MTTError::new(ErrorID::TimeOut)),
}
}
}
impl Drop for MTTClient {