Skip to content

Commit

Permalink
chore(deps): bump mlua from 0.9.9 to 0.10.0 (#1103)
Browse files Browse the repository at this point in the history
* chore(deps): bump mlua from 0.9.9 to 0.10.0

Bumps [mlua](https://github.com/khvzak/mlua) from 0.9.9 to 0.10.0.
- [Release notes](https://github.com/khvzak/mlua/releases)
- [Changelog](https://github.com/mlua-rs/mlua/blob/main/CHANGELOG.md)
- [Commits](mlua-rs/mlua@v0.9.9...v0.10.0)

---
updated-dependencies:
- dependency-name: mlua
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Handle breaking changes

Signed-off-by: Jesse Szwedko <[email protected]>

* one more breaking change

Signed-off-by: Jesse Szwedko <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Jesse Szwedko <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jesse Szwedko <[email protected]>
  • Loading branch information
dependabot[bot] and jszwedko authored Oct 31, 2024
1 parent 929b8a3 commit c69a52e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
15 changes: 8 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ influxdb-line-protocol = { version = "2.0.0", optional = true }
indoc = {version = "2", optional = true }
itertools = { version = "0.13", default-features = false, features=["use_std"], optional = true }
lalrpop-util = { version = "0.22", optional = true }
mlua = { version = "0.9", default-features = false, features = ["lua54", "send", "vendored"], optional = true}
mlua = { version = "0.10", default-features = false, features = ["lua54", "send", "vendored"], optional = true}
nom = { version = "7", default-features = false, features = ["std"], optional = true }
once_cell = { version = "1", default-features = false, features = ["std"], optional = true }
ordered-float = { version = "4", default-features = false, optional = true }
Expand Down Expand Up @@ -233,7 +233,7 @@ serde_json = "1"
indoc = "2"
tracing-test = { version = "0.2", default-features = false }
toml = { version = "0.8", default-features = false }
mlua = { version = "0.9", default-features = false, features = ["lua54", "send", "vendored"]}
mlua = { version = "0.10", default-features = false, features = ["lua54", "send", "vendored"]}
quickcheck = { version = "1"}
regex = { version = "1", default-features = false, features = ["std", "perf", "unicode"] }
paste = { version = "1", default-features = false }
Expand Down
8 changes: 4 additions & 4 deletions src/value/keystring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ mod lua {

use super::KeyString;

impl<'a> FromLua<'a> for KeyString {
fn from_lua(value: LuaValue<'a>, lua: &'a Lua) -> LuaResult<Self> {
impl FromLua for KeyString {
fn from_lua(value: LuaValue, lua: &Lua) -> LuaResult<Self> {
String::from_lua(value, lua).map(Self::from)
}
}

impl<'a> IntoLua<'a> for KeyString {
fn into_lua(self, lua: &'a Lua) -> LuaResult<LuaValue<'_>> {
impl IntoLua for KeyString {
fn into_lua(self, lua: &Lua) -> LuaResult<LuaValue> {
self.0.into_lua(lua)
}
}
Expand Down
26 changes: 13 additions & 13 deletions src/value/value/lua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use ordered_float::NotNan;

use crate::value::Value;

impl<'a> IntoLua<'a> for Value {
impl IntoLua for Value {
#![allow(clippy::wrong_self_convention)] // this trait is defined by mlua
fn into_lua(self, lua: &'a Lua) -> LuaResult<LuaValue<'_>> {
fn into_lua(self, lua: &Lua) -> LuaResult<LuaValue> {
match self {
Self::Bytes(b) => lua.create_string(b.as_ref()).map(LuaValue::String),
Self::Regex(regex) => lua
Expand All @@ -23,15 +23,15 @@ impl<'a> IntoLua<'a> for Value {
}
}

impl<'a> FromLua<'a> for Value {
fn from_lua(value: LuaValue<'a>, lua: &'a Lua) -> LuaResult<Self> {
impl FromLua for Value {
fn from_lua(value: LuaValue, lua: &Lua) -> LuaResult<Self> {
match value {
LuaValue::String(s) => Ok(Self::Bytes(Vec::from(s.as_bytes()).into())),
LuaValue::String(s) => Ok(Self::Bytes(s.as_bytes().to_vec().into())),
LuaValue::Integer(i) => Ok(Self::Integer(i)),
LuaValue::Number(f) => {
let f = NotNan::new(f).map_err(|_| mlua::Error::FromLuaConversionError {
from: value.type_name(),
to: "Value",
to: String::from("Value"),
message: Some("NaN not supported".to_string()),
})?;
Ok(Self::Float(f))
Expand All @@ -48,7 +48,7 @@ impl<'a> FromLua<'a> for Value {
}
other => Err(mlua::Error::FromLuaConversionError {
from: other.type_name(),
to: "Value",
to: String::from("Value"),
message: Some("Unsupported Lua type".to_string()),
}),
}
Expand All @@ -63,7 +63,7 @@ use mlua::prelude::*;
/// # Errors
///
/// This function will fail insertion into the table fails.
pub fn timestamp_to_table(lua: &Lua, ts: DateTime<Utc>) -> LuaResult<LuaTable<'_>> {
pub fn timestamp_to_table(lua: &Lua, ts: DateTime<Utc>) -> LuaResult<LuaTable> {
let table = lua.create_table()?;
table.raw_set("year", ts.year())?;
table.raw_set("month", ts.month())?;
Expand All @@ -84,7 +84,7 @@ pub fn timestamp_to_table(lua: &Lua, ts: DateTime<Utc>) -> LuaResult<LuaTable<'_
/// # Errors
///
/// This function will fail if the table is malformed.
pub fn table_is_timestamp(t: &LuaTable<'_>) -> LuaResult<bool> {
pub fn table_is_timestamp(t: &LuaTable) -> LuaResult<bool> {
for &key in &["year", "month", "day", "hour", "min", "sec"] {
if !t.contains_key(key)? {
return Ok(false);
Expand All @@ -99,14 +99,14 @@ pub fn table_is_timestamp(t: &LuaTable<'_>) -> LuaResult<bool> {
///
/// This function will fail if the table is malformed.
#[allow(clippy::needless_pass_by_value)] // constrained by mlua types
pub fn table_to_timestamp(t: LuaTable<'_>) -> LuaResult<DateTime<Utc>> {
pub fn table_to_timestamp(t: LuaTable) -> LuaResult<DateTime<Utc>> {
let year = t.raw_get("year")?;
let month = t.raw_get("month")?;
let day = t.raw_get("day")?;
let hour = t.raw_get("hour")?;
let min = t.raw_get("min")?;
let sec = t.raw_get("sec")?;
let nano = t.raw_get::<_, Option<u32>>("nanosec")?.unwrap_or(0);
let nano = t.raw_get::<Option<u32>>("nanosec")?.unwrap_or(0);
Ok(Utc
.ymd(year, month, day)
.and_hms_nano_opt(hour, min, sec, nano)
Expand Down Expand Up @@ -276,13 +276,13 @@ mod test {

let lua = Lua::new();
for (value, test_src) in pairs {
let test_fn: LuaFunction<'_> = lua
let test_fn: LuaFunction = lua
.load(test_src)
.eval()
.unwrap_or_else(|_| panic!("Failed to load {test_src} for value {value:?}"));
assert!(
test_fn
.call::<_, bool>(value.clone())
.call::<bool>(value.clone())
.unwrap_or_else(|_| panic!("Failed to call {test_src} for value {value:?}")),
"Test function: {test_src}, value: {value:?}"
);
Expand Down

0 comments on commit c69a52e

Please sign in to comment.