SerialStudioSource

Struct SerialStudioSource 

Source
pub struct SerialStudioSource { /* private fields */ }
Expand description

A single-connection server for SerialStudio

Implementations§

Source§

impl SerialStudioSource

Source

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}
Source

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}
Source

pub fn stop(&mut self)

Stop the server

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.