enumerated_latin 1.0.0

Encodes short strings as numeric values
Documentation
// SPDX-FileCopyrightText: 2025 Slatian
//
// SPDX-License-Identifier: LGPL-3.0-only

use std::ops::Add;
use std::ops::Div;
use std::ops::Mul;
use std::ops::Rem;
use std::ops::Sub;

/// Trait to imlement for numeric integer types that a string can be encoded into.
pub trait EncodingTarget:
	From<u8>
	+ TryInto<u8>
	+ Add<Self, Output = Self>
	+ Sub<Self, Output = Self>
	+ Mul<Self, Output = Self>
	+ Rem<Output = Self>
	+ Div<Self, Output = Self>
	+ PartialOrd
	+ Copy
{
	/// Returns how many letters can be base26 encoded into this type at maximum.
	const MAX_ENUMERATED_LATIN_LEN: usize;
}

impl EncodingTarget for u128 {
	const MAX_ENUMERATED_LATIN_LEN: usize = 27;
}

impl EncodingTarget for i128 {
	const MAX_ENUMERATED_LATIN_LEN: usize = 26;
}

impl EncodingTarget for u64 {
	const MAX_ENUMERATED_LATIN_LEN: usize = 13;
}

impl EncodingTarget for i64 {
	const MAX_ENUMERATED_LATIN_LEN: usize = 13;
}

impl EncodingTarget for u32 {
	const MAX_ENUMERATED_LATIN_LEN: usize = 6;
}

impl EncodingTarget for i32 {
	const MAX_ENUMERATED_LATIN_LEN: usize = 6;
}

impl EncodingTarget for u16 {
	const MAX_ENUMERATED_LATIN_LEN: usize = 3;
}

impl EncodingTarget for i16 {
	const MAX_ENUMERATED_LATIN_LEN: usize = 2;
}

impl EncodingTarget for u8 {
	const MAX_ENUMERATED_LATIN_LEN: usize = 1;
}