Skip to content

Commit

Permalink
fix(Core): update to latest godot rust
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowApex committed Dec 22, 2024
1 parent 329e196 commit b22b19c
Show file tree
Hide file tree
Showing 30 changed files with 296 additions and 335 deletions.
298 changes: 123 additions & 175 deletions extensions/Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion extensions/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]

members = ["core", "reaper"]
resolver = "2"
16 changes: 8 additions & 8 deletions extensions/core/src/bluetooth/bluez.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl BluezInstance {
fn get_adapters(&self) -> Array<Gd<BluetoothAdapter>> {
let mut adapters = array![];
for adapter in self.adapters.values() {
adapters.push(adapter.clone());
adapters.push(adapter);
}

adapters
Expand All @@ -136,7 +136,7 @@ impl BluezInstance {
fn get_discovered_devices(&self) -> Array<Gd<BluetoothDevice>> {
let mut devices = array![];
for device in self.devices.values() {
devices.push(device.clone());
devices.push(device);
}

devices
Expand Down Expand Up @@ -174,10 +174,10 @@ impl BluezInstance {
fn process_signal(&mut self, signal: Signal) {
match signal {
Signal::Started => {
self.base_mut().emit_signal("started".into(), &[]);
self.base_mut().emit_signal("started", &[]);
}
Signal::Stopped => {
self.base_mut().emit_signal("stopped".into(), &[]);
self.base_mut().emit_signal("stopped", &[]);
}
Signal::ObjectAdded { path, ifaces } => {
let obj_type = ObjectType::from_ifaces(ifaces);
Expand All @@ -187,13 +187,13 @@ impl BluezInstance {
let adapter = BluetoothAdapter::new(path.as_str());
self.adapters.insert(path, adapter.clone());
self.base_mut()
.emit_signal("adapter_added".into(), &[adapter.to_variant()]);
.emit_signal("adapter_added", &[adapter.to_variant()]);
}
ObjectType::Device => {
let device = BluetoothDevice::new(path.as_str());
self.devices.insert(path, device.clone());
self.base_mut()
.emit_signal("device_added".into(), &[device.to_variant()]);
.emit_signal("device_added", &[device.to_variant()]);
}
}
}
Expand All @@ -204,12 +204,12 @@ impl BluezInstance {
ObjectType::Adapter => {
self.adapters.remove(&path);
self.base_mut()
.emit_signal("adapter_removed".into(), &[path.to_variant()]);
.emit_signal("adapter_removed", &[path.to_variant()]);
}
ObjectType::Device => {
self.devices.remove(&path);
self.base_mut()
.emit_signal("device_removed".into(), &[path.to_variant()]);
.emit_signal("device_removed", &[path.to_variant()]);
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions extensions/core/src/bluetooth/bluez/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,19 @@ impl BluetoothAdapter {

// Check to see if a resource already exists for this device
let mut resource_loader = ResourceLoader::singleton();
if resource_loader.exists(res_path.clone().into()) {
if let Some(res) = resource_loader.load(res_path.clone().into()) {
if resource_loader.exists(res_path.as_str()) {
if let Some(res) = resource_loader.load(res_path.as_str()) {
log::info!("Resource already exists with path '{res_path}', loading that instead");
let device: Gd<BluetoothAdapter> = res.cast();
device
} else {
let mut device = BluetoothAdapter::from_path(path.to_string().into());
device.take_over_path(res_path.into());
device.take_over_path(res_path.as_str());
device
}
} else {
let mut device = BluetoothAdapter::from_path(path.to_string().into());
device.take_over_path(res_path.into());
device.take_over_path(res_path.as_str());
device
}
}
Expand Down Expand Up @@ -472,23 +472,23 @@ impl BluetoothAdapter {
match signal {
Signal::Discoverable { value } => {
self.base_mut()
.emit_signal("discoverable_changed".into(), &[value.to_variant()]);
.emit_signal("discoverable_changed", &[value.to_variant()]);
}
Signal::Discovering { value } => {
self.base_mut()
.emit_signal("discovering_changed".into(), &[value.to_variant()]);
.emit_signal("discovering_changed", &[value.to_variant()]);
}
Signal::Pairable { value } => {
self.base_mut()
.emit_signal("pairable_changed".into(), &[value.to_variant()]);
.emit_signal("pairable_changed", &[value.to_variant()]);
}
Signal::Powered { value } => {
self.base_mut()
.emit_signal("powered_changed".into(), &[value.to_variant()]);
.emit_signal("powered_changed", &[value.to_variant()]);
}
Signal::PowerState { value } => {
self.base_mut()
.emit_signal("power_state_changed".into(), &[value.to_variant()]);
.emit_signal("power_state_changed", &[value.to_variant()]);
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions extensions/core/src/bluetooth/bluez/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,19 @@ impl BluetoothDevice {

// Check to see if a resource already exists for this device
let mut resource_loader = ResourceLoader::singleton();
if resource_loader.exists(res_path.clone().into()) {
if let Some(res) = resource_loader.load(res_path.clone().into()) {
if resource_loader.exists(res_path.as_str()) {
if let Some(res) = resource_loader.load(res_path.as_str()) {
log::info!("Resource already exists with path '{res_path}', loading that instead");
let device: Gd<BluetoothDevice> = res.cast();
device
} else {
let mut device = BluetoothDevice::from_path(path.to_string().into());
device.take_over_path(res_path.into());
device.take_over_path(res_path.as_str());
device
}
} else {
let mut device = BluetoothDevice::from_path(path.to_string().into());
device.take_over_path(res_path.into());
device.take_over_path(res_path.as_str());
device
}
}
Expand Down Expand Up @@ -467,15 +467,15 @@ impl BluetoothDevice {
log::trace!("Got signal: {signal:?}");
match signal {
Signal::Updated => {
self.base_mut().emit_signal("updated".into(), &[]);
self.base_mut().emit_signal("updated", &[]);
}
Signal::ConnectedChanged { value } => {
self.base_mut()
.emit_signal("connected_changed".into(), &[value.to_variant()]);
.emit_signal("connected_changed", &[value.to_variant()]);
}
Signal::PairedChanged { value } => {
self.base_mut()
.emit_signal("paired_changed".into(), &[value.to_variant()]);
.emit_signal("paired_changed", &[value.to_variant()]);
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions extensions/core/src/disk/udisks2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl UDisks2Instance {
log::info!(
"Adding {dbus_path} as unprotected device. It is not a partition_devices"
);
unprotected_devices.push(block_device.clone());
unprotected_devices.push(block_device);
continue;
}
log::info!("Skipping {dbus_path}. It is a partition_device.");
Expand All @@ -187,7 +187,7 @@ impl UDisks2Instance {
log::info!(
"Adding {dbus_path} as unprotected device. It does not have a FilesystemDevice"
);
unprotected_devices.push(block_device.clone());
unprotected_devices.push(block_device);
continue;
};

Expand All @@ -201,7 +201,7 @@ impl UDisks2Instance {
log::info!(
"Adding {dbus_path} as unprotected device. It does not have any mounts in PROTECTED_MOUNTS"
);
unprotected_devices.push(block_device.clone());
unprotected_devices.push(block_device);
}
}

Expand Down Expand Up @@ -233,7 +233,7 @@ impl UDisks2Instance {
}
let unprotected_devices = self.get_unprotected_devices();
self.base_mut().emit_signal(
"unprotected_devices_updated".into(),
"unprotected_devices_updated",
&[unprotected_devices.to_variant()],
);
}
Expand All @@ -242,10 +242,10 @@ impl UDisks2Instance {
fn process_signal(&mut self, signal: Signal) {
match signal {
Signal::Started => {
self.base_mut().emit_signal("started".into(), &[]);
self.base_mut().emit_signal("started", &[]);
}
Signal::Stopped => {
self.base_mut().emit_signal("stopped".into(), &[]);
self.base_mut().emit_signal("stopped", &[]);
}
Signal::ObjectAdded { path, ifaces } => {
let obj_types = ObjectType::from_ifaces(ifaces);
Expand All @@ -255,26 +255,26 @@ impl UDisks2Instance {
let block = BlockDevice::new(path.as_str());
self.block_devices.insert(path.clone(), block.clone());
self.base_mut()
.emit_signal("block_device_added".into(), &[block.to_variant()]);
.emit_signal("block_device_added", &[block.to_variant()]);
}
ObjectType::Drive => {
let drive = DriveDevice::new(path.as_str());
self.drive_devices.insert(path.clone(), drive.clone());
self.base_mut()
.emit_signal("drive_device_added".into(), &[drive.to_variant()]);
.emit_signal("drive_device_added", &[drive.to_variant()]);
}
ObjectType::Partition => {
let partition = PartitionDevice::new(path.as_str());
self.partition_devices
.insert(path.clone(), partition.clone());
self.base_mut()
.emit_signal("partition_added".into(), &[partition.to_variant()]);
.emit_signal("partition_added", &[partition.to_variant()]);
}
ObjectType::Filesystem => {
let fs = FilesystemDevice::new(path.as_str());
self.filesystem_devices.insert(path.clone(), fs.clone());
self.base_mut()
.emit_signal("filesystem_added".into(), &[fs.to_variant()]);
.emit_signal("filesystem_added", &[fs.to_variant()]);
}
}
}
Expand All @@ -286,22 +286,22 @@ impl UDisks2Instance {
ObjectType::Block => {
self.block_devices.remove(&path);
self.base_mut()
.emit_signal("block_device_removed".into(), &[path.to_variant()]);
.emit_signal("block_device_removed", &[path.to_variant()]);
}
ObjectType::Drive => {
self.drive_devices.remove(&path);
self.base_mut()
.emit_signal("drive_device_removed".into(), &[path.to_variant()]);
.emit_signal("drive_device_removed", &[path.to_variant()]);
}
ObjectType::Partition => {
self.partition_devices.remove(&path);
self.base_mut()
.emit_signal("partition_removed".into(), &[path.to_variant()]);
.emit_signal("partition_removed", &[path.to_variant()]);
}
ObjectType::Filesystem => {
self.filesystem_devices.remove(&path);
self.base_mut()
.emit_signal("filesystem_removed".into(), &[path.to_variant()]);
.emit_signal("filesystem_removed", &[path.to_variant()]);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions extensions/core/src/disk/udisks2/block_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ impl BlockDevice {

// Check to see if a resource already exists for this device
let mut resource_loader = ResourceLoader::singleton();
if resource_loader.exists(res_path.clone().into()) {
if let Some(res) = resource_loader.load(res_path.clone().into()) {
if resource_loader.exists(res_path.as_str()) {
if let Some(res) = resource_loader.load(res_path.as_str()) {
log::info!("Resource already exists with path '{res_path}', loading that instead");
let device: Gd<BlockDevice> = res.cast();
device
} else {
let mut device = BlockDevice::from_path(path.to_string().into());
device.take_over_path(res_path.into());
device.take_over_path(res_path.as_str());
device
}
} else {
let mut device = BlockDevice::from_path(path.to_string().into());
device.take_over_path(res_path.into());
device.take_over_path(res_path.as_str());
device
}
}
Expand All @@ -114,7 +114,7 @@ impl BlockDevice {
for partition in partitions {
let path = partition.as_str();
let partition_device = PartitionDevice::new(path);
all_partitions.push(partition_device);
all_partitions.push(&partition_device);
}

all_partitions
Expand Down
8 changes: 4 additions & 4 deletions extensions/core/src/disk/udisks2/drive_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@ impl DriveDevice {

// Check to see if a resource already exists for this device
let mut resource_loader = ResourceLoader::singleton();
if resource_loader.exists(res_path.clone().into()) {
if let Some(res) = resource_loader.load(res_path.clone().into()) {
if resource_loader.exists(res_path.as_str()) {
if let Some(res) = resource_loader.load(res_path.as_str()) {
log::info!("Resource already exists with path '{res_path}', loading that instead");
let device: Gd<DriveDevice> = res.cast();
device
} else {
let mut device = DriveDevice::from_path(path.to_string().into());
device.take_over_path(res_path.into());
device.take_over_path(res_path.as_str());
device
}
} else {
let mut device = DriveDevice::from_path(path.to_string().into());
device.take_over_path(res_path.into());
device.take_over_path(res_path.as_str());
device
}
}
Expand Down
10 changes: 5 additions & 5 deletions extensions/core/src/disk/udisks2/filesystem_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ impl FilesystemDevice {

// Check to see if a resource already exists for this device
let mut resource_loader = ResourceLoader::singleton();
if resource_loader.exists(res_path.clone().into()) {
if let Some(res) = resource_loader.load(res_path.clone().into()) {
if resource_loader.exists(res_path.as_str()) {
if let Some(res) = resource_loader.load(res_path.as_str()) {
log::info!("Resource already exists with path '{res_path}', loading that instead");
let device: Gd<FilesystemDevice> = res.cast();
device
} else {
let mut device = FilesystemDevice::from_path(path.to_string().into());
device.take_over_path(res_path.into());
device.take_over_path(res_path.as_str());
device
}
} else {
let mut device = FilesystemDevice::from_path(path.to_string().into());
device.take_over_path(res_path.into());
device.take_over_path(res_path.as_str());
device
}
}
Expand All @@ -89,7 +89,7 @@ impl FilesystemDevice {
let mount_points_bytes = proxy.mount_points().unwrap_or_default();
for mount_point_bytes in mount_points_bytes {
let mount_point = String::from_utf8_lossy(mount_point_bytes.as_slice());
mount_points.push(mount_point.to_string().to_godot());
mount_points.push(mount_point.to_string().as_str());
}

mount_points
Expand Down
8 changes: 4 additions & 4 deletions extensions/core/src/disk/udisks2/partition_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,19 @@ impl PartitionDevice {

// Check to see if a resource already exists for this device
let mut resource_loader = ResourceLoader::singleton();
if resource_loader.exists(res_path.clone().into()) {
if let Some(res) = resource_loader.load(res_path.clone().into()) {
if resource_loader.exists(res_path.as_str()) {
if let Some(res) = resource_loader.load(res_path.as_str()) {
log::info!("Resource already exists with path '{res_path}', loading that instead");
let device: Gd<PartitionDevice> = res.cast();
device
} else {
let mut device = PartitionDevice::from_path(path.to_string().into());
device.take_over_path(res_path.into());
device.take_over_path(res_path.as_str());
device
}
} else {
let mut device = PartitionDevice::from_path(path.to_string().into());
device.take_over_path(res_path.into());
device.take_over_path(res_path.as_str());
device
}
}
Expand Down
3 changes: 1 addition & 2 deletions extensions/core/src/gamescope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ impl GamescopeInstance {
pub fn get_xwaylands(&self) -> Array<Gd<GamescopeXWayland>> {
let mut xwaylands = array![];
for xwayland in self.xwaylands.values() {
let item = xwayland.clone();
xwaylands.push(item);
xwaylands.push(xwayland);
}

xwaylands
Expand Down
Loading

0 comments on commit b22b19c

Please sign in to comment.