Skip to content

Commit b58f170

Browse files
committed
refactor: Simplify function signatures in client and handler modules
1 parent 4aea04e commit b58f170

File tree

7 files changed

+17
-42
lines changed

7 files changed

+17
-42
lines changed

audit-trail-rs/src/client/full_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ impl<S> AuditTrailClient<S> {
6767
AuditTrailBuilder::new()
6868
}
6969

70-
pub async fn migrate(&self, _trail_id: ObjectID, _cap_id: ObjectID) -> Result<(), Error> {
70+
pub async fn migrate(&self, _trail_id: ObjectID) -> Result<(), Error> {
7171
Err(Error::NotImplemented("AuditTrailClient::migrate"))
7272
}
7373

74-
pub async fn delete_trail(&self, _trail_id: ObjectID, _cap_id: ObjectID) -> Result<(), Error> {
74+
pub async fn delete_trail(&self, _trail_id: ObjectID) -> Result<(), Error> {
7575
Err(Error::NotImplemented("AuditTrailClient::delete_trail"))
7676
}
7777
}

audit-trail-rs/src/core/handler/capabilities.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ impl<'a, C> TrailCapabilities<'a, C> {
1717
Self { client, trail_id }
1818
}
1919

20-
pub async fn issue(&self, _cap_id: ObjectID, _role: String) -> Result<(), Error>
20+
pub async fn issue(&self, _role: String) -> Result<(), Error>
2121
where
2222
C: AuditTrailFull,
2323
{
2424
Err(Error::NotImplemented("TrailCapabilities::issue"))
2525
}
2626

27-
pub async fn revoke(&self, _cap_id: ObjectID, _capability_id: ObjectID) -> Result<(), Error>
27+
pub async fn revoke(&self, _capability_id: ObjectID) -> Result<(), Error>
2828
where
2929
C: AuditTrailFull,
3030
{

audit-trail-rs/src/core/handler/locking.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ impl<'a, C> TrailLocking<'a, C> {
1818
Self { client, trail_id }
1919
}
2020

21-
pub async fn update(&self, _cap_id: ObjectID, _config: LockingConfig) -> Result<(), Error>
21+
pub async fn update(&self, _config: LockingConfig) -> Result<(), Error>
2222
where
2323
C: AuditTrailFull,
2424
{
2525
Err(Error::NotImplemented("TrailLocking::update"))
2626
}
2727

28-
pub async fn update_delete_record_window(&self, _cap_id: ObjectID, _window: LockingWindow) -> Result<(), Error>
28+
pub async fn update_delete_record_window(&self, _window: LockingWindow) -> Result<(), Error>
2929
where
3030
C: AuditTrailFull,
3131
{

audit-trail-rs/src/core/handler/records.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,7 @@ impl<'a, C, D> TrailRecords<'a, C, D> {
9292
)))
9393
}
9494

95-
pub async fn correct(
96-
&self,
97-
_cap_id: ObjectID,
98-
_replaces: Vec<u64>,
99-
_data: D,
100-
_metadata: Option<String>,
101-
) -> Result<(), Error>
95+
pub async fn correct(&self, _replaces: Vec<u64>, _data: D, _metadata: Option<String>) -> Result<(), Error>
10296
where
10397
C: AuditTrailFull,
10498
{

audit-trail-rs/src/core/handler/roles.rs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,23 @@ impl<'a, C> TrailRoles<'a, C> {
2424
}
2525

2626
/// Creates a new role with the provided permissions.
27-
pub async fn create(
28-
&self,
29-
_cap_id: ObjectID,
30-
_name: impl Into<String>,
31-
_permissions: PermissionSet,
32-
) -> Result<(), Error>
27+
pub async fn create(&self, _name: impl Into<String>, _permissions: PermissionSet) -> Result<(), Error>
3328
where
3429
C: AuditTrailFull,
3530
{
3631
Err(Error::NotImplemented("TrailRoles::create"))
3732
}
3833

3934
/// Updates permissions for an existing role.
40-
pub async fn update(
41-
&self,
42-
_cap_id: ObjectID,
43-
_name: impl Into<String>,
44-
_permissions: PermissionSet,
45-
) -> Result<(), Error>
35+
pub async fn update(&self, _name: impl Into<String>, _permissions: PermissionSet) -> Result<(), Error>
4636
where
4737
C: AuditTrailFull,
4838
{
4939
Err(Error::NotImplemented("TrailRoles::update"))
5040
}
5141

5242
/// Deletes an existing role.
53-
pub async fn delete(&self, _cap_id: ObjectID, _name: impl Into<String>) -> Result<(), Error>
43+
pub async fn delete(&self, _name: impl Into<String>) -> Result<(), Error>
5444
where
5545
C: AuditTrailFull,
5646
{
@@ -67,27 +57,23 @@ pub struct RoleHandle<'a, C> {
6757

6858
impl<'a, C> RoleHandle<'a, C> {
6959
pub(crate) fn new(client: &'a C, trail_id: ObjectID, name: String) -> Self {
70-
Self {
71-
client,
72-
trail_id,
73-
name,
74-
}
60+
Self { client, trail_id, name }
7561
}
7662

7763
pub fn name(&self) -> &str {
7864
&self.name
7965
}
8066

8167
/// Updates permissions for this role.
82-
pub async fn update_permissions(&self, _cap_id: ObjectID, _permissions: PermissionSet) -> Result<(), Error>
68+
pub async fn update_permissions(&self, _permissions: PermissionSet) -> Result<(), Error>
8369
where
8470
C: AuditTrailFull,
8571
{
8672
Err(Error::NotImplemented("RoleHandle::update_permissions"))
8773
}
8874

8975
/// Deletes this role.
90-
pub async fn delete(&self, _cap_id: ObjectID) -> Result<(), Error>
76+
pub async fn delete(&self) -> Result<(), Error>
9177
where
9278
C: AuditTrailFull,
9379
{

audit-trail-rs/src/core/types/audit_trail.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use iota_interaction::types::base_types::IotaAddress;
55
use iota_interaction::types::id::UID;
66
use serde::{Deserialize, Serialize};
77

8+
use crate::core::types::Data;
9+
810
use super::locking::LockingConfig;
911
use super::metadata::ImmutableMetadata;
1012
use super::permission::Permission;
@@ -13,7 +15,7 @@ use super::role_map::RoleMap;
1315

1416
/// An audit trail stored on-chain.
1517
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
16-
pub struct AuditTrail<D = super::record::Data> {
18+
pub struct AuditTrail<D = Data> {
1719
pub id: UID,
1820
pub creator: IotaAddress,
1921
pub created_at: u64,

audit-trail-rs/src/core/types/record_correction.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,13 @@ use std::collections::HashSet;
66
use serde::{Deserialize, Serialize};
77

88
/// Bidirectional correction tracking for audit records.
9-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
9+
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
1010
pub struct RecordCorrection {
1111
pub replaces: HashSet<u64>,
1212
pub is_replaced_by: Option<u64>,
1313
}
1414

1515
impl RecordCorrection {
16-
pub fn new() -> Self {
17-
Self {
18-
replaces: HashSet::new(),
19-
is_replaced_by: None,
20-
}
21-
}
22-
2316
pub fn with_replaces(replaces: HashSet<u64>) -> Self {
2417
Self {
2518
replaces,

0 commit comments

Comments
 (0)