MCPcopy Create free account
hub / github.com/hashintel/hash / validate_encode

Function validate_encode

libs/@local/harpc/wire-protocol/src/bin/codec.rs:78–96  ·  view source on GitHub ↗
(args: &mut Vec<String>)

Source from the content-addressed store, hash-verified

76};
77
78fn validate_encode<T>(args: &mut Vec<String>)
79where
80 T: Decode<Context = ()> + serde::Serialize + fmt::Debug,
81{
82 let value = args
83 .pop()
84 .expect("third argument should be a base64 encoded string");
85
86 let bytes = BASE64_STANDARD
87 .decode(&value)
88 .expect("input should be valid base64");
89 let mut bytes = Bytes::from(bytes);
90 let mut buffer = Buffer::new(&mut bytes);
91
92 let header = T::decode(&mut buffer, ()).expect("input should represent a valid value");
93
94 serde_json::to_writer(std::io::stdout(), &header)
95 .expect("should be able to write json to stdout");
96}
97
98fn validate_decode<T>(args: &mut Vec<String>)
99where

Callers

nothing calls this directly

Calls 5

popMethod · 0.65
fromFunction · 0.50
decodeFunction · 0.50
expectMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected