Skip to content

Commit 1954ce2

Browse files
authored
change Into -> From in nexus external API views file (#779)
1 parent 3767f83 commit 1954ce2

File tree

1 file changed

+48
-44
lines changed

1 file changed

+48
-44
lines changed

nexus/src/external_api/views.rs

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ pub struct Organization {
2626
pub identity: IdentityMetadata,
2727
}
2828

29-
impl Into<Organization> for model::Organization {
30-
fn into(self) -> Organization {
31-
Organization { identity: self.identity() }
29+
impl From<model::Organization> for Organization {
30+
fn from(org: model::Organization) -> Self {
31+
Self { identity: org.identity() }
3232
}
3333
}
3434

@@ -44,11 +44,11 @@ pub struct Project {
4444
pub organization_id: Uuid,
4545
}
4646

47-
impl Into<Project> for model::Project {
48-
fn into(self) -> Project {
49-
Project {
50-
identity: self.identity(),
51-
organization_id: self.organization_id,
47+
impl From<model::Project> for Project {
48+
fn from(project: model::Project) -> Self {
49+
Self {
50+
identity: project.identity(),
51+
organization_id: project.organization_id,
5252
}
5353
}
5454
}
@@ -88,14 +88,14 @@ pub struct Vpc {
8888
pub dns_name: Name,
8989
}
9090

91-
impl Into<Vpc> for model::Vpc {
92-
fn into(self) -> Vpc {
93-
Vpc {
94-
identity: self.identity(),
95-
project_id: self.project_id,
96-
system_router_id: self.system_router_id,
97-
ipv6_prefix: *self.ipv6_prefix,
98-
dns_name: self.dns_name.0,
91+
impl From<model::Vpc> for Vpc {
92+
fn from(vpc: model::Vpc) -> Self {
93+
Self {
94+
identity: vpc.identity(),
95+
project_id: vpc.project_id,
96+
system_router_id: vpc.system_router_id,
97+
ipv6_prefix: *vpc.ipv6_prefix,
98+
dns_name: vpc.dns_name.0,
9999
}
100100
}
101101
}
@@ -118,13 +118,13 @@ pub struct VpcSubnet {
118118
pub ipv6_block: Ipv6Net,
119119
}
120120

121-
impl Into<VpcSubnet> for model::VpcSubnet {
122-
fn into(self) -> VpcSubnet {
123-
VpcSubnet {
124-
identity: self.identity(),
125-
vpc_id: self.vpc_id,
126-
ipv4_block: self.ipv4_block.0,
127-
ipv6_block: self.ipv6_block.0,
121+
impl From<model::VpcSubnet> for VpcSubnet {
122+
fn from(subnet: model::VpcSubnet) -> Self {
123+
Self {
124+
identity: subnet.identity(),
125+
vpc_id: subnet.vpc_id,
126+
ipv4_block: subnet.ipv4_block.0,
127+
ipv6_block: subnet.ipv6_block.0,
128128
}
129129
}
130130
}
@@ -137,8 +137,8 @@ pub enum VpcRouterKind {
137137
}
138138

139139
impl From<model::VpcRouterKind> for VpcRouterKind {
140-
fn from(k: model::VpcRouterKind) -> Self {
141-
match k {
140+
fn from(kind: model::VpcRouterKind) -> Self {
141+
match kind {
142142
model::VpcRouterKind::Custom => Self::Custom,
143143
model::VpcRouterKind::System => Self::System,
144144
}
@@ -160,8 +160,12 @@ pub struct VpcRouter {
160160
}
161161

162162
impl From<model::VpcRouter> for VpcRouter {
163-
fn from(r: model::VpcRouter) -> Self {
164-
Self { identity: r.identity(), vpc_id: r.vpc_id, kind: r.kind.into() }
163+
fn from(router: model::VpcRouter) -> Self {
164+
Self {
165+
identity: router.identity(),
166+
vpc_id: router.vpc_id,
167+
kind: router.kind.into(),
168+
}
165169
}
166170
}
167171

@@ -174,9 +178,9 @@ pub struct Rack {
174178
pub identity: IdentityMetadata,
175179
}
176180

177-
impl Into<Rack> for model::Rack {
178-
fn into(self) -> Rack {
179-
Rack { identity: self.identity() }
181+
impl From<model::Rack> for Rack {
182+
fn from(rack: model::Rack) -> Self {
183+
Self { identity: rack.identity() }
180184
}
181185
}
182186

@@ -190,9 +194,9 @@ pub struct Sled {
190194
pub service_address: SocketAddr,
191195
}
192196

193-
impl Into<Sled> for model::Sled {
194-
fn into(self) -> Sled {
195-
Sled { identity: self.identity(), service_address: self.address() }
197+
impl From<model::Sled> for Sled {
198+
fn from(sled: model::Sled) -> Self {
199+
Self { identity: sled.identity(), service_address: sled.address() }
196200
}
197201
}
198202

@@ -207,9 +211,9 @@ pub struct User {
207211
pub identity: IdentityMetadata,
208212
}
209213

210-
impl Into<User> for model::UserBuiltin {
211-
fn into(self) -> User {
212-
User { identity: self.identity() }
214+
impl From<model::UserBuiltin> for User {
215+
fn from(user: model::UserBuiltin) -> Self {
216+
Self { identity: user.identity() }
213217
}
214218
}
215219

@@ -221,9 +225,9 @@ pub struct SessionUser {
221225
pub id: Uuid,
222226
}
223227

224-
impl Into<SessionUser> for authn::Actor {
225-
fn into(self) -> SessionUser {
226-
SessionUser { id: self.0 }
228+
impl From<authn::Actor> for SessionUser {
229+
fn from(actor: authn::Actor) -> Self {
230+
Self { id: actor.0 }
227231
}
228232
}
229233

@@ -236,11 +240,11 @@ pub struct Role {
236240
pub description: String,
237241
}
238242

239-
impl Into<Role> for model::RoleBuiltin {
240-
fn into(self) -> Role {
241-
Role {
242-
name: RoleName::new(&self.resource_type, &self.role_name),
243-
description: self.description,
243+
impl From<model::RoleBuiltin> for Role {
244+
fn from(role: model::RoleBuiltin) -> Self {
245+
Self {
246+
name: RoleName::new(&role.resource_type, &role.role_name),
247+
description: role.description,
244248
}
245249
}
246250
}

0 commit comments

Comments
 (0)