---
title: RateCounter
summary: A rate counter that can be used with a edge rate limiter or stand alone for counting and rate calculations
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/erl/struct.RateCounter/
---

**Kind:** Struct  
**Module:** [erl](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/erl/)  
**Package:** fastly 0.13.1  
**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/erl.rs#18

```rust
pub struct RateCounter { /* private fields */ }
```

A rate counter that can be used with a edge rate limiter or stand alone for counting and rate calculations

## Methods

### increment

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/erl.rs#94

```rust
fn increment(&self, entry: &str, delta: u32) -> Result<(), ERLError>
```

Increment an entry in the ratecounter by delta.

**Parameters**

- `self`: `&Self`
- `entry`: `&str`
- `delta`: `u32`

**Returns**

`Result<(), ERLError>`

### lookup_count

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/erl.rs#106

```rust
fn lookup_count(&self, entry: &str, duration: CounterDuration) -> Result<u32, ERLError>
```

Lookup the current count for entry in the ratecounter for duration.

**Parameters**

- `self`: `&Self`
- `entry`: `&str`
- `duration`: `CounterDuration`

**Returns**

`Result<u32, ERLError>`

### lookup_rate

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/erl.rs#100

```rust
fn lookup_rate(&self, entry: &str, window: RateWindow) -> Result<u32, ERLError>
```

Lookup the current rate for entry in the ratecounter for a window.

**Parameters**

- `self`: `&Self`
- `entry`: `&str`
- `window`: `RateWindow`

**Returns**

`Result<u32, ERLError>`

### open

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/erl.rs#86

```rust
fn open(ratecounter_name: &str) -> Self
```

Open a RateCounter with the given name for a ratecounter.

**Parameters**

- `ratecounter_name`: `&str`

**Returns**

`Self`

## Auto trait implementations

- `Freeze`
- `RefUnwindSafe`
- `Send`
- `Sync`
- `Unpin`
- `UnsafeUnpin`
- `UnwindSafe`

## Blanket implementations

- `Any`
- `Borrow<T>`
- `BorrowMut<T>`
- `Downcast`
- `DowncastSync`
- `ErasedDestructor`
- `From<T>`
- `Into<U>`
- `IntoEither`
- `Same`
- `TryFrom<U>`
- `TryInto<U>`
