# Comparator

A library to compare structs. BCS uses little-endian encoding for all integer types, so results might be unexpected.

### <mark style="color:blue;">**Result**</mark>

```rust
  struct Result has drop {
    inner: u8,
  }
```

* **inner** - It will hold one of the following values: {SMALLER}, {EQUAL} or {GREATER}.

## Interface

### <mark style="color:blue;">eq</mark>

**It checks if the `result` of {compare} is `EQUAL`.**

```rust
public fun eq(result: &Result): bool
```

* **@param result:** This struct contains one of the following values: {SMALLER}, {EQUAL} or {GREATER}.
* **@return bool.** True if it is `EQUAL`

### <mark style="color:blue;">lt</mark>

**It checks if the `result` of {compare} is `SMALLER`.**

```rust
public fun lt(result: &Result): bool
```

* **@param result:** This struct contains one of the following values: {SMALLER}, {EQUAL} or {GREATER}.
* **@return bool.** True if it is `SMALLER`

### <mark style="color:blue;">gt</mark>

**It checks if the `result` of {compare} is `GREATER`.**

```rust
public fun gt(result: &Result): bool
```

* **@param result:** This struct contains one of the following values: {SMALLER}, {EQUAL} or {GREATER}.
* **@return bool.** True if it is `GREATER`

### <mark style="color:blue;">lte</mark>

**It checks if the `result` of {compare} is `SMALLER` or `EQUAL`.**

```rust
public fun lte(result: &Result): bool
```

* **@param result:** This struct contains one of the following values: {SMALLER}, {EQUAL} or {GREATER}.
* **@return bool.** True if it is `SMALLER` or `EQUAL`.

### <mark style="color:blue;">gte</mark>

**It checks if the `result` of {compare} is `SMALLER` or `EQUAL`.**

```rust
public fun gte(result: &Result): bool
```

* **@param result:** This struct contains one of the following values: {SMALLER}, {EQUAL} or {GREATER}.
* **@return bool.** True if it is `SMALLER` or `EQUAL`.

### <mark style="color:blue;">compare</mark>

**Compares two structs of type `T`. Performs a comparison of two types after BCS serialization.**

```rust
public fun compare<T>(left: &T, right: &T): Result
```

* **@param left:** A struct of type `T`.
* **@param right:** A struct of type `T`.
* **@return Result.** A struct that contains the following values: {SMALLER}, {EQUAL} or {GREATER}.

### <mark style="color:blue;">compare\_u8\_vector</mark>

**Compares two bytes.**

```rust
public fun compare_u8_vector(left: vector<u8>, right: vector<u8>): Result
```

* **@param left:** A set of bytes.
* **@param right:** A set of bytes.
* **@return Result.** A struct that contains the following values: {SMALLER}, {EQUAL} or {GREATER}.
