Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // neuro_bridge.rs - Integration for 1U Dock -> Python 3D Feed
- use tokio::net::TcpStream;
- use tokio::io::AsyncWriteExt;
- pub async fn stream_to_visualizer(variance_data: &[f32]) -> tokio::io::Result<()> {
- // Connect to the local Visualization Port
- let mut stream = TcpStream::connect("127.0.0.1:1234").await?;
- // Convert the f32 slice (5120 nodes) to a raw byte buffer
- let mut byte_buffer = Vec::with_capacity(variance_data.len() * 4);
- for &value in variance_data {
- byte_buffer.extend_from_slice(&value.to_ne_bytes());
- }
- // Push the REAL variation data to the Python feed
- stream.write_all(&byte_buffer).await?;
- stream.flush().await?;
- Ok(())
- }
Advertisement
Add Comment
Please, Sign In to add comment