---
title: SecretHandle
summary: A low-level interface to a secret.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/handle/secret_store/struct.SecretHandle/
---

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

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

A low-level interface to a secret.

Methods here are typically exposed as the APIs on
[`crate::secret_store::Secret`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/secret_store/struct.Secret/) and should not be needed directly.

## Constants

### INVALID

**Type:** `Self`  
**Flags:** read-only  
**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/secret_store/handle.rs#177

An invalid secret handle.

## Methods

### is_invalid

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/secret_store/handle.rs#297

```rust
fn is_invalid(&self) -> bool
```

Return true if the [`crate::secret_store::Secret`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/secret_store/struct.Secret/) handle is invalid.

**Parameters**

- `self`: `&Self`

**Returns**

`bool`

### new

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/secret_store/handle.rs#262

```rust
fn new(secret: &[u8]) -> Result<SecretHandle, FastlyStatus>
```

Create a new "secret" from the given memory. This is not the suggested way to create
`Secret`s; instead, we suggest using `SecretStore::get`.

This method can be used for data that should be secret, but is being obtained by
some other means than the secret store. New "secrets" created this way use plaintext
only, and live in the session's memory unencrypted for much longer than secrets
generated by `SecretStore::get`. They should thus only be used in situations in
which an API requires a `Secret`, but you cannot (for whatever reason) use a
`SecretStore` to store them.

**Parameters**

- `secret`: `&[u8]`

**Returns**

`Result<SecretHandle, FastlyStatus>`

### plaintext

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/secret_store/handle.rs#182

```rust
fn plaintext(&self) -> Result<Bytes, DecryptError>
```

Return the plaintext value of this secret.

**Parameters**

- `self`: `&Self`

**Returns**

`Result<Bytes, DecryptError>`

## Trait implementations

### impl Debug for SecretHandle

#### fmt

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/secret_store/handle.rs#164

```rust
fn fmt(&self, f: &mut Formatter<'_>) -> Result
```

**Parameters**

- `self`: `&Self`
- `f`: `&mut $crate::fmt::Formatter`

**Returns**

`$crate::fmt::Result`

### impl Hash for SecretHandle

#### hash

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/secret_store/handle.rs#165

```rust
fn hash<__H: Hasher>(&self, state: &mut __H)
```

**Parameters**

- `self`: `&Self`
- `state`: `&mut __H`

### impl PartialEq for SecretHandle

#### eq

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/secret_store/handle.rs#165

```rust
fn eq(&self, other: &Self) -> bool
```

**Parameters**

- `self`: `&Self`
- `other`: `&Self`

**Returns**

`bool`

## Auto trait implementations

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

## Blanket implementations

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