# Struct `kurogane::capability::AuthorizedFs`

```rust
pub struct AuthorizedFs<'a> { /* private fields */ }
```

The authority of one origin. Every operation runs the decision rules in
the module documentation; nothing else reaches the filesystem for a
renderer.

## Methods

### `access`

```rust
pub fn access(&self) -> FsAccess
```

Every capability the origin holds, across its grants.

### `read_file`

```rust
pub fn read_file(&self, path: &Path) -> Result<Vec<u8>, FsError>
```

`fs.read_file`: READ. Regular files only, up to the transfer limit.

### `write_file`

```rust
pub fn write_file(&self, path: &Path, contents: &[u8]) -> Result<(), FsError>
```

`fs.write_file`: WRITE to replace an existing file, CREATE to make a
new one. The object decides which applies. Contents over the transfer
limit are refused before anything is opened.

An existing file is replaced whole. The contents go to a new file
beside it which then takes its name and its permissions. A write that
fails part-way leaves the old contents. The file is a new object
afterwards (its owner is the application's user); on Windows another
program holding it open without delete sharing makes the write fail.

### `create_dir`

```rust
pub fn create_dir(&self, path: &Path) -> Result<(), FsError>
```

`fs.create_dir`: CREATE. One level; the parent must exist.

### `remove_file`

```rust
pub fn remove_file(&self, path: &Path) -> Result<(), FsError>
```

`fs.remove_file`: DELETE.

### `remove_dir`

```rust
pub fn remove_dir(&self, path: &Path) -> Result<(), FsError>
```

`fs.remove_dir`: DELETE. The directory must be empty.

### `rename_file`

```rust
pub fn rename_file(&self, from: &Path, to: &Path) -> Result<(), FsError>
```

`fs.rename_file`: RENAME on source and destination, each authorized
independently. An existing destination is replaced.

Every rule is a function of where content lives. A move is also judged
as a whole. It may not carry content out from under a deny rule
(`PATH_DENIED`) nor to a place where the origin holds more access over
it than it held at the source (`PATH_DENIED`).

### `copy_file`

```rust
pub fn copy_file(&self, from: &Path, to: &Path) -> Result<u64, FsError>
```

`fs.copy_file`: READ on the source, CREATE on the destination. Never
overwrites. Returns the number of bytes copied.

### `list_dir`

```rust
pub fn list_dir(&self, path: &Path) -> Result<Vec<DirEntry>, FsError>
```

`fs.read_dir`: LIST. Denied entries, links and reparse points are
omitted, never flagged.

### `exists`

```rust
pub fn exists(&self, path: &Path) -> Result<bool, FsError>
```

`fs.exists`: METADATA. `false` only for genuine absence; a denied path
is an error, never `false`.

### `size`

```rust
pub fn size(&self, path: &Path) -> Result<u64, FsError>
```

`fs.size`: METADATA.

Source: https://github.com/0x48piraj/kurogane/blob/584c586118ee53cc04604007ee038557bd859092/kurogane/src/capability/authorized.rs#L248
