---
title: acl
summary: Compute ACLs.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/acl/
---

**Kind:** Module  
**Package:** fastly 0.13.1  
**Path:** `fastly::acl`

Compute ACLs.

## Management

Management of ACLs is done via api.fastly.com.
See [ACLs in Compute](https://www.fastly.com/documentation/reference/api/acls/acls/).

One or more ACLs can be
[linked](https://www.fastly.com/documentation/reference/api/services/resource/#create-resource) to a
Compute service. Once linked, an ACL can be accessed from within a Compute application via its
linked name.

## Usage

The following example opens an ACL by its linked name and then performs a lookup
within the ACL of the client's IP. Different responses are returned depending on
the result of the lookup (allow or block):

```rust
use fastly::{Error, Request, Response};

#[fastly::main]
fn main(req: Request) -> Result<Response, Error> {
    let acl = fastly::Acl::open("my_acl").expect("can open acl");

    let ip = req.get_client_ip_addr().expect("request has an ip");

    let lookup = acl.try_lookup(ip)?;
    match lookup {
        Some(lookup_match) if lookup_match.is_allow() => {
            // IP is allowed.
            Ok(Response::from_body("allowed!"))
        }
        Some(_) => {
            // IP is not allowed.
            Ok(Response::from_status(403).with_body("blocked!"))
        }
        None => {
            // No prefixes matched the IP.
            Ok(Response::from_body("no match"))
        }
    }
}
```

## Structs

| Name | Summary |
| --- | --- |
| [Acl](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/acl/struct.Acl/) | A Compute ACL. |
| [LookupMatch](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/acl/struct.LookupMatch/) | LookupMatch is the result of an ACL lookup which found a matching prefix. |

## Enums

| Name | Summary |
| --- | --- |
| [LookupError](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/acl/enum.LookupError/) | Errors thrown on lookup failure. |
| [MatchAction](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/acl/enum.MatchAction/) | MatchAction represents an action associated with an ACL prefix. |
| [OpenError](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/acl/enum.OpenError/) | Errors thrown when calling open. |
