@@ -11,16 +11,16 @@ use std::borrow::Cow;
11
11
/// attachments, stored procedures, triggers, and user-defined functions for a particular user.
12
12
/// You can learn more about permissions [here](https://docs.microsoft.com/rest/api/cosmos-db/permissions).
13
13
#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
14
- pub struct Permission < ' a > {
14
+ pub struct Permission {
15
15
/// The unique name that identifies the permission.
16
- pub id : Cow < ' a , str > ,
16
+ pub id : String ,
17
17
#[ serde( flatten) ]
18
18
/// The access mode on the resource for the user
19
19
///
20
20
/// Represented as both "permissionMode" and "resource" in the JSON representation.
21
- pub permission_mode : PermissionMode < ' a > ,
21
+ pub permission_mode : PermissionMode ,
22
22
#[ serde( rename = "_rid" ) ]
23
- rid : Cow < ' a , str > ,
23
+ rid : String ,
24
24
/// The last updated timestamp of the resource.
25
25
///
26
26
/// Represented as "_ts" in the JSON representation.
@@ -30,12 +30,12 @@ pub struct Permission<'a> {
30
30
///
31
31
/// Represented as "_self" in the JSON representation.
32
32
#[ serde( rename = "_self" ) ]
33
- pub uri : Cow < ' a , str > ,
33
+ pub uri : String ,
34
34
/// The resource etag required for optimistic concurrency control.
35
35
///
36
36
/// Represented as "_etag" in the JSON representation.
37
37
#[ serde( rename = "_etag" ) ]
38
- pub etag : Cow < ' a , str > ,
38
+ pub etag : String ,
39
39
/// The resource token for the particular resource and user.
40
40
///
41
41
/// Represented as "_token" in the JSON representation.
@@ -51,22 +51,22 @@ pub struct Permission<'a> {
51
51
/// Constructing a `PermissionMode` manually is error prone. Use one of the constructor methods
52
52
/// (i.e., [`PermissionMode::read`] or [`PermissionMode::all`]) or get a permission directly
53
53
/// from a resource (e.g., `Collection::read_permission`).
54
- pub enum PermissionMode < ' a > {
54
+ pub enum PermissionMode {
55
55
/// read, write, and delete access
56
- All ( Cow < ' a , str > ) ,
56
+ All ( Cow < ' static , str > ) ,
57
57
/// read access only
58
- Read ( Cow < ' a , str > ) ,
58
+ Read ( Cow < ' static , str > ) ,
59
59
}
60
60
61
- impl < ' a > PermissionMode < ' a > {
61
+ impl PermissionMode {
62
62
/// Read permission for a given resource
63
- pub fn read < T : Resource + ?Sized + ' a > ( resource : & ' a T ) -> Self {
64
- PermissionMode :: Read ( Cow :: Borrowed ( resource. uri ( ) ) )
63
+ pub fn read < T : Resource + ?Sized > ( resource : & T ) -> Self {
64
+ PermissionMode :: Read ( Cow :: Owned ( resource. uri ( ) . to_owned ( ) ) )
65
65
}
66
66
67
67
/// Read, write, and delete permissions for a given resource
68
- pub fn all < T : Resource + ?Sized + ' a > ( resource : & ' a T ) -> Self {
69
- PermissionMode :: All ( Cow :: Borrowed ( resource. uri ( ) ) )
68
+ pub fn all < T : Resource + ?Sized > ( resource : & T ) -> Self {
69
+ PermissionMode :: All ( Cow :: Owned ( resource. uri ( ) . to_owned ( ) ) )
70
70
}
71
71
72
72
/// The kind of permission mode as a string. Either "All" or "Read".
@@ -86,7 +86,7 @@ impl<'a> PermissionMode<'a> {
86
86
}
87
87
}
88
88
89
- impl < ' a > std:: convert:: TryFrom < & [ u8 ] > for Permission < ' a > {
89
+ impl std:: convert:: TryFrom < & [ u8 ] > for Permission {
90
90
type Error = crate :: Error ;
91
91
92
92
fn try_from ( slice : & [ u8 ] ) -> Result < Self , Self :: Error > {
@@ -112,7 +112,7 @@ mod tests {
112
112
113
113
#[ test]
114
114
fn parse_permission ( ) {
115
- let permission: Permission < ' _ > = serde_json:: from_str ( PERMISSION_JSON ) . unwrap ( ) ;
115
+ let permission: Permission = serde_json:: from_str ( PERMISSION_JSON ) . unwrap ( ) ;
116
116
117
117
assert_eq ! (
118
118
permission. permission_token,
0 commit comments