Skip to content

Commit

Permalink
resolve issue #23 i.e. add parse/from_str method to AeronUriStringBui…
Browse files Browse the repository at this point in the history
…lder
  • Loading branch information
mimran1980 committed Jan 15, 2025
1 parent 559474e commit c8db770
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions rusteron-archive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod bindings {
}

use bindings::*;
use std::str::FromStr;

pub mod testing;

Expand Down Expand Up @@ -149,6 +150,12 @@ mod tests {
.build(1024)?;
assert_eq!("aeron:udp?ttl=2|control-mode=dynamic|endpoint=localhost:1235|control=localhost:1234|reliable=false", uri);

let uri = AeronUriStringBuilder::from_str("aeron:udp?endpoint=localhost:8010")?
.ttl(5)?
.build(1024)?;

assert_eq!("aeron:udp?ttl=5|endpoint=localhost:8010", uri);

Ok(())
}

Expand Down
10 changes: 10 additions & 0 deletions rusteron-code-gen/src/aeron_custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ impl AeronPublication {
}
}

impl std::str::FromStr for AeronUriStringBuilder {
type Err = AeronCError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let builder = AeronUriStringBuilder::default();
builder.init_on_string(s)?;
Ok(builder)
}
}

impl AeronUriStringBuilder {
#[inline]
pub fn build(&self, max_str_length: usize) -> Result<String, AeronCError> {
Expand Down
2 changes: 2 additions & 0 deletions rusteron-docker-samples/.justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ fix:
cd rusteron-dummy-example && cargo clippy --allow-dirty --allow-staged --fix && cd -

docker-build:
cd rusteron-docker-samples/rusteron-dummy-example && cargo update && cd -
docker build -t aeron-media-driver aeron-media-driver
docker build -t rusteron-dummy-example rusteron-dummy-example

podman-build:
cd rusteron-docker-samples/rusteron-dummy-example && cargo update && cd -
podman build -t rusteron-dummy-example -f Dockerfile rusteron-dummy-example
podman build -t aeron-media-driver -f Dockerfile aeron-media-driver

Expand Down
4 changes: 2 additions & 2 deletions rusteron-docker-samples/rusteron-dummy-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"
websocket-lite = "0.5"
tokio = { version = "1", features = ["full"] }
futures-util = "0.3"
rusteron-archive = { version = "0.1.59", features = ["static"]}
rusteron-media-driver = { version = "0.1.59", features = ["static"]}
rusteron-archive = { version = "0.1", features = ["static"]}
rusteron-media-driver = { version = "0.1", features = ["static"]}
serde = { version = "1", features = ["derive"] }
serde_json = "1"
futures = "0.3"
Expand Down

0 comments on commit c8db770

Please sign in to comment.