reagento / adaptix

An extremely flexible and configurable data model conversion library.
https://adaptix.readthedocs.io
Apache License 2.0
362 stars 24 forks source link

Add BytesIO loader #270

Closed lubaskinc0de closed 4 months ago

lubaskinc0de commented 4 months ago

we can add a io.BytesIO loader like any existing bytes-like loader


from adaptix import Retort, loader, P

@dataclass
class Book:
    image: BytesIO

data = {
    "image": b64encode(bytes(b"hello"))
}

retort = Retort(
    recipe=[
        loader(P[Book].image, lambda x: b64decode(x))
    ]
)

book = retort.load(data, Book)
print(book)
lubaskinc0de commented 4 months ago

i'm work on it

lubaskinc0de commented 4 months ago

we also can add provider for IO[bytes]