TypedMarshaler
This class handles typed marshaling and unmarshaling operations. It encapsulates a Marshaler and stores information about whether the type is a pointer and its element type for efficient processing.
Methods
Set()
@classmethod
def Set(
ctx: context.Context,
key: any,
object: T,
options: store.Option
) - > error
Stores an object in the underlying store using the provided key and options. This method allows callers to persist typed data.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used for cancellation and deadlines. |
| key | any | The key used to identify the object in the store. This can be any type that the underlying store can handle as a key. |
| object | T | The object to be stored. Its type is determined by the TypedMarshaler's generic type parameter. |
| options | store.Option | Options to configure the storage operation, such as expiration or other store-specific settings. |
Returns
| Type | Description |
|---|---|
error | An error if the operation fails, otherwise nil. |
Get()
@classmethod
def Get(
ctx: context.Context,
key: any
) - > (T, error)
Retrieves an object from the underlying store using the provided key. This method allows callers to retrieve typed data previously stored.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used for cancellation and deadlines. |
| key | any | The key used to identify the object in the store. This can be any type that the underlying store can handle as a key. |
Returns
| Type | Description |
|---|---|
(T, error) | The retrieved object of type T and an error if the operation fails or the object is not found. |