# Overload write?

**URL:** <https://discourse.julialang.org/t/overload-write/27528>\
**Category:** General Usage\
**Tags:** question, io\
**Created:** [August 14, 2019, 1:00pm UTC](https://discourse.julialang.org/t/overload-write/27528 "2019-08-14T13:00:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephancb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stephancb/32/14243_2.png) [@stephancb](https://discourse.julialang.org/u/stephancb)\
**Post date:** [August 14, 2019, 1:00pm UTC](https://discourse.julialang.org/t/overload-write/27528/1 "2019-08-14T13:00:06Z")

</div>

```julia
write(io::IO, x)                                                                                                                                                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                     
  Write the canonical binary representation of a value to the given I/O stream or file.

```

I would like to use this for my own I/O, something like

```julia
struct MyIO <: IO
    handle::Ptr{Cvoid}
    ...    
end

myio = MyIO(...)
write(myio, whatevervalue)

```

Which methods does `write` call, that I would have to provide for `MyIO`?

---

<div class="post-metadata">

**Author:** ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)\
**Post date:** [August 14, 2019, 2:44pm UTC](https://discourse.julialang.org/t/overload-write/27528/2 "2019-08-14T14:44:39Z")

</div>

[https://docs.julialang.org/en/v1/base/io-network/#Base.unsafe\_read](https://docs.julialang.org/en/v1/base/io-network/#Base.unsafe_read)  
[https://docs.julialang.org/en/v1/base/io-network/#Base.unsafe\_write](https://docs.julialang.org/en/v1/base/io-network/#Base.unsafe_write)

According to the documentation:

> It is recommended that subtypes `T<:IO` override the following method signature to provide more efficient implementations: `unsafe_read(s::T, p::Ptr{UInt8}, n::UInt)`
