wireshift-uring 0.1.1

Native Linux io_uring backend for wireshift
Documentation
#![allow(missing_docs)]

use std::fs::File;
use tempfile::NamedTempFile;
use wireshift_core::backend::{Backend, BackendSubmission};
use wireshift_core::buffer::BufferPool;
use wireshift_core::config::RingConfig;
use wireshift_core::op::OpDescriptor;
use wireshift_uring::UringBackend;

#[test]
fn test_gap_chained_open_read_close_fails_unsupported() {
    let (tx, _rx) = std::sync::mpsc::channel();
    let config = RingConfig::default();
    let backend = UringBackend::new(&config, tx).expect("backend creation");

    // Create linked chain Open -> Read -> Close.
    // Without direct descriptors, OpenAtDirect might fail or fall back,
    // gap test proves we handle or properly track unsupported op chains without crashing.

    let path = std::path::PathBuf::from("/etc/passwd");
    let buffer = BufferPool::new(4096, 1)
        .unwrap()
        .acquire()
        .unwrap()
        .into_submitted();

    let submission = BackendSubmission { timeout: None, 
        id: 200,
        descriptor: OpDescriptor::Linked {
            descriptors: vec![
                OpDescriptor::OpenAtDirect {
                    dir: None,
                    path,
                    flags: 0,
                    read: true,
                    write: false,
                    create: false,
                    truncate: false,
                    slot: 0,
                },
                OpDescriptor::ReadFixed {
                    slot: 0,
                    offset: 0,
                    buffer,
                },
                OpDescriptor::CloseFixed { slot: 0 },
            ],
        },
    };

    // We expect it to fallback or submit, but NOT to panic the scanner engine.
    let _ = backend.submit(submission);
}

#[test]
fn test_gap_extreme_queue_depth_submission() {
    let (tx, _rx) = std::sync::mpsc::channel();
    let config = RingConfig {
        queue_depth: 32, // Small ring
        ..RingConfig::default()
    };
    let backend = UringBackend::new(&config, tx).expect("backend creation");

    let temp = NamedTempFile::new().unwrap();
    let file = temp.reopen().unwrap();

    // Attempt to submit 100 entries to a 32-depth queue without waiting
    for i in 0..100 {
        let buffer = BufferPool::new(4096, 1)
            .unwrap()
            .acquire()
            .unwrap()
            .into_submitted();
        let submission = BackendSubmission { timeout: None, 
            id: 300 + i as u64,
            descriptor: OpDescriptor::Read {
                file: file.try_clone().unwrap(),
                offset: 0,
                buffer,
                len: None,
            },
        };
        // This might return Error::submission("io_uring submission queue is full..."), but shouldn't panic!
        let _ = backend.submit(submission);
    }
}