pub struct SerialStudioSource { /* private fields */ }Expand description
A single-connection server for SerialStudio
Implementations§
Source§impl SerialStudioSource
impl SerialStudioSource
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/random.rs (line 10)
8fn main() {
9 // Create server
10 let mut server = SerialStudioSource::new();
11
12 // Start
13 server.start("localhost:8019".to_string());
14
15 // Data loop
16 loop {
17 // Get a random-ish value (using only std)
18 let random = Box::into_raw(Box::new(123)) as usize;
19
20 // Send a frame
21 server.publish(TelemetryFrame {
22 title: "Random number generator".to_string(),
23 groups: vec![DataGroup {
24 title: "Main group".to_string(),
25 widget_type: None,
26 datasets: vec![DataSet {
27 title: Some("Random Number".to_string()),
28 value: json!(random),
29 graph: None,
30 unit: None,
31 w_type: None,
32 }],
33 }],
34 });
35
36 // Wait a bit
37 thread::sleep(Duration::from_millis(500));
38 }
39}Sourcepub fn start(&mut self, bind_addr: String)
pub fn start(&mut self, bind_addr: String)
Start the server
Examples found in repository?
examples/random.rs (line 13)
8fn main() {
9 // Create server
10 let mut server = SerialStudioSource::new();
11
12 // Start
13 server.start("localhost:8019".to_string());
14
15 // Data loop
16 loop {
17 // Get a random-ish value (using only std)
18 let random = Box::into_raw(Box::new(123)) as usize;
19
20 // Send a frame
21 server.publish(TelemetryFrame {
22 title: "Random number generator".to_string(),
23 groups: vec![DataGroup {
24 title: "Main group".to_string(),
25 widget_type: None,
26 datasets: vec![DataSet {
27 title: Some("Random Number".to_string()),
28 value: json!(random),
29 graph: None,
30 unit: None,
31 w_type: None,
32 }],
33 }],
34 });
35
36 // Wait a bit
37 thread::sleep(Duration::from_millis(500));
38 }
39}Sourcepub fn publish(&mut self, frame: TelemetryFrame)
pub fn publish(&mut self, frame: TelemetryFrame)
Publish a new frame
Examples found in repository?
examples/random.rs (lines 21-34)
8fn main() {
9 // Create server
10 let mut server = SerialStudioSource::new();
11
12 // Start
13 server.start("localhost:8019".to_string());
14
15 // Data loop
16 loop {
17 // Get a random-ish value (using only std)
18 let random = Box::into_raw(Box::new(123)) as usize;
19
20 // Send a frame
21 server.publish(TelemetryFrame {
22 title: "Random number generator".to_string(),
23 groups: vec![DataGroup {
24 title: "Main group".to_string(),
25 widget_type: None,
26 datasets: vec![DataSet {
27 title: Some("Random Number".to_string()),
28 value: json!(random),
29 graph: None,
30 unit: None,
31 w_type: None,
32 }],
33 }],
34 });
35
36 // Wait a bit
37 thread::sleep(Duration::from_millis(500));
38 }
39}Auto Trait Implementations§
impl Freeze for SerialStudioSource
impl RefUnwindSafe for SerialStudioSource
impl Send for SerialStudioSource
impl Sync for SerialStudioSource
impl Unpin for SerialStudioSource
impl UnwindSafe for SerialStudioSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more