• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

unrenamed / chatd / 9973933170

17 Jul 2024 12:10PM UTC coverage: 32.813% (+16.6%) from 16.215%
9973933170

push

github

unrenamed
test: input validator

820 of 2499 relevant lines covered (32.81%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

28.57
/src/server/session_workflow/handler.rs
1
use std::io::Write;
2

3
use async_trait::async_trait;
4

5
use crate::auth::Auth;
6
use crate::chat::ChatRoom;
7
use crate::terminal::{CloseHandle, Terminal};
8

9
use super::WorkflowContext;
10

11
// The Handler trait declares a method for building the chain of
12
// handlers. It also declares a method for executing a request.
13
#[async_trait]
14
pub trait WorkflowHandler<H>: Send + Sync
15
where
16
    H: Clone + Write + CloseHandle + Send,
17
{
18
    async fn execute(
19
        &mut self,
20
        context: &mut WorkflowContext,
21
        terminal: &mut Terminal<H>,
22
        room: &mut ChatRoom,
23
        auth: &mut Auth,
24
    ) -> anyhow::Result<()> {
25
        match self.handle(context, terminal, room, auth).await {
×
26
            Ok(_) => match &mut self.next() {
×
27
                Some(next) => next.execute(context, terminal, room, auth).await,
×
28
                None => Ok(()),
×
29
            },
30
            Err(err) => Err(err),
×
31
        }
32
    }
33

34
    async fn handle(
35
        &mut self,
36
        context: &mut WorkflowContext,
37
        terminal: &mut Terminal<H>,
38
        room: &mut ChatRoom,
39
        auth: &mut Auth,
40
    ) -> anyhow::Result<()>;
41

42
    fn next(&mut self) -> &mut Option<Box<dyn WorkflowHandler<H>>>;
43
}
44

45
/// Helps to wrap an object into a boxed type.
46
pub fn into_next<H: Clone + Write + CloseHandle + Send>(
2✔
47
    handler: impl WorkflowHandler<H> + Sized + 'static,
48
) -> Option<Box<dyn WorkflowHandler<H>>> {
49
    Some(Box::new(handler))
2✔
50
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc