> For the complete documentation index, see [llms.txt](https://docs.medcrypt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.medcrypt.com/medcrypt-documentation/guardian/api-overview/api-reference/classes/classmedcrypt-guardian-channelguard.md).

# medcrypt::guardian::ChannelGuard

Name channel within a [Session](/medcrypt-documentation/guardian/api-overview/api-reference/classes/classmedcrypt-guardian-channelguard.md).

`#include <ChannelGuard.h>`

## Public Functions

|                                                                                                                               | Name                                                                                                                                                                                                                                  |
| ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                                                                                                                               | <p><a href="#function-~channelguard"><strong>\~ChannelGuard</strong></a>()<br>The destructor.</p>                                                                                                                                     |
| bool                                                                                                                          | <p><a href="#function-isready"><strong>IsReady</strong></a>()<br>The <a href="/medcrypt-documentation/guardian/api-overview/api-reference/classes/classmedcrypt-guardian-channelguard.md">ChannelGuard</a> is ready to send data.</p> |
| [Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="#function-dataforchannel"><strong>DataForChannel</strong></a>(const char \* in\_data, const size\_t & in\_data\_size)<br>Accepts data to encode and send over parent session (blocking)</p>                               |
| [Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="#function-asyncdataforchannel"><strong>AsyncDataForChannel</strong></a>(const char \* in\_data, const size\_t & in\_data\_size)<br>Accepts data to encode and send over parent session (non-blocking)</p>                 |
| [Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status) | <p><a href="#function-datafromchannel"><strong>DataFromChannel</strong></a>(char <em>out\_data, size\_t</em> io\_data\_size)<br>Returns decoded data received by parent session (blocking)</p>                                        |
| [Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status) | [**AsyncDataFromChannel**](#function-asyncdatafromchannel)(char *out\_data, size\_t* io\_data\_size)                                                                                                                                  |
| bool                                                                                                                          | <p><a href="#function-isdatagone"><strong>IsDataGone</strong></a>()<br>Indicates if all data provided to \[Async]DataForChannel has has been sent.</p>                                                                                |
| bool                                                                                                                          | <p><a href="#function-isdatawaiting"><strong>IsDataWaiting</strong></a>()<br>Indicates if there is data waiting to be received with \[Async]DataFromChannel.</p>                                                                      |

## Public Functions Documentation

### function \~ChannelGuard

```cpp
~ChannelGuard()
```

The destructor.

**Parameters**:

* **none**

**Return**: none

The destructor will not affect the internal [Guardian](/medcrypt-documentation/guardian/api-overview/api-reference/classes/classmedcrypt-guardian-guardian.md) representation of the [ChannelGuard](/medcrypt-documentation/guardian/api-overview/api-reference/classes/classmedcrypt-guardian-channelguard.md).

### function IsReady

```cpp
bool IsReady()
```

The [ChannelGuard](/medcrypt-documentation/guardian/api-overview/api-reference/classes/classmedcrypt-guardian-channelguard.md) is ready to send data.

**Parameters**:

* **none**

**Returns**:

* **true** the channel is ready to send data
* **false** the channel is not ready to send data

**Return**: bool

[ChannelGuard](/medcrypt-documentation/guardian/api-overview/api-reference/classes/classmedcrypt-guardian-channelguard.md) will always return any available data with DataFromChannel no matter the internal state. It will block from sending new data unless it is ready.

### function DataForChannel

```cpp
Status DataForChannel(
    const char * in_data,
    const size_t & in_data_size
)
```

Accepts data to encode and send over parent session (blocking)

**Parameters**:

* **in\_data** binary data buffer to encode and send
* **in\_data\_size** size of binary data in in\_data

**Returns**:

* **OK** in\_data has been processed
* **FAIL** general failure, check log
* **BADPARAM** in\_data is nullptr
* **OUTOFMEMORY** provided buffer is too large

**Return**: [medcrypt::guardian::Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status)

Blocking call to send data. When this call completes successfully the provided data has been secured based on the loaded profile and handed to the configured managed network library or unmanaged callback.

If this is a channel in an unmanaged session/service the session must have a registered DataForSocket callback.

### function AsyncDataForChannel

```cpp
Status AsyncDataForChannel(
    const char * in_data,
    const size_t & in_data_size
)
```

Accepts data to encode and send over parent session (non-blocking)

**Parameters**:

* **in\_data** binary data buffer to encode and send
* **in\_data\_size** size of binary data in in\_data

**Returns**:

* **OK** in\_data has been processed
* **FAIL** general failure, check log
* **BADPARAM** in\_data is nullptr
* **OUTOFMEMORY** provided buffer is too large

**Return**: [medcrypt::guardian::Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status)

Non-blocking call to send data. When this call completes successfully the provided data has been secured based on the loaded profile and queued in the parent session to be sent.

### function DataFromChannel

```cpp
Status DataFromChannel(
    char * out_data,
    size_t * io_data_size
)
```

Returns decoded data received by parent session (blocking)

**Parameters**:

* **out\_data** binary data buffer to store output data
* **io\_data\_size** provide size of provided out\_data buffer, on a successful return is set to size of the data in out\_data

**Returns**:

* **OK** out\_data is populated with application data
* **FAIL** general failure
* **BADPARAM** out\_data is nullptr or io\_data\_size is nullptr or 0
* **VERIFYFAIL** out\_data may be populated with data but any contained data failed signature verification
* **OUTOFMEMORY** provided buffer is too small

**Return**: [medcrypt::guardian::Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status)

Blocking call to receive data. When this call completes successfully out\_data is populated with valid data.

If this is a channel in an unmanaged session/service the session must have a registered DataFromSocket callback.

### function AsyncDataFromChannel

```cpp
Status AsyncDataFromChannel(
    char * out_data,
    size_t * io_data_size
)
```

**Parameters**:

* **out\_data** binary data buffer to store output data
* **io\_data\_size** provide size of provided out\_data buffer, on a successful return is set to size of the data in out\_data

**Returns**:

* **OK** out\_data is populated with application data
* **FAIL** general failure
* **BADPARAM** out\_data is nullptr or io\_data\_size is nullptr or 0
* **VERIFYFAIL** out\_data may be populated with data but any contained data failed signature verification
* **OUTOFMEMORY** provided buffer is too small
* **AGAIN** no data is currently available, try again

**Return**: [medcrypt::guardian::Status](/medcrypt-documentation/guardian/api-overview/api-reference/namespaces/namespacemedcrypt-guardian.md#typedef-status)

Returns decoded data received by parent session (non-blocking)

Non-blocking call to receive data. When this call completes successfully out\_data is populated with valid data.

### function IsDataGone

```cpp
bool IsDataGone()
```

Indicates if all data provided to \[Async]DataForChannel has has been sent.

**Parameters**:

* **none**

**Returns**:

* **false** data is waiting to be sent
* **true** no data is waiting to be sent

**Return**: bool

If false there is data that has not been handed to the network layer or user managed transport.

### function IsDataWaiting

```cpp
bool IsDataWaiting()
```

Indicates if there is data waiting to be received with \[Async]DataFromChannel.

**Parameters**:

* **none**

**Returns**:

* **false** no data is waiting to be received
* **true** data is waiting to be received

**Return**: bool

If true \[Async]DataFromChannel will return successfully and DataFromChannel will not block.

## Debugging and logging

Guardian does not create log files. Instead, logging is controlled by the application:

* Guardian logs to `stdout` and `stderr`, which appear in the terminal/CLI of the running application during execution. Look for specific error codes or connection failures in the output.
* **Custom logging:** Use `SetLoggingCallback` to redirect log messages to a callback function, stopping terminal output and allowing custom log handling
* **Log control:** Applications can control log level and verbosity.
* **Guardian Cloud UI**: Check the Guardian Cloud interface for additional error details and provisioning status.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.medcrypt.com/medcrypt-documentation/guardian/api-overview/api-reference/classes/classmedcrypt-guardian-channelguard.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
