pub struct Address {
pub high: u8,
pub mid: u8,
pub low: u8,
}Expand description
SysEx address (3 bytes)
Fields§
§high: u8High byte
mid: u8Mid byte
low: u8Low byte
Implementations§
Source§impl Address
impl Address
Sourcepub fn from_hex(hex: &str) -> Result<Self, RolandError>
pub fn from_hex(hex: &str) -> Result<Self, RolandError>
Create an address from a hex string (6 hex digits)
§Example
use roland_core::Address;
let addr = Address::from_hex("123456").unwrap();
assert_eq!(addr.high, 0x12);
assert_eq!(addr.mid, 0x34);
assert_eq!(addr.low, 0x56);Examples found in repository?
examples/telnet_client.rs (line 141)
140 pub fn write_parameter(&mut self, address: &str, value: u8) -> Result<(), TelnetError> {
141 let addr = Address::from_hex(address)?;
142 let cmd = Command::WriteParameter {
143 address: addr,
144 value,
145 };
146 let response = self.send_command(&cmd)?;
147
148 match response {
149 Response::Acknowledge => Ok(()),
150 Response::Error(e) => Err(TelnetError::Protocol(e)),
151 _ => Err(TelnetError::Protocol(RolandError::InvalidResponse)),
152 }
153 }
154
155 /// Read a parameter value
156 ///
157 /// # Arguments
158 /// * `address` - SysEx address (3 bytes as hex string, e.g., "123456")
159 /// * `size` - Size to read (typically 1 for single byte)
160 ///
161 /// # Returns
162 /// * `Result<u8, TelnetError>` - Parameter value or error
163 pub fn read_parameter(&mut self, address: &str, size: u32) -> Result<u8, TelnetError> {
164 let addr = Address::from_hex(address)?;
165 let cmd = Command::ReadParameter {
166 address: addr,
167 size,
168 };
169 let response = self.send_command(&cmd)?;
170
171 match response {
172 Response::Data { value, .. } => Ok(value),
173 Response::Error(e) => Err(TelnetError::Protocol(e)),
174 _ => Err(TelnetError::Protocol(RolandError::InvalidResponse)),
175 }
176 }Trait Implementations§
impl Copy for Address
impl Eq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations§
impl Freeze for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more