File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 1- name : Build
1+ name : Check proto
22
33on :
44 push :
3636 run : |
3737 if [ ! -d target ]; then mkdir target; fi
3838 protoc --rust_opt='experimental-codegen=enabled,kernel=cpp' --rust_out=./target psh.proto
39+
40+ - name : Test
41+ run : |
42+ cargo test --workspace
Original file line number Diff line number Diff line change 11tonic:: include_proto!( "psh.proto.instance" ) ;
2+
3+ impl From < std:: net:: Ipv6Addr > for Ipv6Addr {
4+ fn from ( value : std:: net:: Ipv6Addr ) -> Self {
5+ let ip = value. to_bits ( ) . to_be ( ) ;
6+ let high = ( ip >> 64 ) as u64 ;
7+ let low = ip as u64 ;
8+ Self {
9+ hi_64_bits : high,
10+ lo_64_bits : low,
11+ }
12+ }
13+ }
14+
15+ #[ test]
16+ fn test_ipv6_into_pb_repr ( ) {
17+ use std:: net:: Ipv6Addr as StdIpv6Addr ;
18+
19+ let var: u128 = 1 ;
20+
21+ let raw = StdIpv6Addr :: from_bits ( var) ;
22+
23+ let pb_repr: Ipv6Addr = raw. into ( ) ;
24+
25+ let hi = ( pb_repr. hi_64_bits as u128 ) << 64 ;
26+ let lo = pb_repr. lo_64_bits as u128 ;
27+ let ip = StdIpv6Addr :: from_bits ( u128:: from_be ( hi | lo) ) ;
28+
29+ assert_eq ! ( ip, StdIpv6Addr :: from_bits( 1 ) ) ;
30+ }
You can’t perform that action at this time.
0 commit comments