[core] API: compiling Seam 1 skeleton (types, signatures, stubs)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
//! Small shared helpers: title checks, a stable hash, the lettered cover.
|
||||
|
||||
use crate::error::ParseError;
|
||||
use crate::id::GameId;
|
||||
use crate::model::CoverHint;
|
||||
|
||||
/// Checks a display title: trimmed, 1 to `MAX_TITLE` characters, no control characters.
|
||||
pub(crate) fn title(s: &str, field: &'static str) -> Result<String, ParseError> {
|
||||
let _ = s;
|
||||
Err(ParseError::Missing(field))
|
||||
}
|
||||
|
||||
/// FNV-1a, 64 bit: stable across builds and platforms (unlike `std`'s hasher).
|
||||
pub(crate) fn fnv1a64(bytes: &[u8]) -> u64 {
|
||||
let mut h: u64 = 0xcbf2_9ce4_8422_2325;
|
||||
for &b in bytes {
|
||||
h ^= u64::from(b);
|
||||
h = h.wrapping_mul(0x0000_0100_0000_01b3);
|
||||
}
|
||||
h
|
||||
}
|
||||
|
||||
pub(crate) fn lettered(title: &str, id: &GameId) -> CoverHint {
|
||||
let _ = (title, id);
|
||||
CoverHint::Lettered { letter: '#', hue: 0 }
|
||||
}
|
||||
Reference in New Issue
Block a user