/// <nodoc />
        public static ReadJournalRequest Read(ChangeJournalServiceProtocolReader reader)
        {
            Contract.Requires(reader != null);

            return(new ReadJournalRequest(
                       reader.ReadVolumeGuidPath(),
                       journalId: reader.ReadUInt64(),
                       startUsn: new Usn(reader.ReadUInt64()),
                       endUsn: reader.ReadBoolean() ? new Usn(reader.ReadUInt64()) : (Usn?)null,
                       extraReadCount: reader.ReadBoolean() ? reader.ReadInt32() : (int?)null,
                       timeLimit: reader.ReadBoolean() ? TimeSpan.FromTicks(reader.ReadInt64()) : (TimeSpan?)null));
        }
        public static QueryUsnJournalResult ReadQueryUsnJournalResult(this ChangeJournalServiceProtocolReader reader)
        {
            Contract.Requires(reader != null);

            var queryStatusValue = reader.ReadInt32();
            QueryUsnJournalStatus queryStatus;

            if (!EnumTraits <QueryUsnJournalStatus> .TryConvert(queryStatusValue, out queryStatus))
            {
                throw new BuildXLException("Invalid QueryUsnJournalStatus");
            }

            if (queryStatus == QueryUsnJournalStatus.Success)
            {
                QueryUsnJournalData data = reader.ReadUsnJournalData();
                return(new QueryUsnJournalResult(queryStatus, data));
            }

            return(new QueryUsnJournalResult(queryStatus, data: null));
        }