Skip to content

Commit 9412ab6

Browse files
authored
Merge pull request #47 from dstrub18/main
Removed Result return type from new function of attribute
2 parents 451b676 + db43ce7 commit 9412ab6

File tree

11 files changed

+59
-65
lines changed

11 files changed

+59
-65
lines changed

matter/src/data_model/cluster_basic_information.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,43 +60,43 @@ impl BasicInfoCluster {
6060
AttrValue::Uint8(1),
6161
Access::RV,
6262
Quality::FIXED,
63-
)?,
63+
),
6464
Attribute::new(
6565
Attributes::VendorId as u16,
6666
AttrValue::Uint16(cfg.vid),
6767
Access::RV,
6868
Quality::FIXED,
69-
)?,
69+
),
7070
Attribute::new(
7171
Attributes::ProductId as u16,
7272
AttrValue::Uint16(cfg.pid),
7373
Access::RV,
7474
Quality::FIXED,
75-
)?,
75+
),
7676
Attribute::new(
7777
Attributes::HwVer as u16,
7878
AttrValue::Uint16(cfg.hw_ver),
7979
Access::RV,
8080
Quality::FIXED,
81-
)?,
81+
),
8282
Attribute::new(
8383
Attributes::SwVer as u16,
8484
AttrValue::Uint32(cfg.sw_ver),
8585
Access::RV,
8686
Quality::FIXED,
87-
)?,
87+
),
8888
Attribute::new(
8989
Attributes::SwVerString as u16,
9090
AttrValue::Utf8(cfg.sw_ver_str),
9191
Access::RV,
9292
Quality::FIXED,
93-
)?,
93+
),
9494
Attribute::new(
9595
Attributes::SerialNo as u16,
9696
AttrValue::Utf8(cfg.serial_no),
9797
Access::RV,
9898
Quality::FIXED,
99-
)?,
99+
),
100100
];
101101
cluster.base.add_attributes(&attrs[..])?;
102102

matter/src/data_model/cluster_media_playback.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,46 +136,46 @@ impl MediaPlaybackCluster {
136136
AttrValue::Uint8(PlaybackState::NotPlaying as u8),
137137
Access::RV,
138138
Quality::PERSISTENT,
139-
)?,
139+
),
140140
// epoch-us
141141
Attribute::new(
142142
Attributes::StartTime as u16,
143143
AttrValue::Uint64(0),
144144
Access::RV,
145145
Quality::PERSISTENT,
146-
)?,
146+
),
147147
Attribute::new(
148148
Attributes::Duration as u16,
149149
AttrValue::Uint64(1),
150150
Access::RV,
151151
Quality::PERSISTENT,
152-
)?,
152+
),
153153
// Playback-Position
154154
Attribute::new(
155155
Attributes::SampledPosition as u16,
156156
AttrValue::Custom,
157157
Access::RV,
158158
Quality::PERSISTENT,
159-
)?,
159+
),
160160
// Float
161161
Attribute::new(
162162
Attributes::PlaybackSpeed as u16,
163163
AttrValue::Custom,
164164
Access::RV,
165165
Quality::PERSISTENT,
166-
)?,
166+
),
167167
Attribute::new(
168168
Attributes::SeekRangeEnd as u16,
169169
AttrValue::Uint64(0),
170170
Access::RV,
171171
Quality::PERSISTENT,
172-
)?,
172+
),
173173
Attribute::new(
174174
Attributes::SeekRangeStart as u16,
175175
AttrValue::Uint64(0),
176176
Access::RV,
177177
Quality::PERSISTENT,
178-
)?,
178+
),
179179
// Options - probably want a custom type here for mapping cluster options to TLV bitmask
180180
];
181181
cluster.base.add_attributes(&attrs)?;

matter/src/data_model/cluster_on_off.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub enum Commands {
3737
Toggle = 0x02,
3838
}
3939

40-
fn attr_on_off_new() -> Result<Attribute, Error> {
40+
fn attr_on_off_new() -> Attribute {
4141
// OnOff, Value: false
4242
Attribute::new(
4343
Attributes::OnOff as u16,
@@ -56,7 +56,7 @@ impl OnOffCluster {
5656
let mut cluster = Box::new(OnOffCluster {
5757
base: Cluster::new(ID)?,
5858
});
59-
cluster.base.add_attribute(attr_on_off_new()?)?;
59+
cluster.base.add_attribute(attr_on_off_new())?;
6060
Ok(cluster)
6161
}
6262
}

matter/src/data_model/objects/attribute.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,13 @@ impl Default for Attribute {
171171
}
172172

173173
impl Attribute {
174-
pub fn new(
175-
id: u16,
176-
value: AttrValue,
177-
access: Access,
178-
quality: Quality,
179-
) -> Result<Attribute, Error> {
180-
Ok(Attribute {
174+
pub fn new(id: u16, value: AttrValue, access: Access, quality: Quality) -> Self {
175+
Attribute {
181176
id,
182177
value,
183178
access,
184179
quality,
185-
})
180+
}
186181
}
187182

188183
pub fn set_value(&mut self, value: AttrValue) -> Result<(), Error> {

matter/src/data_model/objects/cluster.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ impl Cluster {
139139
AttrValue::Uint32(0),
140140
Access::RV,
141141
Quality::NONE,
142-
)?)?;
142+
))?;
143143

144144
self.add_attribute(Attribute::new(
145145
GlobalElements::AttributeList as u16,
146146
AttrValue::Custom,
147147
Access::RV,
148148
Quality::NONE,
149-
)?)
149+
))
150150
}
151151

152152
pub fn add_attributes(&mut self, attrs: &[Attribute]) -> Result<(), Error> {

matter/src/data_model/sdm/admin_commissioning.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub enum Commands {
4848
RevokeComm = 0x02,
4949
}
5050

51-
fn attr_window_status_new() -> Result<Attribute, Error> {
51+
fn attr_window_status_new() -> Attribute {
5252
Attribute::new(
5353
Attributes::WindowStatus as u16,
5454
AttrValue::Custom,
@@ -57,7 +57,7 @@ fn attr_window_status_new() -> Result<Attribute, Error> {
5757
)
5858
}
5959

60-
fn attr_admin_fabid_new() -> Result<Attribute, Error> {
60+
fn attr_admin_fabid_new() -> Attribute {
6161
Attribute::new(
6262
Attributes::AdminFabricIndex as u16,
6363
AttrValue::Custom,
@@ -66,7 +66,7 @@ fn attr_admin_fabid_new() -> Result<Attribute, Error> {
6666
)
6767
}
6868

69-
fn attr_admin_vid_new() -> Result<Attribute, Error> {
69+
fn attr_admin_vid_new() -> Attribute {
7070
Attribute::new(
7171
Attributes::AdminVendorId as u16,
7272
AttrValue::Custom,
@@ -129,9 +129,9 @@ impl AdminCommCluster {
129129
pase_mgr,
130130
base: Cluster::new(ID)?,
131131
});
132-
c.base.add_attribute(attr_window_status_new()?)?;
133-
c.base.add_attribute(attr_admin_fabid_new()?)?;
134-
c.base.add_attribute(attr_admin_vid_new()?)?;
132+
c.base.add_attribute(attr_window_status_new())?;
133+
c.base.add_attribute(attr_admin_fabid_new())?;
134+
c.base.add_attribute(attr_admin_vid_new())?;
135135
Ok(c)
136136
}
137137

matter/src/data_model/sdm/general_commissioning.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub enum RegLocationType {
6262
IndoorOutdoor = 2,
6363
}
6464

65-
fn attr_bread_crumb_new(bread_crumb: u64) -> Result<Attribute, Error> {
65+
fn attr_bread_crumb_new(bread_crumb: u64) -> Attribute {
6666
Attribute::new(
6767
Attributes::BreadCrumb as u16,
6868
AttrValue::Uint64(bread_crumb),
@@ -71,7 +71,7 @@ fn attr_bread_crumb_new(bread_crumb: u64) -> Result<Attribute, Error> {
7171
)
7272
}
7373

74-
fn attr_reg_config_new(reg_config: RegLocationType) -> Result<Attribute, Error> {
74+
fn attr_reg_config_new(reg_config: RegLocationType) -> Attribute {
7575
Attribute::new(
7676
Attributes::RegConfig as u16,
7777
AttrValue::Uint8(reg_config as u8),
@@ -80,7 +80,7 @@ fn attr_reg_config_new(reg_config: RegLocationType) -> Result<Attribute, Error>
8080
)
8181
}
8282

83-
fn attr_location_capability_new(reg_config: RegLocationType) -> Result<Attribute, Error> {
83+
fn attr_location_capability_new(reg_config: RegLocationType) -> Attribute {
8484
Attribute::new(
8585
Attributes::LocationCapability as u16,
8686
AttrValue::Uint8(reg_config as u8),
@@ -89,7 +89,7 @@ fn attr_location_capability_new(reg_config: RegLocationType) -> Result<Attribute
8989
)
9090
}
9191

92-
fn attr_comm_info_new() -> Result<Attribute, Error> {
92+
fn attr_comm_info_new() -> Attribute {
9393
Attribute::new(
9494
Attributes::BasicCommissioningInfo as u16,
9595
AttrValue::Custom,
@@ -160,15 +160,14 @@ impl GenCommCluster {
160160
failsafe,
161161
base: Cluster::new(ID)?,
162162
});
163-
c.base.add_attribute(attr_bread_crumb_new(0)?)?;
163+
c.base.add_attribute(attr_bread_crumb_new(0))?;
164164
// TODO: Arch-Specific
165165
c.base
166-
.add_attribute(attr_reg_config_new(RegLocationType::IndoorOutdoor)?)?;
166+
.add_attribute(attr_reg_config_new(RegLocationType::IndoorOutdoor))?;
167167
// TODO: Arch-Specific
168-
c.base.add_attribute(attr_location_capability_new(
169-
RegLocationType::IndoorOutdoor,
170-
)?)?;
171-
c.base.add_attribute(attr_comm_info_new()?)?;
168+
c.base
169+
.add_attribute(attr_location_capability_new(RegLocationType::IndoorOutdoor))?;
170+
c.base.add_attribute(attr_comm_info_new())?;
172171

173172
Ok(c)
174173
}

matter/src/data_model/sdm/noc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,25 @@ impl NocCluster {
131131
AttrValue::Custom,
132132
Access::RV,
133133
Quality::NONE,
134-
)?,
134+
),
135135
Attribute::new(
136136
Attributes::Fabrics as u16,
137137
AttrValue::Custom,
138138
Access::RV | Access::FAB_SCOPED,
139139
Quality::NONE,
140-
)?,
140+
),
141141
Attribute::new(
142142
Attributes::SupportedFabrics as u16,
143143
AttrValue::Uint8(MAX_SUPPORTED_FABRICS as u8),
144144
Access::RV,
145145
Quality::FIXED,
146-
)?,
146+
),
147147
Attribute::new(
148148
Attributes::CommissionedFabrics as u16,
149149
AttrValue::Custom,
150150
Access::RV,
151151
Quality::NONE,
152-
)?,
152+
),
153153
];
154154
c.base.add_attributes(&attrs[..])?;
155155
Ok(c)

matter/src/data_model/system_model/access_control.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ impl AccessControlCluster {
4949
base: Cluster::new(ID)?,
5050
acl_mgr,
5151
});
52-
c.base.add_attribute(attr_acl_new()?)?;
53-
c.base.add_attribute(attr_extension_new()?)?;
54-
c.base.add_attribute(attr_subjects_per_entry_new()?)?;
55-
c.base.add_attribute(attr_targets_per_entry_new()?)?;
56-
c.base.add_attribute(attr_entries_per_fabric_new()?)?;
52+
c.base.add_attribute(attr_acl_new())?;
53+
c.base.add_attribute(attr_extension_new())?;
54+
c.base.add_attribute(attr_subjects_per_entry_new())?;
55+
c.base.add_attribute(attr_targets_per_entry_new())?;
56+
c.base.add_attribute(attr_entries_per_fabric_new())?;
5757
Ok(c)
5858
}
5959

@@ -143,7 +143,7 @@ impl ClusterType for AccessControlCluster {
143143
}
144144
}
145145

146-
fn attr_acl_new() -> Result<Attribute, Error> {
146+
fn attr_acl_new() -> Attribute {
147147
Attribute::new(
148148
Attributes::Acl as u16,
149149
AttrValue::Custom,
@@ -152,7 +152,7 @@ fn attr_acl_new() -> Result<Attribute, Error> {
152152
)
153153
}
154154

155-
fn attr_extension_new() -> Result<Attribute, Error> {
155+
fn attr_extension_new() -> Attribute {
156156
Attribute::new(
157157
Attributes::Extension as u16,
158158
AttrValue::Custom,
@@ -161,7 +161,7 @@ fn attr_extension_new() -> Result<Attribute, Error> {
161161
)
162162
}
163163

164-
fn attr_subjects_per_entry_new() -> Result<Attribute, Error> {
164+
fn attr_subjects_per_entry_new() -> Attribute {
165165
Attribute::new(
166166
Attributes::SubjectsPerEntry as u16,
167167
AttrValue::Uint16(acl::SUBJECTS_PER_ENTRY as u16),
@@ -170,7 +170,7 @@ fn attr_subjects_per_entry_new() -> Result<Attribute, Error> {
170170
)
171171
}
172172

173-
fn attr_targets_per_entry_new() -> Result<Attribute, Error> {
173+
fn attr_targets_per_entry_new() -> Attribute {
174174
Attribute::new(
175175
Attributes::TargetsPerEntry as u16,
176176
AttrValue::Uint16(acl::TARGETS_PER_ENTRY as u16),
@@ -179,7 +179,7 @@ fn attr_targets_per_entry_new() -> Result<Attribute, Error> {
179179
)
180180
}
181181

182-
fn attr_entries_per_fabric_new() -> Result<Attribute, Error> {
182+
fn attr_entries_per_fabric_new() -> Attribute {
183183
Attribute::new(
184184
Attributes::EntriesPerFabric as u16,
185185
AttrValue::Uint16(acl::ENTRIES_PER_FABRIC as u16),

matter/src/data_model/system_model/descriptor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,25 @@ impl DescriptorCluster {
5454
AttrValue::Custom,
5555
Access::RV,
5656
Quality::NONE,
57-
)?,
57+
),
5858
Attribute::new(
5959
Attributes::ServerList as u16,
6060
AttrValue::Custom,
6161
Access::RV,
6262
Quality::NONE,
63-
)?,
63+
),
6464
Attribute::new(
6565
Attributes::PartsList as u16,
6666
AttrValue::Custom,
6767
Access::RV,
6868
Quality::NONE,
69-
)?,
69+
),
7070
Attribute::new(
7171
Attributes::ClientList as u16,
7272
AttrValue::Custom,
7373
Access::RV,
7474
Quality::NONE,
75-
)?,
75+
),
7676
];
7777
c.base.add_attributes(&attrs[..])?;
7878
Ok(c)

0 commit comments

Comments
 (0)