Skip to content

Commit

Permalink
release: 0.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Jun 1, 2023
2 parents eb80ca4 + 796df5b commit 6086027
Show file tree
Hide file tree
Showing 24 changed files with 155 additions and 149 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/ci.yaml
Expand Up @@ -2,9 +2,9 @@ name: Build

on:
push:
branches: [ master ]
branches: []
pull_request:
branches: [ master ]
branches: []

defaults:
run:
Expand Down Expand Up @@ -48,14 +48,20 @@ jobs:
- name: Build
run: |
cargo build --bin fyi --target ${{ matrix.target }}
cargo build --bin fyi --release --target ${{ matrix.target }}
- name: Clippy
run: |
cargo clippy --release --all-features --target ${{ matrix.target }}
cargo clippy --release --no-default-features --target ${{ matrix.target }}
- name: Tests
- name: Tests (Debug)
run: |
cargo test --all-features --target ${{ matrix.target }}
cargo test --no-default-features --target ${{ matrix.target }}
- name: Tests (Release)
run: |
cargo test --release --all-features --target ${{ matrix.target }}
cargo test --release --no-default-features --target ${{ matrix.target }}
54 changes: 54 additions & 0 deletions .github/workflows/msrv.yaml
@@ -0,0 +1,54 @@
name: MSRV

on:
push:
branches: []
pull_request:
branches: []

defaults:
run:
shell: bash

env:
CARGO_TERM_COLOR: always

jobs:
all:
name: All

strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-apple-darwin
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest

runs-on: ${{matrix.os}}

env:
RUSTFLAGS: "-D warnings"

steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: taiki-e/install-action@v2
with:
tool: cargo-msrv

- name: Info
run: |
rustup --version
cargo --version
cargo clippy --version
- name: MSRV
run: |
cargo msrv --path fyi verify
cargo msrv --path fyi_msg verify -- cargo check --all-features
13 changes: 6 additions & 7 deletions CREDITS.md
@@ -1,15 +1,14 @@
# Project Dependencies
Package: fyi
Version: 0.10.8
Generated: 2023-04-20 16:28:44 UTC
Version: 0.11.0
Generated: 2023-06-01 20:36:30 UTC

| Package | Version | Author(s) | License |
| ---- | ---- | ---- | ---- |
| [argyle](https://github.com/Blobfolio/argyle) | 0.6.7 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
| [argyle](https://github.com/Blobfolio/argyle) | 0.6.8 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
| [const_fn](https://github.com/taiki-e/const_fn) | 0.4.9 | | Apache-2.0 or MIT |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.4.8 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.10.8 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.5.0 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.11.0 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
| [num-traits](https://github.com/rust-num/num-traits) | 0.2.15 | The Rust Project Developers | Apache-2.0 or MIT |
| [once_cell](https://github.com/matklad/once_cell) | 1.17.1 | [Aleksey Kladov](mailto:aleksey.kladov@gmail.com) | Apache-2.0 or MIT |
| [tz-rs](https://github.com/x-hgg-x/tz-rs) | 0.6.14 | x-hgg-x | Apache-2.0 or MIT |
| [utc2k](https://github.com/Blobfolio/utc2k) | 0.5.15 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
| [utc2k](https://github.com/Blobfolio/utc2k) | 0.6.0 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL |
6 changes: 3 additions & 3 deletions fyi/Cargo.toml
@@ -1,10 +1,10 @@
[package]
name = "fyi"
version = "0.10.8"
version = "0.11.0"
license = "WTFPL"
authors = ["Blobfolio, LLC. <hello@blobfolio.com>"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.70"
description = "A dead-simple CLI status message printer for use in BASH scripts, etc."
repository = "https://github.com/Blobfolio/fyi"
publish = false
Expand Down Expand Up @@ -169,7 +169,7 @@ subcommands = [ "confirm", "print", "crunched", "debug", "done", "error", "info"
path = "../fyi_msg"

[dependencies]
dactyl = "0.4.*"
dactyl = "0.5.*"

[dependencies.argyle]
version = "0.6.*"
Expand Down
10 changes: 5 additions & 5 deletions fyi_msg/Cargo.toml
@@ -1,9 +1,9 @@
[package]
name = "fyi_msg"
version = "0.10.8"
version = "0.11.0"
authors = ["Blobfolio, LLC. <hello@blobfolio.com>"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.70"
description = "Simple ANSI-formatted, prefixed messages for console printing."
license = "WTFPL"
repository = "https://github.com/Blobfolio/fyi"
Expand All @@ -18,7 +18,7 @@ default-target = "x86_64-unknown-linux-gnu"
targets = [ "x86_64-unknown-linux-gnu", "x86_64-apple-darwin" ]

[dependencies]
dactyl = "0.4.*, >= 0.4.2"
dactyl = "0.5.*"

[dependencies.ahash]
version = "0.8.*"
Expand All @@ -38,12 +38,12 @@ version = "0.1.*"
optional = true

[dependencies.utc2k]
version = "0.5.*"
version = "0.6.*"
features = [ "local" ]
optional = true

[dev-dependencies]
brunch = "0.4.*"
brunch = "0.5.*"
rayon = "1.7.*"

[[bench]]
Expand Down
10 changes: 2 additions & 8 deletions fyi_msg/src/fitted.rs
Expand Up @@ -149,10 +149,7 @@ fn length_width_unicode(bytes: &[u8], len: usize, width: usize, stop: usize) ->
// Build a string from the bytes so we can get access to the inner chars.
// This shouldn't fail, but if it does, it will return the length the call
// was seeded with.
let strung = match std::str::from_utf8(bytes) {
Ok(s) => s,
Err(_) => { return len; },
};
let Ok(strung) = std::str::from_utf8(bytes) else { return len; };

let mut in_ansi: bool = false;
match strung.chars()
Expand Down Expand Up @@ -200,10 +197,7 @@ fn width_unicode(bytes: &[u8], width: usize) -> usize {

// Build a string from the bytes so we can get access to the inner chars.
// This shouldn't fail, but if it does, it will default to a byte count.
let strung = match std::str::from_utf8(bytes) {
Ok(s) => s,
Err(_) => { return width + bytes.len(); },
};
let Ok(strung) = std::str::from_utf8(bytes) else { return width + bytes.len(); };

let mut in_ansi: bool = false;
strung.chars()
Expand Down
62 changes: 6 additions & 56 deletions fyi_msg/src/msg/buffer.rs
Expand Up @@ -14,7 +14,6 @@ use std::{
Deref,
Range,
},
ptr,
};


Expand Down Expand Up @@ -163,31 +162,6 @@ impl<const N: usize> MsgBuffer<N> {
/// Return as a byte slice.
pub fn as_bytes(&self) -> &[u8] { &self.buf }

#[allow(unsafe_code)]
#[must_use]
#[inline]
/// # As Pointer.
///
/// This method returns a read-only pointer to the underlying buffer.
pub(crate) unsafe fn as_ptr(&self, idx: u32) -> *const u8 {
self.buf.as_ptr().add(idx as usize)
}

#[allow(unsafe_code)]
#[must_use]
#[inline]
/// # As Mut Pointer.
///
/// This method returns a mutable pointer to the underlying buffer.
///
/// ## Safety
///
/// Any changes written to the pointer must not affect the table of
/// contents or undefined things will happen!
pub(crate) unsafe fn as_mut_ptr(&mut self, idx: u32) -> *mut u8 {
self.buf.as_mut_ptr().add(idx as usize)
}

#[must_use]
#[inline]
/// # As Str.
Expand Down Expand Up @@ -285,7 +259,6 @@ impl<const N: usize> MsgBuffer<N> {
}

#[allow(clippy::cast_possible_truncation)] // We've previously asserted it fits.
#[allow(unsafe_code)]
/// # Extend Part.
///
/// ## Panics
Expand All @@ -306,19 +279,13 @@ impl<const N: usize> MsgBuffer<N> {
}
else {
self.resize_grow(idx, len);
unsafe {
std::ptr::copy_nonoverlapping(
buf.as_ptr(),
self.as_mut_ptr(end),
len as usize
);
}
let end = end as usize;
self.buf[end..end + buf.len()].copy_from_slice(buf);
}
}
}

#[allow(clippy::comparison_chain)] // We're only matching 2/3.
#[allow(unsafe_code)]
/// # Replace Part.
///
/// ## Panics
Expand All @@ -341,13 +308,8 @@ impl<const N: usize> MsgBuffer<N> {

// Write it!
if 0 != new_len {
unsafe {
std::ptr::copy_nonoverlapping(
buf.as_ptr(),
self.as_mut_ptr(self.start(idx)),
new_len as usize
);
}
let from = self.start(idx) as usize;
self.buf[from..from + buf.len()].copy_from_slice(buf);
}
}

Expand All @@ -362,7 +324,6 @@ impl<const N: usize> MsgBuffer<N> {

/// ## Internal.
impl<const N: usize> MsgBuffer<N> {
#[allow(unsafe_code)]
/// # Grow.
///
/// ## Panics
Expand All @@ -384,22 +345,11 @@ impl<const N: usize> MsgBuffer<N> {

let end: u32 = self.end(idx);
let len: u32 = self.total_len();
self.buf.reserve(adj as usize);
self.buf.resize((len + adj) as usize, b' ');

// We need to shift things over.
if end < len {
unsafe {
ptr::copy(
self.as_ptr(end),
self.as_mut_ptr(end + adj),
(len - end) as usize
);

self.buf.set_len((len + adj) as usize);
}
}
else {
unsafe { self.buf.set_len((len + adj) as usize); }
self.buf.copy_within(end as usize..len as usize, (end + adj) as usize);
}

self.raise_parts_from(idx, adj);
Expand Down
4 changes: 2 additions & 2 deletions fyi_msg/src/msg/mod.rs
Expand Up @@ -807,6 +807,7 @@ impl Msg {
/// Return the entire message as a string slice. Alternatively, you could
/// use [`Msg::as_ref`] or [`Msg::borrow`].
pub fn as_str(&self) -> &str {
debug_assert!(std::str::from_utf8(&self.0).is_ok(), "Bug: Message is not UTF8.");
unsafe { std::str::from_utf8_unchecked(&self.0) }
}

Expand All @@ -817,14 +818,13 @@ impl Msg {
/// Consume the message, returning an owned `Vec<u8>`.
pub fn into_vec(self) -> Vec<u8> { self.0.into_vec() }

#[allow(unsafe_code)]
#[must_use]
#[inline]
/// # Into String.
///
/// Consume the message, returning an owned string.
pub fn into_string(self) -> String {
unsafe { String::from_utf8_unchecked(self.0.into_vec()) }
String::from_utf8(self.0.into_vec()).unwrap_or_else(|_| String::new())
}

#[cfg(feature = "fitted")]
Expand Down

0 comments on commit 6086027

Please sign in to comment.