You could to something like
julia> struct Foo
fill::Cchar
sex::Cchar
days::Int16
breed::Tuple{Cchar, Cchar}
end
julia> Base.show(io::IO, f::Foo) = print(io, Char(f.sex), ' ', f.days, ' ', Char(f.breed[1]), Char(f.breed[2]))
julia> buf = zeros(UInt8, 6);
julia> open("test.bin", "r") do io
for i in 1:3
read!(io, @view(buf[2:6]))
println(i, ": ", reinterpret(Foo, buf)[1])
end
end
1: F 1111 JE
2: M 2222 AY
3: F 3333 HO
or even
julia> function readfile(file)
open(file, "r") do io
out = zeros(UInt8, 18)
for i in 0:2
read!(io, @view(out[6i .+ (2:6)]))
end
reinterpret(Foo, out)
end
end
readfile (generic function with 1 method)
julia> readfile("test.bin")
3-element reinterpret(Foo, ::Vector{UInt8}):
F 1111 JE
M 2222 AY
F 3333 HO