android_manifest/
path_permission.rs

1use serde::{Deserialize, Serialize};
2
3/// Defines the path and required permissions for a specific subset of data
4/// within a content provider.
5///
6/// This element can be specified multiple times to
7/// supply multiple paths.
8///
9/// ## XML Syntax
10/// ```xml
11/// <path-permission android:path="string"
12///                  android:pathPrefix="string"
13///                  android:pathPattern="string"
14///                  android:permission="string"
15///                  android:readPermission="string"
16///                  android:writePermission="string" />
17/// ```
18///
19/// ## Contained in
20/// * [`<provider>`]
21///
22/// ## Introduced in
23/// API Level 4
24///
25/// [`<provider>`]: crate::Provider
26#[derive(
27    Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Eq, Default, Clone,
28)]
29pub struct PathPermission {
30    /// A complete URI path for a subset of content provider data. Permission can be
31    /// granted only to the particular data identified by this path. When used to
32    /// provide search suggestion content, it must be appended with
33    /// "/search_suggest_query".
34    #[yaserde(attribute, prefix = "android")]
35    pub path: Option<String>,
36    /// The initial part of a URI path for a subset of content provider data. Permission
37    /// can be granted to all data subsets with paths that share this initial part.
38    #[yaserde(attribute, prefix = "android", rename = "pathPrefix")]
39    pub path_prefix: Option<String>,
40    /// A complete URI path for a subset of content provider data, but one that
41    /// can use the following wildcards:
42    ///
43    /// * An asterisk `('*')`. This matches a sequence of 0 to many occurrences of the
44    ///   immediately precedingcharacter.
45    /// * A period followed by an asterisk `(".*")`. This matches any
46    /// sequence of 0 or more characters.
47    ///
48    /// Because `'\'` is used as an escape character when the string is read from XML
49    /// (before it is parsed as a pattern), you will need to double-escape. For
50    /// example, a literal `'*'` would be written as `"\\*"` and a literal `'\'` would be
51    /// written as `"\\"`. This is basically the same as what you would need to write if
52    /// constructing the string in Java code.
53    ///
54    /// For more information on these types of patterns, see the descriptions of
55    /// [`PATTERN_LITERAL`], [`PATTERN_PREFIX`], and [`PATTERN_SIMPLE_GLOB`] in the
56    /// [`PatternMatcher`] class.
57    ///
58    /// [`PATTERN_LITERAL`]: https://developer.android.com/reference/android/os/PatternMatcher#PATTERN_LITERAL
59    /// [`PATTERN_PREFIX`]: https://developer.android.com/reference/android/os/PatternMatcher#PATTERN_PREFIX
60    /// [`PATTERN_SIMPLE_GLOB`]: https://developer.android.com/reference/android/os/PatternMatcher#PATTERN_SIMPLE_GLOB
61    /// [`PatternMatcher`]: https://developer.android.com/reference/android/os/PatternMatcher
62    #[yaserde(attribute, prefix = "android", rename = "pathPattern")]
63    pub path_pattern: Option<String>,
64    /// The name of a permission that clients must have in order to read or write the
65    /// content provider's data. This attribute is a convenient way of setting a
66    /// single permission for both reading and writing. However, the `readPermission`
67    /// and `writePermission` attributes take precedence over this one.
68    #[yaserde(attribute, prefix = "android")]
69    pub permission: Option<String>,
70    /// A permission that clients must have in order to query the content provider.
71    #[yaserde(attribute, prefix = "android", rename = "readPermission")]
72    pub read_permission: Option<String>,
73    /// A permission that clients must have in order to make changes to the data
74    /// controlled by the content provider.
75    #[yaserde(attribute, prefix = "android", rename = "writePermission")]
76    pub write_permission: Option<String>,
77}