MCPcopy Create free account
hub / github.com/argumentcomputer/ix / put_name_component

Function put_name_component

crates/ixon/src/serialize.rs:960–979  ·  view source on GitHub ↗

Serialize a Name component (references parent by address). Format: tag (1 byte) + parent_addr (32 bytes) + data

(name: &Name, buf: &mut Vec<u8>)

Source from the content-addressed store, hash-verified

958impl ConstantInfo {
959 /// Serialize a non-Muts ConstantInfo (Muts is handled separately in Constant::put)
960 pub fn put(&self, buf: &mut Vec<u8>) {
961 match self {
962 Self::Defn(d) => d.put(buf),
963 Self::Recr(r) => r.put(buf),
964 Self::Axio(a) => a.put(buf),
965 Self::Quot(q) => q.put(buf),
966 Self::CPrj(c) => c.put(buf),
967 Self::RPrj(r) => r.put(buf),
968 Self::IPrj(i) => i.put(buf),
969 Self::DPrj(d) => d.put(buf),
970 Self::Muts(_) => unreachable!("Muts handled in Constant::put"),
971 }
972 }
973
974 /// Deserialize a non-Muts ConstantInfo (Muts is handled separately with FLAG_MUTS)
975 pub fn get(variant: u64, buf: &mut &[u8]) -> Result<Self, String> {
976 match variant {
977 Self::CONST_DEFN => Ok(Self::Defn(Definition::get(buf)?)),
978 Self::CONST_RECR => Ok(Self::Recr(Recursor::get(buf)?)),
979 Self::CONST_AXIO => Ok(Self::Axio(Axiom::get(buf)?)),
980 Self::CONST_QUOT => Ok(Self::Quot(Quotient::get(buf)?)),
981 Self::CONST_CPRJ => Ok(Self::CPrj(ConstructorProj::get(buf)?)),
982 Self::CONST_RPRJ => Ok(Self::RPrj(RecursorProj::get(buf)?)),

Callers 2

putMethod · 0.85

Calls 7

put_bytesFunction · 0.85
as_dataMethod · 0.80
as_bytesMethod · 0.80
get_hashMethod · 0.80
put_u8Function · 0.70
put_u64Function · 0.70
lenMethod · 0.45

Tested by

no test coverage detected