rust-nex/rnex-protocols/base-protos/src/lib.rs
red binder be7bc79762
All checks were successful
Build and Test / build-editions (wii-u-chat) (push) Successful in 3m7s
Build and Test / build-editions (minecraft-wiiu) (push) Successful in 3m44s
Build and Test / build-editions (DATABASE_FRIENDS, friends) (push) Successful in 3m45s
Build and Test / build-editions (sonic-transformed) (push) Successful in 4m28s
Build and Test / build-editions (terraria) (push) Successful in 5m44s
Build and Test / build-editions (fast-racing-neo) (push) Successful in 6m0s
Build and Test / build-editions (mario-tennis) (push) Successful in 6m24s
Build and Test / build-editions (splatoon-testfire) (push) Successful in 6m27s
Build and Test / build-editions (DATABASE_SMM, super-mario-maker) (push) Successful in 6m31s
Build and Test / build-editions (DATABASE_SMM, wii-sports-club) (push) Successful in 6m36s
Build and Test / build-editions (DATABASE_SMM, puyopuyo) (push) Successful in 6m37s
Build and Test / build-editions (splatoon) (push) Successful in 6m56s
fix(resultsrange): use usize min instead of usize max
2026-08-08 19:01:16 +02:00

45 lines
1.2 KiB
Rust

#![allow(async_fn_in_trait)]
use rnex_rmc::{RmcSerialize, define_rmc_proto};
pub mod secure;
pub mod util;
use secure::{RawSecure, RawSecureInfo, RemoteSecure, Secure};
use util::{RawUtility, RawUtilityInfo, RemoteUtility, Utility};
use cfg_if::cfg_if;
#[derive(RmcSerialize, Debug, Default, Clone)]
#[rmc_struct(0)]
pub struct ResultsRange {
pub offset: u32,
pub size: u32,
}
cfg_if! {
if #[cfg(feature = "v3-8-13")] {
impl ResultsRange {
pub fn make_from_list<T: Clone>(&self, list: &[T]) -> Vec<T> {
let start = (self.offset as usize).min(list.len());
let end = (start + self.size as usize).min(list.len());
list[start..end].to_vec()
}
}
} else {
impl ResultsRange {
pub fn make_from_list<T: Clone>(&self, list: &[T]) -> Vec<T> {
let end = usize::max(list.len(), self.offset as usize + self.size as usize);
list.get(self.offset as usize..end)
.unwrap_or_default()
.into()
}
}
}
}
define_rmc_proto!(
proto BaseProtocol{
Secure,
Utility,
}
);