membuf

Crates.iomembuf
lib.rsmembuf
version0.0.5
sourcesrc
created_at2015-05-06 08:42:51.306208
updated_at2015-12-11 23:54:10.497015
descriptionA safe-ish wrapper for allocating and reallocating heap buffers.
homepage
repositoryhttps://github.com/reem/rust-membuf.git
max_upload_size
id2040
size15,787
log (github:rust-lang:log)

documentation

README

membuf

A safe-ish wrapper for allocating, reallocating and deallocating heap buffers.

Overview

A safe wrapper around a heap allocated buffer of Ts, tracking capacity only.

MemBuf makes no promises about the actual contents of this memory, that's up to the user of the structure and can be manipulated using the standard pointer utilities, accessible through the impl of Deref<Target=*mut T> for MemBuf<T>.

You can think of MemBuf<T> as an approximation for Box<[T]> where the elements are not guaranteed to be valid/initialized. It is meant to be used as a building block for other collections, so they do not have to concern themselves with the minutiae of allocating, reallocating, and deallocating memory.

However, note that MemBuf<T> does not have a destructor, and implements Copy, as a result, it does not implement Send or Sync, and it is the responsibility of the user to call deallocate if they wish to free memory.

There is also a UniqueBuf<T> which does not implement Copy, implements Send and Sync, and has a destructor responsible for deallocation.

Usage

Use the crates.io repository; add this to your Cargo.toml along with the rest of your dependencies:

[dependencies]
membuf = "*"

Author

Jonathan Reem is the primary author and maintainer of membuf.

License

MIT

Commit count: 13

cargo fmt