Skip to content

Instantly share code, notes, and snippets.

View grinapo's full-sized avatar

Peter Gervai grinapo

View GitHub Profile
@grinapo
grinapo / bufsplit.rs
Last active May 26, 2026 22:08
Split a text into BUFFER_MAX sized packets by preferably splitting at `\n`, or space.
//! Split a text into BUFFER_MAX sized packets, by preferably splitting at `\n`, or space.
//! If that's not possible then the lines are cut at the last character before the buffer
//! size, keeping multibyte UTF-8 characters valid.
//!
//! May contain nuts, slop (mainly the tests) and dairy products
//! but it has been manually (eyebally?) reviewed.
pub const BUFFER_MAX: usize = 32_768;
/// Split `input` into `BUFFER_MAX` sized buffers.

Keybase proof

I hereby claim:

  • I am grinapo on github.
  • I am grinapo (https://keybase.io/grinapo) on keybase.
  • I have a public key ASByJa94zueMIzK9IhBjdKpMoiIp1GEpecod8kDjZk2B-Ao

To claim this, I am signing this object: