linux-rust: bump dependencies and clean up media_controller

This commit is contained in:
Kavish Devar
2026-04-06 13:54:33 +05:30
parent a0cdbb2842
commit 2f1208ca87
10 changed files with 2184 additions and 2384 deletions

3321
linux-rust/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,24 +4,24 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
tokio = {version = "1.47.1", features = ["full"]} tokio = {version = "1.50.0", features = ["full"]}
bluer = { version = "0.17.4", features = ["full"] } bluer = { version = "0.17.4", features = ["full"] }
env_logger = {version = "0.11.8", features = ["auto-color"]} env_logger = {version = "0.11.10", features = ["auto-color"]}
uuid = "1.18.1" uuid = "1.23.0"
log = "0.4.28" log = "0.4.29"
dbus = "0.9.9" dbus = "0.9.10"
hex = "0.4.3" hex = "0.4.3"
iced = { version = "0.13.1", features = ["tokio", "image"] } iced = { version = "0.14.0", features = ["tokio", "image"] }
libpulse-binding = "2.30.1" libpulse-binding = "2.30.1"
ksni = "0.3.1" ksni = "0.3.1"
image = "0.25.8" image = "0.25.8"
imageproc = "0.25.0" imageproc = "0.26.1"
ab_glyph = "0.2.32" ab_glyph = "0.2.32"
clap = { version = "4.5.50", features = ["derive"] } clap = { version = "4.6.0", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
aes = "0.8.4" aes = "0.9.0-rc.4"
futures = "0.3.31" futures = "0.3.32"
[profile.release] [profile.release]
opt-level = "s" opt-level = "s"

View File

@@ -3,8 +3,8 @@ use crate::devices::enums::{DeviceData, DeviceInformation, DeviceType};
use crate::ui::tray::MyTray; use crate::ui::tray::MyTray;
use crate::utils::{ah, get_devices_path, get_preferences_path}; use crate::utils::{ah, get_devices_path, get_preferences_path};
use aes::Aes128; use aes::Aes128;
use aes::cipher::generic_array::GenericArray; use aes::cipher::Array;
use aes::cipher::{BlockDecrypt, KeyInit}; use aes::cipher::{BlockCipherDecrypt, KeyInit};
use bluer::monitor::{Monitor, MonitorEvent, Pattern}; use bluer::monitor::{Monitor, MonitorEvent, Pattern};
use bluer::{Address, Session}; use bluer::{Address, Session};
use futures::StreamExt; use futures::StreamExt;
@@ -17,8 +17,8 @@ use std::sync::Arc;
use tokio::sync::Mutex; use tokio::sync::Mutex;
fn decrypt(key: &[u8; 16], data: &[u8; 16]) -> [u8; 16] { fn decrypt(key: &[u8; 16], data: &[u8; 16]) -> [u8; 16] {
let cipher = Aes128::new(&GenericArray::from(*key)); let cipher = Aes128::new(&Array::from(*key));
let mut block = GenericArray::from(*data); let mut block = Array::from(*data);
cipher.decrypt_block(&mut block); cipher.decrypt_block(&mut block);
block.into() block.into()
} }

View File

@@ -55,14 +55,14 @@ impl AirPodsDevice {
error!("Failed to send handshake to AirPods device: {}", e); error!("Failed to send handshake to AirPods device: {}", e);
} }
sleep(Duration::from_millis(100)).await; sleep(Duration::from_millis(300)).await;
info!("Setting feature flags"); info!("Setting feature flags");
if let Err(e) = aacp_manager.send_set_feature_flags_packet().await { if let Err(e) = aacp_manager.send_set_feature_flags_packet().await {
error!("Failed to set feature flags: {}", e); error!("Failed to set feature flags: {}", e);
} }
sleep(Duration::from_millis(100)).await; sleep(Duration::from_millis(300)).await;
info!("Requesting notifications"); info!("Requesting notifications");
if let Err(e) = aacp_manager.send_notification_request().await { if let Err(e) = aacp_manager.send_notification_request().await {

View File

@@ -22,7 +22,7 @@ use ksni::TrayMethods;
use log::{info, warn}; use log::{info, warn};
use std::collections::HashMap; use std::collections::HashMap;
use std::env; use std::env;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool};
use std::sync::Arc; use std::sync::Arc;
use tokio::sync::RwLock; use tokio::sync::RwLock;
use tokio::sync::mpsc::unbounded_channel; use tokio::sync::mpsc::unbounded_channel;
@@ -64,18 +64,18 @@ fn main() -> iced::Result {
} }
let log_level = if args.debug { "debug" } else { "info" }; let log_level = if args.debug { "debug" } else { "info" };
let wayland_display = env::var("WAYLAND_DISPLAY").is_ok(); // let wayland_display = env::var("WAYLAND_DISPLAY").is_ok();
if wayland_display && env::var("WGPU_BACKEND").is_err() { // if wayland_display && env::var("WGPU_BACKEND").is_err() {
unsafe { env::set_var("WGPU_BACKEND", "gl") }; // unsafe { env::set_var("WGPU_BACKEND", "gl") };
} // }
if env::var("RUST_LOG").is_err() { if env::var("RUST_LOG").is_err() {
unsafe { unsafe {
env::set_var( env::set_var(
"RUST_LOG", "RUST_LOG",
log_level.to_owned() log_level.to_owned()
+ &format!( + &format!(
",winit=warn,tracing=warn,iced_wgpu=warn,wgpu_hal=warn,wgpu_core=warn,cosmic_text=warn,naga=warn,iced_winit=warn,librepods_rust::bluetooth::le={}", ",zbus=warn,winit=warn,tracing=warn,iced_wgpu=warn,wgpu_hal=warn,wgpu_core=warn,cosmic_text=warn,naga=warn,iced_winit=warn,librepods::bluetooth::le={}",
if args.le_debug { "debug" } else { "warn" } if args.le_debug { "debug" } else { "info" }
), ),
) )
}; };

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@ use iced::overlay::menu;
use iced::widget::button::Style; use iced::widget::button::Style;
use iced::widget::rule::FillMode; use iced::widget::rule::FillMode;
use iced::widget::{ use iced::widget::{
Rule, Space, button, column, combo_box, container, row, rule, text, text_input, toggler, Space, button, column, combo_box, container, row, rule, text, text_input, toggler,
}; };
use iced::{Background, Border, Center, Color, Length, Padding, Theme}; use iced::{Background, Border, Center, Color, Length, Padding, Theme};
use log::error; use log::error;
@@ -30,13 +30,13 @@ pub fn airpods_view<'a>(
let aacp_manager_for_rename = aacp_manager.clone(); let aacp_manager_for_rename = aacp_manager.clone();
let rename_input = container( let rename_input = container(
row![ row![
Space::with_width(10), Space::new().width(10),
text("Name").size(16).style(|theme: &Theme| { text("Name").size(16).style(|theme: &Theme| {
let mut style = text::Style::default(); let mut style = text::Style::default();
style.color = Some(theme.palette().text); style.color = Some(theme.palette().text);
style style
}), }),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
text_input("", &state.device_name) text_input("", &state.device_name)
.padding(Padding { .padding(Padding {
top: 5.0, top: 5.0,
@@ -99,7 +99,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text); style.color = Some(theme.palette().text);
style style
}), }),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
{ {
let state_clone = state.clone(); let state_clone = state.clone();
let mac = mac.clone(); let mac = mac.clone();
@@ -159,6 +159,7 @@ pub fn airpods_view<'a>(
selected_background: Background::Color( selected_background: Background::Color(
theme.palette().primary.scale_alpha(0.3), theme.palette().primary.scale_alpha(0.3),
), ),
shadow: Default::default()
}) })
} }
] ]
@@ -242,13 +243,13 @@ pub fn airpods_view<'a>(
.align_y(Center) .align_y(Center)
.spacing(8) .spacing(8)
}, },
Rule::horizontal(8).style( rule::horizontal(1).style(
|theme: &Theme| { |theme: &Theme| {
rule::Style { rule::Style {
color: theme.palette().text, color: theme.palette().text.scale_alpha(0.2),
width: 1,
radius: Radius::from(12), radius: Radius::from(12),
fill_mode: FillMode::Full fill_mode: FillMode::Full,
snap: false
} }
} }
), ),
@@ -371,7 +372,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text); style.color = Some(theme.palette().text);
style style
}), }),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
text(airpods_info.model_number.clone()).size(16) text(airpods_info.model_number.clone()).size(16)
], ],
row![ row![
@@ -380,7 +381,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text); style.color = Some(theme.palette().text);
style style
}), }),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
text(airpods_info.manufacturer.clone()).size(16) text(airpods_info.manufacturer.clone()).size(16)
], ],
row![ row![
@@ -389,7 +390,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text); style.color = Some(theme.palette().text);
style style
}), }),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
button(text(airpods_info.serial_number.clone()).size(16)) button(text(airpods_info.serial_number.clone()).size(16))
.style(|theme: &Theme, _status| { .style(|theme: &Theme, _status| {
let mut style = Style::default(); let mut style = Style::default();
@@ -406,7 +407,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text); style.color = Some(theme.palette().text);
style style
}), }),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
button(text(airpods_info.left_serial_number.clone()).size(16)) button(text(airpods_info.left_serial_number.clone()).size(16))
.style(|theme: &Theme, _status| { .style(|theme: &Theme, _status| {
let mut style = Style::default(); let mut style = Style::default();
@@ -425,7 +426,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text); style.color = Some(theme.palette().text);
style style
}), }),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
button(text(airpods_info.right_serial_number.clone()).size(16)) button(text(airpods_info.right_serial_number.clone()).size(16))
.style(|theme: &Theme, _status| { .style(|theme: &Theme, _status| {
let mut style = Style::default(); let mut style = Style::default();
@@ -444,7 +445,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text); style.color = Some(theme.palette().text);
style style
}), }),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
text(airpods_info.version1.clone()).size(16) text(airpods_info.version1.clone()).size(16)
], ],
row![ row![
@@ -453,7 +454,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text); style.color = Some(theme.palette().text);
style style
}), }),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
text(airpods_info.version2.clone()).size(16) text(airpods_info.version2.clone()).size(16)
], ],
row![ row![
@@ -462,7 +463,7 @@ pub fn airpods_view<'a>(
style.color = Some(theme.palette().text); style.color = Some(theme.palette().text);
style style
}), }),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
text(airpods_info.version3.clone()).size(16) text(airpods_info.version3.clone()).size(16)
] ]
] ]
@@ -508,13 +509,13 @@ pub fn airpods_view<'a>(
container(column![ container(column![
rename_input, rename_input,
Space::with_height(Length::from(20)), Space::new().height(Length::from(20)),
listening_mode, listening_mode,
Space::with_height(Length::from(20)), Space::new().height(Length::from(20)),
audio_settings_col, audio_settings_col,
Space::with_height(Length::from(20)), Space::new().height(Length::from(20)),
off_listening_mode_toggle, off_listening_mode_toggle,
Space::with_height(Length::from(20)), Space::new().height(Length::from(20)),
information_col information_col
]) ])
.padding(20) .padding(20)

View File

@@ -29,14 +29,14 @@ pub fn nothing_view<'a>(
style.color = Some(theme.palette().primary); style.color = Some(theme.palette().primary);
style style
})) }))
.push(Space::with_height(iced::Length::from(10))) .push(Space::new().height(iced::Length::from(10)))
.push(iced::widget::row![ .push(iced::widget::row![
text("Serial Number").size(16).style(|theme: &Theme| { text("Serial Number").size(16).style(|theme: &Theme| {
let mut style = text::Style::default(); let mut style = text::Style::default();
style.color = Some(theme.palette().text); style.color = Some(theme.palette().text);
style style
}), }),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
text(nothing_info.serial_number.clone()).size(16) text(nothing_info.serial_number.clone()).size(16)
]) ])
.push(iced::widget::row![ .push(iced::widget::row![
@@ -45,7 +45,7 @@ pub fn nothing_view<'a>(
style.color = Some(theme.palette().text); style.color = Some(theme.palette().text);
style style
}), }),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
text(nothing_info.firmware_version.clone()).size(16) text(nothing_info.firmware_version.clone()).size(16)
]); ]);
} }
@@ -57,7 +57,7 @@ pub fn nothing_view<'a>(
style.color = Some(theme.palette().text); style.color = Some(theme.palette().text);
style style
}), }),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
{ {
let state_clone = state.clone(); let state_clone = state.clone();
let mac = mac.clone(); let mac = mac.clone();
@@ -137,6 +137,7 @@ pub fn nothing_view<'a>(
selected_background: Background::Color( selected_background: Background::Color(
theme.palette().primary.scale_alpha(0.3), theme.palette().primary.scale_alpha(0.3),
), ),
shadow: Default::default()
}) })
} }
] ]
@@ -159,7 +160,7 @@ pub fn nothing_view<'a>(
container(column![ container(column![
noise_control_mode, noise_control_mode,
Space::with_height(Length::from(20)), Space::new().height(Length::from(20)),
container(information_col) container(information_col)
.style(|theme: &Theme| { .style(|theme: &Theme| {
let mut style = container::Style::default(); let mut style = container::Style::default();

View File

@@ -17,12 +17,9 @@ use iced::widget::button::Style;
use iced::widget::rule::FillMode; use iced::widget::rule::FillMode;
use iced::widget::{ use iced::widget::{
Space, button, column, combo_box, container, pane_grid, row, rule, scrollable, text, Space, button, column, combo_box, container, pane_grid, row, rule, scrollable, text,
text_input, toggler, vertical_rule, text_input, toggler
};
use iced::{
Background, Border, Center, Element, Font, Length, Padding, Size, Subscription, Task, Theme,
daemon, window,
}; };
use iced::{Background, Border, Center, Element, Font, Length, Padding, Size, Subscription, Task, Theme, daemon, window, Settings};
use log::{debug, error}; use log::{debug, error};
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
@@ -36,12 +33,30 @@ pub fn start_ui(
device_managers: Arc<RwLock<HashMap<String, DeviceManagers>>>, device_managers: Arc<RwLock<HashMap<String, DeviceManagers>>>,
stem_control: Arc<AtomicBool>, stem_control: Arc<AtomicBool>,
) -> iced::Result { ) -> iced::Result {
daemon(App::title, App::update, App::view) let ui_rx = Arc::new(Mutex::new(ui_rx));
.subscription(App::subscription)
.theme(App::theme) // not sure if this is a good idea
.font(include_bytes!("../../assets/font/sf_pro.otf").as_slice()) daemon(
.default_font(Font::with_name("SF Pro Text")) move || {
.run_with(move || App::new(ui_rx, start_minimized, device_managers, stem_control)) App::new(
Arc::clone(&ui_rx),
start_minimized,
Arc::clone(&device_managers),
Arc::clone(&stem_control),
)
},
App::update,
App::view,
)
.subscription(App::subscription)
.theme(App::theme)
.settings(Settings {
id: Some("librepods".to_string()),
fonts: vec![include_bytes!("../../assets/font/sf_pro.otf").as_slice().into()],
default_font: Font::with_name("SF Pro Text"),
..Settings::default()
})
.run()
} }
pub struct App { pub struct App {
@@ -109,7 +124,7 @@ pub enum Pane {
impl App { impl App {
pub fn new( pub fn new(
ui_rx: UnboundedReceiver<BluetoothUIMessage>, ui_rx: Arc<Mutex<UnboundedReceiver<BluetoothUIMessage>>>,
start_minimized: bool, start_minimized: bool,
device_managers: Arc<RwLock<HashMap<String, DeviceManagers>>>, device_managers: Arc<RwLock<HashMap<String, DeviceManagers>>>,
stem_control: Arc<AtomicBool>, stem_control: Arc<AtomicBool>,
@@ -118,7 +133,6 @@ impl App {
let split = panes.split(pane_grid::Axis::Vertical, first_pane, Pane::Content); let split = panes.split(pane_grid::Axis::Vertical, first_pane, Pane::Content);
panes.resize(split.unwrap().1, 0.2); panes.resize(split.unwrap().1, 0.2);
let ui_rx = Arc::new(Mutex::new(ui_rx));
let wait_task = Task::perform(wait_for_message(Arc::clone(&ui_rx)), |msg| msg); let wait_task = Task::perform(wait_for_message(Arc::clone(&ui_rx)), |msg| msg);
@@ -773,46 +787,47 @@ impl App {
let content = column![ let content = column![
row![ row![
text("Devices").size(18), text("Devices").size(18),
Space::with_width(Length::Fill), // Removing until I actually add support for devices other than AirPods
button( // Space::new().width(Length::Fill),
container(text("+").size(18)).center_x(Length::Fill).center_y(Length::Fill) // button(
) // container(text("+").size(18)).center_x(Length::Fill).center_y(Length::Fill)
.style( // )
|theme: &Theme, _status| { // .style(
let mut style = Style::default(); // |theme: &Theme, _status| {
style.text_color = theme.palette().text; // let mut style = Style::default();
style.background = Some(Background::Color(theme.palette().primary.scale_alpha(0.1))); // style.text_color = theme.palette().text;
style.border = Border { // style.background = Some(Background::Color(theme.palette().primary.scale_alpha(0.1)));
width: 1.0, // style.border = Border {
color: theme.palette().primary.scale_alpha(0.1), // width: 1.0,
radius: Radius::from(8.0), // color: theme.palette().primary.scale_alpha(0.1),
}; // radius: Radius::from(8.0),
style // };
} // style
) // }
.padding(0) // )
.width(Length::from(28)) // .padding(0)
.height(Length::from(28)) // .width(Length::from(28))
.on_press(Message::ShowNewDialogTab) // .height(Length::from(28))
// .on_press(Message::ShowNewDialogTab)
] ]
.align_y(Center) .align_y(Center)
.padding(4), .padding(4),
Space::with_height(Length::from(8)), Space::new().height(Length::from(8)),
devices, devices,
Space::with_height(Length::Fill), Space::new().height(Length::Fill),
settings settings
] ]
.padding(12); .padding(12);
pane_grid::Content::new( pane_grid::Content::new(
row![ row![
content, content,
vertical_rule(1).style( rule::vertical(1).style(
|theme: &Theme| { |theme: &Theme| {
rule::Style{ rule::Style{
color: theme.palette().primary.scale_alpha(0.2), color: theme.palette().primary.scale_alpha(0.2),
width: 2,
radius: Radius::from(8.0), radius: Radius::from(8.0),
fill_mode: FillMode::Full fill_mode: FillMode::Full,
snap: false
} }
} }
) )
@@ -957,7 +972,7 @@ impl App {
row![ row![
text("Theme") text("Theme")
.size(16), .size(16),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
combo_box( combo_box(
&self.theme_state, &self.theme_state,
"Select theme", "Select theme",
@@ -992,6 +1007,7 @@ impl App {
text_color: theme.palette().text, text_color: theme.palette().text,
selected_text_color: theme.palette().text, selected_text_color: theme.palette().text,
selected_background: Background::Color(theme.palette().primary.scale_alpha(0.3)), selected_background: Background::Color(theme.palette().primary.scale_alpha(0.3)),
shadow: Default::default()
} }
} }
) )
@@ -1088,9 +1104,9 @@ impl App {
container( container(
column![ column![
appearance_settings_col, appearance_settings_col,
Space::with_height(Length::from(20)), Space::new().height(Length::from(20)),
tray_text_mode_toggle, tray_text_mode_toggle,
Space::with_height(Length::from(20)), Space::new().height(Length::from(20)),
controls_settings_col, controls_settings_col,
] ]
) )
@@ -1102,7 +1118,7 @@ impl App {
container( container(
column![ column![
text("Pick a paired device to add:").size(18), text("Pick a paired device to add:").size(18),
Space::with_height(Length::from(10)), Space::new().height(Length::from(10)),
{ {
let mut list_col = column![].spacing(12); let mut list_col = column![].spacing(12);
for device in self.paired_devices.clone() { for device in self.paired_devices.clone() {
@@ -1113,7 +1129,7 @@ impl App {
text(device.0.to_string()).size(16), text(device.0.to_string()).size(16),
text(device.1.to_string()).size(12) text(device.1.to_string()).size(12)
].into(), ].into(),
Space::with_width(Length::Fill).into(), Space::new().height(Length::Fill).into(),
]; ];
if !matches!(&self.pending_add_device, Some((_, addr)) if addr == &device.1) { if !matches!(&self.pending_add_device, Some((_, addr)) if addr == &device.1) {
row_elements.push( row_elements.push(
@@ -1145,7 +1161,7 @@ impl App {
item_col = item_col.push( item_col = item_col.push(
row![ row![
text("Device Type:").size(16), text("Device Type:").size(16),
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
combo_box( combo_box(
&self.device_type_state, &self.device_type_state,
"Select device type", "Select device type",
@@ -1180,6 +1196,7 @@ impl App {
text_color: theme.palette().text, text_color: theme.palette().text,
selected_text_color: theme.palette().text, selected_text_color: theme.palette().text,
selected_background: Background::Color(theme.palette().primary.scale_alpha(0.3)), selected_background: Background::Color(theme.palette().primary.scale_alpha(0.3)),
shadow: Default::default()
} }
} }
) )
@@ -1188,7 +1205,7 @@ impl App {
); );
item_col = item_col.push( item_col = item_col.push(
row![ row![
Space::with_width(Length::Fill), Space::new().width(Length::Fill),
button(text("Cancel").size(16).width(Length::Fill).center()) button(text("Cancel").size(16).width(Length::Fill).center())
.on_press(Message::CancelAddDevice) .on_press(Message::CancelAddDevice)
.style(|theme: &Theme, _status| { .style(|theme: &Theme, _status| {
@@ -1200,7 +1217,7 @@ impl App {
}) })
.width(Length::from(120)) .width(Length::from(120))
.padding(4), .padding(4),
Space::with_width(Length::from(20)), Space::new().width(Length::from(20)),
button(text("Add Device").size(16).width(Length::Fill).center()) button(text("Add Device").size(16).width(Length::Fill).center())
.on_press(Message::ConfirmAddDevice) .on_press(Message::ConfirmAddDevice)
.style(|theme: &Theme, _status| { .style(|theme: &Theme, _status| {

View File

@@ -1,6 +1,6 @@
use aes::Aes128; use aes::Aes128;
use aes::cipher::generic_array::GenericArray; use aes::cipher::Array;
use aes::cipher::{BlockEncrypt, KeyInit}; use aes::cipher::{BlockCipherEncrypt, KeyInit};
use iced::Theme; use iced::Theme;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::path::PathBuf; use std::path::PathBuf;
@@ -34,8 +34,8 @@ fn e(key: &[u8; 16], data: &[u8; 16]) -> [u8; 16] {
swapped_key.reverse(); swapped_key.reverse();
let mut swapped_data = *data; let mut swapped_data = *data;
swapped_data.reverse(); swapped_data.reverse();
let cipher = Aes128::new(&GenericArray::from(swapped_key)); let cipher = Aes128::new(&Array::from(swapped_key));
let mut block = GenericArray::from(swapped_data); let mut block = Array::from(swapped_data);
cipher.encrypt_block(&mut block); cipher.encrypt_block(&mut block);
let mut result: [u8; 16] = block.into(); let mut result: [u8; 16] = block.into();
result.reverse(); result.reverse();