async_std/fs/
permissions.rs

1cfg_not_docs! {
2    pub use std::fs::Permissions;
3}
4
5cfg_docs! {
6    /// A set of permissions on a file or directory.
7    ///
8    /// This type is a re-export of [`std::fs::Permissions`].
9    ///
10    /// [`std::fs::Permissions`]: https://doc.rust-lang.org/std/fs/struct.Permissions.html
11    #[derive(Clone, PartialEq, Eq, Debug)]
12    pub struct Permissions {
13        _private: (),
14    }
15
16    impl Permissions {
17        /// Returns the read-only flag.
18        ///
19        /// # Examples
20        ///
21        /// ```no_run
22        /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
23        /// #
24        /// use async_std::fs;
25        ///
26        /// let perm = fs::metadata("a.txt").await?.permissions();
27        /// println!("{:?}", perm.readonly());
28        /// #
29        /// # Ok(()) }) }
30        /// ```
31        pub fn readonly(&self) -> bool {
32            unreachable!("this impl only appears in the rendered docs")
33        }
34
35        /// Configures the read-only flag.
36        ///
37        /// [`fs::set_permissions`]: fn.set_permissions.html
38        ///
39        /// # Examples
40        ///
41        /// ```no_run
42        /// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
43        /// #
44        /// use async_std::fs;
45        ///
46        /// let mut perm = fs::metadata("a.txt").await?.permissions();
47        /// perm.set_readonly(true);
48        /// fs::set_permissions("a.txt", perm).await?;
49        /// #
50        /// # Ok(()) }) }
51        /// ```
52        pub fn set_readonly(&mut self, readonly: bool) {
53            unreachable!("this impl only appears in the rendered docs")
54        }
55    }
56}