# IO type that wraps an AbstractVector{UInt8}?

**URL:** <https://discourse.julialang.org/t/io-type-that-wraps-an-abstractvector-uint8/114987>\
**Category:** Data\
**Tags:** question\
**Created:** [May 30, 2024, 8:47pm UTC](https://discourse.julialang.org/t/io-type-that-wraps-an-abstractvector-uint8/114987 "2024-05-30T20:47:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nhz2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nhz2/32/44428_2.png) [@nhz2](https://discourse.julialang.org/u/nhz2)\
**Post date:** [May 30, 2024, 8:47pm UTC](https://discourse.julialang.org/t/io-type-that-wraps-an-abstractvector-uint8/114987/1 "2024-05-30T20:47:55Z")

</div>

Besides `IOBuffer`, which doesn’t support all `AbstractVector{UInt8}`, is there an existing package with a type that wraps a vector of bytes as a read-only seekable `IO`?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [May 30, 2024, 9:52pm UTC](https://discourse.julialang.org/t/io-type-that-wraps-an-abstractvector-uint8/114987/2 "2024-05-30T21:52:52Z")

</div>

What type do you want to support?

You can construct an `IOBuffer` from an arbitrary `AbstractVector{UInt8}`, but [the default `read` method requires](https://github.com/JuliaLang/julia/blob/4ecdc373d62ac3a28e4ee93a584ead080e8b6113/base/iobuffer.jl#L184-L194) the array to support `pointer`.

In principle, if you had a particular array type you wanted to support, you could define your own `read` method. I agree that it would be nice to make this more generic in Base, but up to now there hasn’t been much demand.

---

<div class="post-metadata">

**Author:** ![nhz2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nhz2/32/44428_2.png) [@nhz2](https://discourse.julialang.org/u/nhz2)\
**Post date:** [May 30, 2024, 10:15pm UTC](https://discourse.julialang.org/t/io-type-that-wraps-an-abstractvector-uint8/114987/3 "2024-05-30T22:15:56Z")

</div>

I want to support all `AbstractVector{UInt8}` for use in ZipArchives.jl

In that case, I want to be able to open an IO view of an entry in a zip archive in a vector of bytes that the user provides.

---

<div class="post-metadata">

**Author:** ![nhz2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nhz2/32/44428_2.png) [@nhz2](https://discourse.julialang.org/u/nhz2)\
**Post date:** [May 30, 2024, 10:36pm UTC](https://discourse.julialang.org/t/io-type-that-wraps-an-abstractvector-uint8/114987/4 "2024-05-30T22:36:51Z")

</div>

I made an issue for that [`GenericIOBuffer` assumes data is stored contiguously in memory · Issue #54636 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/54636)

---

<div class="post-metadata">

**Author:** ![nhz2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nhz2/32/44428_2.png) [@nhz2](https://discourse.julialang.org/u/nhz2)\
**Post date:** [May 31, 2024, 11:18pm UTC](https://discourse.julialang.org/t/io-type-that-wraps-an-abstractvector-uint8/114987/5 "2024-05-31T23:18:59Z")

</div>

I made a package for this type.

> **[GitHub - nhz2/InputBuffers.jl: A Julia package to wrap an...](https://github.com/nhz2/InputBuffers.jl)**
>
> A Julia package to wrap an AbstractVector{UInt8} in a readable seekable IO type. - nhz2/InputBuffers.jl
