mirror of
https://github.com/openai/codex.git
synced 2026-04-30 11:21:34 +03:00
chore: introduce *Args types for new() methods (#10009)
Constructors with long param lists can be hard to reason about when a number of the args are `None`, in practice. Introducing a struct to use as the args type helps make things more self-documenting.
This commit is contained in:
@@ -73,15 +73,25 @@ pub struct BlockedRequest {
|
||||
pub timestamp: i64,
|
||||
}
|
||||
|
||||
pub struct BlockedRequestArgs {
|
||||
pub host: String,
|
||||
pub reason: String,
|
||||
pub client: Option<String>,
|
||||
pub method: Option<String>,
|
||||
pub mode: Option<NetworkMode>,
|
||||
pub protocol: String,
|
||||
}
|
||||
|
||||
impl BlockedRequest {
|
||||
pub fn new(
|
||||
host: String,
|
||||
reason: String,
|
||||
client: Option<String>,
|
||||
method: Option<String>,
|
||||
mode: Option<NetworkMode>,
|
||||
protocol: String,
|
||||
) -> Self {
|
||||
pub fn new(args: BlockedRequestArgs) -> Self {
|
||||
let BlockedRequestArgs {
|
||||
host,
|
||||
reason,
|
||||
client,
|
||||
method,
|
||||
mode,
|
||||
protocol,
|
||||
} = args;
|
||||
Self {
|
||||
host,
|
||||
reason,
|
||||
|
||||
Reference in New Issue
Block a user