strid_examples/
bytes.rs

1//! An example of constructing a basic strongly-typed wrapper around
2//! a [`Bytes`]-backed value.
3//!
4//! The types in this module do not perform any validation or normalization
5//! of their values, so every valid UTF-8 string is potentially valid for
6//! these types.
7//!
8//! Note: This example requires facet support for `bytestring::ByteString`.
9//! See: https://github.com/facet-rs/facet/issues/1284
10//!
11//! [`Bytes`]: https://docs.rs/bytes/*/bytes/struct.Bytes.html
12
13#![allow(dead_code)]
14
15#[cfg(feature = "bytestring-facet")]
16use bytestring::ByteString;
17#[cfg(feature = "bytestring-facet")]
18use strid::braid;
19
20/// A basic example of a wrapper around a [`Bytes`]
21///
22/// This type ends in _Buf_, so the borrowed form of this type
23/// will be named [`Username`].
24///
25/// [`Bytes`]: https://docs.rs/bytes/*/bytes/struct.Bytes.html
26#[cfg(feature = "bytestring-facet")]
27#[braid(
28    serde,
29    ref_doc = "A borrowed reference to a basic string slice wrapper"
30)]
31pub struct UsernameBuf(ByteString);