use std::fmt;
use llama_crab_sys as sys;
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(transparent)]
pub struct LlamaToken(pub sys::llama_token);
impl LlamaToken {
#[must_use]
pub const fn raw(self) -> sys::llama_token {
self.0
}
#[must_use]
pub fn new(raw: i32) -> Option<Self> {
Some(Self(raw))
}
pub const NULL: Self = Self(sys::LLAMA_TOKEN_NULL);
}
impl fmt::Debug for LlamaToken {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "LlamaToken({})", self.0)
}
}
impl fmt::Display for LlamaToken {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
}
}
impl From<i32> for LlamaToken {
fn from(v: i32) -> Self {
Self(v)
}
}