Skip to content

Commit

Permalink
renamed Inner to Proto
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Jun 11, 2024
1 parent 4a107f4 commit 248ba2b
Show file tree
Hide file tree
Showing 74 changed files with 414 additions and 414 deletions.
4 changes: 2 additions & 2 deletions commons/zenoh-codec/src/core/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use zenoh_buffers::{
reader::{DidntRead, Reader},
writer::{DidntWrite, Writer},
};
use zenoh_protocol::core::{Timestamp, ZenohIdInner};
use zenoh_protocol::core::{Timestamp, ZenohIdProto};

use crate::{LCodec, RCodec, WCodec, Zenoh080};

Expand Down Expand Up @@ -53,7 +53,7 @@ where
if size > (uhlc::ID::MAX_SIZE) {
return Err(DidntRead);
}
let mut id = [0_u8; ZenohIdInner::MAX_SIZE];
let mut id = [0_u8; ZenohIdProto::MAX_SIZE];
reader.read_exact(&mut id[..size])?;

let time = uhlc::NTP64(time);
Expand Down
36 changes: 18 additions & 18 deletions commons/zenoh-codec/src/core/zenohid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,70 +17,70 @@ use zenoh_buffers::{
reader::{DidntRead, Reader},
writer::{DidntWrite, Writer},
};
use zenoh_protocol::core::ZenohIdInner;
use zenoh_protocol::core::ZenohIdProto;

use crate::{LCodec, RCodec, WCodec, Zenoh080, Zenoh080Length};

impl LCodec<&ZenohIdInner> for Zenoh080 {
fn w_len(self, x: &ZenohIdInner) -> usize {
impl LCodec<&ZenohIdProto> for Zenoh080 {
fn w_len(self, x: &ZenohIdProto) -> usize {
x.size()
}
}

impl<W> WCodec<&ZenohIdInner, &mut W> for Zenoh080
impl<W> WCodec<&ZenohIdProto, &mut W> for Zenoh080
where
W: Writer,
{
type Output = Result<(), DidntWrite>;

fn write(self, writer: &mut W, x: &ZenohIdInner) -> Self::Output {
fn write(self, writer: &mut W, x: &ZenohIdProto) -> Self::Output {
self.write(&mut *writer, &x.to_le_bytes()[..x.size()])
}
}

impl<R> RCodec<ZenohIdInner, &mut R> for Zenoh080
impl<R> RCodec<ZenohIdProto, &mut R> for Zenoh080
where
R: Reader,
{
type Error = DidntRead;

fn read(self, reader: &mut R) -> Result<ZenohIdInner, Self::Error> {
fn read(self, reader: &mut R) -> Result<ZenohIdProto, Self::Error> {
let size: usize = self.read(&mut *reader)?;
if size > ZenohIdInner::MAX_SIZE {
if size > ZenohIdProto::MAX_SIZE {
return Err(DidntRead);
}
let mut id = [0; ZenohIdInner::MAX_SIZE];
let mut id = [0; ZenohIdProto::MAX_SIZE];
reader.read_exact(&mut id[..size])?;
ZenohIdInner::try_from(&id[..size]).map_err(|_| DidntRead)
ZenohIdProto::try_from(&id[..size]).map_err(|_| DidntRead)
}
}

impl<W> WCodec<&ZenohIdInner, &mut W> for Zenoh080Length
impl<W> WCodec<&ZenohIdProto, &mut W> for Zenoh080Length
where
W: Writer,
{
type Output = Result<(), DidntWrite>;

fn write(self, writer: &mut W, x: &ZenohIdInner) -> Self::Output {
if self.length > ZenohIdInner::MAX_SIZE {
fn write(self, writer: &mut W, x: &ZenohIdProto) -> Self::Output {
if self.length > ZenohIdProto::MAX_SIZE {
return Err(DidntWrite);
}
writer.write_exact(&x.to_le_bytes()[..x.size()])
}
}

impl<R> RCodec<ZenohIdInner, &mut R> for Zenoh080Length
impl<R> RCodec<ZenohIdProto, &mut R> for Zenoh080Length
where
R: Reader,
{
type Error = DidntRead;

fn read(self, reader: &mut R) -> Result<ZenohIdInner, Self::Error> {
if self.length > ZenohIdInner::MAX_SIZE {
fn read(self, reader: &mut R) -> Result<ZenohIdProto, Self::Error> {
if self.length > ZenohIdProto::MAX_SIZE {
return Err(DidntRead);
}
let mut id = [0; ZenohIdInner::MAX_SIZE];
let mut id = [0; ZenohIdProto::MAX_SIZE];
reader.read_exact(&mut id[..self.length])?;
ZenohIdInner::try_from(&id[..self.length]).map_err(|_| DidntRead)
ZenohIdProto::try_from(&id[..self.length]).map_err(|_| DidntRead)
}
}
4 changes: 2 additions & 2 deletions commons/zenoh-codec/src/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use zenoh_buffers::{
};
use zenoh_protocol::{
common::{imsg, ZExtZ64, ZExtZBufHeader},
core::{EntityId, Reliability, ZenohIdInner},
core::{EntityId, Reliability, ZenohIdProto},
network::{ext::EntityGlobalIdType, *},
};

Expand Down Expand Up @@ -265,7 +265,7 @@ where
let length = 1 + ((flags >> 4) as usize);

let lodec = Zenoh080Length::new(length);
let zid: ZenohIdInner = lodec.read(&mut *reader)?;
let zid: ZenohIdProto = lodec.read(&mut *reader)?;

let eid: EntityId = self.codec.read(&mut *reader)?;

Expand Down
22 changes: 11 additions & 11 deletions commons/zenoh-codec/src/scouting/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ use zenoh_buffers::{
};
use zenoh_protocol::{
common::{imsg, ZExtUnknown},
core::{Locator, WhatAmI, ZenohIdInner},
core::{Locator, WhatAmI, ZenohIdProto},
scouting::{
hello::{flag, HelloInner},
hello::{flag, HelloProto},
id,
},
};

use crate::{RCodec, WCodec, Zenoh080, Zenoh080Header, Zenoh080Length};

impl<W> WCodec<&HelloInner, &mut W> for Zenoh080
impl<W> WCodec<&HelloProto, &mut W> for Zenoh080
where
W: Writer,
{
type Output = Result<(), DidntWrite>;

fn write(self, writer: &mut W, x: &HelloInner) -> Self::Output {
let HelloInner {
fn write(self, writer: &mut W, x: &HelloProto) -> Self::Output {
let HelloProto {
version,
whatami,
zid,
Expand Down Expand Up @@ -73,26 +73,26 @@ where
}
}

impl<R> RCodec<HelloInner, &mut R> for Zenoh080
impl<R> RCodec<HelloProto, &mut R> for Zenoh080
where
R: Reader,
{
type Error = DidntRead;

fn read(self, reader: &mut R) -> Result<HelloInner, Self::Error> {
fn read(self, reader: &mut R) -> Result<HelloProto, Self::Error> {
let header: u8 = self.read(&mut *reader)?;
let codec = Zenoh080Header::new(header);
codec.read(reader)
}
}

impl<R> RCodec<HelloInner, &mut R> for Zenoh080Header
impl<R> RCodec<HelloProto, &mut R> for Zenoh080Header
where
R: Reader,
{
type Error = DidntRead;

fn read(self, reader: &mut R) -> Result<HelloInner, Self::Error> {
fn read(self, reader: &mut R) -> Result<HelloProto, Self::Error> {
if imsg::mid(self.header) != id::HELLO {
return Err(DidntRead);
}
Expand All @@ -108,7 +108,7 @@ where
};
let length = 1 + ((flags >> 4) as usize);
let lodec = Zenoh080Length::new(length);
let zid: ZenohIdInner = lodec.read(&mut *reader)?;
let zid: ZenohIdProto = lodec.read(&mut *reader)?;

let locators = if imsg::has_flag(self.header, flag::L) {
let locs: Vec<Locator> = self.codec.read(&mut *reader)?;
Expand All @@ -124,7 +124,7 @@ where
has_extensions = more;
}

Ok(HelloInner {
Ok(HelloProto {
version,
zid,
whatami,
Expand Down
4 changes: 2 additions & 2 deletions commons/zenoh-codec/src/scouting/scout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use zenoh_buffers::{
};
use zenoh_protocol::{
common::{imsg, ZExtUnknown},
core::{whatami::WhatAmIMatcher, ZenohIdInner},
core::{whatami::WhatAmIMatcher, ZenohIdProto},
scouting::{
id,
scout::{flag, Scout},
Expand Down Expand Up @@ -93,7 +93,7 @@ where
let zid = if imsg::has_flag(flags, flag::I) {
let length = 1 + ((flags >> 4) as usize);
let lodec = Zenoh080Length::new(length);
let zid: ZenohIdInner = lodec.read(&mut *reader)?;
let zid: ZenohIdProto = lodec.read(&mut *reader)?;
Some(zid)
} else {
None
Expand Down
6 changes: 3 additions & 3 deletions commons/zenoh-codec/src/transport/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use zenoh_buffers::{
};
use zenoh_protocol::{
common::{iext, imsg},
core::{Resolution, WhatAmI, ZenohIdInner},
core::{Resolution, WhatAmI, ZenohIdProto},
transport::{
batch_size, id,
init::{ext, flag, InitAck, InitSyn},
Expand Down Expand Up @@ -160,7 +160,7 @@ where
};
let length = 1 + ((flags >> 4) as usize);
let lodec = Zenoh080Length::new(length);
let zid: ZenohIdInner = lodec.read(&mut *reader)?;
let zid: ZenohIdProto = lodec.read(&mut *reader)?;

let mut resolution = Resolution::default();
let mut batch_size = batch_size::UNICAST.to_le_bytes();
Expand Down Expand Up @@ -373,7 +373,7 @@ where
};
let length = 1 + ((flags >> 4) as usize);
let lodec = Zenoh080Length::new(length);
let zid: ZenohIdInner = lodec.read(&mut *reader)?;
let zid: ZenohIdProto = lodec.read(&mut *reader)?;

let mut resolution = Resolution::default();
let mut batch_size = batch_size::UNICAST.to_le_bytes();
Expand Down
4 changes: 2 additions & 2 deletions commons/zenoh-codec/src/transport/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use zenoh_buffers::{
};
use zenoh_protocol::{
common::{iext, imsg, ZExtZBufHeader},
core::{Priority, Resolution, WhatAmI, ZenohIdInner},
core::{Priority, Resolution, WhatAmI, ZenohIdProto},
transport::{
batch_size, id,
join::{ext, flag, Join},
Expand Down Expand Up @@ -242,7 +242,7 @@ where
};
let length = 1 + ((flags >> 4) as usize);
let lodec = Zenoh080Length::new(length);
let zid: ZenohIdInner = lodec.read(&mut *reader)?;
let zid: ZenohIdProto = lodec.read(&mut *reader)?;

let mut resolution = Resolution::default();
let mut batch_size = batch_size::MULTICAST.to_le_bytes();
Expand Down
6 changes: 3 additions & 3 deletions commons/zenoh-codec/src/zenoh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use zenoh_buffers::{
use zenoh_protocol::common::{iext, ZExtUnit};
use zenoh_protocol::{
common::{imsg, ZExtZBufHeader},
core::{Encoding, EntityGlobalIdInner, EntityId, ZenohIdInner},
core::{Encoding, EntityGlobalIdProto, EntityId, ZenohIdProto},
zenoh::{ext, id, PushBody, RequestBody, ResponseBody},
};

Expand Down Expand Up @@ -186,14 +186,14 @@ where
let length = 1 + ((flags >> 4) as usize);

let lodec = Zenoh080Length::new(length);
let zid: ZenohIdInner = lodec.read(&mut *reader)?;
let zid: ZenohIdProto = lodec.read(&mut *reader)?;

let eid: EntityId = self.codec.read(&mut *reader)?;
let sn: u32 = self.codec.read(&mut *reader)?;

Ok((
ext::SourceInfoType {
id: EntityGlobalIdInner { zid, eid },
id: EntityGlobalIdProto { zid, eid },
sn,
},
more,
Expand Down
6 changes: 3 additions & 3 deletions commons/zenoh-codec/tests/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ fn codec_string_bounded() {

#[test]
fn codec_zid() {
run!(ZenohIdInner, ZenohIdInner::default());
run!(ZenohIdProto, ZenohIdProto::default());
}

#[test]
Expand Down Expand Up @@ -348,7 +348,7 @@ fn codec_locator() {
fn codec_timestamp() {
run!(Timestamp, {
let time = uhlc::NTP64(thread_rng().gen());
let id = uhlc::ID::try_from(ZenohIdInner::rand().to_le_bytes()).unwrap();
let id = uhlc::ID::try_from(ZenohIdProto::rand().to_le_bytes()).unwrap();
Timestamp::new(time, id)
});
}
Expand Down Expand Up @@ -447,7 +447,7 @@ fn codec_scout() {

#[test]
fn codec_hello() {
run!(HelloInner, HelloInner::rand());
run!(HelloProto, HelloProto::rand());
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion commons/zenoh-config/src/mode_dependent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use serde::{
Deserialize, Serialize,
};
pub use zenoh_protocol::core::{
whatami, EndPoint, Locator, WhatAmI, WhatAmIMatcher, WhatAmIMatcherVisitor, ZenohIdInner,
whatami, EndPoint, Locator, WhatAmI, WhatAmIMatcher, WhatAmIMatcherVisitor, ZenohIdProto,
};

pub trait ModeDependent<T> {
Expand Down
Loading

0 comments on commit 248ba2b

Please sign in to comment.