Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrise committed Feb 22, 2025
1 parent 7b3fcf0 commit f381a1d
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ members = [
resolver = "3"

[workspace.package]
edition = "2021"
edition = "2024"
authors = ["Lyrise <lyrise1984@gmail.com>"]

[workspace.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion modules/base/src/serde/base64.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use base64::{engine::general_purpose::STANDARD as BASE64, Engine};
use base64::{Engine, engine::general_purpose::STANDARD as BASE64};
use serde::{Deserialize, Deserializer, Serialize, Serializer};

pub fn serialize<S: Serializer>(v: &Vec<u8>, s: S) -> Result<S::Ok, S::Error> {
Expand Down
6 changes: 3 additions & 3 deletions modules/base/src/tsid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use chrono::{DateTime, Utc};
use crate::{clock::Clock, random_bytes::RandomBytesProvider};

pub trait TsidProvider {
fn gen(&mut self) -> Tsid;
fn create(&mut self) -> Tsid;
}

pub struct TsidProviderImpl<TClock, TRandomBytesProvider>
Expand Down Expand Up @@ -44,7 +44,7 @@ where
TSystemClock: Clock<Utc>,
TRandomBytesProvider: RandomBytesProvider,
{
fn gen(&mut self) -> Tsid {
fn create(&mut self) -> Tsid {
let timestamp = self.clock.now();
let random_bytes = self.random_bytes_provider.get_bytes(self.random_byte_count);
Tsid { timestamp, random_bytes }
Expand All @@ -70,6 +70,6 @@ mod tests {
#[tokio::test]
async fn print_test() {
let mut p = TsidProviderImpl::new(ClockUtc, FakeRandomBytesProvider::new(), 16);
println!("{:}", p.gen());
println!("{:}", p.create());
}
}
7 changes: 5 additions & 2 deletions modules/cloud/src/aws/s3/s3_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ mod tests {
#[ignore]
#[tokio::test]
async fn simple_test() {
env::set_var("AWS_PROFILE", "opxs-dev");
env::set_var("AWS_REGION", "us-east-1");
unsafe {
env::set_var("AWS_PROFILE", "opxs-dev");
env::set_var("AWS_REGION", "us-east-1");
}

let sdk_config = aws_config::load_defaults(BehaviorVersion::latest()).await;
let s3 = S3ClientImpl {
client: aws_sdk_s3::Client::new(&sdk_config),
Expand Down
2 changes: 1 addition & 1 deletion modules/omnikit/src/model/omni_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
str::FromStr,
};

use nom::{branch::*, bytes::complete::*, character::complete::*, combinator::*, multi::*, sequence::*, IResult, Parser};
use nom::{IResult, Parser, branch::*, bytes::complete::*, character::complete::*, combinator::*, multi::*, sequence::*};

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct OmniAddr {
Expand Down
6 changes: 4 additions & 2 deletions modules/omnikit/src/model/omni_sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use std::fmt;
use std::str::FromStr;

use bitflags::bitflags;
use ed25519_dalek::pkcs8::{DecodePrivateKey as _, DecodePublicKey as _, EncodePrivateKey as _, EncodePublicKey as _};
use ed25519_dalek::Signer as _;
use ed25519_dalek::{
Signer as _,
pkcs8::{DecodePrivateKey as _, DecodePublicKey as _, EncodePrivateKey as _, EncodePublicKey as _},
};
use omnius_core_rocketpack::{RocketMessage, RocketMessageReader, RocketMessageWriter};
use rand_core::OsRng;
use sha3::{Digest, Sha3_256};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use aes_gcm::{aead::Aead, Aes256Gcm, Error, Key, KeyInit as _};
use aes_gcm::{Aes256Gcm, Error, Key, KeyInit as _, aead::Aead};
use sha3::digest::generic_array::GenericArray;

use super::util::increment_bytes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use aes_gcm::{aead::Aead, Aes256Gcm, Error, Key, KeyInit as _};
use aes_gcm::{Aes256Gcm, Error, Key, KeyInit as _, aead::Aead};
use sha3::digest::generic_array::GenericArray;

use super::util::increment_bytes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl RocketMessage for ProfileMessage {

#[cfg(test)]
mod tests {
use base64::{engine::general_purpose::URL_SAFE_NO_PAD as BASE64_URL, Engine};
use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD as BASE64_URL};
use testresult::TestResult;

use super::*;
Expand Down
14 changes: 4 additions & 10 deletions modules/omnikit/src/service/connection/secure/v1/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ where
WriteState::Init => {
this.write_state = WriteState::WritePlaintext { plaintext: BytesMut::new() };
}
WriteState::WritePlaintext { ref mut plaintext } => {
WriteState::WritePlaintext { plaintext } => {
let size = std::cmp::min(MAX_FRAME_LENGTH - plaintext.len(), write_buf.len());
plaintext.extend_from_slice(&write_buf[..size]);

Expand All @@ -232,10 +232,7 @@ where

return std::task::Poll::Ready(Ok(size));
}
WriteState::SendPayload {
ref mut header,
ref mut body,
} => {
WriteState::SendPayload { header, body } => {
if header.offset < header.buf.len() {
let n = match tokio::io::AsyncWrite::poll_write(Pin::new(&mut this.writer), cx, &header.buf[header.offset..]) {
std::task::Poll::Ready(Ok(n)) => n,
Expand Down Expand Up @@ -268,7 +265,7 @@ where
WriteState::Init => {
return tokio::io::AsyncWrite::poll_flush(Pin::new(&mut this.writer), cx);
}
WriteState::WritePlaintext { ref mut plaintext } => {
WriteState::WritePlaintext { plaintext } => {
let enc_buf = match this.encoder.encode(plaintext) {
Ok(buf) => buf,
Err(e) => return std::task::Poll::Ready(Err(std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))),
Expand All @@ -281,10 +278,7 @@ where
body: SendBody { offset: 0, buf: enc_buf },
};
}
WriteState::SendPayload {
ref mut header,
ref mut body,
} => {
WriteState::SendPayload { header, body } => {
if header.offset < header.buf.len() {
let n = match tokio::io::AsyncWrite::poll_write(Pin::new(&mut this.writer), cx, &header.buf[header.offset..]) {
std::task::Poll::Ready(Ok(n)) => n,
Expand Down
2 changes: 1 addition & 1 deletion modules/omnikit/src/service/converter/omni_base.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use base64::{engine::general_purpose::URL_SAFE_NO_PAD as BASE64_URL, Engine};
use base64::{Engine, engine::general_purpose::URL_SAFE_NO_PAD as BASE64_URL};

// ref. https://github.com/multiformats/multibase#multibase-table

Expand Down
16 changes: 8 additions & 8 deletions modules/rocketpack/src/varint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,14 @@ mod tests {

// 8
for _ in 0..32 {
let v = rng.gen();
let v = rng.r#gen();
let mut buf = BytesMut::new();
Varint::put_u8(v, &mut buf);
let mut buf = buf.clone().freeze();
assert_eq!(Varint::get_u8(&mut buf)?, v);
}
for _ in 0..32 {
let v = rng.gen();
let v = rng.r#gen();
let mut buf = BytesMut::new();
Varint::put_i8(v, &mut buf);
let mut buf = buf.clone().freeze();
Expand All @@ -512,14 +512,14 @@ mod tests {

// 16
for _ in 0..32 {
let v = rng.gen();
let v = rng.r#gen();
let mut buf = BytesMut::new();
Varint::put_u16(v, &mut buf);
let mut buf = buf.clone().freeze();
assert_eq!(Varint::get_u16(&mut buf)?, v);
}
for _ in 0..32 {
let v = rng.gen();
let v = rng.r#gen();
let mut buf = BytesMut::new();
Varint::put_i16(v, &mut buf);
let mut buf = buf.clone().freeze();
Expand All @@ -528,14 +528,14 @@ mod tests {

// 32
for _ in 0..32 {
let v = rng.gen();
let v = rng.r#gen();
let mut buf = BytesMut::new();
Varint::put_u32(v, &mut buf);
let mut buf = buf.clone().freeze();
assert_eq!(Varint::get_u32(&mut buf)?, v);
}
for _ in 0..32 {
let v = rng.gen();
let v = rng.r#gen();
let mut buf = BytesMut::new();
Varint::put_i32(v, &mut buf);
let mut buf = buf.clone().freeze();
Expand All @@ -544,14 +544,14 @@ mod tests {

// 64
for _ in 0..32 {
let v = rng.gen();
let v = rng.r#gen();
let mut buf = BytesMut::new();
Varint::put_u64(v, &mut buf);
let mut buf = buf.clone().freeze();
assert_eq!(Varint::get_u64(&mut buf)?, v);
}
for _ in 0..32 {
let v = rng.gen();
let v = rng.r#gen();
let mut buf = BytesMut::new();
Varint::put_i64(v, &mut buf);
let mut buf = buf.clone().freeze();
Expand Down
2 changes: 1 addition & 1 deletion modules/testkit/src/containers/postgres.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use testcontainers::{core::WaitFor, runners::AsyncRunner, ContainerAsync, GenericImage, ImageExt as _};
use testcontainers::{ContainerAsync, GenericImage, ImageExt as _, core::WaitFor, runners::AsyncRunner};

pub struct PostgresContainer {
#[allow(unused)]
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.84.0"
channel = "1.85.0"
components = ["clippy", "rustfmt"]

0 comments on commit f381a1d

Please sign in to comment.