Skip to content

Commit ef3b2e4

Browse files
committed
Amend examples
1 parent 718247a commit ef3b2e4

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

examples/examples/dtls/dial/psk/dial_psk.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ async fn main() -> Result<(), Error> {
6262
println!("connecting {server}..");
6363

6464
let config = Config {
65-
psk: Some(Arc::new(|hint: &[u8]| -> Result<Vec<u8>, Error> {
66-
println!("Server's hint: {}", String::from_utf8(hint.to_vec())?);
67-
Ok(vec![0xAB, 0xC1, 0x23])
65+
psk: Some(Arc::new(|hint: &[u8]| {
66+
let hint = hint.to_owned();
67+
Box::pin(async move {
68+
println!("Server's hint: {}", String::from_utf8(hint.to_vec())?);
69+
Ok(vec![0xAB, 0xC1, 0x23])
70+
})
6871
})),
6972
psk_identity_hint: Some("webrtc-rs DTLS Server".as_bytes().to_vec()),
7073
cipher_suites: vec![CipherSuiteId::Tls_Psk_With_Aes_128_Ccm_8],

examples/examples/dtls/listen/psk/listen_psk.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ async fn main() -> Result<(), Error> {
5757
let host = matches.value_of("host").unwrap().to_owned();
5858

5959
let cfg = Config {
60-
psk: Some(Arc::new(|hint: &[u8]| -> Result<Vec<u8>, Error> {
61-
println!("Client's hint: {}", String::from_utf8(hint.to_vec())?);
62-
Ok(vec![0xAB, 0xC1, 0x23])
60+
psk: Some(Arc::new(|hint: &[u8]| {
61+
let hint = hint.to_owned();
62+
Box::pin(async move {
63+
println!("Client's hint: {}", String::from_utf8(hint.to_vec())?);
64+
Ok(vec![0xAB, 0xC1, 0x23])
65+
})
6366
})),
6467
psk_identity_hint: Some("webrtc-rs DTLS Client".as_bytes().to_vec()),
6568
cipher_suites: vec![CipherSuiteId::Tls_Psk_With_Aes_128_Ccm_8],

0 commit comments

Comments
 (0)