pub trait Length {
// Required method
fn length(&self) -> usize;
}
Expand description
Trait for determining the length of SMPP
values.
§Implementation
use rusmpp::encode::{Encode, Length};
struct Foo {
a: u8,
b: u16,
c: u32,
}
impl Length for Foo {
fn length(&self) -> usize {
self.a.length() + self.b.length() + self.c.length()
}
}
let foo = Foo {
a: 0x01,
b: 0x0203,
c: 0x04050607,
};
assert_eq!(foo.length(), 7);