code
stringlengths
40
729k
docstring
stringlengths
22
46.3k
func_name
stringlengths
1
97
language
stringclasses
1 value
repo
stringlengths
6
48
path
stringlengths
8
176
url
stringlengths
47
228
license
stringclasses
7 values
pub async fn trace_transaction( &self, tx_hash: TxHash, ) -> Result<Vec<LocalizedTransactionTrace>> { let _permit = self.permit_request().await; Self::map_err(self.provider.trace_transaction(tx_hash).await) }
Returns all traces of a given transaction
trace_transaction
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn trace_call( &self, transaction: TransactionRequest, trace_type: Vec<TraceType>, block_number: Option<BlockNumber>, ) -> Result<TraceResults> { let _permit = self.permit_request().await; if let Some(bn) = block_number { return Self::map_err( self.provider.trace_call(&transaction, &trace_type).block_id(bn.into()).await, ); } Self::map_err(self.provider.trace_call(&transaction, &trace_type).await) }
Returns traces for given call data
trace_call
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn get_storage_at( &self, address: Address, slot: U256, block_number: BlockNumber, ) -> Result<U256> { let _permit = self.permit_request().await; Self::map_err( self.provider.get_storage_at(address, slot).block_id(block_number.into()).await, ) }
Get stored data at given location
get_storage_at
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn call2( &self, address: Address, call_data: Vec<u8>, block_number: BlockNumber, ) -> Result<Bytes> { let transaction = TransactionRequest { to: Some(address.into()), input: TransactionInput::new(call_data.into()), ..Default::default() }; let _permit = self.permit_request().await; Self::map_err(self.provider.call(&transaction).block(block_number.into()).await) }
Return output data of a contract call
call2
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn trace_call2( &self, address: Address, call_data: Vec<u8>, trace_type: Vec<TraceType>, block_number: Option<BlockNumber>, ) -> Result<TraceResults> { let transaction = TransactionRequest { to: Some(address.into()), input: TransactionInput::new(call_data.into()), ..Default::default() }; let _permit = self.permit_request().await; if block_number.is_some() { Self::map_err( self.provider .trace_call(&transaction, &trace_type) .block_id(block_number.unwrap().into()) .await, ) } else { Self::map_err(self.provider.trace_call(&transaction, &trace_type).await) } }
Return output data of a contract call
trace_call2
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn geth_debug_trace_block_javascript_traces( &self, js_tracer: String, block_number: u32, include_transaction_hashes: bool, ) -> Result<(Option<u32>, Vec<Option<Vec<u8>>>, Vec<serde_json::Value>)> { let tracer = GethDebugTracerType::JsTracer(js_tracer); let options = GethDebugTracingOptions { tracer: Some(tracer), ..Default::default() }; let (block, txs, traces) = self.geth_debug_trace_block(block_number, options, include_transaction_hashes).await?; let mut calls = Vec::new(); for trace in traces.into_iter() { match trace { TraceResult::Success { result, tx_hash } => match result { GethTrace::JS(value) => calls.push(value), _ => { return Err(CollectError::CollectError(format!( "invalid trace result in tx {:?}", tx_hash ))) } }, TraceResult::Error { error, tx_hash } => { return Err(CollectError::CollectError(format!( "invalid trace result in tx {:?}: {}", tx_hash, error ))) } } } Ok((block, txs, calls)) }
get geth debug block call traces
geth_debug_trace_block_javascript_traces
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn geth_debug_trace_block_opcodes( &self, block_number: u32, include_transaction_hashes: bool, options: GethDebugTracingOptions, ) -> Result<(Option<u32>, Vec<Option<Vec<u8>>>, Vec<DefaultFrame>)> { let (block, txs, traces) = self.geth_debug_trace_block(block_number, options, include_transaction_hashes).await?; let mut calls = Vec::new(); for trace in traces.into_iter() { match trace { TraceResult::Success { result, tx_hash } => match result { GethTrace::Default(frame) => calls.push(frame), _ => { return Err(CollectError::CollectError(format!( "invalid trace result in tx {:?}", tx_hash ))) } }, TraceResult::Error { error, tx_hash } => { return Err(CollectError::CollectError(format!( "inalid trace result in tx {:?}: {}", tx_hash, error ))); } } } Ok((block, txs, calls)) }
get geth debug block opcode traces
geth_debug_trace_block_opcodes
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn geth_debug_trace_block_prestate( &self, block_number: u32, include_transaction_hashes: bool, ) -> Result<(Option<u32>, Vec<Option<Vec<u8>>>, Vec<BTreeMap<Address, AccountState>>)> { let tracer = GethDebugTracerType::BuiltInTracer(GethDebugBuiltInTracerType::PreStateTracer); let options = GethDebugTracingOptions { tracer: Some(tracer), ..Default::default() }; let (block, txs, traces) = self.geth_debug_trace_block(block_number, options, include_transaction_hashes).await?; let mut calls = Vec::new(); for trace in traces.into_iter() { match trace { // GethTrace::Known(GethTraceFrame::PreStateTracer(PreStateFrame::Default( // PreStateMode(frame), // ))) => calls.push(frame), // _ => return Err(CollectError::CollectError("invalid trace result".to_string())), TraceResult::Success { result, tx_hash } => match result { GethTrace::PreStateTracer(PreStateFrame::Default(frame)) => calls.push(frame.0), _ => { return Err(CollectError::CollectError(format!( "invalid trace result in tx {:?}", tx_hash ))) } }, TraceResult::Error { error, tx_hash } => { return Err(CollectError::CollectError(format!( "invalid trace result in tx {:?}: {}", tx_hash, error ))); } } } Ok((block, txs, calls)) }
get geth debug block call traces
geth_debug_trace_block_prestate
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn geth_debug_trace_block_calls( &self, block_number: u32, include_transaction_hashes: bool, ) -> Result<(Option<u32>, Vec<Option<Vec<u8>>>, Vec<CallFrame>)> { let tracer = GethDebugTracerType::BuiltInTracer(GethDebugBuiltInTracerType::CallTracer); // let config = GethDebugTracerConfig::BuiltInTracer( // GethDebugBuiltInTracerConfig::CallTracer(CallConfig { ..Default::default() }), // ); let options = GethDebugTracingOptions::default() .with_tracer(tracer) .with_call_config(CallConfig::default()); let (block, txs, traces) = self.geth_debug_trace_block(block_number, options, include_transaction_hashes).await?; let mut calls = Vec::new(); for trace in traces.into_iter() { // match trace { // GethTrace::Known(GethTraceFrame::CallTracer(call_frame)) => // calls.push(call_frame), _ => return // Err(CollectError::CollectError("invalid trace result".to_string())), } match trace { TraceResult::Success { result, tx_hash } => match result { GethTrace::CallTracer(frame) => calls.push(frame), _ => { return Err(CollectError::CollectError(format!( "invalid trace result in tx {:?}", tx_hash ))) } }, TraceResult::Error { error, tx_hash } => { return Err(CollectError::CollectError(format!( "invalid trace result in tx {:?}: {}", tx_hash, error ))); } } } Ok((block, txs, calls)) }
get geth debug block call traces
geth_debug_trace_block_calls
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn geth_debug_trace_block_diffs( &self, block_number: u32, include_transaction_hashes: bool, ) -> Result<(Option<u32>, Vec<Option<Vec<u8>>>, Vec<DiffMode>)> { let tracer = GethDebugTracerType::BuiltInTracer(GethDebugBuiltInTracerType::PreStateTracer); // let config = GethDebugTracerConfig::BuiltInTracer( // GethDebugBuiltInTracerConfig::PreStateTracer(PreStateConfig { diff_mode: Some(true) // }), let options = GethDebugTracingOptions::default() .with_prestate_config(PreStateConfig { diff_mode: Some(true), disable_code: None, disable_storage: None, }) .with_tracer(tracer); let (block, txs, traces) = self.geth_debug_trace_block(block_number, options, include_transaction_hashes).await?; let mut diffs = Vec::new(); for trace in traces.into_iter() { match trace { TraceResult::Success { result, tx_hash } => match result { GethTrace::PreStateTracer(PreStateFrame::Diff(diff)) => diffs.push(diff), GethTrace::JS(serde_json::Value::Object(map)) => { let diff = parse_geth_diff_object(map)?; diffs.push(diff); } _ => { println!("{:?}", result); return Err(CollectError::CollectError(format!( "invalid trace result in tx {:?}", tx_hash ))); } }, TraceResult::Error { error, tx_hash } => { return Err(CollectError::CollectError(format!( "invalid trace result in tx {:?}: {}", tx_hash, error ))); } } } Ok((block, txs, diffs)) }
get geth debug block diff traces
geth_debug_trace_block_diffs
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn geth_debug_trace_transaction_javascript_traces( &self, js_tracer: String, transaction_hash: Vec<u8>, include_block_number: bool, ) -> Result<(Option<u32>, Vec<Option<Vec<u8>>>, Vec<serde_json::Value>)> { let tracer = GethDebugTracerType::JsTracer(js_tracer); let options = GethDebugTracingOptions { tracer: Some(tracer), ..Default::default() }; let (block, txs, traces) = self .geth_debug_trace_transaction(transaction_hash, options, include_block_number) .await?; let mut calls = Vec::new(); for trace in traces.into_iter() { match trace { GethTrace::JS(value) => calls.push(value), _ => return Err(CollectError::CollectError("invalid trace result".to_string())), } } Ok((block, txs, calls)) }
get geth debug block javascript traces
geth_debug_trace_transaction_javascript_traces
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn geth_debug_trace_transaction_opcodes( &self, transaction_hash: Vec<u8>, include_block_number: bool, options: GethDebugTracingOptions, ) -> Result<(Option<u32>, Vec<Option<Vec<u8>>>, Vec<DefaultFrame>)> { let (block, txs, traces) = self .geth_debug_trace_transaction(transaction_hash, options, include_block_number) .await?; let mut calls = Vec::new(); for trace in traces.into_iter() { match trace { GethTrace::Default(frame) => calls.push(frame), _ => return Err(CollectError::CollectError("invalid trace result".to_string())), } } Ok((block, txs, calls)) }
get geth debug block opcode traces
geth_debug_trace_transaction_opcodes
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn geth_debug_trace_transaction_prestate( &self, transaction_hash: Vec<u8>, include_block_number: bool, ) -> Result<(Option<u32>, Vec<Option<Vec<u8>>>, Vec<BTreeMap<Address, AccountState>>)> { let tracer = GethDebugTracerType::BuiltInTracer(GethDebugBuiltInTracerType::PreStateTracer); let options = GethDebugTracingOptions { tracer: Some(tracer), ..Default::default() }; let (block, txs, traces) = self .geth_debug_trace_transaction(transaction_hash, options, include_block_number) .await?; let mut calls = Vec::new(); for trace in traces.into_iter() { match trace { GethTrace::PreStateTracer(PreStateFrame::Default(frame)) => calls.push(frame.0), _ => return Err(CollectError::CollectError("invalid trace result".to_string())), } } Ok((block, txs, calls)) }
get geth debug block call traces
geth_debug_trace_transaction_prestate
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn geth_debug_trace_transaction_calls( &self, transaction_hash: Vec<u8>, include_block_number: bool, ) -> Result<(Option<u32>, Vec<Option<Vec<u8>>>, Vec<CallFrame>)> { let tracer = GethDebugTracerType::BuiltInTracer(GethDebugBuiltInTracerType::CallTracer); // let config = GethDebugTracerConfig::BuiltInTracer( // GethDebugBuiltInTracerConfig::CallTracer(CallConfig { ..Default::default() }), // ); let options = GethDebugTracingOptions::default() .with_tracer(tracer) .with_call_config(CallConfig::default()); let (block, txs, traces) = self .geth_debug_trace_transaction(transaction_hash, options, include_block_number) .await?; let mut calls = Vec::new(); for trace in traces.into_iter() { match trace { // GethTrace::Known(GethTraceFrame::CallTracer(call_frame)) => // calls.push(call_frame), GethTrace::CallTracer(frame) => calls.push(frame), _ => return Err(CollectError::CollectError("invalid trace result".to_string())), } } Ok((block, txs, calls)) }
get geth debug block call traces
geth_debug_trace_transaction_calls
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub async fn geth_debug_trace_transaction_diffs( &self, transaction_hash: Vec<u8>, include_transaction_hashes: bool, ) -> Result<(Option<u32>, Vec<Option<Vec<u8>>>, Vec<DiffMode>)> { let tracer = GethDebugTracerType::BuiltInTracer(GethDebugBuiltInTracerType::PreStateTracer); // let config = GethDebugTracerConfig::BuiltInTracer( // GethDebugBuiltInTracerConfig::PreStateTracer(PreStateConfig { diff_mode: Some(true) // }), ); let options = GethDebugTracingOptions::default().with_tracer(tracer).with_prestate_config( PreStateConfig { diff_mode: Some(true), disable_code: None, disable_storage: None }, ); let (block, txs, traces) = self .geth_debug_trace_transaction(transaction_hash, options, include_transaction_hashes) .await?; let mut diffs = Vec::new(); for trace in traces.into_iter() { match trace { // GethTrace::Known(GethTraceFrame::PreStateTracer(PreStateFrame::Diff(diff))) => { // diffs.push(diff) // } GethTrace::PreStateTracer(PreStateFrame::Diff(diff)) => diffs.push(diff), _ => return Err(CollectError::CollectError("invalid trace result".to_string())), } } Ok((block, txs, diffs)) }
get geth debug block diff traces
geth_debug_trace_transaction_diffs
rust
paradigmxyz/cryo
crates/freeze/src/types/sources.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/sources.rs
Apache-2.0
pub fn fold(self, other: ChunkStats<T>) -> ChunkStats<T> { let min_value = std::cmp::min(self.min_value, other.min_value); let max_value = std::cmp::max(self.max_value, other.max_value); let total_values = self.total_values + other.total_values; let chunk_size = self.chunk_size; let n_chunks = self.n_chunks + other.n_chunks; ChunkStats { min_value, max_value, total_values, chunk_size, n_chunks } }
reduce ChunkStats of two chunks into one
fold
rust
paradigmxyz/cryo
crates/freeze/src/types/chunks/chunk_ops.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/chunks/chunk_ops.rs
Apache-2.0
pub fn to_log_filter_options(&self, log_request_size: &u64) -> Vec<FilterBlockOption> { match self { NumberChunk::Numbers(block_numbers) => block_numbers .iter() .map(|block| FilterBlockOption::Range { from_block: Some((*block).into()), to_block: Some((*block).into()), }) .collect(), NumberChunk::Range(start_block, end_block) => { let chunks = range_to_chunks(start_block, &(end_block + 1), log_request_size); chunks .iter() .map(|(start, end)| FilterBlockOption::Range { from_block: Some((*start).into()), to_block: Some((*end).into()), }) .collect() } } }
convert block range to a list of Filters for get_logs()
to_log_filter_options
rust
paradigmxyz/cryo
crates/freeze/src/types/chunks/number_chunk.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/chunks/number_chunk.rs
Apache-2.0
pub fn align(self, chunk_size: u64) -> Option<NumberChunk> { match self { NumberChunk::Numbers(numbers) => Some(NumberChunk::Numbers(numbers)), NumberChunk::Range(start, end) => { let start = start.div_ceil(chunk_size) * chunk_size; let end = (end / chunk_size) * chunk_size; if end > start { Some(NumberChunk::Range(start, end)) } else { None } } } }
align boundaries of chunk to clean boundaries
align
rust
paradigmxyz/cryo
crates/freeze/src/types/chunks/number_chunk.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/chunks/number_chunk.rs
Apache-2.0
fn transform(_response: Self::Response, _columns: &mut Self, _schemas: &Arc<Query>) -> R<()> { Err(CollectError::CollectError("CollectByBlock not implemented".to_string())) }
transform block data response into column data
transform
rust
paradigmxyz/cryo
crates/freeze/src/types/collection/collect_by_block.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/collection/collect_by_block.rs
Apache-2.0
async fn transform_channel( mut receiver: mpsc::Receiver<R<Self::Response>>, query: &Arc<Query>, ) -> R<Self> { let mut columns = Self::default(); while let Some(message) = receiver.recv().await { match message { Ok(message) => Self::transform(message, &mut columns, query)?, Err(e) => return Err(e), } } Ok(columns) }
convert block-derived data to dataframe
transform_channel
rust
paradigmxyz/cryo
crates/freeze/src/types/collection/collect_by_block.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/collection/collect_by_block.rs
Apache-2.0
fn can_collect_by_block() -> bool { std::any::type_name::<Self::Response>() != "()" }
whether data can be collected by block
can_collect_by_block
rust
paradigmxyz/cryo
crates/freeze/src/types/collection/collect_by_block.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/collection/collect_by_block.rs
Apache-2.0
fn transform(_response: Self::Response, _columns: &mut Self, _query: &Arc<Query>) -> R<()> { Err(CollectError::CollectError("CollectByTransaction not implemented".to_string())) }
transform block data response into column data
transform
rust
paradigmxyz/cryo
crates/freeze/src/types/collection/collect_by_transaction.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/collection/collect_by_transaction.rs
Apache-2.0
async fn transform_channel( mut receiver: mpsc::Receiver<R<Self::Response>>, query: &Arc<Query>, ) -> R<Self> { let mut columns = Self::default(); while let Some(message) = receiver.recv().await { match message { Ok(message) => Self::transform(message, &mut columns, query)?, Err(e) => return Err(e), } } Ok(columns) }
convert transaction-derived data to dataframe
transform_channel
rust
paradigmxyz/cryo
crates/freeze/src/types/collection/collect_by_transaction.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/collection/collect_by_transaction.rs
Apache-2.0
fn can_collect_by_transaction() -> bool { std::any::type_name::<Self::Response>() != "()" }
whether data can be collected by transaction
can_collect_by_transaction
rust
paradigmxyz/cryo
crates/freeze/src/types/collection/collect_by_transaction.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/collection/collect_by_transaction.rs
Apache-2.0
fn df_to_parquet( df: &mut DataFrame, filename: &Path, file_output: &FileOutput, ) -> Result<(), FileError> { let file = std::fs::File::create(filename).map_err(|_e| FileError::FileWriteError)?; let result = ParquetWriter::new(file) .with_statistics(file_output.parquet_statistics) .with_compression(file_output.parquet_compression) .with_row_group_size(file_output.row_group_size) .finish(df); match result { Err(_e) => Err(FileError::FileWriteError), _ => Ok(()), } }
write polars dataframe to parquet file
df_to_parquet
rust
paradigmxyz/cryo
crates/freeze/src/types/dataframes/export.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/dataframes/export.rs
Apache-2.0
fn df_to_csv(df: &mut DataFrame, filename: &Path) -> Result<(), FileError> { let file = std::fs::File::create(filename).map_err(|_e| FileError::FileWriteError)?; let result = CsvWriter::new(file).finish(df); match result { Err(_e) => Err(FileError::FileWriteError), _ => Ok(()), } }
write polars dataframe to csv file
df_to_csv
rust
paradigmxyz/cryo
crates/freeze/src/types/dataframes/export.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/dataframes/export.rs
Apache-2.0
fn df_to_json(df: &mut DataFrame, filename: &Path) -> Result<(), FileError> { let file = std::fs::File::create(filename).map_err(|_e| FileError::FileWriteError)?; let result = JsonWriter::new(file).with_json_format(JsonFormat::Json).finish(df); match result { Err(_e) => Err(FileError::FileWriteError), _ => Ok(()), } }
write polars dataframe to json file
df_to_json
rust
paradigmxyz/cryo
crates/freeze/src/types/dataframes/export.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/dataframes/export.rs
Apache-2.0
pub fn read_binary_column(path: &str, column: &str) -> Result<Vec<Vec<u8>>, ParseError> { let file = std::fs::File::open(path) .map_err(|_e| ParseError::ParseError("could not open file path".to_string()))?; let df = ParquetReader::new(file) .with_columns(Some(vec![column.to_string()])) .finish() .map_err(|_e| ParseError::ParseError("could not read data from column".to_string()))?; let series = df .column(column) .map_err(|_e| ParseError::ParseError("could not get column".to_string()))? .unique() .map_err(|_e| ParseError::ParseError("could not get column".to_string()))?; let ca = series .binary() .map_err(|_e| ParseError::ParseError("could not convert to binary column".to_string()))?; ca.into_iter() .map(|value| { value .ok_or_else(|| ParseError::ParseError("transaction hash missing".to_string())) .map(|data| data.into()) }) .collect() }
read single binary column of parquet file as Vec<u8>
read_binary_column
rust
paradigmxyz/cryo
crates/freeze/src/types/dataframes/read.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/dataframes/read.rs
Apache-2.0
pub fn cluster_datatypes(dts: Vec<Datatype>) -> Vec<MetaDatatype> { // use MultiDatatypes that have at least 2 ScalarDatatypes in datatype list let mdts: Vec<MultiDatatype> = MultiDatatype::variants() .iter() .filter(|mdt| mdt.datatypes().iter().filter(|x| dts.contains(x)).count() >= 2) .cloned() .collect(); let mdt_dts: Vec<Datatype> = mdts.iter().flat_map(|mdt| mdt.datatypes()).filter(|dt| dts.contains(dt)).collect(); let other_dts: Vec<Datatype> = dts.iter().filter(|dt| !mdt_dts.contains(dt)).copied().collect(); [ mdts.iter().map(|mdt| MetaDatatype::Multi(*mdt)).collect::<Vec<MetaDatatype>>(), other_dts.into_iter().map(MetaDatatype::Scalar).collect(), ] .concat() }
cluster datatypes into MultiDatatype / ScalarDatatype groups
cluster_datatypes
rust
paradigmxyz/cryo
crates/freeze/src/types/datatypes/meta.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/datatypes/meta.rs
Apache-2.0
pub fn variants() -> Vec<MultiDatatype> { vec![ MultiDatatype::BlocksAndTransactions, MultiDatatype::CallTraceDerivatives, MultiDatatype::GethStateDiffs, MultiDatatype::StateDiffs, MultiDatatype::StateReads, ] }
return all variants of multi datatype
variants
rust
paradigmxyz/cryo
crates/freeze/src/types/datatypes/multi.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/datatypes/multi.rs
Apache-2.0
pub fn new(event_signature: String) -> Result<Self, String> { match Event::parse(&event_signature) { Ok(event) => Ok(Self { event, raw: event_signature.clone() }), Err(e) => { let err = format!("incorrectly formatted event {} (expect something like event Transfer(address indexed from, address indexed to, uint256 amount) err: {}", event_signature, e); eprintln!("{}", err); Err(err) } } }
create a new LogDecoder from an event signature ex: LogDecoder::new("event Transfer(address indexed from, address indexed to, uint256 amount)".to_string())
new
rust
paradigmxyz/cryo
crates/freeze/src/types/decoders/log_decoder.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/decoders/log_decoder.rs
Apache-2.0
pub fn field_names(&self) -> Vec<String> { self.event.inputs.iter().map(|i| i.name.clone()).collect() }
get field names of event inputs
field_names
rust
paradigmxyz/cryo
crates/freeze/src/types/decoders/log_decoder.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/decoders/log_decoder.rs
Apache-2.0
pub fn parse_log_from_event( &self, logs: Vec<Log>, ) -> indexmap::IndexMap<String, Vec<DynSolValue>> { let mut map: indexmap::IndexMap<String, Vec<DynSolValue>> = indexmap::IndexMap::new(); let indexed_keys: Vec<String> = self .event .inputs .clone() .into_iter() .filter_map(|x| if x.indexed { Some(x.name) } else { None }) .collect(); let body_keys: Vec<String> = self .event .inputs .clone() .into_iter() .filter_map(|x| if x.indexed { None } else { Some(x.name) }) .collect(); for log in logs { match self.event.decode_log_parts(log.topics().to_vec(), log.data().data.as_ref(), true) { Ok(decoded) => { for (idx, param) in decoded.indexed.into_iter().enumerate() { map.entry(indexed_keys[idx].clone()).or_default().push(param); } for (idx, param) in decoded.body.into_iter().enumerate() { map.entry(body_keys[idx].clone()).or_default().push(param); } } Err(e) => eprintln!("error parsing log: {:?}", e), } } map }
converts from a log type to an abi token type this function assumes all logs are of the same type and skips fields if they don't match the passed event definition
parse_log_from_event
rust
paradigmxyz/cryo
crates/freeze/src/types/decoders/log_decoder.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/decoders/log_decoder.rs
Apache-2.0
pub fn make_series( &self, name: String, data: Vec<DynSolValue>, chunk_len: usize, u256_types: &[U256Type], column_encoding: &ColumnEncoding, ) -> Result<Vec<Series>, CollectError> { // This is a smooth brain way of doing this, but I can't think of a better way right now let mut ints: Vec<i64> = vec![]; let mut uints: Vec<u64> = vec![]; let mut u256s: Vec<U256> = vec![]; let mut i256s: Vec<I256> = vec![]; let mut bytes: Vec<Vec<u8>> = vec![]; let mut hexes: Vec<String> = vec![]; let mut bools: Vec<bool> = vec![]; let mut strings: Vec<String> = vec![]; // TODO: support array & tuple types for token in data { match token { DynSolValue::Address(a) => match column_encoding { ColumnEncoding::Binary => bytes.push(a.to_vec()), ColumnEncoding::Hex => hexes.push(format!("{:?}", a)), }, DynSolValue::FixedBytes(b, _) => match column_encoding { ColumnEncoding::Binary => bytes.push(b.to_vec()), ColumnEncoding::Hex => hexes.push(b.encode_hex()), }, DynSolValue::Bytes(b) => match column_encoding { ColumnEncoding::Binary => bytes.push(b), ColumnEncoding::Hex => hexes.push(b.encode_hex()), }, DynSolValue::Uint(i, size) => { if size <= 64 { uints.push(i.wrapping_to::<u64>()) } else { u256s.push(i) } } DynSolValue::Int(i, size) => { if size <= 64 { ints.push(i.unchecked_into()); } else { i256s.push(i); } } DynSolValue::Bool(b) => bools.push(b), DynSolValue::String(s) => strings.push(s), DynSolValue::Array(_) | DynSolValue::FixedArray(_) => {} DynSolValue::Tuple(_) => {} DynSolValue::Function(_) => {} } } let mixed_length_err = format!("could not parse column {}, mixed type", name); let mixed_length_err = mixed_length_err.as_str(); // check each vector, see if it contains any values, if it does, check if it's the same // length as the input data and map to a series let name = format!("event__{}", name); if !ints.is_empty() { Ok(vec![Series::new(name.as_str(), ints)]) } else if !i256s.is_empty() { let mut series_vec = Vec::new(); for u256_type in u256_types.iter() { series_vec.push(i256s.to_u256_series( name.clone(), u256_type.clone(), column_encoding, )?) } Ok(series_vec) } else if !u256s.is_empty() { let mut series_vec: Vec<Series> = Vec::new(); for u256_type in u256_types.iter() { series_vec.push(u256s.to_u256_series( name.clone(), u256_type.clone(), column_encoding, )?) } Ok(series_vec) } else if !uints.is_empty() { Ok(vec![Series::new(name.as_str(), uints)]) } else if !bytes.is_empty() { if bytes.len() != chunk_len { return Err(err(mixed_length_err)) } Ok(vec![Series::new(name.as_str(), bytes)]) } else if !hexes.is_empty() { if hexes.len() != chunk_len { return Err(err(mixed_length_err)) } Ok(vec![Series::new(name.as_str(), hexes)]) } else if !bools.is_empty() { if bools.len() != chunk_len { return Err(err(mixed_length_err)) } Ok(vec![Series::new(name.as_str(), bools)]) } else if !strings.is_empty() { if strings.len() != chunk_len { return Err(err(mixed_length_err)) } Ok(vec![Series::new(name.as_str(), strings)]) } else { // case where no data was passed Ok(vec![Series::new(name.as_str(), vec![None::<u64>; chunk_len])]) } }
data should never be mixed type, otherwise this will return inconsistent results
make_series
rust
paradigmxyz/cryo
crates/freeze/src/types/decoders/log_decoder.rs
https://github.com/paradigmxyz/cryo/blob/master/crates/freeze/src/types/decoders/log_decoder.rs
Apache-2.0
fn collect_tests() -> eyre::Result<Vec<Trial>> { fn visit_dir(path: &Path, tests: &mut Vec<Trial>) -> eyre::Result<()> { for entry in fs::read_dir(path)? { let entry = entry?; let file_type = entry.file_type()?; // Handle files let path = entry.path(); if file_type.is_file() { if path.extension() == Some(OsStr::new("june")) { let name = path .strip_prefix(env::current_dir()?)? .display() .to_string(); if parse_special_comments(&path).is_none() { continue; } let test = Trial::test(name, move || eval_source_runner(&path)); tests.push(test); } } else if file_type.is_dir() { // Handle directories visit_dir(&path, tests)?; } } Ok(()) } // We recursively look for `.june` files, starting from the current // directory. let mut tests = Vec::new(); let current_dir = env::var("CARGO_MANIFEST_DIR") .map(PathBuf::from)? .join("tests"); visit_dir(&current_dir, &mut tests)?; Ok(tests) }
Creates one test for each `.june` file in the current directory or sub-directories of the current directory.
collect_tests
rust
sophiajt/june
tests/integration_tests.rs
https://github.com/sophiajt/june/blob/master/tests/integration_tests.rs
MIT
pub fn new(bus: B) -> UsbBusAllocator<B> { UsbBusAllocator { bus: RefCell::new(bus), bus_ptr: AtomicPtr::new(ptr::null_mut()), state: RefCell::new(AllocatorState { next_interface_number: 0, next_string_index: 4, }), } }
Creates a new [`UsbBusAllocator`] that wraps the provided [`UsbBus`]. Usually only called by USB driver implementations.
new
rust
rust-embedded-community/usb-device
src/bus.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/bus.rs
MIT
pub fn alloc<D: EndpointDirection>( &self, ep_addr: Option<EndpointAddress>, ep_type: EndpointType, max_packet_size: u16, interval: u8, ) -> Result<Endpoint<'_, B, D>> { self.bus .borrow_mut() .alloc_ep(D::DIRECTION, ep_addr, ep_type, max_packet_size, interval) .map(|a| Endpoint::new(&self.bus_ptr, a, ep_type, max_packet_size, interval)) }
Allocates an endpoint with the specified direction and address. This directly delegates to [`UsbBus::alloc_ep`], so see that method for details. In most cases classes should call the endpoint type specific methods instead.
alloc
rust
rust-embedded-community/usb-device
src/bus.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/bus.rs
MIT
fn get_configuration_descriptors(&self, writer: &mut DescriptorWriter) -> Result<()> { let _ = writer; Ok(()) }
Called when a GET_DESCRIPTOR request is received for a configuration descriptor. When called, the implementation should write its interface, endpoint and any extra class descriptors into `writer`. The configuration descriptor itself will be written by [UsbDevice](crate::device::UsbDevice) and shouldn't be written by classes. # Errors Generally errors returned by `DescriptorWriter`. Implementors should propagate any errors using `?`.
get_configuration_descriptors
rust
rust-embedded-community/usb-device
src/class.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/class.rs
MIT
fn get_bos_descriptors(&self, writer: &mut BosWriter) -> Result<()> { let _ = writer; Ok(()) }
Called when a GET_DESCRIPTOR request is received for a BOS descriptor. When called, the implementation should write its blobs such as capability descriptors into `writer`. The BOS descriptor itself will be written by [UsbDevice](crate::device::UsbDevice) and shouldn't be written by classes.
get_bos_descriptors
rust
rust-embedded-community/usb-device
src/class.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/class.rs
MIT
fn get_string(&self, index: StringIndex, lang_id: LangID) -> Option<&str> { let _ = (index, lang_id); None }
Gets a class-specific string descriptor. Note: All string descriptor requests are passed to all classes in turn, so implementations should return [`None`] if an unknown index is requested. # Arguments * `index` - A string index allocated earlier with [`UsbAllocator`](crate::bus::UsbBusAllocator). * `lang_id` - The language ID for the string to retrieve. If the requested lang_id is not valid it will default to EN_US.
get_string
rust
rust-embedded-community/usb-device
src/class.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/class.rs
MIT
fn control_out(&mut self, xfer: ControlOut<B>) { let _ = xfer; }
Called when a control request is received with direction HostToDevice. All requests are passed to classes in turn, which can choose to accept, ignore or report an error. Classes can even choose to override standard requests, but doing that is rarely necessary. See [`ControlOut`] for how to respond to the transfer. When implementing your own class, you should ignore any requests that are not meant for your class so that any other classes in the composite device can process them. # Arguments * `req` - The request from the SETUP packet. * `xfer` - A handle to the transfer.
control_out
rust
rust-embedded-community/usb-device
src/class.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/class.rs
MIT
fn control_in(&mut self, xfer: ControlIn<B>) { let _ = xfer; }
Called when a control request is received with direction DeviceToHost. All requests are passed to classes in turn, which can choose to accept, ignore or report an error. Classes can even choose to override standard requests, but doing that is rarely necessary. See [`ControlIn`] for how to respond to the transfer. When implementing your own class, you should ignore any requests that are not meant for your class so that any other classes in the composite device can process them. # Arguments * `req` - The request from the SETUP packet. * `data` - Data to send in the DATA stage of the control transfer.
control_in
rust
rust-embedded-community/usb-device
src/class.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/class.rs
MIT
fn endpoint_setup(&mut self, addr: EndpointAddress) { let _ = addr; }
Called when endpoint with address `addr` has received a SETUP packet. Implementing this shouldn't be necessary in most cases, but is provided for completeness' sake. Note: This method may be called for an endpoint address you didn't allocate, and in that case you should ignore the event.
endpoint_setup
rust
rust-embedded-community/usb-device
src/class.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/class.rs
MIT
fn endpoint_out(&mut self, addr: EndpointAddress) { let _ = addr; }
Called when endpoint with address `addr` has received data (OUT packet). Note: This method may be called for an endpoint address you didn't allocate, and in that case you should ignore the event.
endpoint_out
rust
rust-embedded-community/usb-device
src/class.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/class.rs
MIT
fn get_alt_setting(&mut self, interface: InterfaceNumber) -> Option<u8> { let _ = interface; None }
Called when the interfaces alternate setting state is requested. Note: This method may be called on interfaces, that are not relevant to this class. You should return `None, if `interface` belongs to an interface you don't know.
get_alt_setting
rust
rust-embedded-community/usb-device
src/class.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/class.rs
MIT
fn set_alt_setting(&mut self, interface: InterfaceNumber, alternative: u8) -> bool { let _ = (interface, alternative); false }
Called when the interfaces alternate setting state is altered. Note: This method may be called on interfaces, that are not relevant to this class. You should return `false`, if `interface` belongs to an interface you don't know.
set_alt_setting
rust
rust-embedded-community/usb-device
src/class.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/class.rs
MIT
pub fn accept_with(self, data: &[u8]) -> Result<()> { self.pipe.accept_in(|buf| { if data.len() > buf.len() { return Err(UsbError::BufferOverflow); } buf[..data.len()].copy_from_slice(data); Ok(data.len()) }) }
Accepts the transfer with the supplied buffer.
accept_with
rust
rust-embedded-community/usb-device
src/class.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/class.rs
MIT
pub fn descriptor_type_index(&self) -> (u8, u8) { ((self.value >> 8) as u8, self.value as u8) }
Gets the descriptor type and index from the value field of a GET_DESCRIPTOR request.
descriptor_type_index
rust
rust-embedded-community/usb-device
src/control.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/control.rs
MIT
pub fn write(&mut self, descriptor_type: u8, descriptor: &[u8]) -> Result<()> { self.write_with(descriptor_type, |buf| { if descriptor.len() > buf.len() { return Err(UsbError::BufferOverflow); } buf[..descriptor.len()].copy_from_slice(descriptor); Ok(descriptor.len()) }) }
Writes an arbitrary (usually class-specific) descriptor.
write
rust
rust-embedded-community/usb-device
src/descriptor.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/descriptor.rs
MIT
pub fn write_with( &mut self, descriptor_type: u8, f: impl FnOnce(&mut [u8]) -> Result<usize>, ) -> Result<()> { if self.position + 2 > self.buf.len() { return Err(UsbError::BufferOverflow); } let data_end = min(self.buf.len(), self.position + 256); let data_buf = &mut self.buf[self.position + 2..data_end]; let total_len = f(data_buf)? + 2; if self.position + total_len > self.buf.len() { return Err(UsbError::BufferOverflow); } self.buf[self.position] = total_len as u8; self.buf[self.position + 1] = descriptor_type; self.position += total_len; Ok(()) }
Writes an arbitrary (usually class-specific) descriptor by using a callback function. The callback function gets a reference to the remaining buffer space, and it should write the descriptor into it and return the number of bytes written. If the descriptor doesn't fit, the function should return `Err(UsbError::BufferOverflow)`. That and any error returned by it will be propagated up.
write_with
rust
rust-embedded-community/usb-device
src/descriptor.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/descriptor.rs
MIT
pub fn iad( &mut self, first_interface: InterfaceNumber, interface_count: u8, function_class: u8, function_sub_class: u8, function_protocol: u8, function_string: Option<StringIndex>, ) -> Result<()> { if !self.write_iads { return Ok(()); } let str_index = function_string.map_or(0, Into::into); self.write( descriptor_type::IAD, &[ first_interface.into(), // bFirstInterface interface_count, // bInterfaceCount function_class, function_sub_class, function_protocol, str_index, ], )?; Ok(()) }
Writes a interface association descriptor. Call from `UsbClass::get_configuration_descriptors` before writing the USB class or function's interface descriptors if your class has more than one interface and wants to play nicely with composite devices on Windows. If the USB device hosting the class was not configured as composite with IADs enabled, calling this function does nothing, so it is safe to call from libraries. # Arguments * `first_interface` - Number of the function's first interface, previously allocated with [`UsbBusAllocator::interface`](crate::bus::UsbBusAllocator::interface). * `interface_count` - Number of interfaces in the function. * `function_class` - Class code assigned by USB.org. Use `0xff` for vendor-specific devices that do not conform to any class. * `function_sub_class` - Sub-class code. Depends on class. * `function_protocol` - Protocol code. Depends on class and sub-class. * `function_string` - Index of string descriptor describing this function
iad
rust
rust-embedded-community/usb-device
src/descriptor.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/descriptor.rs
MIT
pub fn interface( &mut self, number: InterfaceNumber, interface_class: u8, interface_sub_class: u8, interface_protocol: u8, ) -> Result<()> { self.interface_alt( number, device::DEFAULT_ALTERNATE_SETTING, interface_class, interface_sub_class, interface_protocol, None, ) }
Writes a interface descriptor. # Arguments * `number` - Interface number previously allocated with [`UsbBusAllocator::interface`](crate::bus::UsbBusAllocator::interface). * `interface_class` - Class code assigned by USB.org. Use `0xff` for vendor-specific devices that do not conform to any class. * `interface_sub_class` - Sub-class code. Depends on class. * `interface_protocol` - Protocol code. Depends on class and sub-class.
interface
rust
rust-embedded-community/usb-device
src/descriptor.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/descriptor.rs
MIT
pub fn interface_alt( &mut self, number: InterfaceNumber, alternate_setting: u8, interface_class: u8, interface_sub_class: u8, interface_protocol: u8, interface_string: Option<StringIndex>, ) -> Result<()> { if alternate_setting == device::DEFAULT_ALTERNATE_SETTING { match self.num_interfaces_mark { Some(mark) => self.buf[mark] += 1, None => return Err(UsbError::InvalidState), }; } let str_index = interface_string.map_or(0, Into::into); self.num_endpoints_mark = Some(self.position + 4); self.write( descriptor_type::INTERFACE, &[ number.into(), // bInterfaceNumber alternate_setting, // bAlternateSetting 0, // bNumEndpoints interface_class, // bInterfaceClass interface_sub_class, // bInterfaceSubClass interface_protocol, // bInterfaceProtocol str_index, // iInterface ], )?; Ok(()) }
Writes a interface descriptor with a specific alternate setting and interface string identifier. # Arguments * `number` - Interface number previously allocated with [`UsbBusAllocator::interface`](crate::bus::UsbBusAllocator::interface). * `alternate_setting` - Number of the alternate setting * `interface_class` - Class code assigned by USB.org. Use `0xff` for vendor-specific devices that do not conform to any class. * `interface_sub_class` - Sub-class code. Depends on class. * `interface_protocol` - Protocol code. Depends on class and sub-class. * `interface_string` - Index of string descriptor describing this interface
interface_alt
rust
rust-embedded-community/usb-device
src/descriptor.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/descriptor.rs
MIT
pub fn endpoint<B: UsbBus, D: EndpointDirection>( &mut self, endpoint: &Endpoint<'_, B, D>, ) -> Result<()> { self.endpoint_ex(endpoint, |_| Ok(0)) }
Writes an endpoint descriptor. # Arguments * `endpoint` - Endpoint previously allocated with [`UsbBusAllocator`](crate::bus::UsbBusAllocator).
endpoint
rust
rust-embedded-community/usb-device
src/descriptor.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/descriptor.rs
MIT
pub fn endpoint_ex<B: UsbBus, D: EndpointDirection>( &mut self, endpoint: &Endpoint<'_, B, D>, f: impl FnOnce(&mut [u8]) -> Result<usize>, ) -> Result<()> { match self.num_endpoints_mark { Some(mark) => self.buf[mark] += 1, None => return Err(UsbError::InvalidState), }; self.write_with(descriptor_type::ENDPOINT, |buf| { if buf.len() < 5 { return Err(UsbError::BufferOverflow); } let mps = endpoint.max_packet_size(); buf[0] = endpoint.address().into(); buf[1] = endpoint.ep_type().to_bm_attributes(); buf[2] = mps as u8; buf[3] = (mps >> 8) as u8; buf[4] = endpoint.interval(); Ok(f(&mut buf[5..])? + 5) }) }
Writes an endpoint descriptor with extra trailing data. This is rarely needed and shouldn't be used except for compatibility with standard USB classes that require it. Extra data is normally written in a separate class specific descriptor. # Arguments * `endpoint` - Endpoint previously allocated with [`UsbBusAllocator`](crate::bus::UsbBusAllocator). * `f` - Callback for the extra data. See `write_with` for more information.
endpoint_ex
rust
rust-embedded-community/usb-device
src/descriptor.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/descriptor.rs
MIT
pub fn capability(&mut self, capability_type: u8, data: &[u8]) -> Result<()> { match self.num_caps_mark { Some(mark) => self.writer.buf[mark] += 1, None => return Err(UsbError::InvalidState), } let mut start = self.writer.position; let blen = data.len(); if (start + blen + 3) > self.writer.buf.len() || (blen + 3) > 255 { return Err(UsbError::BufferOverflow); } self.writer.buf[start] = (blen + 3) as u8; self.writer.buf[start + 1] = descriptor_type::CAPABILITY; self.writer.buf[start + 2] = capability_type; start += 3; self.writer.buf[start..start + blen].copy_from_slice(data); self.writer.position = start + blen; Ok(()) }
Writes capability descriptor to a BOS # Arguments * `capability_type` - Type of a capability * `data` - Binary data of the descriptor
capability
rust
rust-embedded-community/usb-device
src/descriptor.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/descriptor.rs
MIT
pub fn set_self_powered(&mut self, is_self_powered: bool) { self.self_powered = is_self_powered; }
Sets whether the device is currently self powered.
set_self_powered
rust
rust-embedded-community/usb-device
src/device.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/device.rs
MIT
pub fn poll(&mut self, classes: &mut ClassList<'_, B>) -> bool { let pr = self.bus.poll(); if self.device_state == UsbDeviceState::Suspend { match pr { PollResult::Suspend | PollResult::None => { return false; } _ => { self.bus.resume(); self.device_state = self .suspended_device_state .expect("Unknown state before suspend"); self.suspended_device_state = None; } } } match pr { PollResult::None => {} PollResult::Reset => self.reset(classes), PollResult::Data { ep_out, ep_in_complete, ep_setup, } => { // Combine bit fields for quick tests let mut eps = ep_out | ep_in_complete | ep_setup; // Pending events for endpoint 0? if (eps & 1) != 0 { usb_debug!( "EP0: setup={}, in_complete={}, out={}", ep_setup & 1, ep_in_complete & 1, ep_out & 1 ); let req = if (ep_setup & 1) != 0 { self.control.handle_setup() } else if (ep_out & 1) != 0 { match self.control.handle_out() { Ok(req) => req, Err(_err) => { // TODO: Propagate error out of `poll()` usb_debug!("Failed to handle EP0: {:?}", _err); None } } } else { None }; match req { Some(req) if req.direction == UsbDirection::In => { if let Err(_err) = self.control_in(classes, req) { // TODO: Propagate error out of `poll()` usb_debug!("Failed to handle input control request: {:?}", _err); } } Some(req) if req.direction == UsbDirection::Out => { if let Err(_err) = self.control_out(classes, req) { // TODO: Propagate error out of `poll()` usb_debug!("Failed to handle output control request: {:?}", _err); } } None if ((ep_in_complete & 1) != 0) => { // We only handle EP0-IN completion if there's no other request being // processed. EP0-IN tokens may be issued due to completed STATUS // phases of the control transfer. If we just got a SETUP packet or // an OUT token, we can safely ignore the IN-COMPLETE indication and // continue with the next transfer. let completed = match self.control.handle_in_complete() { Ok(completed) => completed, Err(_err) => { // TODO: Propagate this out of `poll()` usb_debug!( "Failed to process control-input complete: {:?}", _err ); false } }; if !B::QUIRK_SET_ADDRESS_BEFORE_STATUS && completed && self.pending_address != 0 { self.bus.set_device_address(self.pending_address); self.pending_address = 0; self.device_state = UsbDeviceState::Addressed; } } _ => (), }; eps &= !1; } // Pending events for other endpoints? if eps != 0 { let mut bit = 2u16; for i in 1..MAX_ENDPOINTS { if (ep_setup & bit) != 0 { for cls in classes.iter_mut() { usb_trace!("Handling EP{}-SETUP", i); cls.endpoint_setup(EndpointAddress::from_parts( i, UsbDirection::Out, )); } } else if (ep_out & bit) != 0 { usb_trace!("Handling EP{}-OUT", i); for cls in classes.iter_mut() { cls.endpoint_out(EndpointAddress::from_parts(i, UsbDirection::Out)); } } if (ep_in_complete & bit) != 0 { usb_trace!("Handling EP{}-IN", i); for cls in classes.iter_mut() { cls.endpoint_in_complete(EndpointAddress::from_parts( i, UsbDirection::In, )); } } eps &= !bit; if eps == 0 { // No more pending events for higher endpoints break; } bit <<= 1; } } for cls in classes.iter_mut() { cls.poll(); } return true; } PollResult::Resume => {} PollResult::Suspend => { usb_debug!("Suspending bus"); self.bus.suspend(); self.suspended_device_state = Some(self.device_state); self.device_state = UsbDeviceState::Suspend; } } false }
Polls the [`UsbBus`] for new events and dispatches them to the provided classes. Returns true if one of the classes may have data available for reading or be ready for writing, false otherwise. This should be called periodically as often as possible for the best data rate, or preferably from an interrupt handler. Must be called at least once every 10 milliseconds while connected to the USB host to be USB compliant. Note: The list of classes passed in must be the same classes in the same order for every call while the device is configured, or the device may enumerate incorrectly or otherwise misbehave. The easiest way to do this is to call the `poll` method in only one place in your code, as follows: ``` ignore usb_dev.poll(&mut [&mut class1, &mut class2]); ``` Strictly speaking the list of classes is allowed to change between polls if the device has been reset, which is indicated by `state` being equal to [`UsbDeviceState::Default`].
poll
rust
rust-embedded-community/usb-device
src/device.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/device.rs
MIT
pub fn new(lang_id: LangID) -> Self { Self { id: lang_id, serial: None, product: None, manufacturer: None, } }
Create a new descriptor list with the provided language.
new
rust
rust-embedded-community/usb-device
src/device_builder.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/device_builder.rs
MIT
pub fn serial_number(mut self, serial: &'a str) -> Self { self.serial.replace(serial); self }
Specify the serial number for this language.
serial_number
rust
rust-embedded-community/usb-device
src/device_builder.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/device_builder.rs
MIT
pub fn manufacturer(mut self, manufacturer: &'a str) -> Self { self.manufacturer.replace(manufacturer); self }
Specify the manufacturer name for this language.
manufacturer
rust
rust-embedded-community/usb-device
src/device_builder.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/device_builder.rs
MIT
pub fn product(mut self, product: &'a str) -> Self { self.product.replace(product); self }
Specify the product name for this language.
product
rust
rust-embedded-community/usb-device
src/device_builder.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/device_builder.rs
MIT
pub fn new( alloc: &'a UsbBusAllocator<B>, vid_pid: UsbVidPid, control_buffer: &'a mut [u8], ) -> UsbDeviceBuilder<'a, B> { UsbDeviceBuilder { alloc, control_buffer, config: Config { device_class: 0x00, device_sub_class: 0x00, device_protocol: 0x00, max_packet_size_0: 8, vendor_id: vid_pid.0, product_id: vid_pid.1, usb_rev: UsbRev::Usb210, device_release: 0x0010, string_descriptors: heapless::Vec::new(), self_powered: false, supports_remote_wakeup: false, composite_with_iads: false, max_power: 50, }, } }
Creates a builder for constructing a new [`UsbDevice`].
new
rust
rust-embedded-community/usb-device
src/device_builder.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/device_builder.rs
MIT
pub fn build(self) -> Result<UsbDevice<'a, B>, BuilderError> { if self.control_buffer.len() < self.config.max_packet_size_0 as usize { return Err(BuilderError::ControlBufferTooSmall); } Ok(UsbDevice::build( self.alloc, self.config, self.control_buffer, )) }
Creates the [`UsbDevice`] instance with the configuration in this builder.
build
rust
rust-embedded-community/usb-device
src/device_builder.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/device_builder.rs
MIT
pub fn composite_with_iads(mut self) -> Self { // Magic values specified in USB-IF ECN on IADs. self.config.device_class = 0xEF; self.config.device_sub_class = 0x02; self.config.device_protocol = 0x01; self.config.composite_with_iads = true; self }
Configures the device as a composite device with interface association descriptors.
composite_with_iads
rust
rust-embedded-community/usb-device
src/device_builder.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/device_builder.rs
MIT
pub fn strings(mut self, descriptors: &[StringDescriptors<'a>]) -> Result<Self, BuilderError> { // The 16 language limit comes from the size of the buffer used to provide the list of // language descriptors to the host. self.config.string_descriptors = heapless::Vec::from_slice(descriptors).map_err(|_| BuilderError::TooManyLanguages)?; Ok(self) }
Specify the strings for the device. # Note Up to 16 languages may be provided.
strings
rust
rust-embedded-community/usb-device
src/device_builder.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/device_builder.rs
MIT
pub fn max_packet_size_0(mut self, max_packet_size_0: u8) -> Result<Self, BuilderError> { match max_packet_size_0 { 8 | 16 | 32 | 64 => {} _ => return Err(BuilderError::InvalidPacketSize), } if self.control_buffer.len() < max_packet_size_0 as usize { return Err(BuilderError::ControlBufferTooSmall); } self.config.max_packet_size_0 = max_packet_size_0; Ok(self) }
Sets the maximum packet size in bytes for the control endpoint 0. Valid values are 8, 16, 32 and 64. There's generally no need to change this from the default value of 8 bytes unless a class uses control transfers for sending large amounts of data, in which case using a larger packet size may be more efficient. Default: 8 bytes
max_packet_size_0
rust
rust-embedded-community/usb-device
src/device_builder.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/device_builder.rs
MIT
pub fn max_power(mut self, max_power_ma: usize) -> Result<Self, BuilderError> { if max_power_ma > 500 { return Err(BuilderError::PowerTooHigh); } self.config.max_power = (max_power_ma / 2) as u8; Ok(self) }
Sets the maximum current drawn from the USB bus by the device in milliamps. The default is 100 mA. If your device always uses an external power source and never draws power from the USB bus, this can be set to 0. See also: `self_powered` Default: 100mA
max_power
rust
rust-embedded-community/usb-device
src/device_builder.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/device_builder.rs
MIT
pub fn to_bm_attributes(&self) -> u8 { match self { EndpointType::Control => 0b00, EndpointType::Isochronous { synchronization, usage, } => { let sync_bits = match synchronization { IsochronousSynchronizationType::NoSynchronization => 0b00, IsochronousSynchronizationType::Asynchronous => 0b01, IsochronousSynchronizationType::Adaptive => 0b10, IsochronousSynchronizationType::Synchronous => 0b11, }; let usage_bits = match usage { IsochronousUsageType::Data => 0b00, IsochronousUsageType::Feedback => 0b01, IsochronousUsageType::ImplicitFeedbackData => 0b10, }; (usage_bits << 4) | (sync_bits << 2) | 0b01 } EndpointType::Bulk => 0b10, EndpointType::Interrupt => 0b11, } }
Format EndpointType for use in bmAttributes transfer type field USB 2.0 spec section 9.6.6
to_bm_attributes
rust
rust-embedded-community/usb-device
src/endpoint.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/endpoint.rs
MIT
pub fn stall(&self) { self.bus().set_stalled(self.address, true); }
Sets the STALL condition for the endpoint.
stall
rust
rust-embedded-community/usb-device
src/endpoint.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/endpoint.rs
MIT
pub fn unstall(&self) { self.bus().set_stalled(self.address, false); }
Clears the STALL condition of the endpoint.
unstall
rust
rust-embedded-community/usb-device
src/endpoint.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/endpoint.rs
MIT
pub fn write(&self, data: &[u8]) -> Result<usize> { self.bus().write(self.address, data) }
Writes a single packet of data to the specified endpoint and returns number of bytes actually written. The buffer must not be longer than the `max_packet_size` specified when allocating the endpoint. # Errors Note: USB bus implementation errors are directly passed through, so be prepared to handle other errors as well. * [`WouldBlock`](crate::UsbError::WouldBlock) - The transmission buffer of the USB peripheral is full and the packet cannot be sent now. A peripheral may or may not support concurrent transmission of packets. * [`BufferOverflow`](crate::UsbError::BufferOverflow) - The data is longer than the `max_packet_size` specified when allocating the endpoint. This is generally an error in the class implementation.
write
rust
rust-embedded-community/usb-device
src/endpoint.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/endpoint.rs
MIT
pub fn read(&self, data: &mut [u8]) -> Result<usize> { self.bus().read(self.address, data) }
Reads a single packet of data from the specified endpoint and returns the actual length of the packet. The buffer should be large enough to fit at least as many bytes as the `max_packet_size` specified when allocating the endpoint. # Errors Note: USB bus implementation errors are directly passed through, so be prepared to handle other errors as well. * [`WouldBlock`](crate::UsbError::WouldBlock) - There is no packet to be read. Note that this is different from a received zero-length packet, which is valid and significant in USB. A zero-length packet will return `Ok(0)`. * [`BufferOverflow`](crate::UsbError::BufferOverflow) - The received packet is too long to fit in `data`. This is generally an error in the class implementation.
read
rust
rust-embedded-community/usb-device
src/endpoint.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/endpoint.rs
MIT
pub fn make_device_builder<'a>( &self, usb_bus: &'a UsbBusAllocator<B>, ) -> UsbDeviceBuilder<'a, B> { UsbDeviceBuilder::new(usb_bus, UsbVidPid(VID, PID), unsafe { CONTROL_BUFFER.get_mut() }) .strings(&[StringDescriptors::default() .manufacturer(MANUFACTURER) .product(PRODUCT) .serial_number(SERIAL_NUMBER)]) .unwrap() .max_packet_size_0(sizes::CONTROL_ENDPOINT) .unwrap() }
Convenience method to create a UsbDeviceBuilder that is configured correctly for TestClass. The methods sets - manufacturer - product - serial number - max_packet_size_0 on the returned builder. If you change the manufacturer, product, or serial number fields, the test host may misbehave.
make_device_builder
rust
rust-embedded-community/usb-device
src/test_class.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/test_class.rs
MIT
pub fn poll(&mut self) { if self.bench { match self.ep_bulk_out.read(&mut self.bulk_buf) { Ok(_) | Err(UsbError::WouldBlock) => {} Err(err) => panic!("bulk bench read {:?}", err), }; match self .ep_bulk_in .write(&self.bulk_buf[0..self.ep_bulk_in.max_packet_size() as usize]) { Ok(_) | Err(UsbError::WouldBlock) => {} Err(err) => panic!("bulk bench write {:?}", err), }; return; } let temp_i = self.i; match self.ep_bulk_out.read(&mut self.bulk_buf[temp_i..]) { Ok(count) => { if self.expect_bulk_out { self.expect_bulk_out = false; } else { panic!("unexpectedly read data from bulk out endpoint"); } self.i += count; if count < self.ep_bulk_out.max_packet_size() as usize { self.len = self.i; self.i = 0; self.write_bulk_in(count == 0); } } Err(UsbError::WouldBlock) => {} Err(err) => panic!("bulk read {:?}", err), }; match self.ep_interrupt_out.read(&mut self.interrupt_buf) { Ok(count) => { if self.expect_interrupt_out { self.expect_interrupt_out = false; } else { panic!("unexpectedly read data from interrupt out endpoint"); } self.ep_interrupt_in .write(&self.interrupt_buf[0..count]) .expect("interrupt write"); self.expect_interrupt_in_complete = true; } Err(UsbError::WouldBlock) => {} Err(err) => panic!("interrupt read {:?}", err), }; }
Must be called after polling the UsbDevice.
poll
rust
rust-embedded-community/usb-device
src/test_class.rs
https://github.com/rust-embedded-community/usb-device/blob/master/src/test_class.rs
MIT
pub fn is_high_speed(&self) -> bool { self.handle.device().speed() == rusb::Speed::High }
Indicates if this device is (true) or isn't (false) a high-speed device.
is_high_speed
rust
rust-embedded-community/usb-device
tests/test_class_host/device.rs
https://github.com/rust-embedded-community/usb-device/blob/master/tests/test_class_host/device.rs
MIT
pub fn bulk_max_packet_size(&self) -> u16 { self.config_descriptor .interfaces() .flat_map(|intf| intf.descriptors()) .flat_map(|desc| { desc.endpoint_descriptors() .find(|ep| { // Assumes that IN and OUT endpoint MPSes are the same. ep.transfer_type() == rusb::TransferType::Bulk }) .map(|ep| ep.max_packet_size()) }) .next() .expect("TestClass has at least one bulk endpoint") }
Returns the max packet size for the `TestClass` bulk endpoint(s).
bulk_max_packet_size
rust
rust-embedded-community/usb-device
tests/test_class_host/device.rs
https://github.com/rust-embedded-community/usb-device/blob/master/tests/test_class_host/device.rs
MIT
pub fn report_all_stats() { let all_stats = std::mem::take(&mut *ALL_STATS.lock()); if FLAGS.enable_stat_logs { for stats in all_stats { eprintln!("*kati*: {stats}"); stats.dump_top(); } eprintln!("*kati*: {} symbols", symbol_count()); eprintln!("*kati*: {} find nodes", crate::find::get_node_count()); } }
Report all the statistics to stderr, if `--enable_stat_log` is enabled.
report_all_stats
rust
google/kati
src-rs/stats.rs
https://github.com/google/kati/blob/master/src-rs/stats.rs
Apache-2.0
pub fn use_scheme(mut self, value: bool) -> Self { self.use_scheme = value; self }
Whether to use the request's URI scheme when generating the key.
use_scheme
rust
salvo-rs/salvo
crates/cache/src/lib.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/lib.rs
Apache-2.0
pub fn use_authority(mut self, value: bool) -> Self { self.use_authority = value; self }
Whether to use the request's URI authority when generating the key.
use_authority
rust
salvo-rs/salvo
crates/cache/src/lib.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/lib.rs
Apache-2.0
pub fn use_path(mut self, value: bool) -> Self { self.use_path = value; self }
Whether to use the request's URI path when generating the key.
use_path
rust
salvo-rs/salvo
crates/cache/src/lib.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/lib.rs
Apache-2.0
pub fn use_query(mut self, value: bool) -> Self { self.use_query = value; self }
Whether to use the request's URI query when generating the key.
use_query
rust
salvo-rs/salvo
crates/cache/src/lib.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/lib.rs
Apache-2.0
pub fn use_method(mut self, value: bool) -> Self { self.use_method = value; self }
Whether to use the request method when generating the key.
use_method
rust
salvo-rs/salvo
crates/cache/src/lib.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/lib.rs
Apache-2.0
pub fn initial_capacity(mut self, capacity: usize) -> Self { self.inner = self.inner.initial_capacity(capacity); self }
Sets the initial capacity (number of entries) of the cache.
initial_capacity
rust
salvo-rs/salvo
crates/cache/src/moka_store.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/moka_store.rs
Apache-2.0
pub fn max_capacity(mut self, capacity: u64) -> Self { self.inner = self.inner.max_capacity(capacity); self }
Sets the max capacity of the cache.
max_capacity
rust
salvo-rs/salvo
crates/cache/src/moka_store.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/moka_store.rs
Apache-2.0
pub fn time_to_idle(mut self, duration: Duration) -> Self { self.inner = self.inner.time_to_idle(duration); self }
Sets the time to idle of the cache. A cached entry will expire after the specified duration has passed since `get` or `insert`. # Panics `CacheBuilder::build*` methods will panic if the given `duration` is longer than 1000 years. This is done to protect against overflow when computing key expiration.
time_to_idle
rust
salvo-rs/salvo
crates/cache/src/moka_store.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/moka_store.rs
Apache-2.0
pub fn time_to_live(mut self, duration: Duration) -> Self { self.inner = self.inner.time_to_live(duration); self }
Sets the time to live of the cache. A cached entry will expire after the specified duration has passed since `insert`. # Panics `CacheBuilder::build*` methods will panic if the given `duration` is longer than 1000 years. This is done to protect against overflow when computing key expiration.
time_to_live
rust
salvo-rs/salvo
crates/cache/src/moka_store.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/moka_store.rs
Apache-2.0
pub fn eviction_listener( mut self, listener: impl Fn(Arc<K>, CachedEntry, RemovalCause) + Send + Sync + 'static, ) -> Self { self.inner = self.inner.eviction_listener(listener); self }
Sets the eviction listener closure to the cache. # Panics It is very important to ensure the listener closure does not panic. Otherwise, the cache will stop calling the listener after a panic. This is intended behavior because the cache cannot know whether it is memory safe to call the panicked listener again.
eviction_listener
rust
salvo-rs/salvo
crates/cache/src/moka_store.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/moka_store.rs
Apache-2.0
pub fn build(self) -> MokaStore<K> { MokaStore { inner: self.inner.build(), } }
Build a [`MokaStore`]. # Panics Panics if configured with either `time_to_live` or `time_to_idle` higher than 1000 years. This is done to protect against overflow when computing key expiration.
build
rust
salvo-rs/salvo
crates/cache/src/moka_store.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/moka_store.rs
Apache-2.0
pub fn builder() -> Builder<K> { Builder { inner: MokaCache::builder(), } }
Returns a [`Builder`], which can build a `MokaStore`.
builder
rust
salvo-rs/salvo
crates/cache/src/moka_store.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/moka_store.rs
Apache-2.0
pub fn skip_get(self, value: bool) -> Self { self.skip_method(Method::GET, value) }
Add the [`Method::GET`] method to skipped methods.
skip_get
rust
salvo-rs/salvo
crates/cache/src/skipper.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/skipper.rs
Apache-2.0
pub fn skip_post(self, value: bool) -> Self { self.skip_method(Method::POST, value) }
Add the [`Method::POST`] method to skipped methods.
skip_post
rust
salvo-rs/salvo
crates/cache/src/skipper.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/skipper.rs
Apache-2.0
pub fn skip_put(self, value: bool) -> Self { self.skip_method(Method::PUT, value) }
Add the [`Method::PUT`] method to skipped methods.
skip_put
rust
salvo-rs/salvo
crates/cache/src/skipper.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/skipper.rs
Apache-2.0
pub fn skip_delete(self, value: bool) -> Self { self.skip_method(Method::DELETE, value) }
Add the [`Method::DELETE`] method to skipped methods.
skip_delete
rust
salvo-rs/salvo
crates/cache/src/skipper.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/skipper.rs
Apache-2.0
pub fn skip_head(self, value: bool) -> Self { self.skip_method(Method::HEAD, value) }
Add the [`Method::HEAD`] method to skipped methods.
skip_head
rust
salvo-rs/salvo
crates/cache/src/skipper.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/skipper.rs
Apache-2.0
pub fn skip_patch(self, value: bool) -> Self { self.skip_method(Method::PATCH, value) }
Add the [`Method::PATCH`] method to skipped methods.
skip_patch
rust
salvo-rs/salvo
crates/cache/src/skipper.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/skipper.rs
Apache-2.0
pub fn skip_options(self, value: bool) -> Self { self.skip_method(Method::OPTIONS, value) }
Add the [`Method::OPTIONS`] method to skipped methods.
skip_options
rust
salvo-rs/salvo
crates/cache/src/skipper.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/skipper.rs
Apache-2.0
pub fn skip_connect(self, value: bool) -> Self { self.skip_method(Method::CONNECT, value) }
Add the [`Method::CONNECT`] method to skipped methods.
skip_connect
rust
salvo-rs/salvo
crates/cache/src/skipper.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/skipper.rs
Apache-2.0
pub fn skip_trace(self, value: bool) -> Self { self.skip_method(Method::TRACE, value) }
Add the [`Method::TRACE`] method to skipped methods.
skip_trace
rust
salvo-rs/salvo
crates/cache/src/skipper.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/skipper.rs
Apache-2.0
pub fn skip_all(mut self) -> Self { self.skipped_methods = [ Method::GET, Method::POST, Method::PUT, Method::DELETE, Method::HEAD, Method::PATCH, Method::OPTIONS, Method::CONNECT, Method::TRACE, ] .into_iter() .collect(); self }
Add all methods to skipped methods.
skip_all
rust
salvo-rs/salvo
crates/cache/src/skipper.rs
https://github.com/salvo-rs/salvo/blob/master/crates/cache/src/skipper.rs
Apache-2.0