Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading headers from message properties #23

Open
kaxap opened this issue Jun 25, 2020 · 6 comments
Open

Reading headers from message properties #23

kaxap opened this issue Jun 25, 2020 · 6 comments

Comments

@kaxap
Copy link

kaxap commented Jun 25, 2020

Please add documentation and preferably an example on how to read header values from delivery properties.

@jgallagher
Copy link
Collaborator

Header values are available in the properties of a Delivery (in particular, by calling delivery.properties.headers()). Unfortunately the docs for AmqpProperties are pulled in automatically - it's defined in another crate. I'd be happy to take a look at a PR that added some examples to Delivery itself though, if you think that would help clarify things.

@kaxap
Copy link
Author

kaxap commented Jun 26, 2020

I am happy to contribute, and, well, I am new to Rust, would you mind if I ask related questions here?

@jgallagher
Copy link
Collaborator

Not at all - go for it.

@kaxap
Copy link
Author

kaxap commented Jun 26, 2020

Thanks!

First question: the delivery.properties.headers() function returns

pub fn headers(&self) -> &Option<BTreeMap<String, AMQPValue>>

Is there any particular reason why it returns &Option<_> instead of Option<&_> ?

@kaxap
Copy link
Author

kaxap commented Jun 26, 2020

With &Option<_> is it necessary to call headers().as_ref() in order to get the BTreeMap itself?

@jgallagher
Copy link
Collaborator

Is there any particular reason why it returns &Option<> instead of Option<&> ?

I don't know; that seems weird to me too. But AmqpProperties comes from another crate, so it's hard for me to guess. :)

With &Option<_> is it necessary to call headers().as_ref() in order to get the BTreeMap itself?

Yep!

kaxap added a commit to kaxap/amiquip that referenced this issue Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants