rust chksum-md5库 实现获取文件md5值

rust chksum-md5库 实现获取文件md5值

[dependencies] chksum-md5 = "0.0.0" use chksum_md5 as md5; let file = File::open(path)?; let digest = md5::chksum(file)?; assert_eq!( digest.to_hex_lowercase(), "5c71dbb2...

Rust 2024-03-02 PM 305次 0条
Rust读取excel文件的库

Rust读取excel文件的库

Rust是一款新型的、主打安全的语言。但是,百度上搜索读取excel的库还很难找。不过,我找到了一款,推荐给大家:ooxml, 当前版本0.2.7.这是依赖:[dependencies] ooxml = "0.2.7" itertools = "0.11.0" 具体代码如下:use ooxml::document::SpreadsheetDocumen...

Rust 2024-02-29 PM 284次 0条
rust 获取和设置鼠标位置

rust 获取和设置鼠标位置

#[cfg(windows)] extern crate winapi; fn set_cursor_pos(x: i32, y: i32) -> bool { use winapi::um::winuser::SetCursorPos; let ret = unsafe { SetCursorPos(x, y) }; ret == 1 } fn ...

Rust 2024-02-27 PM 276次 0条
rust 延时 500毫秒

rust 延时 500毫秒

要在 Rust 中延迟执行代码,您可以使用 std::thread::sleep() 函数。这个函数接受一个时间量参数,表示需要等待的时间长度。下面是一个示例代码,将延迟 500 毫秒(0.5 秒):use std::{thread, time}; fn main() { let duration = time::Duration::from_millis(500); th...

Rust 2023-05-15 PM 2254次 0条
rust 实现命令行程序 运行 不显示 窗口

rust 实现命令行程序 运行 不显示 窗口

如果你想在 Windows 操作系统上使用 Rust 编写一个命令行程序,并且不想让窗口显示出来,你可以使用 windows::windows_subsystem 模块,将子系统定义为 "windows",如下所示:#![windows_subsystem = "windows"] fn main() { // 在此处编写代码 } 当你构建并运行该程序时,它将终...

Rust 2023-05-15 PM 1996次 0条
rust reqwest交叉编译错误 error: failed to run custom build command for `openssl-sys v0.9.63`

rust reqwest交叉编译错误 error: failed to run custom build command for `openssl-sys v0.9.63`

windows下 编译报错error: failed to run custom build command for openssl-sys v0.9.63解决办法:1.安装opensslWindows下:https://slproweb.com/products/Win32OpenSSL.html网站下载https://slproweb.com/download/Win64OpenSSL-...

Rust 2023-04-24 PM 2404次 0条
rust 保存文本 使用Windows(CRLF)格式

rust 保存文本 使用Windows(CRLF)格式

您可以在Rust中使用标准库中的std::fs模块来保存文本文件,并且在Windows上使用CRLF行尾。下面是一个基本示例:rustuse std::fs::File; use std::io::{BufWriter, Write}; fn main() { // 创建一个新文件并打开它以进行写入 let file = File::create("exampl...

Rust 2023-04-24 PM 966次 0条
rust 清空 文本文件 内容

rust 清空 文本文件 内容

在 Rust 语言中,要清空文本文件的内容可以使用标准库中的 File 和 Write trait。具体步骤如下:打开一个文本文件并获取其句柄。使用 set_len() 方法将该文件的长度设置为 0。关闭该文件。以下是示例代码:use std::fs::{File, OpenOptions}; use std::io::prelude::*; fn main() { let fil...

Rust 2023-04-23 AM 1135次 0条
rust 字符串大小写转换

rust 字符串大小写转换

fn main() { let s = "Hello, World!"; let upper = s.to_uppercase(); let lower = s.to_lowercase(); println!("Original: {}", s); println!("Upper case: {}&...

Rust 2023-04-03 PM 619次 0条
rust 命令行输出日期时间

rust 命令行输出日期时间

//不刷新输出日期时间use chrono::prelude::*;use std::thread;use std::time::Duration;fn main() {loop { let now = Local::now(); println!("{}", now.format("%Y-%m-%d %H:%M:%S")); ...

Rust 2023-04-03 PM 453次 0条
rust windows wmi cpu 占用率

rust windows wmi cpu 占用率

rust wmi cpu 占用率在 Rust 中使用 WMI 获取 CPU 占用率,可以使用 winapi 和 wmi crates。以下是一个简单的例子,使用 WMI 查询 CPU 占用率:use std::collections::HashMap; use std::thread::sleep; use std::time::Duration; use wmi::{COMLibrary,...

Rust 2023-03-27 PM 507次 0条