1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//! # Messages Accepted by [`Queue`]
//!
//! As an asynchronous actor, the item queue communicates with other
//! actors and rust components through message passing. This module
//! defines the various messages that the item queue accepts, their
//! parameters, replies, and code examples.
//!
//! See each message to learn more about interacting with the item
//! queue and to queue/dequeue data items.
//!
use ;
use ;
use PathBuf;
/// # Push a [`DataItem`] into the scan queue.
///
/// A request for [`Queue`] to add a [`DataItem`] to the back of the
/// scan queue. Once enqueued, a data item can be later dequeued and
/// passed to any number of scan engines.
///
/// ## Reply
///
/// Expect no reply from the scan queue.
///
/// ## Example
///
/// ```
/// # use sscan::actors::{lua_vm::LuaVM, queue::{Queue, messages::Enqueue, data_item::RawDatum}};
/// # use kameo::actor::ActorRef;
/// # #[tokio::main]
/// # async fn main() {
/// // Create a new scan queue.
/// let lua_ref = LuaVM::spawn(None);
/// let queue = Queue::spawn(lua_ref.downgrade());
///
/// // Create a new data item for scanning
/// let data = RawDatum::new("hello_world", "blablabla-Hello World-blablabla");
///
/// // Enqueue the data item
/// queue.ask(Enqueue::item(data)).await.unwrap();
/// # }
/// ```
;
/// # Pop and realize a [`DataItem`] from the scan queue.
///
/// A request for [`Queue`] to pull a [`DataItem`] from the front of the
/// scan queue. Once pulled, the data item is [`realized`] before
/// returning to the sender.
///
/// ## Reply
///
/// Expect a reply of type [`QueueResult`].
///
/// ## Example
///
/// ```
/// # use sscan::actors::{lua_vm::LuaVM, queue::{Queue, messages::{Enqueue, Dequeue}, data_item::RawDatum}};
/// # use kameo::actor::ActorRef;
/// # #[tokio::main]
/// # async fn main() {
/// // Create a new scan queue.
/// let lua_ref = LuaVM::spawn(None);
/// let queue = Queue::spawn(lua_ref.downgrade());
///
/// // Create a new data item for scanning
/// let data = RawDatum::new("hello_world", "blablabla-Hello World-blablabla");
///
/// // Enqueue the data item
/// queue.ask(Enqueue::item(data)).await.unwrap();
///
/// // Now, dequeue the data item.
/// let (name, path, content) = queue.ask(Dequeue).await.unwrap();
/// assert_eq!(name, "hello_world");
/// assert_eq!(path, None);
/// assert_eq!(content, b"blablabla-Hello World-blablabla".to_vec());
/// # }
/// ```
/// [`realized`]: super::data_item::DataItem::realize()
;
/// # Check the number of items in the scan queue.
///
/// A request for [`Queue`] to compute the number of [`DataItem`]
/// objects currently enqueued.
///
/// ## Reply
///
/// Expect a reply of type [`usize`].
///
/// ## Example
///
/// ```
/// # use sscan::actors::{queue::{Queue, messages::GetLength}, lua_vm::LuaVM};
/// # #[tokio::main]
/// # async fn main() {
/// # let lua_ref = LuaVM::spawn(None);
/// # let queue = Queue::spawn(lua_ref.downgrade());
/// let length = queue.ask(GetLength).await.unwrap();
/// # assert_eq!(length, 0usize);
/// # }
/// ```
;