Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions stdlib/Serialization/src/Serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,12 @@ Open a file and serialize the given value to it.
"""
serialize(filename::AbstractString, x) = open(io->serialize(io, x), filename, "w")

function serialize(x)::Vector{UInt8}
buf = IOBuffer()
serialize(buf, x)
return take!(buf)
end

## deserializing values ##

"""
Expand All @@ -847,6 +853,8 @@ Open a file and deserialize its contents.
"""
deserialize(filename::AbstractString) = open(deserialize, filename)

deserialize(data::Vector{UInt8}) = deserialize(IOBuffer(data))

function deserialize(s::AbstractSerializer)
handle_deserialize(s, Int32(read(s.io, UInt8)::UInt8))
end
Expand Down