/// <summary> /// Reads the binary representation of the CID from the specified <see cref="CodedInputStream"/>. /// </summary> /// <param name="stream"> /// The <see cref="CodedInputStream"/> to read from. /// </param> /// <returns> /// A new <see cref="Cid"/>. /// </returns> public static Cid Read(CodedInputStream stream) { var cid = new Cid(); var length = stream.ReadLength(); if (length == 34) { cid.Version = 0; } else { cid.Version = stream.ReadInt32(); cid.ContentType = stream.ReadMultiCodec().Name; } cid.Hash = new MultiHash(stream); return cid; }