mirror of
https://github.com/extism/extism.git
synced 2026-01-10 06:18:00 -05:00
chore: fix clippy (#799)
This commit is contained in:
@@ -199,7 +199,7 @@ pub enum WasmInput<'a> {
|
||||
ManifestRef(&'a Manifest),
|
||||
}
|
||||
|
||||
impl<'a> From<Manifest> for WasmInput<'a> {
|
||||
impl From<Manifest> for WasmInput<'_> {
|
||||
fn from(value: Manifest) -> Self {
|
||||
WasmInput::Manifest(value)
|
||||
}
|
||||
@@ -229,7 +229,7 @@ impl<'a> From<&'a str> for WasmInput<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<Vec<u8>> for WasmInput<'a> {
|
||||
impl From<Vec<u8>> for WasmInput<'_> {
|
||||
fn from(value: Vec<u8>) -> Self {
|
||||
WasmInput::Data(value.into())
|
||||
}
|
||||
@@ -1168,7 +1168,7 @@ macro_rules! typed_plugin {
|
||||
|
||||
impl TryFrom<$crate::Plugin> for $name {
|
||||
type Error = $crate::Error;
|
||||
fn try_from(mut x: $crate::Plugin) -> Result<Self, Self::Error> {
|
||||
fn try_from(x: $crate::Plugin) -> Result<Self, Self::Error> {
|
||||
$(
|
||||
if !x.function_exists(stringify!($f)) {
|
||||
return Err($crate::Error::msg(format!("Invalid function: {}", stringify!($f))));
|
||||
|
||||
@@ -884,7 +884,7 @@ fn set_log_file(log_file: impl Into<std::path::PathBuf>, filter: &str) -> Result
|
||||
Ok(())
|
||||
}
|
||||
|
||||
static mut LOG_BUFFER: Option<LogBuffer> = None;
|
||||
static LOG_BUFFER: std::sync::Mutex<Option<LogBuffer>> = std::sync::Mutex::new(None);
|
||||
|
||||
/// Enable a custom log handler, this will buffer logs until `extism_log_drain` is called
|
||||
/// Log level should be one of: info, error, trace, debug, warn
|
||||
@@ -916,8 +916,8 @@ unsafe fn set_log_buffer(filter: &str) -> Result<(), Error> {
|
||||
x.parse_lossy(filter)
|
||||
}
|
||||
});
|
||||
LOG_BUFFER = Some(LogBuffer::default());
|
||||
let buf = LOG_BUFFER.clone().unwrap();
|
||||
*LOG_BUFFER.lock().unwrap() = Some(LogBuffer::default());
|
||||
let buf = LOG_BUFFER.lock().unwrap().clone().unwrap();
|
||||
cfg.with_ansi(false)
|
||||
.with_writer(move || buf.clone())
|
||||
.try_init()
|
||||
@@ -929,7 +929,7 @@ unsafe fn set_log_buffer(filter: &str) -> Result<(), Error> {
|
||||
/// Calls the provided callback function for each buffered log line.
|
||||
/// This is only needed when `extism_log_custom` is used.
|
||||
pub unsafe extern "C" fn extism_log_drain(handler: ExtismLogDrainFunctionType) {
|
||||
if let Some(buf) = LOG_BUFFER.as_mut() {
|
||||
if let Some(buf) = LOG_BUFFER.lock().unwrap().as_mut() {
|
||||
if let Ok(mut buf) = buf.buffer.lock() {
|
||||
for (line, len) in buf.drain(..) {
|
||||
handler(line.as_ptr(), len as u64);
|
||||
|
||||
@@ -447,7 +447,7 @@ fn hello_world_set_error(
|
||||
_user_data: UserData<()>,
|
||||
) -> Result<(), Error> {
|
||||
plugin.set_error("TEST")?;
|
||||
outputs[0] = inputs[0].clone();
|
||||
outputs[0] = inputs[0];
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ fn hello_world_user_data(
|
||||
let mut data = data.lock().unwrap();
|
||||
let s = _plugin.memory_get_val(&inputs[0])?;
|
||||
data.write_all(s)?;
|
||||
outputs[0] = inputs[0].clone();
|
||||
outputs[0] = inputs[0];
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -22,18 +22,18 @@ pub(crate) struct Timer {
|
||||
|
||||
#[cfg(not(target_family = "windows"))]
|
||||
extern "C" fn cleanup_timer() {
|
||||
let mut timer = match unsafe { TIMER.lock() } {
|
||||
let mut timer = match TIMER.lock() {
|
||||
Ok(x) => x,
|
||||
Err(e) => e.into_inner(),
|
||||
};
|
||||
drop(timer.take());
|
||||
}
|
||||
|
||||
static mut TIMER: std::sync::Mutex<Option<Timer>> = std::sync::Mutex::new(None);
|
||||
static TIMER: std::sync::Mutex<Option<Timer>> = std::sync::Mutex::new(None);
|
||||
|
||||
impl Timer {
|
||||
pub(crate) fn tx() -> std::sync::mpsc::Sender<TimerAction> {
|
||||
let mut timer = match unsafe { TIMER.lock() } {
|
||||
let mut timer = match TIMER.lock() {
|
||||
Ok(x) => x,
|
||||
Err(e) => e.into_inner(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user