aboutsummaryrefslogtreecommitdiff
path: root/src/display/display_sink/imp_generic.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/display/display_sink/imp_generic.rs')
-rw-r--r--src/display/display_sink/imp_generic.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/display/display_sink/imp_generic.rs b/src/display/display_sink/imp_generic.rs
new file mode 100644
index 0000000..8819243
--- /dev/null
+++ b/src/display/display_sink/imp_generic.rs
@@ -0,0 +1,26 @@
+/// append `data` to `buf`, assuming `data` is less than 8 bytes and that `buf` has enough space
+/// remaining to hold all bytes in `data`.
+///
+/// Safety: callers must ensure that `buf.capacity() - buf.len() >= data.len()`.
+#[inline(always)]
+pub unsafe fn append_string_lt_8_unchecked(buf: &mut alloc::string::String, data: &str) {
+ buf.push_str(data);
+}
+
+/// append `data` to `buf`, assuming `data` is less than 16 bytes and that `buf` has enough space
+/// remaining to hold all bytes in `data`.
+///
+/// Safety: callers must ensure that `buf.capacity() - buf.len() >= data.len()`.
+#[inline(always)]
+pub unsafe fn append_string_lt_16_unchecked(buf: &mut alloc::string::String, data: &str) {
+ buf.push_str(data);
+}
+
+/// append `data` to `buf`, assuming `data` is less than 32 bytes and that `buf` has enough space
+/// remaining to hold all bytes in `data`.
+///
+/// Safety: callers must ensure that `buf.capacity() - buf.len() >= data.len()`.
+#[inline(always)]
+pub unsafe fn append_string_lt_32_unchecked(buf: &mut alloc::string::String, data: &str) {
+ buf.push_str(data);
+}