#fifo-queue #queue #fifo #io

queue-file

queue-file is a lightning-fast, transactional, file-based FIFO

16 stable releases

1.4.10 Mar 17, 2023
1.4.8 Feb 14, 2023
1.4.6 Jul 4, 2022
1.3.0 Feb 22, 2022
1.0.2 Jun 27, 2019

#97 in Data structures

Download history 3346/week @ 2024-03-14 2530/week @ 2024-03-21 2568/week @ 2024-03-28 1587/week @ 2024-04-04 3322/week @ 2024-04-11 2007/week @ 2024-04-18 3050/week @ 2024-04-25 1791/week @ 2024-05-02 2079/week @ 2024-05-09 3089/week @ 2024-05-16 2971/week @ 2024-05-23 1645/week @ 2024-05-30 2952/week @ 2024-06-06 2221/week @ 2024-06-13 2006/week @ 2024-06-20 767/week @ 2024-06-27

8,387 downloads per month
Used in 2 crates

Apache-2.0

49KB
924 lines

queue-file

Crate API License Windows Build Status

queue-file is a lightning-fast, transactional, file-based FIFO.

Addition and removal of an element from the queue is an O(1) operation and is atomic. Writes are synchronous by default; data will be written to disk before an operation returns.

queue-file crate is a feature complete and binary compatible port of QueueFile class from Tape2 by Square, Inc. Check the original project here.

Documentation

Usage

To use queue-file, first add this to your Cargo.toml:

[dependencies]
queue-file = "1"

Example

use queue_file::QueueFile;

fn main() {
    let mut qf = QueueFile::open("example.qf")
        .expect("cannot open queue file");

    qf.add("ELEMENT #1".as_bytes()).expect("add failed");
    qf.add("ELEMENT #2".as_bytes()).expect("add failed");
    qf.add("ELEMENT #3".as_bytes()).expect("add failed");

    qf.remove().expect("remove failed");

    for (index, elem) in qf.iter().enumerate() {
        println!(
            "{}: {} bytes -> {}",
            index,
            elem.len(),
            std::str::from_utf8(&elem).unwrap_or("<invalid>")
        );
    }

    qf.clear().expect("clear failed");
}

MSRV

Current MSRV is 1.58.1

License

This project is licensed under the Apache 2.0 license.

Dependencies

~2MB
~40K SLoC