devela/text/
bytes.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
//!
//
// IDEA: a safe, mutable static string, where ops are validated.
// with a capacity and length.

/*
help me design a thin layer in Rust to be able to use utf-8 strings as a slice
of [Utf8Bytes], which a static capacity in bytes, but dynamic length of the
string we can. External apis must be safe, and everything can be done safe
*/

#![allow(unused, reason = "WIP")]

///
// THINK DEFAULT?
// use None…something?
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(transparent)]
pub struct Utf8Byte(u8);

///
pub struct Utf8BytesU8<const CAP: usize> {
    buf: [u8; CAP], // or Utf8Byte?
    len: u8,
}

// NOTES
// - safe methods always validate. use alterantive strategies
//   - unsafe for -> &str
//   - simd-utf8

// impl<const CAP: usize> Utf8Bytes<CAP> {
// }