@@ -17,16 +17,24 @@ This crate provides a unified API for declaring permissions across supported pla
1717### Basic Permission Declaration
1818
1919``` rust
20- use permissions :: {static_permission, Permission };
20+ use permissions :: {static_permission, Permission , PermissionBuilder , PermissionKind };
2121
22- // Declare a camera permission
23- const CAMERA : Permission = static_permission! (Camera , description = " Take photos" );
22+ // Declare a camera permission using the builder
23+ const CAMERA : Permission = static_permission! (
24+ Permission :: new (PermissionKind :: Camera , " Take photos" )
25+ );
2426
25- // Declare a location permission with precision
26- const LOCATION : Permission = static_permission! (Location (Fine ), description = " Track your runs" );
27+ // Declare a fine-grained location permission
28+ const LOCATION : Permission = static_permission! (
29+ PermissionBuilder :: location (permissions :: LocationPrecision :: Fine )
30+ . with_description (" Track your runs" )
31+ . build ()
32+ );
2733
2834// Declare a microphone permission
29- const MICROPHONE : Permission = static_permission! (Microphone , description = " Record audio" );
35+ const MICROPHONE : Permission = static_permission! (
36+ Permission :: new (PermissionKind :: Microphone , " Record audio" )
37+ );
3038```
3139
3240### Custom Permissions (For Untested or Special Use Cases)
@@ -35,16 +43,16 @@ For permissions that aren't yet tested or for special use cases, use the `Custom
3543with platform-specific identifiers:
3644
3745``` rust
38- use permissions :: {static_permission, Permission };
46+ use permissions :: {static_permission, Permission , PermissionBuilder };
3947
4048// Example: Request storage permission
4149const STORAGE : Permission = static_permission! (
42- Custom {
43- android = " android.permission.READ_EXTERNAL_STORAGE" ,
44- ios = " NSPhotoLibraryUsageDescription" ,
45- macos = " NSPhotoLibraryUsageDescription"
46- },
47- description = " Access files on your device "
50+ PermissionBuilder :: custom ()
51+ . with_android ( " android.permission.READ_EXTERNAL_STORAGE" )
52+ . with_ios ( " NSPhotoLibraryUsageDescription" )
53+ . with_macos ( " NSPhotoLibraryUsageDescription" )
54+ . with_description ( " Access files on your device " )
55+ . build ()
4856);
4957```
5058
@@ -55,9 +63,13 @@ const STORAGE: Permission = static_permission!(
5563### Using Permissions
5664
5765``` rust
58- use permissions :: {static_permission, Permission , Platform };
66+ use permissions :: {
67+ static_permission, Permission , PermissionBuilder , PermissionKind , Platform ,
68+ };
5969
60- const CAMERA : Permission = static_permission! (Camera , description = " Take photos" );
70+ const CAMERA : Permission = static_permission! (
71+ Permission :: new (PermissionKind :: Camera , " Take photos" )
72+ );
6173
6274// Get the description
6375println! (" Description: {}" , CAMERA . description ());
0 commit comments