rspamd_client/protocol/
commands.rs

1//! Commands that can be sent to the server
2
3/// Commands that can be sent to the server
4pub enum RspamdCommand {
5	Scan,
6	Learnspam,
7	Learnham,
8}
9
10/// Ephemeral endpoint representation
11pub struct RspamdEndpoint<'a> {
12	pub url: &'a str,
13	pub command: RspamdCommand,
14	pub need_body: bool,
15}
16
17/// Represents a request to the Rspamd server
18impl<'a> RspamdEndpoint<'a> {
19	/// Create a new endpoint from a command
20	pub fn from_command(command: RspamdCommand) -> RspamdEndpoint<'a> {
21		match command {
22			RspamdCommand::Scan => Self {
23				url: "/checkv2",
24				command,
25				need_body: true,
26			},
27			RspamdCommand::Learnspam => Self {
28				url: "/learnspam",
29				command,
30				need_body: true,
31			},
32			RspamdCommand::Learnham => Self {
33				url: "/learnham",
34				command,
35				need_body: true,
36			},
37		}
38	}
39}
40