//! Core key builder functions.

use super::SEPARATOR;

/// Build a subject-prefixed key: `{subject}\x00{tag}{suffix}`.
pub(super) fn subject_key(subject: &str, tag: &[u8], suffix: &[u8]) -> Vec<u8> {
    let mut key = Vec::with_capacity(subject.len() + 1 + tag.len() + suffix.len());
    key.extend_from_slice(subject.as_bytes());
    key.push(SEPARATOR);
    key.extend_from_slice(tag);
    key.extend_from_slice(suffix);
    key
}

/// Build a global key: `\x00{tag}{suffix}`.
pub(super) fn global_key(tag: &[u8], suffix: &[u8]) -> Vec<u8> {
    let mut key = Vec::with_capacity(1 + tag.len() + suffix.len());
    key.push(SEPARATOR);
    key.extend_from_slice(tag);
    key.extend_from_slice(suffix);
    key
}
