Property definitions

core $ Writable :: defaultinit
# Things that can be efficienlty written to a `Writer`
#
# The point of this interface is to allow the instance to be efficiently
# written into a `Writer`.
#
# Ready-to-save documents usually provide this interface.
interface Writable
	# Write itself to a `stream`
	# The specific logic it let to the concrete subclasses
	fun write_to(stream: Writer) is abstract

	# Like `write_to` but return a new String (may be quite large).
	#
	# This functionality is anecdotal, since the point
	# of a streamable object is to be efficiently written to a
	# stream without having to allocate and concatenate strings.
	fun write_to_string: String
	do
		var stream = new StringWriter
		write_to(stream)
		return stream.to_s
	end

	# Like `write_to` but return a new Bytes (may be quite large)
	#
	# This functionality is anecdotal, since the point
	# of a streamable object is to be efficiently written to a
	# stream without having to allocate and concatenate buffers.
	#
	# Nevertheless, you might need this method if you want to know
	# the byte size of a writable object.
	fun write_to_bytes: Bytes
	do
		var stream = new BytesWriter
		write_to(stream)
		return stream.bytes
	end
end
lib/core/stream.nit:547,1--584,3