Skip to content

Commit 1c2045a

Browse files
committed
Upgrade to toml 0.8
1 parent 98d452f commit 1c2045a

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ reductive = "0.9"
2828
serde = { version = "1", features = ["derive"] }
2929
smallvec = "1.7"
3030
thiserror = "1"
31-
toml = "0.5"
31+
toml = "0.8"
3232

3333
[dependencies.memmap2]
3434
version = "0.9"

src/chunks/metadata.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::mem;
55
use std::ops::{Deref, DerefMut};
66

77
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
8-
use toml::Value;
98

109
use crate::chunks::io::{ChunkIdentifier, Header, ReadChunk, WriteChunk};
1110
use crate::error::{Error, Result};
@@ -16,18 +15,18 @@ use crate::io::ReadMetadata;
1615
/// finalfusion metadata in TOML format.
1716
#[derive(Clone, Debug, PartialEq)]
1817
pub struct Metadata {
19-
inner: Value,
18+
inner: toml::Table,
2019
}
2120

2221
impl Metadata {
2322
/// Construct new `Metadata`.
24-
pub fn new(data: Value) -> Self {
25-
Metadata { inner: data }
23+
pub fn new(inner: toml::Table) -> Self {
24+
Metadata { inner }
2625
}
2726
}
2827

2928
impl Deref for Metadata {
30-
type Target = Value;
29+
type Target = toml::Table;
3130

3231
fn deref(&self) -> &Self::Target {
3332
&self.inner
@@ -40,9 +39,9 @@ impl DerefMut for Metadata {
4039
}
4140
}
4241

43-
impl From<Value> for Metadata {
44-
fn from(value: Value) -> Self {
45-
Metadata { inner: value }
42+
impl From<toml::Table> for Metadata {
43+
fn from(inner: toml::Table) -> Self {
44+
Metadata { inner }
4645
}
4746
}
4847

@@ -69,7 +68,7 @@ impl ReadChunk for Metadata {
6968

7069
Ok(Metadata::new(
7170
buf_str
72-
.parse::<Value>()
71+
.parse::<toml::Table>()
7372
.map_err(|e| Error::Format(format!("Cannot deserialize TOML metadata: {}", e)))
7473
.map_err(Error::from)?,
7574
))

src/compat/fasttext/io.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::ops::Mul;
55
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
66
use ndarray::{s, Array2, ErrorKind as ShapeErrorKind, ShapeError};
77
use serde::Serialize;
8-
use toml::Value;
98

109
use crate::chunks::metadata::Metadata;
1110
use crate::chunks::norms::NdNorms;
@@ -107,7 +106,7 @@ impl ReadFastTextPrivate for Embeddings<FastTextSubwordVocab, NdArray> {
107106
)));
108107
}
109108

110-
let metadata = Value::try_from(config).map_err(|e| {
109+
let metadata = toml::Table::try_from(config).map_err(|e| {
111110
Error::Format(format!("Cannot serialize model metadata to TOML: {}", e))
112111
})?;
113112

0 commit comments

Comments
 (0)