Crates.io | audiosocket |
lib.rs | audiosocket |
version | 1.0.0 |
source | src |
created_at | 2021-01-06 10:47:22.380694 |
updated_at | 2021-01-27 14:10:07.216396 |
description | Crate for handling AudioSocket messages |
homepage | |
repository | https://github.com/ivan770/audiosocket |
max_upload_size | |
id | 333020 |
size | 13,938 |
AudioSocket is a simple TCP-based protocol for sending and receiving real-time audio streams.
use std::{convert::TryFrom, str::FromStr};
use audiosocket::{Message, RawMessage, Type};
use uuid::Uuid;
// You may replace this with bytes from TCP socket, test file, etc.
let recv = [
// Message contains a stream identifier.
1u8,
// Payload length is 16 bytes.
0,
16,
// Payload with UUID.
4,
54,
67,
12,
43,
2,
98,
76,
32,
50,
87,
5,
1,
33,
43,
87
];
let raw_message = RawMessage::try_from(&recv[..]).unwrap();
assert_eq!(*raw_message.message_type(), Type::Identifier);
let message = Message::try_from(raw_message).unwrap();
assert_eq!(message, Message::Identifier(Uuid::from_str("0436430c-2b02-624c-2032-570501212b57").unwrap()))