Add into_parts for Role and Assignment
This change adds destructuring methods to the Role and Assignment
structs.  This allows these structs to be converted in a manner that
does not require allocations.
@@ -25,7 +25,6 @@ pub use self::diesel::DieselRoleBasedAuthorizationStore;
pub use error::RoleBasedAuthorizationStoreError;
-
/// A Role is a named set of permissions.
pub struct Role {
id: String,
@@ -57,6 +56,12 @@ impl Role {
permissions: self.permissions,
}
}
+
+ /// Converts this role into it's constituent parts. These parts are in the tuple:
+ /// `(id, display_name, permissions)`.
+ pub fn into_parts(self) -> (String, String, Vec<String>) {
+ (self.id, self.display_name, self.permissions)
+ }
}
/// A builder to create new roles.
@@ -217,6 +222,12 @@ impl Assignment {
let Assignment { identity, roles } = self;
AssignmentUpdateBuilder { identity, roles }
}
+
+ /// Converts this assignment into it's constituent parts. These parts are in the tuple:
+ /// `(identity, roles)`.
+ pub fn into_parts(self) -> (Identity, Vec<String>) {
+ (self.identity, self.roles)
+ }
}
/// Constructs new Assignments.
