artnet_protocol

Contains the ArtCommand enum which holds the entire ArtNet protocol v4, as per https://artisticlicence.com/WebSiteMaster/User%20Guides/art-net.pdf

```rust use artnet_protocol::*; use std::net::{UdpSocket, ToSocketAddrs};

let socket = UdpSocket::bind(("0.0.0.0", 6454)).unwrap(); let broadcastaddr = ("255.255.255.255", 6454).tosocketaddrs().unwrap().next().unwrap(); socket.setbroadcast(true).unwrap(); let buff = ArtCommand::Poll(Poll::default()).writetobuffer().unwrap(); socket.sendto(&buff, &broadcastaddr).unwrap();

loop { let mut buffer = [0u8; 1024]; let (length, addr) = socket.recvfrom(&mut buffer).unwrap(); let command = ArtCommand::frombuffer(&buffer[..length]).unwrap();

println!("Received {:?}", command);
match command {
    ArtCommand::Poll(poll) => {
        // This will most likely be our own poll request, as this is broadcast to all devices on the network
    },
    ArtCommand::PollReply(reply) => {
        // This is an ArtNet node on the network. We can send commands to it like this:
        let command = ArtCommand::Output(Output {
            length: 5, // must match your data.len()
            data: vec![1, 2, 3, 4, 5], // The data we're sending to the node
            ..Output::default()
        });
        let bytes = command.write_to_buffer().unwrap();
        socket.send_to(&bytes, &addr).unwrap();
    },
    _ => {}
}

} ```

License: MIT