Nickname is Cross-Platform Rust user defined device-name(nick-name) get set library.
cargo add nick-name
let nickname = nick_name::NickName::new().unwrap();
let device_name = nickname.get().unwrap();
println!("{device_name}");
#[cfg(not(any(target_os = "ios", target_os = "android")))]
{
let set = nickname.set("oligami-pc");
println!("{:?}", set);
let device_name = nickname.get().unwrap();
println!("{device_name}");
}
Look at examples
- linux systems (Linux, FreeBSD, OpenBSD, NetBSD, Solaris, Redox, and so on)
- Windows
- Android
- iPhone
https://doc.rust-lang.org/nightly/rustc/platform-support.html
O
success
X
failed
-
non verify
Target | build | test | run | clippy | fmt | miri | doc |
---|---|---|---|---|---|---|---|
Tier1 | O | O | O | O | O | O linux(get) O Windows X others |
- |
Android | O | O | O cargo-apk X cargo-dinghy |
O | O | X | - |
iPhone | O | O | O cargo-bundle O cargo-dinghy |
O | O | X | - |
Tier2 | O | - | - | O | O | X | - |
- wasi WebAssembly/wasi-libc#196
- wasm
- watchOS
- visionOS
- WearOS
- BlueOS
- get
- get
- get
- set
! Windows don't set %username% yet
! Windows set user
cmd
! macOS is not stable because not using native api yet
look README.md on example https://github.com/nziq53/nickname/tree/main/examples/common
-
add test ※ zero tests(now)
-
Match structure functions
- use native api
- be able to
miri
- be able to
miri
check permission func
by using ndk- add
require permission func
- be able to
miri
- be able to
miri
on set func
- add loongarch64-unknown-none
- cargo test --tests --no-fail-fast
- macOS: 10.12 Sierra
- iOS: 10
- add loongarch64-unknown-linux-gnu
- finish
call finishAndRemoveTask() - get_device_api_level
get api_level
call VERSION.SDK_INT - check_permission_old
check permission - check_permission_new
check permission
- api-level 24:
error: "API level 25 or higher is required"
- api-level 30:
Android SDK built for x86_64
- api-level 33:
sdk_gphone_x86_64
lowest API level 5 min API level < 25
- Android Emulator don't has bluetooth feature and cannot get nickname
- Require BLUETOOTH permission
- Update is required reboot
25 <= min API level
- Update is not required reboot
- Not require permission
This library use native api by Android JavaVM.
So, cargo dinghy and ffi binding must failed.
If you ffi binding, you call init func.
If you call using JavaVM func first, have JavaVM attach. To attach JavaVM is heavy. You drop NickName and free JavaVM attach.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
- BSD-3-clause (LICENSE-BSD-3-clause or https://opensource.org/license/BSD-3-clause) at your option.