Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions libcamera-meta/src/bin/generate_from_git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,26 +308,12 @@ mod generate_rust {
}
out += "}\n";

let name_fn = match ty {
ControlsType::Control => "control_id_name",
ControlsType::Property => "property_id_name",
};

out += &format!("impl {name} {{\n");
out += r#"
pub fn id(&self) -> u32 {
u32::from(*self)
}
"#;
out += "\n";
out += &format!(
"
pub fn name(&self) -> String {{
{name_fn}(*self)
}}
"
);

out += "}\n";

let mut dyn_variants = String::new();
Expand Down Expand Up @@ -454,9 +440,7 @@ mod generate_rust {
use std::ops::{{Deref, DerefMut}};
use num_enum::{{IntoPrimitive, TryFromPrimitive}};
#[allow(unused_imports)]
use crate::control::{{
Control, Property, ControlEntry, DynControlEntry, control_id_name, property_id_name
}};
use crate::control::{{Control, Property, ControlEntry, DynControlEntry}};
use crate::control_value::{{ControlValue, ControlValueError}};
#[allow(unused_imports)]
use crate::geometry::{{Rectangle, Point, Size}};
Expand Down
24 changes: 14 additions & 10 deletions libcamera/src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,16 +456,20 @@ impl<'a> Drop for ControlInfoMapIter<'a> {
}
}

pub fn control_id_name(id: ControlId) -> String {
unsafe { CStr::from_ptr(libcamera_control_name_from_id(id.id())) }
.to_str()
.unwrap()
.into()
impl ControlId {
pub fn name(&self) -> String {
unsafe { CStr::from_ptr(libcamera_control_name_from_id(self.id())) }
.to_str()
.unwrap()
.into()
}
}

pub fn property_id_name(id: PropertyId) -> String {
unsafe { CStr::from_ptr(libcamera_property_name_from_id(id.id())) }
.to_str()
.unwrap()
.into()
impl PropertyId {
pub fn name(&self) -> String {
unsafe { CStr::from_ptr(libcamera_property_name_from_id(self.id())) }
.to_str()
.unwrap()
.into()
}
}
7 changes: 1 addition & 6 deletions libcamera/versioned_files/0.4.0/controls.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::ops::{Deref, DerefMut};
use num_enum::{IntoPrimitive, TryFromPrimitive};
#[allow(unused_imports)]
use crate::control::{
Control, Property, ControlEntry, DynControlEntry, control_id_name, property_id_name,
};
use crate::control::{Control, Property, ControlEntry, DynControlEntry};
use crate::control_value::{ControlValue, ControlValueError};
#[allow(unused_imports)]
use crate::geometry::{Rectangle, Point, Size};
Expand Down Expand Up @@ -639,9 +637,6 @@ impl ControlId {
pub fn id(&self) -> u32 {
u32::from(*self)
}
pub fn name(&self) -> String {
control_id_name(*self)
}
}
/// Enable or disable the AE.
///
Expand Down
7 changes: 1 addition & 6 deletions libcamera/versioned_files/0.4.0/properties.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::ops::{Deref, DerefMut};
use num_enum::{IntoPrimitive, TryFromPrimitive};
#[allow(unused_imports)]
use crate::control::{
Control, Property, ControlEntry, DynControlEntry, control_id_name, property_id_name,
};
use crate::control::{Control, Property, ControlEntry, DynControlEntry};
use crate::control_value::{ControlValue, ControlValueError};
#[allow(unused_imports)]
use crate::geometry::{Rectangle, Point, Size};
Expand Down Expand Up @@ -726,9 +724,6 @@ impl PropertyId {
pub fn id(&self) -> u32 {
u32::from(*self)
}
pub fn name(&self) -> String {
property_id_name(*self)
}
}
/// Camera mounting location
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
Expand Down
7 changes: 1 addition & 6 deletions libcamera/versioned_files/0.5.0/controls.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::ops::{Deref, DerefMut};
use num_enum::{IntoPrimitive, TryFromPrimitive};
#[allow(unused_imports)]
use crate::control::{
Control, Property, ControlEntry, DynControlEntry, control_id_name, property_id_name,
};
use crate::control::{Control, Property, ControlEntry, DynControlEntry};
use crate::control_value::{ControlValue, ControlValueError};
#[allow(unused_imports)]
use crate::geometry::{Rectangle, Point, Size};
Expand Down Expand Up @@ -772,9 +770,6 @@ impl ControlId {
pub fn id(&self) -> u32 {
u32::from(*self)
}
pub fn name(&self) -> String {
control_id_name(*self)
}
}
/// Enable or disable the AEGC algorithm. When this control is set to true,
/// both ExposureTimeMode and AnalogueGainMode are set to auto, and if this
Expand Down
7 changes: 1 addition & 6 deletions libcamera/versioned_files/0.5.0/properties.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::ops::{Deref, DerefMut};
use num_enum::{IntoPrimitive, TryFromPrimitive};
#[allow(unused_imports)]
use crate::control::{
Control, Property, ControlEntry, DynControlEntry, control_id_name, property_id_name,
};
use crate::control::{Control, Property, ControlEntry, DynControlEntry};
use crate::control_value::{ControlValue, ControlValueError};
#[allow(unused_imports)]
use crate::geometry::{Rectangle, Point, Size};
Expand Down Expand Up @@ -726,9 +724,6 @@ impl PropertyId {
pub fn id(&self) -> u32 {
u32::from(*self)
}
pub fn name(&self) -> String {
property_id_name(*self)
}
}
/// Camera mounting location
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
Expand Down
7 changes: 1 addition & 6 deletions libcamera/versioned_files/0.5.1/controls.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::ops::{Deref, DerefMut};
use num_enum::{IntoPrimitive, TryFromPrimitive};
#[allow(unused_imports)]
use crate::control::{
Control, Property, ControlEntry, DynControlEntry, control_id_name, property_id_name,
};
use crate::control::{Control, Property, ControlEntry, DynControlEntry};
use crate::control_value::{ControlValue, ControlValueError};
#[allow(unused_imports)]
use crate::geometry::{Rectangle, Point, Size};
Expand Down Expand Up @@ -772,9 +770,6 @@ impl ControlId {
pub fn id(&self) -> u32 {
u32::from(*self)
}
pub fn name(&self) -> String {
control_id_name(*self)
}
}
/// Enable or disable the AEGC algorithm. When this control is set to true,
/// both ExposureTimeMode and AnalogueGainMode are set to auto, and if this
Expand Down
7 changes: 1 addition & 6 deletions libcamera/versioned_files/0.5.1/properties.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::ops::{Deref, DerefMut};
use num_enum::{IntoPrimitive, TryFromPrimitive};
#[allow(unused_imports)]
use crate::control::{
Control, Property, ControlEntry, DynControlEntry, control_id_name, property_id_name,
};
use crate::control::{Control, Property, ControlEntry, DynControlEntry};
use crate::control_value::{ControlValue, ControlValueError};
#[allow(unused_imports)]
use crate::geometry::{Rectangle, Point, Size};
Expand Down Expand Up @@ -726,9 +724,6 @@ impl PropertyId {
pub fn id(&self) -> u32 {
u32::from(*self)
}
pub fn name(&self) -> String {
property_id_name(*self)
}
}
/// Camera mounting location
#[derive(Debug, Clone, Copy, Eq, PartialEq, TryFromPrimitive, IntoPrimitive)]
Expand Down