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

Parsing Headers into Strings? #117

Closed
Amueller36 opened this issue Dec 5, 2023 · 3 comments
Closed

Parsing Headers into Strings? #117

Amueller36 opened this issue Dec 5, 2023 · 3 comments
Labels

Comments

@Amueller36
Copy link

Hello, am I overseeing something or is there actually no easier way to parse Headers of a rabbitmq message into a String?
This is an example where I tried to extract one header and print it

    pub fn parse_header(&self, properties: BasicProperties) {
        let headers = properties.headers().unwrap();
        let event_id = headers.get(&ShortStr::try_from("eventId").unwrap()).unwrap();
        if let FieldValue::x(byte_array) = event_id {
            let bytes = Vec::from(byte_array.clone());
            let event_id_string = String::from_utf8(bytes).unwrap();
            info!("{:?}", event_id_string);
        } else {
            panic!("Not a ByteArray variant");
        }
    }

Sorry if this is the wrong place for the question..

@gftea
Copy link
Owner

gftea commented Dec 6, 2023

if the FieldValue type is S, then you can get String without parsing raw bytes.

Copy link

github-actions bot commented Jan 6, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Jan 6, 2024
Copy link

This issue was closed because it has been stalled for 5 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants