Skip to content

Commit

Permalink
chore: rename to aligners
Browse files Browse the repository at this point in the history
  • Loading branch information
V0ldek committed May 17, 2022
1 parent 13ffb03 commit 62bbfa5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "align"
version = "0.1.0"
name = "aligners"
version = "0.0.1"
authors = ["Mateusz Gienieczko <[email protected]>"]
edition = "2021"
description = "Utilities for alignment guarantees for data."
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# `align` &ndash; strongly typed memory alignment guarantees
# `aligners` &ndash; strongly typed memory alignment guarantees

[![Rust](https://github.com/V0ldek/align/actions/workflows/rust.yml/badge.svg)](https://github.com/V0ldek/align/actions/workflows/rust.yml)
[![Rust](https://github.com/V0ldek/aligner/actions/workflows/rust.yml/badge.svg)](https://github.com/V0ldek/aligners/actions/workflows/rust.yml)

Some bytes just need to be aligned. Want to process bytes in batches of $8$ by interpreting them as `u64`? They must be $8$-byte aligned. Want to run SIMD operations on your bytes? You need to use special unaligned instructions and risk performance, or align them with target's requirements. Maybe your high-performance algorithm requires page alignment?

Validating that something is aligned is hard. `align` solves this problem by introducing strongly typed alignment types. To have your bytes aligned to a page boundary on the target architecture, all you need to do is:
Validating that something is aligned is hard. `aligners` solves this problem by introducing strongly typed alignment types. To have your bytes aligned to a page boundary on the target architecture, all you need to do is:

```rust
use align::{alignment, AlignedBytes};
use aligners::{alignment, AlignedBytes};

let bytes: [u8; 8] = [ 1, 2, 3, 4, 5, 6, 7, 8 ];
let aligned: AlignedBytes<alignment::Page> = bytes.into();
Expand All @@ -34,7 +34,7 @@ Dependencies graph generated by `cargo-deps`:
Or as the output of `cargo tree`:
<!--cspell: disable -->
```plain
align v0.1.0
aligners v0.0.1
├── cfg-if v1.0.0
├── lazy_static v1.4.0
└── page_size v0.4.2
Expand All @@ -57,6 +57,6 @@ It is recommended to always use [cargo-crev](https://github.com/crev-dev/cargo-c

To add me to your WoT trust my crev-proof repo:

```
```plain
cargo crev trust id https://github.com/V0ldek/crev-proofs
```
4 changes: 2 additions & 2 deletions src/alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub unsafe trait Alignment {
///
/// # Examples
/// ```rust
/// use align::alignment::{self, Alignment};
/// use aligners::alignment::{self, Alignment};
///
/// assert_eq!(1, alignment::One::size());
/// ```
Expand All @@ -34,7 +34,7 @@ pub struct One {}
/// # Examples
/// ```rust
/// use page_size;
/// use align::alignment::{self, Alignment};
/// use aligners::alignment::{self, Alignment};
///
/// assert_eq!(page_size::get(), alignment::Page::size());
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/alignment/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct SimdBlock {}
/// # Examples
#[cfg_attr(not(feature = "simd"), doc = "```ignore")]
#[cfg_attr(feature = "simd", doc = "```")]
/// use align::alignment::{self, Alignment};
/// use aligners::alignment::{self, Alignment};
///
/// assert_eq!(2 * alignment::SimdBlock::size(), alignment::TwoSimdBlocks::size());
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<A: Alignment> AlignedBytes<A> {
///
/// # Examples
/// ```rust
/// # use align::{Aligned, AlignedBytes, alignment::{self, Alignment}};
/// # use aligners::{Aligned, AlignedBytes, alignment::{self, Alignment}};
/// let aligned = AlignedBytes::<alignment::Page>::new_initialize(8, |i| { (i % 2) as u8 });
/// let ptr = aligned.as_ptr();
///
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
//! # Examples
//!
//! ```
//! # use align::{alignment::{self, Alignment}};
//! # use aligners::{alignment::{self, Alignment}};
//! assert_eq!(page_size::get(), alignment::Page::size());
//! ```
//! ```
//! # use align::{Aligned, AlignedBytes, alignment::{self, Alignment}};
//! # use aligners::{Aligned, AlignedBytes, alignment::{self, Alignment}};
//! let possibly_unaligned = [1, 2, 3];
//! let aligned = AlignedBytes::<alignment::Page>::from(possibly_unaligned);
//! let ptr = aligned.as_ptr();
Expand All @@ -48,7 +48,7 @@
//! To create a new aligned block of bytes it's easiest to use [`new_zeroed`](`AlignedBytes::new_zeroed`).
//!
//! ```
//! # use align::{Aligned, AlignedBytes, alignment::{self, Alignment}};
//! # use aligners::{Aligned, AlignedBytes, alignment::{self, Alignment}};
//! let aligned = AlignedBytes::<alignment::Page>::new_zeroed(1024);
//! let ptr = aligned.as_ptr();
//!
Expand All @@ -61,7 +61,7 @@
//! if you immediately want to initialize the memory afterwards.
//!
//! ```
//! # use align::{Aligned, AlignedBytes, alignment::{self, Alignment}};
//! # use aligners::{Aligned, AlignedBytes, alignment::{self, Alignment}};
//! let mut aligned = unsafe { AlignedBytes::<alignment::Page>::new(1024) };
//! let ptr = aligned.as_ptr();
//!
Expand All @@ -83,7 +83,7 @@
//! that initializes all bytes with a function of their index.
//!
//! ```
//! # use align::{Aligned, AlignedBytes, alignment::{self, Alignment}};
//! # use aligners::{Aligned, AlignedBytes, alignment::{self, Alignment}};
//! let aligned = AlignedBytes::<alignment::Page>::new_initialize(8, |i| { i as u8 });
//! let ptr = aligned.as_ptr();
//!
Expand All @@ -98,7 +98,7 @@
//!
#![cfg_attr(not(feature = "simd"), doc = "```ignore")]
#![cfg_attr(feature = "simd", doc = "```")]
//! # use align::{Aligned, AlignedBytes, alignment::{self, Alignment}};
//! # use aligners::{Aligned, AlignedBytes, alignment::{self, Alignment}};
//! let possibly_unaligned = [1, 2, 3];
//! let aligned = AlignedBytes::<alignment::SimdBlock>::from(possibly_unaligned);
//! let ptr = aligned.as_ptr();
Expand Down

0 comments on commit 62bbfa5

Please sign in to comment.