@@ -11,16 +11,16 @@ use std::borrow::Cow;
1111/// attachments, stored procedures, triggers, and user-defined functions for a particular user.
1212/// You can learn more about permissions [here](https://docs.microsoft.com/rest/api/cosmos-db/permissions).
1313#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
14- pub struct Permission < ' a > {
14+ pub struct Permission {
1515 /// The unique name that identifies the permission.
16- pub id : Cow < ' a , str > ,
16+ pub id : String ,
1717 #[ serde( flatten) ]
1818 /// The access mode on the resource for the user
1919 ///
2020 /// Represented as both "permissionMode" and "resource" in the JSON representation.
21- pub permission_mode : PermissionMode < ' a > ,
21+ pub permission_mode : PermissionMode ,
2222 #[ serde( rename = "_rid" ) ]
23- rid : Cow < ' a , str > ,
23+ rid : String ,
2424 /// The last updated timestamp of the resource.
2525 ///
2626 /// Represented as "_ts" in the JSON representation.
@@ -30,12 +30,12 @@ pub struct Permission<'a> {
3030 ///
3131 /// Represented as "_self" in the JSON representation.
3232 #[ serde( rename = "_self" ) ]
33- pub uri : Cow < ' a , str > ,
33+ pub uri : String ,
3434 /// The resource etag required for optimistic concurrency control.
3535 ///
3636 /// Represented as "_etag" in the JSON representation.
3737 #[ serde( rename = "_etag" ) ]
38- pub etag : Cow < ' a , str > ,
38+ pub etag : String ,
3939 /// The resource token for the particular resource and user.
4040 ///
4141 /// Represented as "_token" in the JSON representation.
@@ -51,22 +51,22 @@ pub struct Permission<'a> {
5151/// Constructing a `PermissionMode` manually is error prone. Use one of the constructor methods
5252/// (i.e., [`PermissionMode::read`] or [`PermissionMode::all`]) or get a permission directly
5353/// from a resource (e.g., `Collection::read_permission`).
54- pub enum PermissionMode < ' a > {
54+ pub enum PermissionMode {
5555 /// read, write, and delete access
56- All ( Cow < ' a , str > ) ,
56+ All ( Cow < ' static , str > ) ,
5757 /// read access only
58- Read ( Cow < ' a , str > ) ,
58+ Read ( Cow < ' static , str > ) ,
5959}
6060
61- impl < ' a > PermissionMode < ' a > {
61+ impl PermissionMode {
6262 /// 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 ( ) ) )
6565 }
6666
6767 /// 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 ( ) ) )
7070 }
7171
7272 /// The kind of permission mode as a string. Either "All" or "Read".
@@ -86,7 +86,7 @@ impl<'a> PermissionMode<'a> {
8686 }
8787}
8888
89- impl < ' a > std:: convert:: TryFrom < & [ u8 ] > for Permission < ' a > {
89+ impl std:: convert:: TryFrom < & [ u8 ] > for Permission {
9090 type Error = crate :: Error ;
9191
9292 fn try_from ( slice : & [ u8 ] ) -> Result < Self , Self :: Error > {
@@ -112,7 +112,7 @@ mod tests {
112112
113113 #[ test]
114114 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 ( ) ;
116116
117117 assert_eq ! (
118118 permission. permission_token,
0 commit comments