@@ -20,7 +20,10 @@ use geo_traits::{
2020///
2121/// The contained [dimension][geo_traits::Dimensions] will never be `Unknown`.
2222#[ derive( Debug , Clone ) ]
23- pub struct Wkb < ' a > ( WkbInner < ' a > ) ;
23+ pub struct Wkb < ' a > {
24+ buf : & ' a [ u8 ] ,
25+ inner : WkbInner < ' a > ,
26+ }
2427
2528impl < ' a > Wkb < ' a > {
2629 /// Parse a WKB byte slice into a geometry.
@@ -38,13 +41,13 @@ impl<'a> Wkb<'a> {
3841 /// newly-allocated `f64`.
3942 pub fn try_new ( buf : & ' a [ u8 ] ) -> WkbResult < Self > {
4043 let inner = WkbInner :: try_new ( buf) ?;
41- Ok ( Self ( inner) )
44+ Ok ( Self { buf , inner } )
4245 }
4346
4447 /// Return the [Dimension] of this geometry.
4548 pub fn dimension ( & self ) -> Dimension {
4649 use WkbInner :: * ;
47- match & self . 0 {
50+ match & self . inner {
4851 Point ( g) => g. dimension ( ) ,
4952 LineString ( g) => g. dimension ( ) ,
5053 Polygon ( g) => g. dimension ( ) ,
@@ -58,7 +61,7 @@ impl<'a> Wkb<'a> {
5861 /// Return the [GeometryType] of this geometry.
5962 pub fn geometry_type ( & self ) -> GeometryType {
6063 use WkbInner :: * ;
61- match & self . 0 {
64+ match & self . inner {
6265 Point ( _) => GeometryType :: Point ,
6366 LineString ( _) => GeometryType :: LineString ,
6467 Polygon ( _) => GeometryType :: Polygon ,
@@ -69,9 +72,15 @@ impl<'a> Wkb<'a> {
6972 }
7073 }
7174
75+ /// Return the underlying buffer of this WKB geometry.
76+ #[ inline]
77+ pub fn buf ( & self ) -> & ' a [ u8 ] {
78+ self . buf
79+ }
80+
7281 pub ( crate ) fn size ( & self ) -> u64 {
7382 use WkbInner :: * ;
74- match & self . 0 {
83+ match & self . inner {
7584 Point ( g) => g. size ( ) ,
7685 LineString ( g) => g. size ( ) ,
7786 Polygon ( g) => g. size ( ) ,
@@ -189,7 +198,7 @@ impl<'a> GeometryTrait for Wkb<'a> {
189198 > {
190199 use geo_traits:: GeometryType as B ;
191200 use WkbInner as A ;
192- match & self . 0 {
201+ match & self . inner {
193202 A :: Point ( p) => B :: Point ( p) ,
194203 A :: LineString ( ls) => B :: LineString ( ls) ,
195204 A :: Polygon ( ls) => B :: Polygon ( ls) ,
@@ -265,7 +274,7 @@ impl<'a> GeometryTrait for &Wkb<'a> {
265274 > {
266275 use geo_traits:: GeometryType as B ;
267276 use WkbInner as A ;
268- match & self . 0 {
277+ match & self . inner {
269278 A :: Point ( p) => B :: Point ( p) ,
270279 A :: LineString ( ls) => B :: LineString ( ls) ,
271280 A :: Polygon ( ls) => B :: Polygon ( ls) ,
0 commit comments