pub struct TokenSequence {
pub vocabulary_id: VocabularyId,
pub vocabulary_version: Version,
pub vocabulary_digest: String,
pub modality: Modality,
pub adapter: Option<String>,
pub ids: Vec<u32>,
}Expand description
Token ids scoped to the exact vocabulary that produced them.
Ids from different vocabularies are never interchangeable, so a sequence always travels with the vocabulary id, version and content digest.
Fields§
§vocabulary_id: VocabularyId§vocabulary_version: Version§vocabulary_digest: String§modality: Modality§adapter: Option<String>§ids: Vec<u32>Implementations§
Source§impl TokenSequence
impl TokenSequence
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>>
pub fn to_bytes(&self) -> Result<Vec<u8>>
Serialize to the .kute container: magic, little-endian header length,
JSON header, then LEB128 varint token ids.
Sourcepub fn to_bytes_compressed(&self) -> Result<Vec<u8>>
pub fn to_bytes_compressed(&self) -> Result<Vec<u8>>
Serialize to the compressed .kute container (format 2): the same
header, then the ids as fixed-width little-endian integers inside one
zlib stream. Smaller than format 1 on anything repetitive; from_bytes
reads both.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Parse a .kute container of either format. Rejects truncated,
oversized or trailing data.
Trait Implementations§
Source§impl Clone for TokenSequence
impl Clone for TokenSequence
Source§impl Debug for TokenSequence
impl Debug for TokenSequence
Source§impl<'de> Deserialize<'de> for TokenSequence
impl<'de> Deserialize<'de> for TokenSequence
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for TokenSequence
Source§impl PartialEq for TokenSequence
impl PartialEq for TokenSequence
Source§impl Serialize for TokenSequence
impl Serialize for TokenSequence
impl StructuralPartialEq for TokenSequence
Auto Trait Implementations§
impl Forget for TokenSequence
impl Freeze for TokenSequence
impl Move for TokenSequence
impl RefUnwindSafe for TokenSequence
impl Send for TokenSequence
impl Sync for TokenSequence
impl Unpin for TokenSequence
impl UnsafeUnpin for TokenSequence
impl UnwindSafe for TokenSequence
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more