#### [Abblix\.Oidc\.Server](https://www.abblix.com/en/docs/api/abblix-oidc-server 'index')
### [Abblix\.Oidc\.Server\.Features\.Storages](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages 'Abblix\.Oidc\.Server\.Features\.Storages')

## ProtobufSerializer Class

Provides functionality to serialize and deserialize objects to and from Protocol Buffer binary representations\.
Implements the [IBinarySerializer](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.Interfaces.IBinarySerializer 'Abblix\.Oidc\.Server\.Common\.Interfaces\.IBinarySerializer') interface using Google\.Protobuf for efficient serialization\.

```csharp
public class ProtobufSerializer : Abblix.Oidc.Server.Common.Interfaces.IBinarySerializer
```

Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → ProtobufSerializer

Implements [IBinarySerializer](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.Interfaces.IBinarySerializer 'Abblix\.Oidc\.Server\.Common\.Interfaces\.IBinarySerializer')

### Remarks
This serializer supports only specific OIDC storage types that have protobuf definitions and mappers\.
Attempting to serialize unsupported types will throw InvalidOperationException\.
### Methods

## ProtobufSerializer\.Deserialize\<T\>\(byte\[\]\) Method {#Abblix.Oidc.Server.Features.Storages.ProtobufSerializer.Deserialize_T_(byte[])}

Deserializes a binary representation to an object using Protocol Buffers\.

```csharp
public T? Deserialize<T>(byte[] bytes);
```
#### Type parameters

###### `T` {#Abblix.Oidc.Server.Features.Storages.ProtobufSerializer.Deserialize_T_(byte[]).T}

The type of the object to deserialize into\.
#### Parameters

###### `bytes` [System\.Byte](https://learn.microsoft.com/en-us/dotnet/api/system.byte 'System\.Byte')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.Oidc.Server.Features.Storages.ProtobufSerializer.Deserialize_T_(byte[]).bytes}

The binary representation to deserialize from\.

Implements [Deserialize&lt;T&gt;\(byte\[\]\)](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.Interfaces.IBinarySerializer#Abblix.Oidc.Server.Common.Interfaces.IBinarySerializer.Deserialize_T_(byte[]) 'Abblix\.Oidc\.Server\.Common\.Interfaces\.IBinarySerializer\.Deserialize\<T\>\(byte\[\]\)')

#### Returns
[T](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.ProtobufSerializer#Abblix.Oidc.Server.Features.Storages.ProtobufSerializer.Deserialize_T_(byte[]).T 'Abblix\.Oidc\.Server\.Features\.Storages\.ProtobufSerializer\.Deserialize\<T\>\(byte\[\]\)\.T')  
The deserialized object of type [T](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.ProtobufSerializer#Abblix.Oidc.Server.Features.Storages.ProtobufSerializer.Deserialize_T_(byte[]).T 'Abblix\.Oidc\.Server\.Features\.Storages\.ProtobufSerializer\.Deserialize\<T\>\(byte\[\]\)\.T')\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown when the type is not supported for protobuf deserialization\.

## ProtobufSerializer\.Serialize\<T\>\(T\) Method {#Abblix.Oidc.Server.Features.Storages.ProtobufSerializer.Serialize_T_(T)}

Serializes an object to a binary representation using Protocol Buffers\.

```csharp
public byte[] Serialize<T>(T obj);
```
#### Type parameters

###### `T` {#Abblix.Oidc.Server.Features.Storages.ProtobufSerializer.Serialize_T_(T).T}

The type of the object to serialize\.
#### Parameters

###### `obj` [T](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Storages.ProtobufSerializer#Abblix.Oidc.Server.Features.Storages.ProtobufSerializer.Serialize_T_(T).T 'Abblix\.Oidc\.Server\.Features\.Storages\.ProtobufSerializer\.Serialize\<T\>\(T\)\.T') {#Abblix.Oidc.Server.Features.Storages.ProtobufSerializer.Serialize_T_(T).obj}

The object to serialize\.

Implements [Serialize&lt;T&gt;\(T\)](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.Interfaces.IBinarySerializer#Abblix.Oidc.Server.Common.Interfaces.IBinarySerializer.Serialize_T_(T) 'Abblix\.Oidc\.Server\.Common\.Interfaces\.IBinarySerializer\.Serialize\<T\>\(T\)')

#### Returns
[System\.Byte](https://learn.microsoft.com/en-us/dotnet/api/system.byte 'System\.Byte')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array')  
A byte array representing the serialized object\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown when the type is not supported for protobuf serialization\.
