Struct trycp_client::TrycpClient

source ·
pub struct TrycpClient { /* private fields */ }
Expand description

Trycp client.

Implementations§

source§

impl TrycpClient

source

pub async fn connect<R>(request: R) -> Result<(Self, SignalRecv)>

Connect to a remote trycp server.

Examples found in repository?
examples/start_stop.rs (line 7)
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
async fn main() {
    let (c, _r) = TrycpClient::connect("ws://127.0.0.1:9000").await.unwrap();

    c.request(Request::Reset, ONE_MIN).await.unwrap();

    c.request(
        Request::ConfigurePlayer {
            id: "alice".to_string(),
            partial_config: "".to_string(),
        },
        ONE_MIN,
    )
    .await
    .unwrap();

    c.request(
        Request::Startup {
            id: "alice".to_string(),
            log_level: None,
        },
        ONE_MIN,
    )
    .await
    .unwrap();

    c.request(
        Request::Shutdown {
            id: "alice".to_string(),
            signal: None,
        },
        ONE_MIN,
    )
    .await
    .unwrap();

    c.request(Request::Reset, ONE_MIN).await.unwrap();
}
source

pub async fn request( &self, request: Request, timeout: Duration, ) -> Result<MessageResponse>

Make a request of the trycp server.

Examples found in repository?
examples/start_stop.rs (line 9)
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
async fn main() {
    let (c, _r) = TrycpClient::connect("ws://127.0.0.1:9000").await.unwrap();

    c.request(Request::Reset, ONE_MIN).await.unwrap();

    c.request(
        Request::ConfigurePlayer {
            id: "alice".to_string(),
            partial_config: "".to_string(),
        },
        ONE_MIN,
    )
    .await
    .unwrap();

    c.request(
        Request::Startup {
            id: "alice".to_string(),
            log_level: None,
        },
        ONE_MIN,
    )
    .await
    .unwrap();

    c.request(
        Request::Shutdown {
            id: "alice".to_string(),
            signal: None,
        },
        ONE_MIN,
    )
    .await
    .unwrap();

    c.request(Request::Reset, ONE_MIN).await.unwrap();
}

Trait Implementations§

source§

impl Drop for TrycpClient

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T