MCPcopy Create free account
hub / github.com/apache/fory / _encode

Method _encode

rust/fory-core/src/meta/meta_string.rs:162–192  ·  view source on GitHub ↗
(&self, input: &str)

Source from the content-addressed store, hash-verified

160 }
161
162 fn _encode(&self, input: &str) -> Result<Option<MetaString>, Error> {
163 if input.is_empty() {
164 return Ok(Some(MetaString::new(
165 input.to_string(),
166 Encoding::Utf8,
167 vec![],
168 self.special_char1,
169 self.special_char2,
170 )?));
171 }
172
173 ensure!(
174 input.len() < SHORT_MAX_VALUE,
175 Error::encode_error(format!(
176 "Meta string is too long, max:{SHORT_MAX_VALUE}, current:{}",
177 input.len()
178 ))
179 );
180
181 if !self.is_latin(input) {
182 return Ok(Some(MetaString::new(
183 input.to_string(),
184 Encoding::Utf8,
185 input.as_bytes().to_vec(),
186 self.special_char1,
187 self.special_char2,
188 )?));
189 }
190
191 Ok(None)
192 }
193
194 pub fn encode(&self, input: &str) -> Result<MetaString, Error> {
195 if let Some(ms) = self._encode(input)? {

Callers 2

encodeMethod · 0.80
encode_with_encodingsMethod · 0.80

Calls 4

SomeFunction · 0.85
is_emptyMethod · 0.80
is_latinMethod · 0.80
to_stringMethod · 0.45

Tested by

no test coverage detected