Skip to content
Dari-OSPublic

About

sector is a vector with customizable memory management behaviors that can be switched using state machines

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

sector

A stateful vector implementation that provides different memory management behaviors through Rust traits and state machines.

Rust MIT Apache 2.0 Build Status


Table of Contents


About

sector is a Rust library that provides a stateful vector structure (Sector<State, T>) with choosable memory allocation strategies.
Unlike Vec<T>, it allows developers to control how memory grows/shrinks.

Note

This library is under development. Expect changes and optimizations.

Features

  • Stateful Memory Management – Control memory allocation behavior dynamically.

  • Lightweight & Fast – Minimal overhead while allowing full customization.

  • No Std Support – Support for #![no_std] environments by default.

States

Sector has 6 different states:

  • Normal Acts like the normal std::vec::Vec<T>.
  • Dynamic Grows the internal capacity by a factor of 2. Shrinks to 3/4 of the original capacity
  • Fixed Is not able to grow nor shrink. Returns false if the capacity is full and you try to add elements.
  • Locked Does not allow to add or remove elements, regardless of the inner capacity.
  • Manual Requires you to grow and shrink the inner capacity manually.
  • Tight The inner capacity is exactly as large as the length

Warning

Be careful! Zero Sized Types are treated differently by each state. Refer to the specific documentation of each state to get more information.

Usage

Add sector as a dependency in your Cargo.toml:

[dependencies]
sector = "0.1"

Basic Example

use sector::{states::Normal, Sector};

fn main() {
    let mut sec: Sector<Normal, _> = Sector::new();
    sec.push(10);
    sec.push(20);

    // Access elements
    println!("First element: {:?}", sec.get(0));
}

Documentation

Generate docs locally:

cargo doc --open

Or visit the documentation online:

docs.rs

Contributing

Contributions are welcome!

Roadmap

  • Basic stateful vector implementation
  • Capacity management
  • no_std support
  • Benchmarks & optimizations

License

This project is dual licensed:

About

sector is a vector with customizable memory management behaviors that can be switched using state machines

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages