@jameson recently mentioned an IO
interface in a review. The lack of documentation on this matter was mentioned several years ago.
My best guess at that moment is that the core interface is inferrable from this part of boot.jl focusing on output:
High Level Required
write(io::IO, x::UInt8)::Int
- Default implementation viaBase.io_pointer(io::IO)
write(io::IO, x::String)::Int
- Default implementation viaBase.unsafe_write(io::IO,
Ptr{UInt8}, nb::Int)
.show(io::IO, @nospecialize x)::Nothing
print(io::IO, x::AbstractChar)::Nothing
Low-level interface
Core.io_pointer(io::IO)::Ptr{Cvoid}
unsafe_write(io::IO, x::Ptr{UInt8}, nb::UInt)::Int
- Default implementation viaBase.io_pointer(io::IO)
unsafe_write(io::IO, x::Ptr{UInt8}, nb::Int):;Int
- Default implementation viaBase.io_pointer(io::IO)
Optional
print(io::IO, x::String)
- Default implementation viawrite(io::IO, x::String)
print(io::IO, x)
- Default implementation viashow(io::IO, x)
print(io::IO, x, a...)
- Default implementation viaprint(io::IO, x)
println(io::IO)
- Default implementation viawrite(io::IO, x::UInt8)
println(io::IO, x...)
- Default implementation viaprint(io::IO, x, a...)
andprintln(io::IO)
Other functions
lock(io::IO)
unmark(io::IO)
unlock(io::IO)
reseteof(io::IO)
buffer_writes(x::IO, bufsize=Base.SZ_UNBUFFERED_IO)
isopen(io::IO)
close(io::IO)
closewrite(io::IO)
flush(io::IO)
bytesavailable(io::IO)
readavailable(io::IO)
eof(io::IO)
copy(io::IO)
wait_readnb
wait_close
read(io::IO, String)
unsafe_read(s::IO, p::Ptr{UInt8}, n::UInt64)
unsafe_read(s::IO, p::Ptr, n::Integer)
unsafe_read(s::IO, p::Ref{T}, n::Integer)
I’m getting lost in this.
My sense is that we are missing several abstract subtypes of IO or IO traits.