File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,17 @@ impl Message {
116116 }
117117
118118 /// Query a message metadata property.
119+ ///
120+ /// # Non-UTF8 values
121+ ///
122+ /// The `zmq_msg_gets` man page notes "The encoding of the property and
123+ /// value shall be UTF8". However, this is not actually enforced. For API
124+ /// compatibility reasons, this function will return `None` when
125+ /// encountering a non-UTF8 value; so a missing and a non-UTF8 value cannot
126+ /// currently be distinguished.
127+ ///
128+ /// This is considered a bug in the bindings, and will be fixed with the
129+ /// next API-breaking release.
119130 pub fn gets < ' a > ( & ' a mut self , property : & str ) -> Option < & ' a str > {
120131 let c_str = ffi:: CString :: new ( property. as_bytes ( ) ) . unwrap ( ) ;
121132
@@ -124,9 +135,6 @@ impl Message {
124135 if value. is_null ( ) {
125136 None
126137 } else {
127- // Note: libzmq` does not do UTF-8 validation, even though its doc
128- // suggest that UTF-8 "shall" be used here. Maybe we should changge
129- // the API to return a bytes slice.
130138 str:: from_utf8 ( unsafe { ffi:: CStr :: from_ptr ( value) } . to_bytes ( ) ) . ok ( )
131139 }
132140 }
You can’t perform that action at this time.
0 commit comments