public static <T> int writeTo(OutputStream out, T message, Schema<T> schema,
            LinkedBuffer buffer) throws IOException
    {
        if (buffer.start != buffer.offset)
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");

        final ProtobufOutput output = new ProtobufOutput(buffer);
        schema.writeTo(output, message);
        return LinkedBuffer.writeTo(out, buffer);
    }
Serializes the {@code message} into an {@link OutputStream} using the given schema.

@return the size of the message
protostuff-core/src/main/java/io/protostuff/ProtobufIOUtil.java