audiosocket

Crates.ioaudiosocket
lib.rsaudiosocket
version1.0.0
sourcesrc
created_at2021-01-06 10:47:22.380694
updated_at2021-01-27 14:10:07.216396
descriptionCrate for handling AudioSocket messages
homepage
repositoryhttps://github.com/ivan770/audiosocket
max_upload_size
id333020
size13,938
Ivan Leshchenko (ivan770)

documentation

README

AudioSocket

AudioSocket is a simple TCP-based protocol for sending and receiving real-time audio streams.

Usage

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()))
Commit count: 13

cargo fmt