本文整理汇总了Python中pyndn.Name.wireEncode方法的典型用法代码示例。如果您正苦于以下问题:Python Name.wireEncode方法的具体用法?Python Name.wireEncode怎么用?Python Name.wireEncode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.Name
的用法示例。
在下文中一共展示了Name.wireEncode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_encode_decode
# 需要导入模块: from pyndn import Name [as 别名]
# 或者: from pyndn.Name import wireEncode [as 别名]
def test_encode_decode(self):
name = Name("/local/ndn/prefix")
encoding = name.wireEncode(TlvWireFormat.get())
self.assertTrue(encoding.equals(Blob(TEST_NAME)))
decodedName = Name()
decodedName.wireDecode(Blob(TEST_NAME), TlvWireFormat.get())
self.assertEqual(decodedName, name)
# Test ImplicitSha256Digest.
name2 = Name(
"/local/ndn/prefix/sha256digest=" +
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
encoding2 = name2.wireEncode(TlvWireFormat.get())
self.assertTrue(encoding2.equals(Blob(TEST_NAME_IMPLICIT_DIGEST)))
decodedName2 = Name()
decodedName2.wireDecode(Blob(TEST_NAME_IMPLICIT_DIGEST), TlvWireFormat.get())
self.assertEqual(decodedName2, name2)
# Test ParametersSha256Digest.
name3 = Name(
"/local/ndn/prefix/params-sha256=" +
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
encoding3 = name3.wireEncode(TlvWireFormat.get())
self.assertTrue(encoding3.equals(Blob(TEST_NAME_PARAMETERS_DIGEST)))
decodedName3 = Name()
decodedName3.wireDecode(Blob(TEST_NAME_PARAMETERS_DIGEST), TlvWireFormat.get())
self.assertEqual(decodedName3, name3)
示例2: test_typed_name_component
# 需要导入模块: from pyndn import Name [as 别名]
# 或者: from pyndn.Name import wireEncode [as 别名]
def test_typed_name_component(self):
otherTypeCode = 99
uri = "/ndn/" + str(otherTypeCode) + "=value"
name = Name()
name.append("ndn").append("value", ComponentType.OTHER_CODE, otherTypeCode)
self.assertEqual(uri, name.toUri())
nameFromUri = Name(uri)
self.assertEqual("value", str(nameFromUri.get(1).getValue()))
self.assertEqual(otherTypeCode, nameFromUri.get(1).getOtherTypeCode())
decodedName = Name()
decodedName.wireDecode(name.wireEncode())
self.assertEqual("value", str(decodedName.get(1).getValue()))
self.assertEqual(otherTypeCode, decodedName.get(1).getOtherTypeCode())