public static <T> int writeListTo(LinkedBuffer buffer, List<T> messages,
            Schema<T> schema)
    {
        if (buffer.start != buffer.offset)
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");

        final YamlOutput output = new YamlOutput(buffer, schema);

        try
        {
            output.tail = YamlOutput.writeTag(
                    schema.messageName(),
                    true,
                    output.sink,
                    output,
                    output.sink.writeByteArray(
                            START_DIRECTIVE,
                            output,
                            buffer));

            for (T m : messages)
            {
                schema.writeTo(output.writeSequenceDelim(), m);
                output.reset();
            }
        }
        catch (IOException e)
        {
            throw new RuntimeException("Serializing to a LinkedBuffer threw an IOException " +
                    "(should never happen).", e);
        }

        return output.getSize();
    }
Serializes the {@code messages} a {@link LinkedBuffer} using the given schema.

@return the total bytes written to the output.
protostuff-yaml/src/main/java/io/protostuff/YamlIOUtil.java