use crate::concurrent::atomic_buffer::AtomicBuffer;
use crate::protocol::header_flyweight::{HeaderDefn, HeaderFlyweight};
use crate::utils::types::Index;
pub const STATUS_MESSAGE_DEFN_SIZE: Index = std::mem::size_of::<StatusMessageDefn>() as Index;
#[repr(C, packed(4))]
#[derive(Copy, Clone)]
pub struct StatusMessageDefn {
header: HeaderDefn,
session_id: i32,
stream_id: i32,
consumption_term_id: i32,
consumption_term_offset: i32,
receiver_window: i32,
}
#[allow(dead_code)]
pub struct StatusMessageFlyweight {
header_flyweight: HeaderFlyweight,
m_struct: *mut StatusMessageDefn, }
impl StatusMessageFlyweight {
pub fn new(buffer: AtomicBuffer, offset: Index) -> Self {
let header_flyweight = HeaderFlyweight::new(buffer, offset);
let m_struct = header_flyweight.flyweight.overlay_struct::<StatusMessageDefn>(0);
Self {
header_flyweight,
m_struct,
}
}
#[inline]
pub fn session_id(&self) -> i32 {
unsafe { (*self.m_struct).session_id }
}
#[inline]
pub fn stream_id(&self) -> i32 {
unsafe { (*self.m_struct).stream_id }
}
#[inline]
pub fn consumption_term_id(&self) -> i32 {
unsafe { (*self.m_struct).consumption_term_id }
}
#[inline]
pub fn consumption_term_offset(&self) -> i32 {
unsafe { (*self.m_struct).consumption_term_offset }
}
#[inline]
pub fn receiver_window(&self) -> i32 {
unsafe { (*self.m_struct).receiver_window }
}
#[inline]
pub fn set_session_id(&mut self, value: i32) {
unsafe {
(*self.m_struct).session_id = value;
}
}
#[inline]
pub fn set_stream_id(&mut self, value: i32) {
unsafe {
(*self.m_struct).stream_id = value;
}
}
#[inline]
pub fn set_consumption_term_id(&mut self, value: i32) {
unsafe {
(*self.m_struct).consumption_term_id = value;
}
}
#[inline]
pub fn set_consumption_term_offset(&mut self, value: i32) {
unsafe {
(*self.m_struct).consumption_term_offset = value;
}
}
#[inline]
pub fn set_receiver_window(&mut self, value: i32) {
unsafe {
(*self.m_struct).receiver_window = value;
}
}
#[inline]
pub const fn header_length() -> Index {
STATUS_MESSAGE_DEFN_SIZE
}
}